/* ピアノの楽典ドリル（試作）── 象牙と黒檀・差し色は真鍮だけ（2026-10-11）
   モチーフは 2 つだけ＝鍵盤（上の帯・段階のカード・進み具合）と五線（見出しの下線）。
   ダークモードは作らない（象牙色で固定）。 */
:root {
  color-scheme: light;
  --ivory: #f7f3ea;        /* 地 */
  --ivory-hi: #fffdf7;     /* カード・白鍵の明るい面 */
  --ivory-lo: #ebe4d6;     /* 白鍵の影 */
  --ebony: #15120f;        /* 文字・黒鍵 */
  --ebony-2: #2a2520;
  --sub: #6b6258;          /* 補足の文字 */
  --line: #ddd4c4;         /* 罫・枠 */
  --brass: #b8893a;        /* 差し色（飾り） */
  --brass-ink: #7d5a1c;    /* 差し色（文字に使う濃い方） */
  --brass-soft: #f3e7cc;
  --ng: #9b3b2e;           /* 不正解（くすんだ朱） */
  --ng-soft: #f6e4df;
  --serif: "Shippori Mincho", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(21, 18, 15, .06), 0 6px 18px rgba(21, 18, 15, .07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ivory); }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ebony);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  padding: 0 16px calc(40px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

/* ── 上の鍵盤の帯（CSS だけ・7 白鍵＝98px で 1 オクターブ） */
.keys-band {
  margin: 0 -16px;
  height: 30px;
  background:
    linear-gradient(90deg,
      transparent 0 10px, var(--ebony) 10px 18px, transparent 18px 24px, var(--ebony) 24px 32px,
      transparent 32px 52px, var(--ebony) 52px 60px, transparent 60px 66px, var(--ebony) 66px 74px,
      transparent 74px 80px, var(--ebony) 80px 88px, transparent 88px 98px) 0 0 / 98px 62% repeat-x,
    repeating-linear-gradient(90deg, var(--ivory-hi) 0 13px, #cfc5b3 13px 14px),
    var(--ivory-hi);
  border-top: 3px solid var(--ebony);
  border-bottom: 2px solid var(--brass);
  box-shadow: 0 3px 10px rgba(21, 18, 15, .10);
}

/* ── 見出し（明朝・下に五線） */
.site-head { max-width: 720px; margin: 0 auto; padding: 22px 0 6px; }
.site-head h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.35;
  letter-spacing: .04em;
  margin: 0;
  padding-bottom: 14px;
  background: repeating-linear-gradient(to bottom, rgba(184, 137, 58, .55) 0 1px, transparent 1px 3px) left bottom / 100% 13px no-repeat;
}
.h1-ico { font-size: .8em; margin-right: .3em; vertical-align: .08em; }
.h1-trial { white-space: nowrap; font-size: .6em; letter-spacing: .02em; color: var(--sub); font-weight: 600; margin-left: .2em; }
.trial-note { margin: 8px 0 0; font-size: 12px; color: var(--sub); }
.trial-note span { display: inline-block; }
main { max-width: 720px; margin: 0 auto; }

/* ── 設定（ドレミ／CDE） */
.settings {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 14px 0 18px; padding: 10px 12px 10px 16px;
  background: var(--ivory-hi); border: 1px solid var(--line); border-radius: var(--radius);
}
.settings .label { font-size: 15px; color: var(--sub); font-weight: 500; }
.seg { display: inline-flex; padding: 3px; background: var(--ivory-lo); border-radius: 999px; }
.seg button {
  border: 0; background: transparent; padding: 8px 20px; min-height: 48px; min-width: 88px;
  font-size: 18px; font-weight: 700; color: var(--sub); cursor: pointer; border-radius: 999px;
  transition: background .2s, color .2s;
}
.seg button[aria-pressed="true"] { background: var(--ebony); color: var(--ivory-hi); box-shadow: inset 0 -2px 0 var(--brass); }

/* ── トップの 4 本 × 3 段階 */
.drill {
  background: var(--ivory-hi); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.drill h2 { font-family: var(--serif); font-weight: 700; font-size: 21px; letter-spacing: .04em; margin: 0 0 2px; }
.drill .desc { margin: 0 0 14px; font-size: 14px; color: var(--sub); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
/* 白鍵のような縦長のカード。押すと少し沈む */
.lv {
  position: relative;
  border: 1px solid #cfc5b3; border-top-width: 3px; border-top-color: var(--ebony);
  border-radius: 4px 4px 12px 12px;
  background: linear-gradient(to bottom, var(--ivory-hi) 0%, var(--ivory-hi) 70%, var(--ivory-lo) 100%);
  box-shadow: inset 0 -5px 0 rgba(21, 18, 15, .07), 0 3px 0 #d8cfbf, 0 5px 10px rgba(21, 18, 15, .08);
  min-height: 112px; padding: 12px 4px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
  transition: transform .08s ease-out, box-shadow .08s ease-out;
}
.lv:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgba(21, 18, 15, .07), 0 0 0 #d8cfbf, 0 2px 4px rgba(21, 18, 15, .08); }
.lv .lv-name { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: .08em; color: var(--ebony); }
.lv .lv-count { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
/* 段階の印＝小さな黒鍵 3 本。初級 1 → 中級 2 → 上級 3 本が黒くなる */
.lv-mark { display: flex; gap: 4px; margin-bottom: auto; padding-top: 2px; }
.lv-mark i { display: block; width: 8px; height: 18px; border-radius: 0 0 2px 2px; background: #e2dacb; }
.lv-0 .lv-mark i:nth-child(-n+1),
.lv-1 .lv-mark i:nth-child(-n+2),
.lv-2 .lv-mark i { background: var(--ebony); }

/* ── 問題画面 */
.qbar { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.qbar .title { font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: .03em; flex: 1; min-width: 0; }
.qbar .num { font-variant-numeric: tabular-nums; color: var(--sub); font-size: 15px; font-weight: 500; }
.qbar .quit {
  border: 1px solid var(--line); background: var(--ivory-hi); color: var(--sub);
  border-radius: 999px; padding: 6px 16px; min-height: 48px; font-size: 15px; cursor: pointer;
}
/* 進み具合＝小さな鍵盤 10 個 */
.pkeys { display: flex; gap: 3px; margin: 4px 0 12px; }
.pkeys i {
  flex: 1; height: 16px;
  background: var(--ivory-hi); border: 1px solid #cfc5b3; border-top: 2px solid var(--ebony);
  border-radius: 0 0 4px 4px;
  transition: background .3s, border-color .3s;
}
.pkeys i.cur { border-color: var(--brass); border-top-color: var(--ebony); box-shadow: 0 0 0 1.5px var(--brass); }
.pkeys i.ok { background: var(--brass); border-color: var(--brass); border-top-color: var(--ebony); }
.pkeys i.ng { background: #8e857a; border-color: #8e857a; border-top-color: var(--ebony); }

.prompt { font-size: 21px; font-weight: 700; margin: 6px 0 10px; line-height: 1.45; }
.prompt small { display: block; font-size: 14px; font-weight: 400; color: var(--sub); margin-top: 2px; }
/* 楽譜が主役＝象牙のカード・薄い影・周りに余白 */
.fig {
  background: var(--ivory-hi); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px; margin: 8px auto 12px; max-width: 300px;
  display: flex; align-items: center; justify-content: center;
}
.fig svg { display: block; width: 100%; height: auto; }
.fig.listen { min-height: 112px; max-width: 360px; }
.listen-mark {
  font-family: var(--serif); font-size: 64px; line-height: 1; color: var(--ebony);
  font-variant-emoji: text;
}
.fig.listen.is-rhythm .listen-mark { font-size: 52px; letter-spacing: .1em; }
.fallback { font-size: 18px; text-align: center; padding: 16px 8px; color: var(--ebony); }
.fallback small { display: block; font-size: 12px; color: var(--sub); }

/* もう一度聞く＝黒檀に真鍮の縁 */
.replay {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 4px auto 10px; border: 2px solid var(--brass); background: var(--ebony); color: var(--ivory-hi);
  font-weight: 700; font-size: 18px; letter-spacing: .04em;
  border-radius: 999px; padding: 10px 28px; min-height: 56px; cursor: pointer;
  box-shadow: 0 3px 0 #000, 0 6px 14px rgba(21, 18, 15, .18);
  transition: transform .08s ease-out, box-shadow .08s ease-out;
}
.replay:active { transform: translateY(2px); box-shadow: 0 1px 0 #000, 0 3px 6px rgba(21, 18, 15, .18); }
/* スピーカーの印（CSS だけ） */
.replay-ico { position: relative; width: 18px; height: 16px; }
.replay-ico::before { content: ""; position: absolute; left: 0; top: 4px; width: 5px; height: 8px; background: var(--brass); }
.replay-ico::after {
  content: ""; position: absolute; left: 3px; top: 0; width: 0; height: 0;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-right: 9px solid var(--brass);
}
.sound-hint { text-align: center; font-size: 12px; color: var(--sub); margin: 0 0 8px; }

/* 選択肢＝白鍵の手触り */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 10px; }
.choices.three { grid-template-columns: 1fr; }
.choices.rhythm { grid-template-columns: 1fr; }
@media (min-width: 600px) { .choices.rhythm { grid-template-columns: 1fr 1fr; } .choices.three { grid-template-columns: repeat(3, 1fr); } }
.choice {
  position: relative;
  border: 1px solid #cfc5b3; border-radius: 12px;
  background: linear-gradient(to bottom, var(--ivory-hi) 0%, var(--ivory-hi) 75%, var(--ivory-lo) 100%);
  box-shadow: 0 3px 0 #d8cfbf, 0 5px 10px rgba(21, 18, 15, .06);
  min-height: 72px; padding: 10px 10px; font-size: 26px; font-weight: 700; letter-spacing: .04em;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s ease-out, box-shadow .08s ease-out, opacity .2s, border-color .2s, background .2s;
}
.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 #d8cfbf, 0 2px 4px rgba(21, 18, 15, .06); }
.choices.three .choice { font-size: 20px; min-height: 64px; letter-spacing: .02em; }
.choice .mark { font-size: 18px; color: var(--sub); font-weight: 700; }
.choice .rsvg { flex: 1; background: #fff; border-radius: 6px; padding: 2px 4px; }
.choice .rsvg svg { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; }
.choice:disabled { cursor: default; color: var(--ebony); }
.choices.answered .choice:not(.ok):not(.ng) { opacity: .55; }
/* 正解＝鍵盤が光る（0.3 秒） */
.choice.ok {
  border-color: var(--brass);
  background: linear-gradient(to bottom, #fffaf0 0%, var(--brass-soft) 100%);
  box-shadow: 0 0 0 2px var(--brass), 0 3px 0 #c9a868, 0 6px 16px rgba(184, 137, 58, .28);
  animation: key-glow .3s ease-out;
}
.choice.ok::after {
  content: "○"; position: absolute; top: 6px; right: 10px; font-size: 16px; color: var(--brass-ink); font-weight: 700;
}
.choice.ng {
  border-color: var(--ng); background: var(--ng-soft);
  box-shadow: 0 0 0 1px var(--ng), 0 2px 0 #e2c3bb;
  animation: key-nudge .3s ease-out;
}
.choice.ng::after { content: "×"; position: absolute; top: 4px; right: 10px; font-size: 17px; color: var(--ng); font-weight: 700; }
.choice.ok .rsvg, .choice.ng .rsvg { background: #fff; }
@keyframes key-glow {
  0%   { transform: translateY(3px); box-shadow: 0 0 0 2px var(--brass), 0 0 0 #c9a868, 0 0 0 rgba(184, 137, 58, 0); background: #fff3d6; }
  60%  { box-shadow: 0 0 0 4px rgba(184, 137, 58, .55), 0 3px 0 #c9a868, 0 8px 26px rgba(184, 137, 58, .45); }
  100% { transform: translateY(0); }
}
@keyframes key-nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  65% { transform: translateX(3px); }
}
.feedback { min-height: 34px; font-size: 19px; font-weight: 700; text-align: center; margin: 6px 0 4px; }
.feedback.ok { color: var(--brass-ink); }
.feedback.ng { color: var(--ng); }

.next, .big {
  display: block; width: 100%; border: 0; background: var(--ebony); color: var(--ivory-hi);
  border-radius: 14px; min-height: 60px; font-size: 20px; font-weight: 700; letter-spacing: .08em;
  cursor: pointer; margin: 10px 0;
  box-shadow: inset 0 -3px 0 var(--brass), 0 4px 12px rgba(21, 18, 15, .16);
  transition: transform .08s ease-out;
}
.next:active, .big:active { transform: translateY(2px); }
.big.sub { background: var(--ivory-hi); color: var(--ebony); border: 1.5px solid var(--ebony); box-shadow: none; }
.hidden { display: none !important; }

/* ── 結果 */
.result {
  position: relative; overflow: hidden;
  text-align: center; background: var(--ivory-hi); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px 24px; margin: 18px 0 14px;
}
.result .r-title { font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: .04em; color: var(--sub); }
.result .score { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 10px 0 14px; }
.result .s-pre, .result .s-unit { font-size: 18px; color: var(--sub); font-weight: 500; }
.result .s-num { font-family: var(--serif); font-size: 84px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.result .pkeys { max-width: 340px; margin: 0 auto 14px; }
.result .msg { font-family: var(--serif); font-size: 26px; font-weight: 700; letter-spacing: .1em; }
/* 全問正解だけ真鍮の演出 */
.result.perfect { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass), 0 10px 30px rgba(184, 137, 58, .25); background: linear-gradient(to bottom, #fffaf0, var(--ivory-hi) 60%); }
.result.perfect .s-num, .result.perfect .msg { color: var(--brass-ink); }
.result.perfect::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 236, 190, .75) 48%, transparent 66%) no-repeat;
  background-size: 250% 100%; background-position: 130% 0;
  animation: brass-sheen 1.4s ease-out .2s 1 both;
}
.result.perfect .pkeys i { animation: key-light .4s ease-out both; }
.result.perfect .pkeys i:nth-child(1) { animation-delay: .05s; } .result.perfect .pkeys i:nth-child(2) { animation-delay: .1s; }
.result.perfect .pkeys i:nth-child(3) { animation-delay: .15s; } .result.perfect .pkeys i:nth-child(4) { animation-delay: .2s; }
.result.perfect .pkeys i:nth-child(5) { animation-delay: .25s; } .result.perfect .pkeys i:nth-child(6) { animation-delay: .3s; }
.result.perfect .pkeys i:nth-child(7) { animation-delay: .35s; } .result.perfect .pkeys i:nth-child(8) { animation-delay: .4s; }
.result.perfect .pkeys i:nth-child(9) { animation-delay: .45s; } .result.perfect .pkeys i:nth-child(10) { animation-delay: .5s; }
@keyframes brass-sheen { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes key-light { 0% { transform: translateY(3px); filter: brightness(1.35); } 100% { transform: none; filter: none; } }

.loading { text-align: center; color: var(--sub); padding: 32px 16px; font-family: var(--serif); letter-spacing: .06em; }

@media (min-width: 600px) {
  .site-head h1 { font-size: 32px; }
  .lv { min-height: 124px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
