/* やれば読める！ 〜楽譜よみトレーニング〜
   デザイン: bakusoku-web.com を参考にした明るいポップ路線（2026-07-09 田中さん指示）
   クリーム背景 × 赤 × イエロー、白い大きな角丸カード、極太文字、ピル型ボタン。
   正解=緑／不正解=赤 の学習上の色意味は維持する */

:root {
  --bg: #fff4dc;            /* クリーム背景 */
  --card: #ffffff;
  --card-hi: #faf6ee;
  --line: #f0c9b0;
  --ink: #231815;
  --sub: #6b5b52;
  --accent: #e60012;        /* 赤（ブランド主色） */
  --accent-dark: #c90010;
  --yellow: #ffc928;
  --brown: #2b1712;
  --star: #f0a500;
  --ok: #2f9e44;
  --bad: #e03131;
  /* v2.1・J-2: 色の意味の分担 ── 赤はブランドとエラーに、黄を主ボタン・選択状態に。
     クリーム×赤×イエローの方針（冒頭・田中さん指示）は変えず、
     「押してほしいボタン」「選ばれている状態」を誤答と同じ赤から黄へ移す。
     #ffc928 は白文字と 1.54:1 しかないため、黄の面の文字は必ず --primary-ink（11.05:1）。
     黄の面は境界も 3:1 に届かないので、影か brown の枠を必ず持たせる */
  --primary: var(--yellow);   /* 主ボタン・選択状態 */
  --primary-ink: var(--brown);/* 黄の上に載せる文字 */
  --primary-dark: #f0b400;    /* 黄の hover（brown と 9.10:1） */
  --note-ink: #4f423b;        /* 通常の説明文（白カード上 9.66:1・旧は赤 4.40:1 で不合格） */
  --shadow: 0 14px 36px rgba(43, 23, 18, 0.14);
  --shadow-sm: 0 8px 20px rgba(43, 23, 18, 0.10);

  /* ───────── v4.15（デザインの磨き込み）: そろえ方の物差し ─────────
     色は変えない（アイデンティティ）。**間隔・文字の大きさ・ボタンの高さ**だけを
     ここに集めて、画面ごとの場当たりな数値を無くす。新しく書く時は必ずこの変数を使う。
     間隔は 4px 刻み。文字は5段階（見出し／小見出し／本文／補足／数字）。
     ボタンは3階層（主 48・副 44・小 36）。数字は等幅（桁がぶれない） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --fs-head: 1.2rem;      /* 見出し */
  --fs-sub: 0.82rem;      /* 小見出し（字間を広めに） */
  --fs-body: 0.95rem;     /* 本文 */
  --fs-note: 0.78rem;     /* 補足 */
  --fs-num: 1.05rem;      /* 数字（太字） */
  --btn-h-main: 48px;     /* 主ボタン */
  --btn-h-sub: 44px;      /* 副ボタン（指の最小の的） */
  --btn-h-mini: 36px;     /* 小ボタン */
  /* 運指表の音カード: 音によって形が変わらないよう、枠を固定する */
  --ref-stave-w: 128px;   /* 五線の列（全部そろえる） */
  --ref-fig-h: 68px;      /* 図（木管のキー配置・金管のシルエット）の高さ */
  --ref-fig-w: 160px;     /* 図の幅の上限。替指が2つ並ぶ音でも 1つの音でも 同じ大きさで描く */
  --ref-tag-h: 18px;      /* 「標準／替指」の札の段（札が無い音でも 空けておく） */
  --ref-text-h: 28px;     /* 押すキーの文字の段（2行ぶん） */
}

/* 数字は桁がぶれないように等幅（点・問・回・日・pt） */
.hero-card, .result-card, .col-line, .next-reward, .daily-label, .rank-progress-label,
.badge-row-title, .ref-oct, .decor-body small, .stage-stars { font-variant-numeric: tabular-nums; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden属性は、display指定を持つ要素（.tutorialのflex等）にも必ず勝たせる */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

button { font-family: inherit; }

.screen {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* 画面が表示されるたびに、ふわっと入るトランジション */
.screen:not([hidden]) { animation: screenIn 0.35s ease; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen:not([hidden]), .mascot, .bg-decor::before, .bg-decor::after, .bg-note { animation: none !important; }
}

/* ───── 背景かざり（五線がやさしく光る＋うかぶ音符） ───── */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-decor::before, .bg-decor::after {
  content: "";
  position: absolute;
  left: -12%; right: -12%;
  height: 90px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(230, 0, 18, 0.075) 0 2px,
    transparent 2px 22px
  );
  animation: staffGlow 6.5s ease-in-out infinite;
}
.bg-decor::before { top: 7%; transform: rotate(-3deg); }
.bg-decor::after { bottom: 9%; transform: rotate(2.5deg); animation-delay: 3s; }
@keyframes staffGlow {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
.bg-note {
  position: absolute;
  font-size: 2.2rem;
  color: rgba(230, 0, 18, 0.10);
  font-weight: 900;
  animation: noteDrift 9s ease-in-out infinite;
}
.bg-note.n1 { left: 8%; top: 16%; }
.bg-note.n2 { right: 10%; top: 30%; font-size: 2.8rem; animation-delay: 2.5s; }
.bg-note.n3 { left: 14%; bottom: 14%; font-size: 2.4rem; animation-delay: 5s; }
@keyframes noteDrift {
  0%, 100% { transform: translateY(0) rotate(-6deg); opacity: 0.55; }
  50%      { transform: translateY(-18px) rotate(6deg); opacity: 1; }
}

/* ───── ヘッダー／ロゴ ───── */
.app-header { text-align: center; padding: 12px 0 4px; }
.logo {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}
/* v4.24: 「やればもっと読める！」は10文字。375px（iPhone SE 等）で2行に折れないよう1段小さく
   （〜360px は下の 1.8rem がさらに勝つ） */
@media (max-width: 400px) { .logo { font-size: 1.95rem; } }
.logo-accent {
  color: var(--accent);
  position: relative;
  display: inline-block;
  z-index: 1;
}
.logo-accent::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0.04em;
  height: 0.18em;
  background: var(--yellow);
  border-radius: 999px;
  z-index: -1;
}
.subtitle {
  margin: 12px 0 4px;
  font-size: 0.8rem;
  color: var(--sub);
  font-weight: 800;
  letter-spacing: 0.3em;
}
/* v4.28: ホームに出す版。主役ではないので小さく・薄く、ただし読める大きさにする
   （キャッシュで古いままかどうかを、その場で言えるようにするためのもの） */
.home-version {
  margin: 0 0 2px;
  font-size: 0.62rem;
  color: var(--sub);
  opacity: 0.75;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

/* ───── チャンネル選択画面 ───── */
/* v4.25: ベル/ロゴ/歯車を3列グリッドに（旧: position:absoluteの重ね配置で
   375〜430px幅でロゴ「やればもっと読める！」がボタンに実測でかぶっていた）。
   両端の列をボタンと同じ固定幅にすることで、おしらせ非表示時もロゴ列の中心がずれない。 */
.home-header-row {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: start;
  gap: 4px;
  padding: 16px 8px 0;
}
@media (max-width: 360px) { .home-header-row { grid-template-columns: 42px 1fr 42px; } }
.home-header { display: flex; flex-direction: column; gap: 6px; padding: 0 0 6px; text-align: center; min-width: 0; }
/* v4.72: 題名は真ん中の列に固定。🔔 は おしらせが届くまで（届かなければ ずっと）hidden で、
   列が空くと 題名が 左の 46px 列に入り、1文字ずつ縦に並んでいた（news.json は毎回取りに行くので、開くたびに一瞬崩れる）。
   ⚙ は grid-column: 3 で固定済み。題名だけ自動の置き場所まかせだった */
.home-header-row > .home-header { grid-column: 2; }
/* v4.47: 「みんなの声」をタイトルの下に。しばらくは目立たせる（発注元）。
   主ボタン（黄）と同じ色で、ホームで最初に目に入る位置に置く */
.btn-voices-hero {
  align-self: center;
  margin-top: 4px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 0.95rem;
  font-weight: 900;
  padding: 9px 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn-voices-hero:active { transform: translateY(2px); }
/* v4.47: 見出しの下に「みんなの声」「かんそうを送る」を横に並べ、その下に一言を吹き出しで（発注元） */
/* 見出しの列は両脇の 🔔⚙ のぶん狭い（390px で約300px）。ボタン2つを横に並べるため、
   この行だけ両脇の列の下まで広げる（アイコンは上にあるので重ならない） */
.home-actions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px -44px 0; }
.home-actions .btn-review-home { margin: 0; padding: 9px 14px; font-size: 0.85rem; }
.home-actions .btn-voices-hero { margin: 0; padding: 9px 16px; font-size: 0.9rem; }
@media (max-width: 360px) { .home-actions { margin-inline: -40px; gap: 6px; } .home-actions .btn-review-home, .home-actions .btn-voices-hero { padding: 8px 12px; font-size: 0.82rem; } }
.home-bubble {
  position: relative;
  margin: 12px auto 0;
  max-width: 24em;
  padding: 8px 12px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 0.78rem; font-weight: 800; color: var(--sub);
  line-height: 1.6;
}
.home-bubble::before, .home-bubble::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent;
}
.home-bubble::before { top: -18px; border-bottom-color: var(--line); }
.home-bubble::after { top: -15px; border-bottom-color: var(--card); }

/* 設定は右列に固定（将来の項目追加は screen-settings 側に増やす） */
.btn-gear.btn-gear-fixed {
  grid-column: 3;
  justify-self: end;
  width: 46px; height: 46px;
  padding: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  z-index: 5;
}
@media (max-width: 360px) { .btn-gear.btn-gear-fixed { width: 42px; height: 42px; font-size: 1.15rem; } }

/* ───── ヒーローカード（マスコット＋きろく） ───── */
.hero-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(150deg, #fff 60%, #fff0f4 100%);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: 14px 0 4px;
}
.hero-stats { flex: 1; min-width: 0; }
/* v2.1・M-1(1): 3つのバッジの「文字の縦中心」を揃える。箱の高さは34pxで
   揃っていたが、両脇が display:block（中身が上寄せ）・真ん中だけ flex+baseline で、
   文字が約2px浮いて見えていた（QA 4-2 の実体） */
.hero-badges-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.streak-badge, .week-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff0f4;
  border: 1px solid rgba(230, 0, 18, 0.16);
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.76rem;
  font-weight: 900;
}
.hero-stats .rank-progress { margin: 0 0 5px; }
.hero-stats .rank-progress-label { margin: 0; }

.pt-badge {
  display: flex; align-items: center; gap: 3px;
  background: var(--card);
  border: 1px solid rgba(230, 0, 18, 0.16);
  border-radius: 999px; padding: 7px 14px; font-weight: 900;
  box-shadow: var(--shadow-sm);
}
.pt-badge-icon { font-size: 0.9rem; }
.pt-badge-value { color: var(--accent); font-size: 1rem; }
.pt-badge-unit { color: var(--sub); font-size: 0.72rem; font-weight: 800; }
.rank-badge {
  display: inline-flex;
  align-items: center;
  background: var(--yellow);
  color: var(--brown);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
}

.channel-grid { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 10px; }   /* v4.57: 詰める */
/* v4.55: ホーム画面に追加の案内（1行）と手順 */
.a2hs-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; margin: 10px 0 0; padding: 10px 12px 10px 14px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font-weight: 900; font-size: 0.85rem; text-align: left; cursor: pointer;
}
.a2hs-bar .a2hs-text { flex: 1; min-width: 0; }
.a2hs-bar .a2hs-x { flex: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card-hi); color: var(--sub); font-size: 1.1rem; }
.a2hs-steps { text-align: left; margin: 10px 0 4px; padding-left: 1.4em; font-weight: 700; line-height: 1.8; }
.a2hs-steps li + li { margin-top: 6px; }
.a2hs-share { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0 2px; border-radius: 8px; background: #fff; border: 2px solid var(--line); color: #1a73e8; vertical-align: middle; }
.a2hs-row { display: inline-flex; align-items: center; gap: 8px; margin: 0 2px; padding: 4px 10px; border-radius: 10px; background: #fff; border: 2px solid var(--line); font-weight: 700; vertical-align: middle; }
.a2hs-row-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ink); font-weight: 900; line-height: 1; }

/* v4.57（案E1）: 白いカードの中に、見出しそのものが黄色ボタン（文字幅・中央）。補足はその下 */
.channel-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 3px solid transparent;
  background: var(--card);
  border-radius: 28px;
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.channel-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.channel-card:active { transform: scale(0.98); }
.channel-desc { font-size: 0.8rem; color: var(--sub); font-weight: 800; }
.channel-start {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  border-radius: 999px;
  padding: 13px 30px;
  box-shadow: 0 5px 0 rgba(43, 23, 18, 0.14);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.channel-card:hover .channel-start {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(43, 23, 18, 0.12);
  background: var(--primary-dark);
}

/* ───── カード ───── */
.card {
  background: var(--card);
  border: none;
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--sub);
  font-weight: 900;
  letter-spacing: 0.1em;
}

/* ───── ステージ一覧 ───── */
.stage-list { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 20px; }

.stage-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 3px solid transparent;
  text-align: left;
  background: var(--card);
  border-radius: 24px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, border-color 0.15s;
}
.stage-card:not(.locked):hover { border-color: var(--accent); transform: translateY(-3px); }
.stage-card:not(.locked):active { transform: scale(0.98); }
.stage-card .stage-num {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1.3rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 rgba(43, 23, 18, 0.14);
}
.stage-card.locked { opacity: 0.55; cursor: default; box-shadow: none; background: var(--card-hi); }
.stage-card.locked .stage-num { background: #d8cbbc; color: var(--sub); font-size: 1rem; box-shadow: none; }
/* v4.52: リズムは鍵を外した。代わりに「つぎは ここ」の印（順番どおりで まだの所） */
.stage-card.is-next { border-color: var(--accent); }
.stage-card .stage-next { display: block; font-size: 0.75rem; font-weight: 900; color: var(--accent); }
/* v4.56: こえで遊べるレベルの印（説明文の末尾） */
.stage-card .stage-voice { display: inline-block; font-size: 0.78rem; font-weight: 900; color: #1a73e8; white-space: nowrap; }
.result-buttons > .btn-voice-retry { width: 100%; min-height: 48px; border-color: #1a73e8; color: #1a73e8; font-weight: 900; }
.stage-card .stage-info { flex: 1; }
/* v4.74: リズムの一覧の「チャレンジ」の見出し（超絶・5連・7連をまとめる） */
.rhythm-group-head { margin: 14px 4px 2px; display: flex; flex-direction: column; gap: 2px; }
.rhythm-group-head strong { font-size: 1rem; font-weight: 900; color: var(--ink); }
.rhythm-group-head span { font-size: 0.82rem; color: var(--sub); }
.stage-card .stage-name { font-size: 1.05rem; font-weight: 900; margin: 0; color: var(--ink); }
.stage-card .stage-desc { font-size: 0.76rem; color: var(--sub); font-weight: 800; margin: 3px 0 0; }
.stage-card .stage-stars { font-size: 1rem; color: var(--star); letter-spacing: 2px; }

.pick-first { text-align: center; color: var(--sub); font-weight: 800; font-size: 0.9rem; }

/* ───── 画面見出し・小ボタン ───── */
.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.settings-head h2 { margin: 0; font-size: 1.2rem; font-weight: 900; letter-spacing: -0.02em; }

.btn-small {
  border: 2px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn-small:active { transform: translateY(2px); }
.btn-gear {
  border: 2px solid var(--accent);
  background: var(--card);
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ───── 楽器チップ ───── */
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0;
}
.inst-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.inst-chip:hover { outline: 2px solid var(--accent); }
.inst-chip .chip-sub { color: var(--sub); font-weight: 800; font-size: 0.72rem; margin-left: auto; }

/* ───── 設定画面 ───── */
.inst-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.inst-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 11px;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
}
.inst-btn.selected { border-color: var(--brown); background: rgba(255, 201, 40, 0.28); color: var(--ink); }
.inst-btn .inst-icon { font-size: 1.3rem; flex: none; }
.inst-btn .inst-label { line-height: 1.25; }
.naming-note { margin: 12px 0 0; font-size: 0.78rem; color: var(--note-ink); font-weight: 900; }

.setting-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-label { flex: none; width: 84px; font-size: 0.88rem; font-weight: 900; }
/* v2.1・M-1(3): ラベル84px固定では「こたえのテンポ」（7文字≒99px）が2行に割れ、
   残り幅にピルが収まらず 320px で縦一列（行高120px）に崩れていた（QA 4-6）。
   狭い幅ではラベルを上に出して全幅を使い、広い幅ではラベル幅を7文字ぶんへ */
@media (max-width: 480px) {
  .setting-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .setting-label { width: auto; }
}
@media (min-width: 481px) {
  .setting-label { width: 8.6em; }
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--sub);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
}
.seg button.active { background: var(--primary); border-color: var(--brown); color: var(--primary-ink); }

.footer-note { text-align: center; font-size: 0.72rem; color: var(--sub); font-weight: 800; margin-top: 18px; }
/* v4.22: 入口（ensemblog.jp）へ戻る1行。押せる大きさは保ちつつ、練習の導線より目立たせない */
.entry-link { margin-top: 10px; }
.entry-link a { display: inline-block; padding: 10px 6px; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }

/* ───── プレイ ───── */
.play-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 40px;
}
/* v2.1: 320px 幅では、点10個（164px）＋やめる＋コンボ欄＋かんそうボタンが
   1行に収まらず、横スクロールバーが出ていた（D-1 と同じ系統の不具合）。
   フレックスの既定は min-width:auto ＝ 中身より小さくならないので、
   明示的に縮めるようにしたうえで、足りなければ2行に折り返す */
.progress-dots {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
}
.progress-dots .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line);
}
.progress-dots .dot.now { background: var(--yellow); border-color: var(--yellow); transform: scale(1.3); }
.progress-dots .dot.ok { background: var(--ok); border-color: var(--ok); }
.progress-dots .dot.ng { background: var(--bad); border-color: var(--bad); }

/* テンポ微調整（v2.1・M-1(8)）。判定基準は公称テンポに固定したまま、再生だけ±5 */
/* 一時停止（v2.1）。止まっているあいだは「つづける」だと分かるよう色を変える */
#btn-rhythm-pause { min-width: 42px; }
#btn-rhythm-pause.is-paused { background: var(--primary); color: var(--primary-ink); border-color: var(--brown); }

.tempo-adj { display: inline-flex; align-items: center; gap: 4px; }
.tempo-adj button {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--sub);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.tempo-adj .tempo-label {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--sub);
  min-width: 3.6em;
  text-align: center;
}
.tempo-adj .tempo-label.is-adjusted { color: var(--ink); }
#screen-rhythm-play .play-top { flex-wrap: wrap; }

.combo {
  min-width: 76px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--ok);   /* 連続正解＝正解の色。誤答と同じ赤だったのを是正（v2.1・J-2） */
}

.play-stage {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--sub);
  margin: 0 0 6px;   /* v4.30: 縦を詰める（10→6） */
}

/* 楽譜カード: 白 + 赤枠（参考サイトの menu-card 流儀） */
.stave-card {
  position: relative;
  background: #ffffff;
  border: 3px solid var(--accent);
  border-radius: 28px;
  padding: 6px 8px;   /* v4.30: 上下を詰める（8→6） */
  box-shadow: var(--shadow);
}
.stave { width: 100%; display: flex; justify-content: center; }
.stave svg { width: 100%; height: auto; max-width: 420px; }

/* 回答・運指ゾーン: 出題五線の「上側」に置く（2026-07-09 田中さん指示） */
.above-staff {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  min-height: 56px;
  padding: 4px 6px 0;
}
/* v2.1・C-2: 出題中は「正解発表で出るもの」を置いたまま隠す。
   場所を先に取っておかないと、答え合わせのときに五線カードが伸びて
   回答ボタンが動き、押し間違いの原因になる */
.above-staff.is-pending > * { visibility: hidden; }
.answer-big {
  font-size: 2rem;
  font-weight: 900;
  color: var(--ok);
  line-height: 1;
}
.answer-big.wrong { color: var(--bad); }

/* パート譜ふうの調性表示 in B / in Es / in F / in C */
.stave-key {
  position: absolute;
  left: 16px;
  top: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  font-style: italic;
  color: var(--sub);
}

.status {
  text-align: center;
  font-size: 1rem;
  font-weight: 900;
  color: var(--sub);
  margin: 8px 0;   /* v4.30: 縦を詰める（14→8）。下の min-height は C-2 の判断なので触らない */
  /* v2.1・C-2: 不正解の解説（「正解は『ベー』。五線の下の、加線のあたりの音だよ」）は
     狭い画面で2行になる。1行ぶんしか取っていないと、その差ぶん回答ボタンが下がる。
     全楽器・全音・全位置の文言を総当たりで測って最大2行だったので、2行を確保する */
  min-height: 2.8em;
}
.status.ok { color: var(--ok); }
.status.ng { color: var(--bad); }

.answer-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;   /* v4.30: 10→8。12個ならぶステージで 3行ぶん = 6px 効く */
}
.answer-buttons.few { grid-template-columns: repeat(3, 1fr); }
.answer-buttons.five { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.answer-buttons.five .note-btn { grid-column: span 2; }
.answer-buttons.five .note-btn:nth-child(4) { grid-column: 2 / span 2; }
.answer-buttons.five .note-btn:nth-child(5) { grid-column: 4 / span 2; }
@media (min-width: 720px) and (min-height: 541px) {
  .answer-buttons.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .answer-buttons.five .note-btn:nth-child(n) { grid-column: auto; }
}
.note-btn {
  position: relative;
  border: none;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
  padding: 14px 4px 12px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(43, 23, 18, 0.14);
  transition: transform 0.08s, box-shadow 0.08s;
}
.note-btn:hover { transform: translateY(-3px); box-shadow: 0 9px 0 rgba(43, 23, 18, 0.12); }
.note-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.14); }
.note-btn:disabled { opacity: 0.75; }
.note-btn .note-sub {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--sub);
  margin-top: 3px;
}
.note-btn.hit { background: var(--ok); color: #fff; }
.note-btn.hit .note-sub { color: rgba(255, 255, 255, 0.85); }
.note-btn.miss { background: var(--bad); color: #fff; }
.note-btn.miss .note-sub { color: rgba(255, 255, 255, 0.85); }
/* v4.30: 選択肢が多いステージだけ、ボタンの上下を詰める（12/10 → 8/6）。
   カタカナの読み（ツェー・デス…）は残す ── ドイツ語音名が読めない初心者には
   あれが入口そのもので、高さのために切ってよいものではない */
.answer-buttons.many .note-btn { font-size: 1.15rem; padding: 8px 2px 6px; }
.answer-buttons.many .note-btn .note-sub { font-size: 0.6rem; }

/* ───── 運指表示（五線の上・金管＋木管） ───── */
.fingering {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}
.fingering .f-label {
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--sub);
  margin-right: 2px;
}
/* v2.1・A-1: 運指は「基本運指」であって唯一解ではない（替え指がある）。
   そのことを断ったうえで、間違いを知らせてもらう入口も置く。
   図の邪魔をしないよう、行を改めて小さく出す */
.fingering .f-note {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--sub);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-top: 2px;
}
/* 3本の楽器では出せない音の断り書き（v3.1・テューバは4本が基本仕様）。
   運指図の場所をそのまま使うので、図と同じくらいの高さを取って
   画面が跳ねないようにする（C-2 と同じ考え方） */
.fingering .f-fourvalve {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--sub);
}
.fingering .f-fourvalve b { color: var(--fg); }
.fingering .f-fourvalve small { font-size: 0.66rem; opacity: 0.85; }

.fingering .f-valve {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--brown);
  color: var(--brown);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fingering .f-valve.on { background: var(--brown); color: #fff; }
/* 丸数字だけの運指（v3.1・テューバ／ユーフォニアム）。
   絵をやめたぶん、番号は大きく出す ── ここが読めないと運指が伝わらない */
.fingering .f-nums { display: flex; align-items: center; gap: 7px; }
.fingering .f-nums .f-valve { width: 38px; height: 38px; font-size: 1.15rem; border-width: 3px; }
.fingering .f-open {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--sub);
}
/* トロンボーン2段（v2.1・L-1）。F管は刻み幅が違うので、B♭管と同じ目盛りに重ねない */
.fingering .f-tb { display: flex; flex-direction: column; gap: 4px; }
.fingering .f-tb .f-row { display: flex; align-items: center; gap: 5px; }
/* 確認中（検収がまだ）の印。v2.1: 運指図は出すが、確かめた図と誤解させない */
.f-pending {
  display: inline-block;
  background: #fff0f4;
  color: var(--accent);
  border: 1.5px solid rgba(230, 0, 18, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.62rem;
  font-weight: 900;
  vertical-align: middle;
}
.f-pending-line { flex-basis: 100%; text-align: center; margin-top: 3px; }
.fingering.is-pending-fing .f-note { margin-top: 2px; }

.fingering .f-reach {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--sub);
  margin-top: 2px;
}
.fingering .f-pos {
  min-width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--brown);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

/* 木管の運指図: キーの丸をグループごとに並べる（運指表の見た目に準拠） */
.fingering .f-grp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.fingering .f-grp + .f-grp {
  border-left: 2px solid rgba(43, 23, 18, 0.12);
  padding-left: 7px;
}
.fingering .f-grp-keys { display: flex; gap: 3px; }
.fingering .f-key { flex: none; }   /* 狭い場所でも つぶさない（つぶれると読めない） */
.fingering .f-key {
  min-width: 22px;
  height: 22px;
  padding: 0 3px;
  border-radius: 11px;
  border: 2px solid var(--brown);
  color: var(--brown);
  background: #fff;
  font-size: 0.62rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.fingering .f-key.on { background: var(--brown); color: #fff; }
.fingering .f-grp-name {
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--sub);
}
@media (max-width: 400px) {
  .fingering .f-key { min-width: 19px; height: 19px; font-size: 0.56rem; }
  .fingering .f-grp + .f-grp { padding-left: 5px; }
}

/* ───── ポイント演出 ───── */
.point-pop {
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 900;
  color: var(--star);   /* 獲得＝ごほうびの色（v2.1・J-2） */
  pointer-events: none;
  animation: pointFloat 0.9s ease-out forwards;
  z-index: 5;
}
@keyframes pointFloat {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
  15%  { opacity: 1; transform: translate(-50%, -6px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(1); }
}

.rankup-banner {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%) translateY(-140%);
  display: flex; align-items: center; gap: 8px;
  background: var(--yellow);
  color: var(--brown);
  border-radius: 999px;
  padding: 13px 22px;
  font-weight: 900;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
}
.rankup-banner.show { animation: rankupSlide 2.6s ease forwards; }
@keyframes rankupSlide {
  0%   { transform: translateX(-50%) translateY(-140%); opacity: 0; }
  10%  { transform: translateX(-50%) translateY(0);      opacity: 1; }
  85%  { transform: translateX(-50%) translateY(0);      opacity: 1; }
  100% { transform: translateX(-50%) translateY(-140%); opacity: 0; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--brown); color: #fff;
  border: none;
  border-radius: 999px; padding: 11px 20px;
  font-size: 0.85rem; font-weight: 900;
  /* v4.32: 鍵つきカードの説明など、1行に収まらない文も出すようになった。
     ⚠ left:50% だけだと、はみ出さない幅の計算が「左端50%から右端まで」＝画面の半分に
     なってしまい、どんな短い文でも 195px で折り返していた（390px 幅で実測）。
     width:max-content で中身なりの幅にし、上限だけ決める。
     これまでのトースト（「きょうは ここまで…」など）も同じ理由で窮屈だった */
  width: max-content; max-width: min(88vw, 340px);
  text-align: center; line-height: 1.5;
  opacity: 0; z-index: 60;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast.show { animation: toastPop 2.4s ease forwards; }
/* v4.37: ステージ6を越えた瞬間の1回だけ、長めに出す（app.js の showToast(…, true)）。
   40字ほどの文を2.4秒で読ませるのは、小3には速い。既定のトーストは変えていない */
.toast.show.slow { animation-duration: 4.6s; }
@keyframes toastPop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(20px); }
  10%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  85%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ───── 結果 ───── */
.result-card { text-align: center; margin-top: 40px; padding: 30px 20px; border-radius: 28px; box-shadow: var(--shadow); }
.result-card h2 { margin: 0; font-size: 1.7rem; font-weight: 900; letter-spacing: -0.02em; }
.result-stars { font-size: 2.5rem; color: var(--star); margin: 14px 0; letter-spacing: 8px; }
.result-score { font-size: 1.05rem; font-weight: 900; margin: 4px 0; }
/* 結果の音別内訳（v2.1・M-1(7)） */
.result-notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 4px 8px;
  margin: 8px 0 2px;
  max-height: 9.5em;
  overflow-y: auto;
}
.rn-item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--card-hi);
  border-radius: 8px;
  padding: 4px 8px;
}
.rn-name { color: var(--ink); }
.rn-score { color: var(--sub); }
.rn-item.ok .rn-score { color: var(--ok); }
.rn-item.ng .rn-score { color: var(--bad); }

.result-points { font-size: 0.95rem; font-weight: 900; color: var(--star); margin: 6px 0 2px; }
.rank-progress { height: 10px; border-radius: 999px; background: var(--card-hi); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 4px; }
.rank-progress-bar { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--accent)); border-radius: 999px; transition: width 0.4s ease; }
.rank-progress-label { font-size: 0.72rem; color: var(--sub); font-weight: 800; }
.result-message { font-size: 0.9rem; color: var(--sub); font-weight: 800; min-height: 2.4em; }
.result-buttons { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-4) auto 0; width: 100%; max-width: 560px; }
.result-buttons > .btn-primary { width: 100%; min-width: 0; min-height: 56px; padding: var(--sp-4); border-radius: 16px; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; text-wrap: balance; }
.result-buttons > .result-sub, .result-buttons > .result-friends { width: 100%; min-width: 0; }
.result-buttons button { min-width: 0; }

.btn-primary {
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1.05rem;
  font-weight: 900;
  padding: 15px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(43, 23, 18, 0.14);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 9px 0 rgba(43, 23, 18, 0.12); background: var(--primary-dark); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.14); }
.btn-ghost {
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--sub);
  font-size: 0.95rem;
  font-weight: 900;
  padding: 13px;
  cursor: pointer;
}

/* ───── デイリー目標・花だん ───── */
.daily-row { display: flex; align-items: center; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.daily-title { font-size: 0.68rem; font-weight: 900; color: var(--sub); flex: none; }
/* v2.1・I-1: 目標が3桁になるとラベルが広がる。60px のままだと幅360pxで
   行が折り返して花だんが2行目に落ちるので、バーの下限を少し下げる */
.daily-bar { flex: 1; min-width: 48px; height: 8px; border-radius: 999px; background: var(--card-hi); border: 1px solid var(--line); overflow: hidden; }
.daily-bar-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.4s ease; }
.daily-label { font-size: 0.68rem; font-weight: 900; color: var(--sub); }
.daily-star { font-size: 0.9rem; }
.garden { display: inline-flex; gap: 2px; font-size: 0.95rem; }
.garden-slot { filter: grayscale(0.4); opacity: 0.7; transition: transform 0.3s; }
.garden-slot.bloom { filter: none; opacity: 1; animation: bloomPop 0.5s ease; }
@keyframes bloomPop { 0% { transform: scale(0.4); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* ───── おすすめ練習ボタン ───── */
.recommend-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  border: none;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--brown);
  font-weight: 900;
  padding: 13px;
  margin: 12px 0 2px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 23, 18, 0.14);
  transition: transform 0.1s, box-shadow 0.1s;
}
.recommend-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 rgba(43, 23, 18, 0.12); }
.recommend-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.14); }
.recommend-main { font-size: 1rem; }
.recommend-sub { font-size: 0.72rem; font-weight: 800; opacity: 0.8; }

/* ───── 仮想けんばん（こたえかた: けんばん） ───── */
.answer-buttons.piano {
  display: block;
  position: relative;
  height: 190px;
  background: var(--brown);
  border-radius: 16px;
  padding: 6px 6px 8px;
  box-shadow: var(--shadow-sm);
}
.piano .note-btn.key-white {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: calc(100% / 7);
  height: 100%;
  border: 1px solid rgba(43, 23, 18, 0.25);
  border-radius: 0 0 10px 10px;
  padding: 0 0 8px;
  margin: 0;
  box-shadow: none;
  font-size: 1rem;
  vertical-align: top;
}
.piano .note-btn.key-black {
  position: absolute;
  top: 6px;
  width: 14%;
  height: 58%;
  background: #3a2a24;
  color: #fff;
  border-radius: 0 0 8px 8px;
  border: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 6px;
  margin: 0;
  font-size: 0.72rem;
  z-index: 2;
}
.piano .note-btn .key-label { font-weight: 900; pointer-events: none; }
.piano .note-btn.hit { background: var(--ok) !important; color: #fff; }
.piano .note-btn.miss { background: var(--bad) !important; color: #fff; }
.piano .note-btn:hover { transform: none; }
.piano .note-btn:active { transform: none; filter: brightness(0.92); }

/* ───── 紙吹雪 ───── */
.confetti {
  position: fixed;
  top: -24px;
  z-index: 70;
  pointer-events: none;
  animation: confettiFall 1.6s ease-in forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0.6; }
}

/* ───── マスター3つ星 ───── */
.result-stars .m-star {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0 10px;
  font-size: 2.2rem;
  line-height: 1;
  color: #d8cbbc;
  letter-spacing: 0;
}
.result-stars .m-star.on { color: var(--star); }
.result-stars .m-star small { font-size: 0.62rem; font-weight: 900; color: var(--sub); margin-top: 4px; }
.result-summary { font-size: 0.85rem; font-weight: 900; color: var(--ink); margin: 6px 0 2px; min-height: 1.2em; }

/* ───── チュートリアル ───── */
.tutorial {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(43, 23, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.tutorial-card {
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: screenIn 0.35s ease;
}
.mascot-small { width: 76px; }
.tutorial-text { font-size: 0.95rem; font-weight: 900; line-height: 1.8; white-space: pre-line; min-height: 5.4em; margin: 10px 0; }
.tutorial-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.t-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.t-dot.on { background: var(--primary); box-shadow: 0 0 0 1px var(--brown); }
.tutorial-btns { display: flex; flex-direction: column; gap: 8px; }

/* ───── レビュー導線（かんそうを送る） ───── */
/* プレイ画面 play-top の小さな絵文字ボタン（.btn-small を継承） */
.btn-review {
  flex: none;
  padding: 8px 12px;
  font-size: 1rem;
  line-height: 1;
}
/* トップページの控えめな白ピル */
.btn-review-home {
  display: block;
  margin: 16px auto 0;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--sub);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn-review-home:hover { border-color: var(--accent); color: var(--accent); }
.btn-review-home:active { transform: translateY(2px); }

/* 促しポップアップ（オーバーレイ＋中央カード） */
.review-popup {
  position: fixed;
  inset: 0;
  z-index: 78;
  background: rgba(43, 23, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: reviewFade 0.3s ease;
  /* v3.0: カードが画面より高いときにスクロールできるように。
     align-items: center だけだと、あふれたカードは上下とも切れて
     いちばん下の「とじる」に届かなくなる（こえの じゅんび画面・iPhoneで実害） */
  overflow-y: auto;
  overscroll-behavior: contain;   /* 端まで行っても背後の画面を動かさない */
}
@keyframes reviewFade { from { opacity: 0; } to { opacity: 1; } }
.review-card {
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: screenIn 0.35s ease;
  /* 収まるときは中央（auto マージン）、あふれたら 0 に潰れて全体がスクロール圏内に入る */
  margin: auto;
}
.review-title { font-size: 1.15rem; font-weight: 900; color: var(--ink); margin: 0 0 10px; }
.review-text { font-size: 0.9rem; font-weight: 800; color: var(--sub); line-height: 1.7; margin: 0 0 18px; }
.review-btns { display: flex; flex-direction: column; gap: 8px; }
@media (prefers-reduced-motion: reduce) {
  .review-popup, .review-card { animation: none !important; }
}

/* ───── 木管の運指図（v2.2・位置関係のある図） ───── */
.f-ww { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.wd { width: 100%; max-width: 300px; max-height: 200px; height: auto; display: block; }
/* 出題画面は縦がきびしい（320x568 で判定文が隠れた前例がある）ので少し小さく */
#fingering .wd { max-height: 176px; }
.wd-tube { fill: #f0e6dc; stroke: var(--line); stroke-width: 2; }
.wd-hole, .wd-key { fill: #fff; stroke: var(--note-ink, #4a3b33); stroke-width: 2.5; }
.wd-hole.on, .wd-key.on { fill: var(--primary); stroke: var(--primary-dark, var(--primary)); }
.wd-label {
  font-size: 9px; font-weight: 900; fill: var(--sub);
  text-anchor: middle; dominant-baseline: central;
  pointer-events: none;
}
.wd-label.on { fill: var(--primary-ink, #fff); }
.wd-span { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.wd-hand {
  font-size: 11px; font-weight: 900; fill: var(--sub);
  text-anchor: middle; dominant-baseline: central;
}
/* ───── 木管の運指図・イラスト版（v2.3） ─────
   art/*.svg（Illustratorで描いたもの）を tools/build-art.mjs が取り込んだもの。
   絵の側は塗りを持たず class だけ持っている ── 色はここで全部決める。
   そうしないと、属性の塗りが勝って「押している状態」を色で出せない。

   線の太さは、スマホの実寸（横 300px 前後＝原寸の約半分）で見えることを
   基準に決めてある。原寸で見ると少し太いが、細いほうの害が大きい */
/* 横に長い楽器なので、略図より広く使わせる（狭い端末ではカードの幅で頭打ち） */
.wd-il { max-width: 640px; }
.wd-il * { stroke: var(--note-ink, #4a3b33); stroke-linejoin: round; }
.wd-il .k-body { fill: #d9d2ca; stroke-width: 1.6; }
.wd-il .k-cup2 { fill: #eae3da; stroke-width: 1.6; }
.wd-il .k-cup  { fill: #fff; stroke-width: 2.4; }
.wd-il .k-ring { fill: none; stroke-width: 2.4; }
/* 押しているキーだけ塗る。中の輪郭（k-ring）は塗らないので、
   押しても「わっか」が残って、キーの形が分かる */
.wd-il .f-key.on .k-cup { fill: var(--primary); }

/* 図と同じ内容を文字でも出す（読み上げ・図が読めないとき） */
.f-ww-text {
  font-size: 0.78rem; font-weight: 800; color: var(--sub);
  line-height: 1.5; text-align: center;
}

/* v4.34: 運指をまだ持たない楽器の「じゅんびちゅう」。
   「確認中」（未検収の運指に付ける印・赤系）とは別のものなので、色でも分ける。
   出題中は .above-staff.is-pending が visibility で隠すので、答え合わせでだけ見える */
.f-soon {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; padding: 6px 0; color: var(--sub);
  font-size: 0.82rem; font-weight: 800; text-align: center;
}
.f-soon small { font-size: 0.7rem; font-weight: 700; opacity: 0.8; }

/* v4.30: 運指の「もじで見る／替指も見る」。
   主役は運指の図なので、押せることは分かるが目は奪わない大きさにする。
   高さは指で押せる下限（36px）を割らない ── 低学年の指で外すと、
   「押しても何も起きない」= 今回ステージ一覧で見つけたのと同じ失敗になる */
.f-more {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 6px 10px; width: 100%; padding: 2px 0 0;
}
.f-toggle {
  min-height: 36px; padding: 6px 12px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--sub);
  font-size: 0.74rem; font-weight: 800; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.f-toggle.is-on { color: var(--ink); background: var(--card-hi); }
.f-toggle:active { transform: translateY(1px); }

/* ───── おしらせ（v2.2） ───── */
/* 🔔 は左上（⚙ の反対がわ）。⚙ の左どなりに置くと、
   幅の狭い端末でロゴの「る！」に かぶった（320px で実測） */
.btn-gear.btn-news-fixed {
  grid-column: 1;
  justify-self: start;
  width: 46px; height: 46px;
  padding: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  z-index: 5;
}
@media (max-width: 360px) { .btn-gear.btn-news-fixed { width: 42px; height: 42px; font-size: 1.05rem; } }
.news-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bad, #e0603c);
  border: 2px solid var(--card);
}
.news-card { text-align: left; max-width: 400px; }
.news-card .review-title { text-align: center; }
/* 件数が増えても押し出されないよう、一覧の中だけスクロールさせる */
.news-list {
  max-height: min(56vh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 16px;
}
.news-item {
  border-top: 2px solid var(--line);
  padding: 12px 2px;
}
.news-item:first-child { border-top: none; padding-top: 0; }
.news-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.news-date { font-size: 0.75rem; font-weight: 800; color: var(--sub); }
.news-new {
  font-size: 0.65rem; font-weight: 900; color: #fff;
  background: var(--bad, #e0603c);
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.05em;
}
.news-item-title {
  flex: 1 1 100%;
  font-size: 0.98rem; font-weight: 900; color: var(--ink); line-height: 1.5;
}
.news-body {
  font-size: 0.86rem; font-weight: 700; color: var(--sub);
  line-height: 1.75;
  margin: 0;
  white-space: pre-wrap;      /* news.json の改行をそのまま出す */
}
.news-go { margin-top: 10px; }
/* v4.46: みんなの声（news の部品を借りる。声＝太字、返事＝おしらせの本文と同じ調子） */
.voices-lead { font-size: 0.86rem; margin: 0 0 12px; }
.voice-ask { margin: 0 0 4px; font-size: 0.95rem; font-weight: 900; color: var(--ink); line-height: 1.6; }
.voice-who { font-size: 0.75rem; font-weight: 800; color: var(--sub); margin-left: 2px; }
.voice-reply { margin: 0; font-size: 0.86rem; font-weight: 700; color: var(--sub); line-height: 1.75; white-space: pre-wrap; }

/* 配信が新しくなったときの案内。画面の下に出して、プレイの邪魔をしない */
.update-bar {
  position: fixed;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 10px 8px 16px;
  font-size: 0.85rem; font-weight: 800; color: var(--ink);
  width: max-content;
  max-width: calc(100vw - 24px);
}
/* v4.22: 引っ越しの案内。はじめての案内（.tutorial・80）より上に出す。
   新しい人が旧いURLから来たときも、まず引っ越しの案内を押せるように */
.move-popup { z-index: 90; }
.move-note { font-size: 0.8rem; margin-bottom: 12px; }
/* 帯の中では折り返さない ── 折り返すと丸帯の中で文字が縦に積まれて読めない */
.update-bar span, .update-bar .btn-small { white-space: nowrap; }
.update-bar .btn-small { flex: none; padding: 6px 14px; font-size: 0.8rem; }
/* v4.47（発注元 2026-09-17）: 「あたらしい版が あります」は画面の下・周りと同系色で見落とされていた。
   上に出して タイトルに被せ、濃い地に白い文字。ボタンは主ボタンの黄。
   #move-bar（旧い場所の引っ越しの帯）はこれまでどおり下に出る */
.update-bar--top {
  top: 10px; bottom: auto;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-size: 0.95rem;
  padding: 10px 12px 10px 18px;
  z-index: 95;
  animation: updateBarIn 0.4s ease;
}
.update-bar--top .btn-small { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-size: 0.9rem; padding: 8px 16px; }
@keyframes updateBarIn { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (max-width: 360px) {
  .update-bar { font-size: 0.78rem; padding: 7px 8px 7px 13px; gap: 8px; }
}

/* 試用ゲート（あいことば入力） */
.trial-code-row { display: flex; gap: 8px; }
.trial-code-input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 1.05rem;
  font-weight: 900;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  text-align: center;
  letter-spacing: 0.15em;
}
.trial-code-input:focus { outline: none; border-color: var(--accent); }
.trial-code-input.shake { animation: trialShake 0.3s ease; }
@keyframes trialShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.btn-trial-ok { flex: none; }
@media (prefers-reduced-motion: reduce) {
  .trial-code-input.shake { animation: none !important; }
}

/* スペースキー押下中の操作ボタン（指で押したときの:activeと同じ押し込み表現） */
.rhythm-tap-btn.space-press {
  transform: scale(0.96);
  filter: brightness(1.06);
}

/* ───── リズム: タイムライン ─────
   上段=期待オンセットの点 / 中段=音価ぶんの目標バー＋実測バー / 下段=自分のタップ */
.rhythm-timeline {
  position: relative;
  height: 52px;
  margin: 10px 2px 0;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-grid.strong { width: 2px; background: #dcc39f; }
.tl-tick {
  position: absolute;
  top: 3px;
  width: 10px; height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  border: 2.5px solid var(--brown);
  background: #fff;
}
.tl-tick.hit { background: var(--ok); border-color: var(--ok); }
.tl-tick.missed { background: var(--bad); border-color: var(--bad); animation: missPulse 0.6s ease 2; }
@keyframes missPulse { 50% { transform: scale(1.5); } }
/* 音価ぶんの目標バー（うすく敷く）と、70%＝長さOKの下限の到達ライン */
.tl-target {
  position: absolute;
  top: 19px;
  height: 10px;
  background: rgba(43, 23, 18, 0.13);
  box-shadow: inset 0 0 0 1px rgba(43, 23, 18, 0.07);
  border-radius: 5px;
}
.tl-reach {
  position: absolute;
  top: 16px;
  width: 2px; height: 16px;
  margin-left: -1px;
  background: rgba(43, 23, 18, 0.38);
  border-radius: 1px;
}
/* 押している間ずっと伸びる実測バー。70%を越えた瞬間に色が変わる */
.tl-live {
  position: absolute;
  top: 20px;
  height: 8px;
  border-radius: 4px;
  background: var(--star);
  opacity: 0.95;
  z-index: 2;
}
.tl-live.reached { background: var(--ok); }
.tl-live.done { transition: opacity 0.5s linear; opacity: 0; }

.tl-tap {
  position: absolute;
  bottom: 4px;
  width: 8px; height: 8px;
  margin-left: -4px;
  border-radius: 50%;
}
/* 5段階グラデーション（パーフェクト→ギリギリ） */
.tl-tap.tap-t5 { background: #2f9e44; }
.tl-tap.tap-t4 { background: #7cb342; }
.tl-tap.tap-t3 { background: #f0a500; }
.tl-tap.tap-t2 { background: #f57c00; }
.tl-tap.tap-t1 { background: #e05c2b; }
.tl-tap.tap-bad { background: var(--bad); }

/* パーフェクト時に譜面カードが光る */
.stave-card.flash { animation: staveFlash 0.9s ease; }
@keyframes staveFlash {
  0%, 100% { box-shadow: var(--shadow); }
  40% { box-shadow: 0 0 0 6px rgba(255, 201, 40, 0.55), var(--shadow); }
}

/* ───── リズムトレーニング ───── */
.rhythm-intro { font-size: 0.85rem; color: var(--sub); font-weight: 800; margin: 4px 0 14px; }
/* カウントの数字は、五線・音符に重ならないよう譜面の“上の帯”に置く
   （真ん中に出すとリズムを読ませたい時間に譜面を隠してしまう・実機の指摘）。
   帯のぶんの高さは #screen-rhythm-play .stave-card の padding-top で確保する */
/* v2.1・D-1: 以前は left:0; right:0 で親の幅いっぱいに広げ、その箱ごと
   countPop で 1.6倍に拡大していた。中身は「4」「3」「2」「1」「と」の1文字なのに、
   箱が画面より約66px はみ出して横スクロールバーを誘発し、
   スクロールバーのぶんレイアウトが動いて「おして のばす」ボタンが跳ねていた
   （QAレビュー3-2。予備拍のたびに起きるので「一瞬だけ」出る）。
   文字ぶんだけの箱にして中央へ置けば、1.6倍にしてもはみ出さない。 */
.rhythm-count {
  position: absolute;
  left: 50%; top: 2px;
  transform: translateX(-50%);
  max-width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 2;
}
/* v4.18: 拍の丸が画面下へ移ったので、譜面カードの上の帯は
   スイング指示のぶんだけでよくなった（旧: 40px） */
#screen-rhythm-play .stave-card { padding-top: 26px; }
/* トーストが画面下の「押す帯」に重ならないように上へ逃がす */
body:has(#screen-rhythm-play:not([hidden])) .toast { bottom: calc(28vh + 20px); }
.rhythm-count.pop { animation: countPop 0.3s ease; }
@keyframes countPop {
  0% { transform: translateX(-50%) scale(1.6); opacity: 0.4; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
/* 判定表示: タイミングと長さを2行に並べる（v2.0・上書きしない） */
.rhythm-judge {
  text-align: center;
  min-height: 3.1em;
  /* v2.1・M-1(2): 判定の前後に息つぎの余白。縦の場所は五線の可変化と
     下の media（背の低い端末で帯・ボールを薄くする）で先に作ってある */
  margin: 14px 0 18px;
}
/* 出るのは即座に、消えるのはゆっくり。
   次の判定が来るまでの短い時間でも、読み終わる猶予をつくる（実機の指摘） */
.rj-line {
  font-weight: 900;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.55s ease;
}
.rj-line.show { opacity: 1; transition: opacity 0.08s ease; }
.rj-timing { font-size: 1.25rem; min-height: 1.4em; }
.rj-hold { font-size: 0.95rem; min-height: 3em; }   /* 長さの助言は390px幅で2行になる */
.rj-line.good { color: var(--ok); }
.rj-line.soso { color: var(--star); }
.rj-line.bad { color: var(--bad); }
.rhythm-tap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* v2.0: 画面下いっぱいの帯。上端がボールの床になる（margin-top は0のまま） */
  width: 100%;
  height: calc(var(--tap-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  margin: 0;
  pointer-events: auto;
  border: none;
  border-radius: 26px 26px 0 0;
  background: radial-gradient(ellipse at 50% 0%, #ff5a63, var(--accent) 72%);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 900;
  cursor: pointer;
  /* v3.0: manipulation だと指が滑ったときブラウザがスクロールと解釈して
     pointercancel が飛び、「早く離した（音が短い）」誤判定になる（モニター報告）。
     none にして、この帯の上ではジェスチャーを渡さない */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 -6px 26px rgba(230, 0, 18, 0.28);
  transition: filter 0.06s;
}
.rhythm-tap-btn:active { filter: brightness(1.12); }
.rhythm-tap-btn .tap-main { font-weight: 900; }
.rhythm-tap-btn .tap-sub { font-size: 0.72rem; font-weight: 900; opacity: 0.85; margin-top: 6px; }

/* ── 声でリズム（v2.4）: 帯はそのまま「マイクの状態表示」になる ──
   帯の高さ・位置は変えない（上端＝ボールの床、という関係を崩さないため）。
   メーターは「マイクが自分の声を聞いている」ことの見える化で、
   これが無いと 子どもは声が届いているのか分からず どんどん大声になる */
.rhythm-tap-btn.voice-mode { cursor: default; }
.rhythm-tap-btn.voice-mode:active { filter: none; }
.voice-meter {
  display: block;
  width: min(70%, 300px);
  height: 8px;
  margin-top: 7px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  overflow: hidden;
}
.voice-meter { position: relative; }
/* 設定の「ズレを はかる」ポップアップに置くメーター（白地の上なので配色が別） */
.voice-meter-setup {
  width: 100%;
  margin: 10px 0 2px;
  background: var(--card-hi);
  border: 1px solid var(--line);
}
.voice-meter-setup i { background: var(--ok); }
.voice-meter-setup b { background: var(--sub); opacity: 0.5; }
.voice-setup-progress { min-height: 1.4em; font-variant-numeric: tabular-nums; }
/* 実機の切り分け用の書き出し（クリップボードが使えない端末の受け皿） */
.voice-log-box {
  width: 100%;
  height: 110px;
  margin-top: 8px;
  font: 11px/1.5 ui-monospace, monospace;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--card-hi);
  color: var(--ink);
}
.voice-meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.06s linear;
}
/* 「ここまで ふれたら ひろえる」の目印（検出の下限 −50dB の位置） */
.voice-meter b {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 28.6%;
  width: 2px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 2px;
}

/* 背の低い縦画面（iPhone SE 2/3 等）では、帯＋ボール＋五線が画面高の約4割を
   占め、判定表示が下の固定帯の裏に完全に隠れていた（実測: 320×568 で判定の
   下端が帯の上端より 148px 下）。帯とボールを薄くして本文の場所を残す。
   ※ 帯を薄くする＝押す的が小さくなるので、96px を下回らせない（v2.1・M-1(2)） */
@media (orientation: portrait) and (max-height: 740px) {
  #screen-rhythm-play .stave-card { padding-top: 22px; }
  /* 低い画面では丸を小さくして、跳ねる高さを残す（丸の数と順番は変えない） */
  #screen-rhythm-play .beat-dots-floor .bd { width: 26px; height: 26px; font-size: 0.9rem; }
}

/* 横向きは画面が低いので、帯とボールを薄くして本文の場所を残す */
@media (orientation: landscape) and (max-height: 540px) {
  #screen-rhythm-play {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: auto auto auto 1fr;
    column-gap: 16px;
    max-width: 900px;
  }
  #screen-rhythm-play .play-top { grid-column: 1 / -1; }
  #screen-rhythm-play .stave-card { grid-column: 1; grid-row: 2 / span 2; align-self: start; }
  #screen-rhythm-play .rhythm-timeline { grid-column: 1; grid-row: 4; }
  #screen-rhythm-play .status { grid-column: 2; grid-row: 2; margin: 2px 0; min-height: 3em; }
  #screen-rhythm-play .rhythm-judge { grid-column: 2; grid-row: 3; min-height: 2.6em; }
  #screen-rhythm-play .rhythm-motion-note { grid-column: 1 / -1; }
  #screen-rhythm-play .beat-dots-floor .bd { width: 26px; height: 26px; font-size: 0.9rem; }
}

/* ───── レスポンシブ ─────
   〜519px: スマホ縦（基準デザイン） */

/* タブレット・PC（720px〜） */
@media (min-width: 720px) {
  .screen { max-width: 760px; padding-top: 28px; }
  .logo { font-size: 2.8rem; }
  .inst-grid { grid-template-columns: repeat(3, 1fr); }
  .note-btn { font-size: 1.7rem; padding: 18px 6px 15px; }
  .note-btn .note-sub { font-size: 0.78rem; }
  .stave svg { max-width: 480px; }
  /* 主操作・副操作・共有は広い画面でも縦の3段を保つ。 */
  .result-buttons { flex-direction: column; }
  .channel-grid { flex-direction: row; }
  .channel-card { flex: 1; }
}

/* スマホ横向き: プレイ画面を左右2分割 */
@media (orientation: landscape) and (max-height: 540px) {
  #screen-play {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    grid-template-rows: auto auto auto 1fr;
    column-gap: 16px;
    max-width: 900px;
    padding-bottom: 16px;
  }
  #screen-play .play-top { grid-column: 1 / -1; margin-bottom: 6px; }
  #screen-play .play-stage { grid-column: 1 / -1; }
  #screen-play .stave-card { grid-column: 1; grid-row: 3 / span 2; align-self: start; }
  #screen-play .status { grid-column: 2; grid-row: 3; margin: 4px 0 10px; }
  #screen-play .answer-buttons { grid-column: 2; grid-row: 4; align-content: start; }
  .note-btn { padding: 12px 4px 10px; font-size: 1.3rem; }
}

/* 極小画面（〜360px） */
@media (max-width: 360px) {
  .note-btn { font-size: 1.25rem; padding: 12px 2px 10px; }
  .logo { font-size: 1.8rem; }
}

/* ═══ rhythm 2026-07-09 追記 ═══ */
/* ホーム画面のバッキング選択 */
.rhythm-backing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 2px 2px 16px;
}
.rhythm-backing-label { flex: none; font-size: 0.85rem; font-weight: 900; color: var(--sub); }
#seg-rhythm-backing button { padding: 6px 13px; font-size: 0.8rem; }
/* 音価が短すぎたタップは点線枠で区別（塗りなし＝ボーナス不成立） */
.tl-tap.hold-short {
  background: transparent;
  border: 2px dotted var(--bad);
  width: 9px; height: 9px;
  margin-left: -4.5px;
}

/* ═══ v2.0（2026-08 改訂） ═══ */

/* ───── リズム: 画面下に固定した「押す帯」＋その上を跳ねるボール ─────
   円ボタンだと機種によっては画面の下に隠れ、ボールの着地点まで見えなくなる。
   帯の全幅をタップ領域にし、その上端をボールの床にする（＝どこを押してもよい）。
   本文には帯のぶんの余白を確保して、下に隠れる要素が出ないようにする */
/* v4.18（案2）: ボールの床は「1・2・3・4 の丸の上端」になった。丸のぶん（約30px）
   だけ余分に要るが、跳ぶ高さは 丸の間隔に合わせて低くしたので（rhythm.js）、
   帯ぜんたいの高さは v4.17 とほぼ同じ。譜面カードの上の帯（旧「4・3・2・1」の
   数字のための余白・丸が下りたので不要）も 40px→26px に返している */
#screen-rhythm-play {
  --tap-h: clamp(132px, 26vh, 210px);
  --ball-h: clamp(112px, 15vh, 136px);
  padding-bottom: calc(var(--tap-h) + var(--ball-h) + 14px);
}
/* 低い画面（縦）と横向きは、帯とボールを薄くして本文の場所を残す。
   ※ この2つは かならず 上の既定値より **後ろ** に置く。@media は詳細度を上げないので、
      前に書くと 既定値に上書きされて効かない（v2.1 からの取りこぼし・v4.18 で気づいた）。
   ※ 帯を薄くする＝押す的が小さくなるので、96px を下回らせない（v2.1・M-1(2)） */
@media (orientation: portrait) and (max-height: 740px) {
  #screen-rhythm-play { --tap-h: clamp(96px, 17vh, 132px); --ball-h: clamp(96px, 15vh, 118px); }
}
@media (orientation: landscape) and (max-height: 540px) {
  #screen-rhythm-play { --tap-h: clamp(74px, 26vh, 120px); --ball-h: clamp(80px, 22vh, 104px); }
}
.rhythm-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  pointer-events: none;   /* 帯のボタンだけが受ける */
}
/* v4.18: ボールの箱と 拍の丸を重ねる舞台。丸は箱の外に置く
   （「拍のうごき」をオフにするとレイヤーごと畳むので、中に入れると丸まで消える） */
.rhythm-beat-stage {
  position: relative;
  width: 100%;
  height: var(--ball-h);
  pointer-events: none;
}
.rhythm-ball-layer {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  margin: 0;
  pointer-events: none;
}
/* v2.1・D-1: 以前は overflow:visible で、着地の波紋（r = 9 + 72×経過秒）と
   しっぽの先が箱の外へはみ出していた。はみ出しぶんがページの表示領域を一瞬だけ広げ、
   スクロールバーが出たり消えたりして「おして のばす」ボタンが上下に跳ねた（QAレビュー3-2）。

   閉じる前に、切れて困るものが入る余白を用意する。床のすぐ下に出るもの
   （波紋の下半分・落下前のしっぽの先）のために、SVGの箱だけを床の下へ
   BALL_FLOOR_PAD ぶん伸ばす（高さは rhythm.js が実寸で入れる）。
   伸ばすのは絶対配置の SVG だけなので、レイヤーの高さ＝タップボタンの位置は変わらない。 */
.rhythm-ball-svg {
  display: block;
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
}
.ball-floor  { stroke: rgba(43, 23, 18, 0.28); stroke-width: 3; stroke-linecap: round; }
.ball-apex   { stroke: rgba(43, 23, 18, 0.16); stroke-width: 2; stroke-dasharray: 5 6; }
.ball-ripple { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.ball-shadow { fill: #2b1712; }
/* 着地の瞬間はタップボタン（同じ赤）と接する。輪郭を1本入れて、
   いちばん見せたい打点でボールが背景に溶けないようにする */
.ball-body   { fill: var(--accent); stroke: rgba(43, 23, 18, 0.30); stroke-width: 2; }

/* スイング指示（譜面は均等に書いて跳ねて吹く、という実際の譜面の作法） */
.rhythm-swing-badge {
  position: absolute;
  left: 14px; top: 8px;
  font-size: 0.66rem;
  font-weight: 900;
  font-style: italic;
  color: var(--sub);
  background: var(--card-hi);
  border-radius: 999px;
  padding: 3px 10px;
  z-index: 2;
}

/* リズムのステータス行は、長い一言ガイドが入っても高さが暴れないよう小さめに。
   min-height を固定するのは、行数が増えたときに下のタップボタンが動いてしまうと
   演奏中に指の位置がずれるため（押す的が動くのは致命的） */
#screen-rhythm-play .status {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0;
  min-height: 4.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 「拍のうごき」がオフのときの案内（黙って無効化しないための導線） */
.rhythm-motion-note {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sub);
  margin: 10px 8px 0;
  line-height: 1.6;
}

/* 長さが 0.55〜0.70（あと少し）のタップは黄色系。赤は0.55未満のときだけ */
.tl-tap.hold-near {
  background: transparent;
  border: 2px dotted var(--star);
  width: 9px; height: 9px;
  margin-left: -4.5px;
}

/* ───── 不正解のあとの「つぎの もんだいへ」 ─────
   小さなヒント文字では「押せる」と気づかれなかったので、はっきりしたボタンにする。

   v2.1・C-2: 以前は display:none ⇔ block で出し入れしていたため、
   このボタンが消えた瞬間にレイアウトが詰まり、すぐ下の #answer-buttons が
   約60px せり上がっていた。「つぎへ」に伸ばした指が、せり上がってきた回答ボタンを
   押してしまう事故の原因（LINEでの報告）。
   場所は常に確保したまま visibility だけで出し入れし、回答ボタンを1pxも動かさない。 */
.next-hint {
  display: block;
  visibility: hidden;
  width: 100%;
  border: none;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--brown);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  padding: 12px;
  margin: 0 0 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 23, 18, 0.16);
}
.next-hint.show {
  visibility: visible;
  animation: nextHintPop 0.3s ease, nextHintPulse 1.8s ease-in-out 0.3s infinite;
}
.next-hint:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.16); }
.next-hint .next-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  opacity: 0.75;
  margin-top: 3px;
}
@keyframes nextHintPop { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nextHintPulse { 50% { box-shadow: 0 5px 0 rgba(43, 23, 18, 0.16), 0 0 0 6px rgba(255, 201, 40, 0.35); } }
@media (prefers-reduced-motion: reduce) {
  .next-hint.show { animation: none !important; }
}

/* ───── ホルン: F管・B♭管の2段表示 ───── */
.fingering .f-horn { display: flex; flex-direction: column; gap: 4px; }
.fingering .f-row { display: flex; align-items: center; gap: 5px; }
.fingering .f-side {
  min-width: 40px;
  font-size: 0.62rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 2px 6px;
  text-align: center;
  color: #fff;
}
.fingering .f-side.side-f { background: #1a6fb5; }
.fingering .f-side.side-bb { background: var(--accent); }
.fingering .f-horn .f-valve { width: 25px; height: 25px; font-size: 0.82rem; border-width: 2px; }
/* どちら側を基本にするかの札（v3.1・外部監査 §9-2）。
   並べるだけでは「2つ出てきた。どっち？」で止まるので、順番と札で示す */
.fingering .f-pref {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--card-hi);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.fingering .f-pref.is-main { color: var(--card); background: var(--ink); border-color: var(--ink); }
.fingering .f-pref-note {
  flex-basis: 100%;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--sub);
  margin-top: 1px;
}

/* ───── 運指: トロンボーンのスライド図・金管のピストン図 ───── */
.fingering .f-slide { display: inline-flex; align-items: center; }
.fingering .f-label small { display: block; font-size: 0.55rem; font-weight: 800; opacity: 0.8; }
/* スライド図は横に長い（実物がそうなので）。1行を丸ごと使い、
   目盛りの数字が読める大きさを確保する（v2.1・実機の指摘） */
.fingering .f-slide { flex-basis: 100%; justify-content: center; }
.fingering .tb-slide { width: 100%; max-width: 300px; height: auto; }
.fingering .f-tb .f-slide { flex: 1; min-width: 0; flex-basis: auto; }
.fingering .f-brass { width: 146px; height: 75px; }
@media (max-width: 400px) {
  .fingering .f-brass { width: 126px; height: 65px; }
}

/* ───── エンドレスモード ───── */
.stage-card.endless-card { border-style: dashed; }
.endless-count { font-size: 3rem; font-weight: 900; color: var(--ink); letter-spacing: 0; }
.endless-count small { font-size: 0.9rem; font-weight: 900; color: var(--sub); margin-left: 6px; }

/* ───── 補足テキスト（レビューの opt-in 文言・試用ゲートの注記） ───── */
.review-note {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--sub);
  line-height: 1.6;
  background: var(--card-hi);
  border-radius: 12px;
  padding: 8px 10px;
  margin: 0 0 14px;
  text-align: left;
}

/* 専門用語の初出ルビ（v2.1・J-1）。語全体に1つだけ掛ける。
   テストが文字列で見る語（「音の高さ」等）をまたいで掛けると
   textContent に読みが混ざって壊れるので、掛けてよい場所は
   stage-desc / channel-desc など innerHTML 経由の説明文だけ */
ruby { ruby-position: over; }
rt { font-size: 0.5em; font-weight: 700; line-height: 1; color: var(--sub); }

/* かんそう送信の「ようやくを付ける」チェック（v2.1・K-1: 送る直前に本人が選ぶ） */
.review-share-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.review-share-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

/* 初回ガイドのきびしさ選択（縦積みで押しやすく） */
.seg.seg-wide { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.seg.seg-wide button { width: 100%; }

/* ───── v2.1・B-1: 音とタップのズレ（レイテンシ補正） ───── */
.latency-row { display: flex; align-items: center; gap: 8px; }
.latency-value {
  min-width: 68px;
  text-align: right;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.latency-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 12px 0 10px;
  min-height: 14px;
}
.latency-dots span {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--sub);
  background: transparent;
  transition: transform 0.12s ease, background 0.12s ease;
}
.latency-dots span.lead { border-style: dashed; opacity: 0.5; }
.latency-dots span.on   { background: var(--yellow); border-color: var(--brown); transform: scale(1.25); }
.latency-dots span.got  { background: var(--ok); border-color: var(--ok); }
.latency-pad {
  display: block;
  width: 100%;
  border: none;
  border-radius: 20px;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  padding: 26px 12px;
  margin: 0 0 10px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 23, 18, 0.16);
  touch-action: manipulation;
}
.latency-pad:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.16); }
.latency-pad[disabled] { opacity: 0.5; }
.latency-pad.space-press { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.16); }

/* ───── v2.1・F-1: 音名と運指の一覧 ───── */
.btn-ref-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  border: none;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--brown);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 900;
  padding: 13px 12px;
  margin: 0 0 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 23, 18, 0.16);
}
.btn-ref-open:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43, 23, 18, 0.16); }
.ref-open-sub { font-size: 0.68rem; font-weight: 800; opacity: 0.75; }

.ref-list { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-1) 0 18px; }
/* v4.15: 音カードの形を そろえる（発注元の指摘「音によって ばらつきがあって 見ていて汚い」）。
   以前は 図の入る音だけ列の幅が変わり（clamp が2種類）、五線の幅も 120／132 と揺れ、
   運指の図の左端が 28px／244px の2か所に分かれていた。
   これからは **どの音も同じ枠**: 1段目＝五線・音名・ボタン、2段目＝運指（必ず場所を空ける）。
   図と札と文字にも高さを与えるので、替指の有無で 上の段がずれない */
.ref-row {
  display: grid;
  grid-template-columns: var(--ref-stave-w) minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  padding: var(--sp-3);
}
/* v2.5: 五線が小さすぎて音符が読めなかった（実機の指摘）。
   幅は画面に応じて伸ばす ── 一覧は「音符を読む」ための表なので、
   ここが読めないと表そのものが成り立たない */
/* v3.1: 幅は**列に合わせる**。自前で clamp を持つと、木管・ホルンの行
   （.has-keys は列が clamp(120px,24vw,170px) と狭い）で五線が列からはみ出し、
   音名の文字に重なっていた（ホルンで顕著・実機の指摘） */
.ref-stave { width: 100%; min-width: 0; grid-column: 1; grid-row: 1; }
.ref-stave svg { width: 100%; height: auto; display: block; }
.ref-name { display: flex; flex-direction: column; line-height: 1.15; grid-column: 2; grid-row: 1; }
.ref-label { font-size: 1.35rem; font-weight: 900; color: var(--ink); }
/* 同音異名のもう一方（v3.1）。主より小さく薄く ── 主がどちらかを一目で */
.ref-alt { font-size: 0.78em; font-weight: 800; color: var(--sub); }
.ref-kana { font-size: 0.68rem; font-weight: 800; color: var(--sub); }
/* トロンボーンのスライド図など、幅の決まった図が入る。
   狭い画面で列からはみ出して横スクロールバーを出さないよう、縮めて収める */
/* v4.15: 運指は どの音でも 2段目の全幅（図の有無・替指の有無で 場所が動かない） */
.ref-fing {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  overflow: visible;
  min-height: var(--ref-fig-h);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref-fing svg { max-width: 100%; height: auto; }
.ref-fing .fingering { justify-content: center; gap: 5px; width: 100%; }
/* 入りきらない端末では、指のグループ単位で折り返す（グループごとに名前が付くので読める） */
.ref-row.has-keys .ref-fing .fingering { justify-content: center; flex-wrap: wrap; row-gap: 6px; }
/* 金管の丸数字は、どの音でも同じ位置から始める（v3.1）。
   「開放」の文字を流れから外さないと、その1文字ぶん行が広がって
   中央そろえの位置がずれる（発注元の指摘「①〜④が音ごとにガタガタ」） */
.ref-row.has-keys .ref-fing .f-brass-row { position: relative; }
.ref-row.has-keys .ref-fing .f-brass-row .f-open {
  position: absolute;
  left: 100%;
  margin-left: 7px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
}
.ref-fing .f-brass { width: 96px; height: 50px; }
.ref-fing .tb-slide { width: 100%; max-width: 150px; height: auto; }
.ref-fing .f-key, .ref-fing .f-valve { width: 22px; height: 22px; font-size: 0.62rem; }
/* 一覧でも丸数字は大きいまま（v3.1）。絵を外した代わりに、ここで読ませる */
.ref-fing .f-nums .f-valve { width: 30px; height: 30px; font-size: 0.92rem; border-width: 2.5px; }
.ref-fing .f-note { display: none; }
.ref-fing-none { font-size: 0.66rem; font-weight: 800; color: var(--sub); }

/* v4.15: 木管の1つぶんを「札の段・図・押すキーの文字」の 決まった段に入れる（運指表だけ）。
   札の無い音でも 札の段を空けておくので、替指のある音と 図の高さがそろう。
   図は高さを固定して 縦横比のまま縮める（音ごとに 大きさが変わらない）。
   **文字は削らない**（読めなくなるより、少し高くなる方がまし）。2行ぶんは必ず確保する */
.ref-fing .f-ww {
  display: grid;
  grid-template-rows: var(--ref-tag-h) var(--ref-fig-h) minmax(var(--ref-text-h), auto) auto;
  justify-items: center;
  align-items: center;
  gap: var(--sp-1);
  width: 100%;
}
/* 段は 中身に関係なく 決め打ちで割り当てる。自動配置に任せると、札の無い音では
   図が「札の段（18px）」に入り込んで 文字に重なる（実機で確認） */
.ref-fing .f-ww > .f-ww-tag { grid-row: 1; }
.ref-fing .f-ww > svg { grid-row: 2; }
.ref-fing .f-ww > .f-ww-text { grid-row: 3; align-self: start; }
.ref-fing .f-ww > .f-alt-note { grid-row: 4; }
/* 図は 高さを **決め打ちしない**（縦横比のまま、枠に収まるところまで縮める）。
   幅の上限を そろえるので、替指が2つ並ぶ音でも 1つだけの音でも **同じ大きさ**で描かれる */
.ref-fing .f-ww > svg {
  max-height: var(--ref-fig-h); max-width: min(100%, var(--ref-fig-w)); height: auto; width: auto;
}
/* 金管も同じ考え方（札の段を空けて、図の高さをそろえる） */
.ref-fing .f-brass-row {
  display: grid;
  grid-template-rows: var(--ref-tag-h) auto auto;
  justify-items: center;
  align-items: center;
  gap: var(--sp-1);
}
.ref-fing .f-brass-row > .f-ww-tag,
.ref-fing .f-brass-row > .f-label { grid-row: 1; }
.ref-fing .f-brass-row > svg,
.ref-fing .f-brass-row > .f-nums { grid-row: 2; }
.ref-fing .f-brass-row > .f-alt-note { grid-row: 3; }
/* ── 替え指（v2.5） ──
   運指表と同じく 標準 → 替指 の順に積む。どちらが標準かが一目で分かること
   （ラベルが無いと「2つあるうちのどちらを覚えるのか」が読めない） */
.f-ww-tag {
  align-self: center;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--card);
  background: var(--ink);
  border-radius: 999px;
  padding: 1px 10px;
}
.f-ww-tag.is-alt { color: var(--ink); background: var(--card-hi); border: 1.5px solid var(--line); }
/* 替え指の説明（v3.1・外部監査 §18）。「いつ使うのか」が無いと替え指は雑音になる */
.fingering .f-alt-note {
  flex-basis: 100%;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--sub);
  text-align: center;
  margin-top: 2px;
}
.fingering .f-alt-note b { color: var(--ink); }
.ref-fing .f-alt-note { font-size: 0.6rem; }
/* 一覧の上に出す、前提にしている楽器の仕様（v3.1） */
.ref-spec {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 2px 0 10px;
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--sub);
  background: var(--card-hi);
  border-radius: 12px;
}
.ref-spec-row b {
  display: inline-block;
  min-width: 4.2em;
  color: var(--ink);
  font-weight: 900;
}
/* 金管の替え指も同じ積み方（図＋札を1行として縦にならべる） */
.f-brass-row { display: flex; align-items: center; gap: 6px; }
.fingering .f-brass-row + .f-brass-row { margin-top: 8px; padding-top: 8px; border-top: 1.5px dashed var(--line); }
/* v4.15: 標準と替指は **横に並べる**（見くらべる物なので）。
   縦に積むと カードが2倍の高さになり、一覧を上下に流したとき 音の切れ目が読めなくなる。
   360px 未満では入らないので 縦に戻す */
.ref-row.has-alts .ref-fing .fingering {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  column-gap: var(--sp-3);
}
.ref-row.has-alts .ref-fing .fingering .f-ww + .f-ww,
.ref-row.has-alts .ref-fing .fingering .f-brass-row + .f-brass-row {
  margin-top: 0; padding-top: 0; border-top: none;
  border-left: 1.5px dashed var(--line); padding-left: var(--sp-3);
}
@media (max-width: 359px) {
  .ref-row.has-alts .ref-fing .fingering { grid-template-columns: 1fr; row-gap: var(--sp-2); }
  .ref-row.has-alts .ref-fing .fingering .f-ww + .f-ww,
  .ref-row.has-alts .ref-fing .fingering .f-brass-row + .f-brass-row {
    border-left: none; padding-left: 0; border-top: 1.5px dashed var(--line); padding-top: var(--sp-2);
  }
}
.fingering .f-ww + .f-ww { margin-top: 10px; padding-top: 10px; border-top: 1.5px dashed var(--line); }

.ref-btns { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ref-play {
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(43, 23, 18, 0.16);
}
.ref-play:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(43, 23, 18, 0.16); }
/* 実音ボタン（v3.0）: ♪と同じ列に縦に積む。読み上げなしで音の高さだけ鳴る */
.ref-tone {
  width: 44px; height: 44px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  font-size: 0.62rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(43, 23, 18, 0.16);
}
.ref-tone:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(43, 23, 18, 0.16); }
@media (max-width: 380px) {
  .ref-row { grid-template-columns: clamp(104px, 30vw, 150px) minmax(58px, auto) 1fr 40px; gap: 7px; }
  .ref-stave { width: clamp(104px, 30vw, 150px); }
  .ref-play { width: 40px; height: 40px; }
  .ref-tone { width: 40px; height: 40px; font-size: 0.58rem; }
}
/* v2.1・H-1: 音のながさは星にせず、事実の1行としてそえる */
.rhythm-result-hold { margin-top: 2px; opacity: 0.9; }
/* 「入りのタイミング」は8文字あるので、3つの星が折り返さないよう幅を分け合う */
.result-stars { display: flex; justify-content: center; align-items: flex-start; }
.result-stars .m-star { flex: 1 1 0; min-width: 0; margin: 0 4px; }
.result-stars .m-star small { display: block; line-height: 1.15; }

/* ───── v2.1・G-1: 打楽器（音の高さを読まないパート） ───── */
/* カードは消さずに残す。消すと「壊れた？」という新しい分からなさを作る */
.channel-card.is-na { opacity: 0.62; }
.channel-card.is-na .channel-start { background: var(--sub); color: #fff; }   /* 灰地に brown は読めないので白のまま */
.rhythm-only-note {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding: 20px 18px;
  text-align: center;
}
.rhythm-only-note p { margin: 0 0 12px; font-size: 0.9rem; font-weight: 800; line-height: 1.6; }
.btn-goto-rhythm { width: 100%; margin: 4px 0 10px; }
.rhythm-only-note .naming-note { margin: 0; }
/* v2.1・I-1: チュートリアル1枚目の楽器グリッド。
   13件を丸ごと出すと縦に長くなるので、カードの中でスクロールさせる。
   これが無いと iPhone 縦（390×844）で「つぎへ」が画面の外に落ちる */
/* v3.1（外部評価 U1）: 格子の中だけをスクロールさせない。2列固定・短い楽器名・
   ボタンを詰めて、1枚に収める（カード全体は小さい画面で丸ごとスクロールできる） */
.inst-grid.tutorial-inst { max-height: none; overflow: visible; margin: 4px 0 10px; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tutorial-inst .inst-btn { padding: 7px 8px; font-size: 0.84rem; min-height: 44px; }
.tutorial-inst .inst-btn .inst-icon { font-size: 1.1rem; }
/* 小さい画面（320×568）では 13楽器×2列がカードに収まらない。格子の中を
   スクロールさせない代わりに、カード全体がスクロールし、ボタンは下に貼りつく */
.tutorial-card .tutorial-btns { position: sticky; bottom: -16px; background: var(--card); padding: 8px 0 16px; margin-bottom: -16px; }
.tutorial-card .tutorial-btns::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; background: linear-gradient(rgba(255,255,255,0), var(--card)); }
/* v3.1（U8）: 押す場所は 44px 以上（小学生の指・タブレットの誤タップ） */
.btn-small, .seg button, .review-btns button, .tutorial-btns button, .news-go { min-height: 44px; }
.ref-tone { min-height: 44px; }
.ref-oct { font-size: 0.62em; font-weight: 800; color: var(--sub); margin-left: 2px; vertical-align: baseline; }
.ref-jump { display: flex; gap: 8px; justify-content: center; margin: 4px 0 10px; }
.ref-jump-btn { padding: 6px 14px; }
.voice-setup-mic { font-variant-numeric: tabular-nums; }
.f-pending-lv { font-size: 0.68rem; color: var(--sub); margin-left: 4px; font-weight: 800; }
/* v3.1（P1-3）: 4本でだけ出る低音域の、補正機構の注記 */
.fingering .f-comp-note { display: block; width: 100%; font-size: 0.72rem; color: var(--sub); font-weight: 800; line-height: 1.5; margin-top: 4px; text-align: left; }
.fingering .f-comp-note.is-nc { color: var(--ink); background: rgba(255, 201, 40, 0.18); border-radius: 10px; padding: 6px 8px; }
.fingering .f-comp-note b { color: var(--ink); }
.fingering .f-comp-note small { display: block; font-size: 0.66rem; opacity: 0.85; }
.ref-fing .f-comp-note { font-size: 0.62rem; }
.tl-tick.unheard { background: #c9c2bd; border-color: #a89f99; }
.tutorial-card { max-height: 92vh; overflow-y: auto; }

/* ───────── v3.1（外部評価 U5）: 結果画面「できたこと → つぎの1つ → 内訳」 ───────── */
.result-next {
  margin: 12px auto 6px; padding: 10px 14px; max-width: 420px;
  background: var(--card-hi, #fff7ea); border: 2px solid var(--accent, #ff8c42); border-radius: 16px;
  text-align: left;
}
.result-next-label { display: block; font-size: 0.72rem; font-weight: 900; color: var(--accent, #ff8c42); letter-spacing: 0.06em; }
.result-next-text { margin: 4px 0 0; font-size: 0.98rem; font-weight: 900; color: var(--ink); line-height: 1.5; }
.result-detail { margin-top: 12px; padding-top: 8px; border-top: 1px dashed #e2d6c6; }
.result-detail-title { margin: 0 0 2px; font-size: 0.72rem; font-weight: 900; color: var(--sub); letter-spacing: 0.06em; }
/* 回復（7.5）: もう一度出す問題 */
.status.retry { color: var(--accent, #ff8c42); }
/* 復習カード（8.2） */
.stage-card.review-card .stage-num { background: #e6f4ea; color: #2f9e44; font-size: 1.2rem; box-shadow: none; }
.stage-card.review-card.done { opacity: 0.85; }
.stage-card.review-card .stage-stars { font-size: 0.78rem; color: var(--ok, #2f9e44); letter-spacing: 0; }

/* ───────── v3.1（外部評価 U3・U4・T2） ───────── */
.btn-placement { background: #eef6ff; border-color: #bcd4f5; }
.lab-details { margin-bottom: 14px; }
.lab-details > summary {
  cursor: pointer; list-style: none; padding: 14px 18px; border-radius: 24px;
  background: var(--card-hi); color: var(--sub); font-size: 0.82rem; font-weight: 900; letter-spacing: 0.1em;
  box-shadow: var(--shadow-sm); min-height: 44px; box-sizing: border-box;
}
.lab-details > summary::-webkit-details-marker { display: none; }
.lab-details > summary::before { content: "▸ "; }
.lab-details[open] > summary { border-radius: 24px 24px 0 0; }
.lab-details[open] > summary::before { content: "▾ "; }
.lab-details > .lab-note { margin: 8px 18px 4px; }
.lab-details > .card { border-radius: 0 0 24px 24px; }
.backup-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.backup-box {
  width: 100%; box-sizing: border-box; font-family: ui-monospace, Menlo, monospace; font-size: 0.72rem;
  border: 2px solid #e2d6c6; border-radius: 12px; padding: 8px; background: #fff; color: var(--ink); resize: vertical;
  word-break: break-all;
}

/* ───────── v3.1（外部評価 声③）: フレーズ評価（参考） ───────── */
.rhythm-phrase {
  margin: 8px auto 4px; padding: 8px 12px; max-width: 420px; text-align: left;
  background: var(--card-hi); border-radius: 14px; font-size: 0.8rem; font-weight: 900;
}
.rhythm-phrase .phrase-title { display: block; font-size: 0.72rem; color: var(--sub); letter-spacing: 0.06em; margin-bottom: 4px; }
.rhythm-phrase .phrase-item { display: block; color: var(--ink); line-height: 1.6; }
.rhythm-phrase .phrase-item.ok { color: var(--ok); }
.rhythm-phrase .phrase-item.ng { color: #b8860b; }

/* ───────── v4.0（第2段階）: きねんバッジ ───────── */
.badge-banner { background: #e6f4ea; color: #1f6b30; top: 64px; }
/* v4.13（8項目の7）: 花畑の かざり（ホームは 取った物だけ・コレクションに条件） */
.garden-decor { display: inline-flex; gap: 2px; align-items: center; font-size: 0.9rem; line-height: 1; }
.decor-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.decor-item { display: flex; align-items: center; gap: var(--sp-2); opacity: 0.55; }
.decor-item.on { opacity: 1; }
.decor-icon {
  flex: none; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--card-hi); font-size: 1rem;
  border: 1.5px solid var(--line);   /* v4.17: 未獲得は点線にするので、獲得側にも線を持たせる */
}
.decor-item.on .decor-icon { background: #eaf7ea; }
.decor-body { display: flex; flex-direction: column; text-align: left; flex: 1 1 auto; min-width: 0; }
.decor-body strong { font-size: 0.86rem; font-weight: 900; color: var(--ink); }
.decor-body small { font-size: 0.7rem; font-weight: 700; color: var(--sub); font-variant-numeric: tabular-nums; }
.col-sub { margin: 12px 0 0; font-size: 0.8rem; font-weight: 900; color: var(--sub); letter-spacing: 0.06em; }

/* v4.12（8項目の6）: つぎの小さな報酬までの距離（1行・いちばん近い1つだけ） */
.next-reward {
  margin: 8px 0 0; padding: 6px 10px; border-radius: 10px; background: var(--card-hi);
  font-size: 0.78rem; font-weight: 900; color: var(--sub); text-align: left; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

/* v4.15: バッジは **同じ大きさの丸メダル＋短い名前** に統一（発注元の指摘「バッジの形が ばらばら」）。
   以前は 名前の長さで 帯の幅が変わり、行のたびに 形が違って見えた。
   いまは 1枚 = 幅 64px の同じタイル。丸の大きさも 名前の段の高さも 固定 */
.badge-row {
  display: grid; grid-template-columns: repeat(auto-fill, 64px); justify-content: start;
  gap: var(--sp-2); align-items: start; margin-top: var(--sp-2);
}
.badge-row-title { font-size: 0.72rem; font-weight: 900; color: var(--sub); grid-column: 1 / -1; }
.badge-chip {
  display: grid; grid-template-rows: 36px auto; justify-items: center; align-items: center;
  gap: 2px; width: 64px; padding: 0; border: none; background: none; text-align: center;
  color: var(--sub); font-weight: 900; line-height: 1;
}
.badge-medal {
  width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: var(--card-hi); border: 1.5px dashed #d8cbbc; font-size: 1.1rem;
}
/* 名前は 1行でも2行でも タイルの高さを変えない（2行ぶんを 先に空けておく） */
.badge-chip small {
  font-size: 0.6rem; font-weight: 900; line-height: 1.2; color: var(--sub);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  min-height: 2.4em;
}
.badge-chip.on .badge-medal { background: #fff4c2; border: 1.5px solid #f0c419; }
.badge-chip.on, .badge-chip.on small { color: var(--brown, #5a3e1b); }
/* 「ほか n」も 同じ大きさのタイル（数だけ・丸は薄いまま） */
.badge-chip.badge-more .badge-medal { font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* ───────── v4.2（第3段階）: 結果画面の主ボタン1つ＋副ボタン＋畳んだ内訳 ───────── */
/* v4.11（8項目の5）: 「友だちと」── けっかを送る／同じ問題で勝負 は別のこと。
   小見出しの下に アイコン・名前・一行の説明を積んだ 同じ大きさの札を並べる */
.result-friends { margin-top: 12px; border-top: 1.5px dashed var(--line); padding-top: 10px; }
.result-friends .friends-title {
  display: block; font-size: 0.72rem; font-weight: 900; color: var(--sub); letter-spacing: 0.08em; margin-bottom: 6px; text-align: left;
}
.friends-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-friend {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px;
  min-height: 72px; padding: 8px 6px; box-sizing: border-box; width: 100%; margin: 0;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--sub); cursor: pointer; text-align: center;
}
.btn-friend .friend-icon { font-size: 1.15rem; line-height: 1.2; }
.btn-friend .friend-label { font-size: 0.86rem; font-weight: 900; color: var(--ink); line-height: 1.25; }
.btn-friend .friend-desc { font-size: 0.68rem; font-weight: 700; color: var(--sub); line-height: 1.3; }
.friends-row > .btn-friend:nth-child(odd of :not([hidden])):nth-last-child(1 of :not([hidden])) { grid-column: 1 / -1; }

/* v4.7: 副ボタンは 2列の格子（幅がそろう）。見えているボタンが奇数のとき、最後だけ 幅いっぱい */
.result-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-sub .btn-ghost { min-height: 44px; padding: 10px 8px; font-size: 0.88rem; box-sizing: border-box; width: 100%; margin: 0; white-space: normal; line-height: 1.3; }
.result-sub > .btn-ghost:nth-child(odd of :not([hidden])):nth-last-child(1 of :not([hidden])) { grid-column: 1 / -1; }
.result-details { margin-top: 12px; text-align: left; }
.result-details > summary {
  cursor: pointer; list-style: none; text-align: center; font-size: 0.8rem; font-weight: 900; color: var(--sub);
  padding: 10px; min-height: 44px; box-sizing: border-box; border-radius: 12px; background: var(--card-hi);
}
.result-details > summary::-webkit-details-marker { display: none; }
.result-details > summary::before { content: "▸ "; }
.result-details[open] > summary::before { content: "▾ "; }
.result-details .result-detail { border-top: none; text-align: center; }

/* ───────── v4.3（第4段階）: フレーズ初見モード ───────── */
.phrase-stave { position: relative; }
.phrase-stave svg { max-width: 640px; }
.phrase-cursor {
  position: absolute; width: 3px; margin-left: -1px; background: #1c7ed6; opacity: 0.7; border-radius: 2px;
  pointer-events: none; top: 0; height: 100%;
}
.phrase-judge { font-weight: 900; font-size: 1rem; min-width: 60px; text-align: right; color: var(--sub); }
.phrase-judge.ok { color: var(--ok); }
.phrase-judge.ng { color: var(--bad); }
.phrase-judge.pop { animation: phrasePop 0.35s ease; }
@keyframes phrasePop { from { transform: scale(1.3); } to { transform: scale(1); } }
.phrase-answers .phrase-tap { flex: 1 1 100%; min-height: 96px; font-size: 1.4rem; touch-action: none; }
.phrase-note { text-align: center; }
.phrase-head { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; }
.phrase-head-title { font-size: 0.95rem; font-weight: 900; color: var(--ink); }
.phrase-hint-row { font-size: 0.78rem; font-weight: 900; color: var(--sub); display: flex; align-items: center; gap: 6px; min-height: 44px; }
.stage-card.phrase-card .stage-num { background: #e7f0ff; color: #1c5fb8; font-size: 1.1rem; box-shadow: none; }
/* v4.10: 解禁の予告（押せない・ステージ1のあいだだけ）。取れなかった物ではなく「これから」なので点線 */
.stage-card.phrase-teaser { border: 2px dashed #cbd8ea; background: #f7faff; opacity: 0.9; }
.stage-card.phrase-teaser .stage-desc strong { color: #1c5fb8; }
.stage-card.phrase-teaser .stage-stars { font-size: 0.76rem; font-weight: 900; color: var(--sub); }
@media (prefers-reduced-motion: reduce) { .phrase-judge.pop { animation: none; } }

/* ───────── v4.5（第6段階）: コレクション ───────── */
.btn-collection {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  margin-top: 10px; padding: 10px 12px; min-height: 44px; border-radius: 14px; border: 1.5px dashed #d8cbbc;
  background: transparent; color: var(--sub); font-size: 0.82rem; font-weight: 900; cursor: pointer;
}
.btn-collection-arrow { color: var(--ink); }

/* 音楽のひみつカード */
.btn-columns { width: 100%; margin-top: 10px; padding: 13px 15px; border: 2px solid #8d6e63; border-radius: 15px; background: #fffaf0; color: var(--ink); font: inherit; font-weight: 900; display: flex; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer; }
.btn-columns span:last-child { color: var(--sub); font-size: .8rem; text-align: right; }
.columns-summary { padding: 18px; text-align: center; }
.columns-summary p { font-weight: 900; }
.columns-list { display: grid; gap: 12px; margin-top: 16px; }
.column-list-card { width: 100%; min-height: 76px; border: 2px solid #d8c4aa; border-radius: 16px; background: #fff; color: var(--ink); padding: 14px; text-align: left; font: inherit; font-weight: 900; display: grid; gap: 7px; cursor: pointer; }
.column-list-card small { color: var(--sub); }
.column-list-card.teased { background: #f5f1eb; cursor: default; opacity: 1; }
.columns-missing { padding: 18px; border: 2px dashed #d8c4aa; border-radius: 16px; color: var(--sub); text-align: center; font-weight: 900; }
.columns-reward { margin: 12px 0; padding: 14px; border: 2px solid #8d6e63; border-radius: 16px; background: #fffaf0; text-align: center; }
.columns-reward > div { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.columns-dialog { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 16px; background: rgba(35, 27, 22, .62); }
.columns-dialog-card { width: min(720px, 100%); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 22px; background: #fffdf8; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .28); }
.columns-dialog-card h2 { margin-top: 0; text-align: center; }
.columns-dialog-status { text-align: center; font-weight: 900; }
.columns-offer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.secret-card { min-height: 190px; border: 3px solid #8d6e63; border-radius: 18px; background: linear-gradient(145deg, #f5d78e, #fff6d6); color: var(--ink); padding: 14px 10px; font: inherit; font-weight: 900; display: grid; place-items: center; align-content: center; gap: 13px; cursor: pointer; transition: transform .5s ease, background .5s ease; }
.secret-card:not(:disabled):hover, .secret-card:not(:disabled):focus-visible { transform: translateY(-5px); }
.secret-card:disabled { opacity: 1; cursor: default; }
.secret-card.selected { border-color: var(--accent); background: #fff; transform: translateY(-5px); }
.secret-card-back { font-size: 3.4rem; }
.secret-card-title { line-height: 1.55; overflow-wrap: anywhere; }
.secret-card small { color: var(--sub); line-height: 1.4; }
.columns-dialog-actions { display: grid; gap: 9px; max-width: 420px; margin: 0 auto; }
.columns-reader article { padding: 18px; border: 2px solid #d8c4aa; border-radius: 18px; background: #fff; outline: none; }
.columns-reader h3 { font-size: 1.35rem; line-height: 1.5; }
.columns-reader p { font-size: 1.05rem; line-height: 1.9; }
.column-read-mark { color: var(--ok); font-weight: 900; }

@media (max-width: 520px) {
  .columns-offer { grid-template-columns: 1fr; }
  .secret-card { min-height: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  .secret-card { transition: none !important; }
  .secret-card:not(:disabled):hover, .secret-card:not(:disabled):focus-visible, .secret-card.selected { transform: none; }
}
.col-line { margin: 4px 0 8px; font-size: 0.95rem; font-weight: 900; color: var(--ink); }
.week-garden { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wg-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; background: var(--card-hi); font-size: 1.2rem; }
.wg-slot small { font-size: 0.66rem; font-weight: 900; color: var(--sub); }
.wg-slot.today { outline: 2px solid var(--accent); }
.wg-slot.future { opacity: 0.5; }
.badge-list, .rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
/* v4.15: コレクションの一覧も 同じ丸メダル（大きさを固定して 名前の左端をそろえる） */
.badge-item { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-2) var(--sp-3); border-radius: 12px; background: var(--card-hi); opacity: 0.75; }
.badge-item.on { opacity: 1; background: #fff4c2; }
.badge-item-icon {
  flex: none; width: 32px; height: 32px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1.5px solid var(--line); font-size: 1rem;
}
.badge-item-body { display: flex; flex-direction: column; gap: 2px; font-size: 0.86rem; flex: 1 1 auto; min-width: 0; }
.badge-item-body small { font-size: 0.72rem; color: var(--sub); font-weight: 800; }

/* v4.17: 「とった／まだ」は **文字でも**示す。
   v4.16 で 未獲得でも 本物のアイコンが出るようになり（何がもらえるか 分かるのは良い）、
   とったかどうかの差が 濃さと背景の色だけになっていた。色や濃さが分からない人にも読めるよう、
   右端に短い札を置き、未獲得の丸は 点線にする（形でも 差が出る） */
.item-state {
  flex: none; align-self: center; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; border: 1.5px dashed var(--line); color: var(--sub); background: var(--card);
}
.badge-item.on .item-state, .decor-item.on .item-state {
  border-style: solid; border-color: #f0c419; background: #fff4c2; color: var(--brown, #5a3e1b);
}
.badge-item:not(.on) .badge-item-icon, .decor-item:not(.on) .decor-icon { border-style: dashed; }
.rank-list li { display: flex; justify-content: space-between; font-weight: 900; color: var(--sub); padding: 4px 8px; border-radius: 8px; }
.rank-list li.on { color: var(--ink); }
.rank-list li.now { background: #fff4c2; }
.rank-list small { font-weight: 800; }

/* ───────── v4.6: 拍の丸（1・2・3・4 のカウントアップ） ───────── */
.beat-dots {
  position: absolute; left: 50%; top: 4px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; max-width: 100%; pointer-events: none; z-index: 2;
}
.beat-dots-top { position: static; transform: none; margin: 0 auto; }
/* v4.18: リズムでは 丸をボールの床の高さ＝舞台の下端（押す帯のすぐ上）に並べる。
   ボールはこの丸の上に着地する。※ .beat-dots より後ろに置くこと（top を打ち消すため） */
.beat-dots-floor { top: auto; bottom: 0; gap: 18px; }
.bd {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: #efe6da; color: var(--sub); font-weight: 900; font-size: 1rem;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.bd.was { background: #f7c5cb; color: #8a3a44; }
.bd.on { background: var(--accent); color: #fff; transform: scale(1.25); box-shadow: 0 0 0 4px rgba(230, 0, 18, 0.18); }
.bd-sub { width: 10px; text-align: center; color: #d8cbbc; font-weight: 900; font-size: 0.8rem; }
.bd-sub.on { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .bd, .bd.on { transition: none; transform: none; box-shadow: none; }
}

/* v4.16 · 第3回監査。配色は既存変数のまま、情報の基準位置を固定する。 */
/* 2–5: 標準運指を左端へ。注記は図のセルから独立させる。 */
.ref-row {
  grid-template-columns: clamp(120px, 34vw, 176px) minmax(0, 1fr) 44px;
  grid-template-rows: 120px auto;
  gap: var(--sp-3);
  padding: var(--sp-3);
  align-items: start;
}
.ref-stave { width: 100%; align-self: center; }
.ref-name { justify-content: center; min-height: 120px; gap: var(--sp-2); min-width: 0; }
.ref-label { line-height: 1.3; }
.ref-primary { display: block; white-space: nowrap; }
.ref-alt { display: block; font-size: var(--fs-note); margin-top: var(--sp-1); }
.ref-oct { font-size: 0.65em; margin-left: 3px; vertical-align: baseline; }
.ref-kana { font-size: 0.72rem; line-height: 1.6; overflow-wrap: anywhere; }
.ref-btns { grid-column: 3; grid-row: 1; gap: var(--sp-2); align-self: center; }
.ref-play, .ref-tone { width: 44px; height: 44px; border-radius: 12px; }
.ref-tone { font-size: 0.7rem; }
.ref-fing { align-items: start; justify-content: start; border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.ref-row .ref-fing .fingering,
.ref-row.has-keys .ref-fing .fingering,
.ref-row.has-alts .ref-fing .fingering {
  display: flex; flex-direction: column; align-items: stretch;
  justify-content: flex-start; gap: var(--sp-3); width: 100%;
}
.ref-variants {
  display: grid; grid-template-columns: minmax(0, 1fr);
  align-items: start; gap: var(--sp-3); width: 100%;
}
.ref-fing .ref-variants > .f-ww,
.ref-fing .ref-variants > .f-brass-row {
  width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr);
  justify-items: start; gap: var(--sp-2); margin: 0; padding: 0; border: 0;
}
.ref-row.has-alts .ref-fing .ref-variants > .f-ww + .f-ww,
.ref-row.has-alts .ref-fing .ref-variants > .f-brass-row + .f-brass-row {
  margin: 0; padding: var(--sp-3) 0 0; border: 0; border-top: 1px dashed var(--line);
}
.ref-fing .f-ww { grid-template-rows: var(--ref-tag-h) 96px minmax(var(--ref-text-h), auto) auto; }
.ref-fing .f-ww > svg { width: 220px; max-width: 100%; max-height: 96px; height: auto; }
.ref-fing .f-ww-text, .ref-fing .f-alt-note { text-align: left; font-size: 0.72rem; line-height: 1.6; }
.ref-fing .f-brass-row { grid-template-rows: var(--ref-tag-h) auto auto auto; }
.ref-fing .f-nums { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--sp-2); width: 100%; }
.ref-row.has-keys .ref-fing .f-brass-row .f-open {
  position: static; transform: none; margin: 0; font-size: 0.72rem;
}
.ref-fing .f-nums .f-open { flex: 0 0 100%; }
.ref-fing .f-brass-row > .f-open { grid-row: 3; }
.ref-fing .f-brass-row > .f-alt-note { grid-row: 4; }
.ref-fing .f-brass { width: 146px; height: 76px; }
.ref-meta { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); width: 100%; }
.ref-meta:not(:has(> :not(.f-note))) { display: none; }
.ref-meta .f-pending-line { justify-content: flex-start; margin: 0; }
.ref-meta .f-reach, .ref-meta .f-comp-note, .ref-meta .f-fourvalve { font-size: 0.72rem; line-height: 1.6; text-align: left; }
.ref-fing .f-horn { align-items: flex-start; gap: var(--sp-2); }
.ref-fing .f-horn .f-row { justify-content: flex-start; flex-wrap: wrap; }
.ref-fing .f-horn .f-pref { flex: 0 0 46px; text-align: center; }
.ref-fing .f-horn .f-side { flex: 0 0 44px; }
.ref-fing .f-pref-note { text-align: left; font-size: 0.72rem; line-height: 1.6; }
.ref-fing .ref-variants:has(> .f-pos) { grid-template-columns: 64px 32px minmax(0, 1fr); align-items: center; gap: var(--sp-2); }
.ref-fing .ref-variants > .f-label { margin: 0; }
.ref-fing .ref-variants > .f-slide { min-width: 0; width: 100%; }
.ref-fing .f-tb { width: 100%; }
.ref-fing .tb-slide { max-width: 220px; }
.ref-spec { padding: var(--sp-4); gap: var(--sp-2); line-height: 1.7; }
.ref-spec-row { display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: var(--sp-2); }
/* 7–8: 読める未獲得表示と、共通の記念章。文字は薄くしない。 */
.badge-art { display: block; width: 24px; height: 24px; }
.badge-medal .badge-art { width: 26px; height: 26px; }
#badge-icon .badge-art { width: 40px; height: 40px; }
.badge-medal, .badge-item-icon { color: var(--brown); }
.badge-item { opacity: 1; align-items: flex-start; padding: var(--sp-3); gap: var(--sp-3); }
.badge-item:not(.on) .badge-item-icon { color: var(--sub); border-style: dashed; background: var(--card-hi); }
.badge-item-body { min-width: 0; line-height: 1.6; gap: var(--sp-1); }
.badge-item-body small { font-size: var(--fs-note); font-weight: 500; }
.badge-item:not(.on) .badge-item-body::after { content: "未獲得"; font-size: 0.7rem; color: var(--sub); }
.badge-item.on .badge-item-body::after { content: "獲得済み"; font-size: 0.7rem; color: var(--sub); }
.decor-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); margin: var(--sp-3) 0; }
.decor-item { opacity: 1; padding: var(--sp-3); border: 1px solid var(--line); border-radius: 12px; background: var(--card-hi); gap: var(--sp-3); }
.decor-item:not(.on) .decor-icon { filter: grayscale(1); opacity: 0.7; }
.decor-body { min-width: 0; line-height: 1.6; }
.decor-body small { font-size: var(--fs-note); }
/* 9: 操作領域は全幅のまま、譜面と同じ左右端を示す。床とボールの位置は保つ。 */
.rhythm-tap-btn .tap-main, .rhythm-tap-btn .tap-sub {
  width: min(calc(100% - 32px), 728px); text-align: center;
}
.rhythm-tap-btn .tap-main {
  padding: var(--sp-3) var(--sp-4); border: 1px solid currentColor; border-radius: 16px;
}
#screen-rhythm-play .rhythm-judge { line-height: 1.6; margin: var(--sp-3) 0 var(--sp-4); }
/* 10: 見出しと説明を分離し、読み順と後回しの操作を一つにする。 */
.tutorial-card { max-width: 440px; padding: var(--sp-5); }
.tutorial-heading { font-size: var(--fs-head); line-height: 1.5; margin: 0 0 var(--sp-3); text-wrap: balance; }
.tutorial-text { text-align: left; font-weight: 700; min-height: 0; line-height: 1.8; margin: 0 0 var(--sp-4); text-wrap: pretty; }
.tutorial-btns button { word-break: keep-all; overflow-wrap: anywhere; line-height: 1.5; }
.tutorial-inst .inst-btn { min-width: 0; }
.tutorial-inst .inst-label { font-size: 0.78rem; word-break: keep-all; overflow-wrap: anywhere; }
/* v4.36: 楽器の絵は発注元が描いたもの（icons/inst/）。黒一色の絵を mask にして、
   background に currentColor を敷くことで、絵を作り直さずにアプリの色（--brown）になる。
   暗い背景でも文字色に追従するので、色を焼き付けた <img> より安全。
   ⚠ 楽器を足したら、下の一覧にも1行足すこと。無いと枠だけ出て絵が出ない。 */
.instrument-art {
  width: 28px; height: 28px; display: inline-block; vertical-align: middle; flex: none;
  background-color: currentColor;
  -webkit-mask: var(--inst-art) center / contain no-repeat;
  mask: var(--inst-art) center / contain no-repeat;
}
.instrument-art[data-inst="flute"]        { --inst-art: url("icons/inst/flute.png"); }
.instrument-art[data-inst="oboe"]         { --inst-art: url("icons/inst/oboe.png"); }
.instrument-art[data-inst="clarinet"]     { --inst-art: url("icons/inst/clarinet.png"); }
.instrument-art[data-inst="bassclarinet"] { --inst-art: url("icons/inst/bassclarinet.png"); }
.instrument-art[data-inst="bassoon"]      { --inst-art: url("icons/inst/bassoon.png"); }
.instrument-art[data-inst="altosax"]      { --inst-art: url("icons/inst/altosax.png"); }
.instrument-art[data-inst="tenorsax"]     { --inst-art: url("icons/inst/tenorsax.png"); }
.instrument-art[data-inst="baritonesax"]  { --inst-art: url("icons/inst/baritonesax.png"); }
.instrument-art[data-inst="trumpet"]      { --inst-art: url("icons/inst/trumpet.png"); }
.instrument-art[data-inst="horn"]         { --inst-art: url("icons/inst/horn.png"); }
.instrument-art[data-inst="althorn"]      { --inst-art: url("icons/inst/althorn.png"); }
.instrument-art[data-inst="trombone"]     { --inst-art: url("icons/inst/trombone.png"); }
.instrument-art[data-inst="euphonium"]    { --inst-art: url("icons/inst/euphonium.png"); }
.instrument-art[data-inst="tuba"]         { --inst-art: url("icons/inst/tuba.png"); }
.instrument-art[data-inst="keyboard"]     { --inst-art: url("icons/inst/keyboard.png"); }
.instrument-art[data-inst="percussion"]   { --inst-art: url("icons/inst/percussion.png"); }
.inst-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px; color: var(--brown); }
.inst-btn { align-items: center; }
.inst-label { min-width: 0; line-height: 1.5; }
#ref-inst, #play-stage-label { display: flex; align-items: center; gap: var(--sp-2); }
#play-stage-label .instrument-art { width: 20px; height: 20px; }
@media (min-width: 600px) { .decor-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 720px) {
  #screen-reference { max-width: 920px; }
  .ref-row { grid-template-columns: 180px 112px minmax(0, 1fr) 44px; grid-template-rows: auto; padding: var(--sp-4); }
  .ref-btns { grid-column: 4; align-self: start; }
  .ref-fing { grid-column: 3; grid-row: 1; padding: 0 0 0 var(--sp-4); border-top: 0; border-left: 1px solid var(--line); min-height: 120px; }
  .ref-name { justify-content: flex-start; padding-top: var(--sp-3); }
  .ref-stave { align-self: start; }
  .ref-row:has(> .ref-fing:empty) {
    max-width: 560px; margin-inline: auto;
    grid-template-columns: 180px minmax(0, 1fr) 44px;
  }
  .ref-row:has(> .ref-fing:empty) .ref-btns { grid-column: 3; }
}
.ref-row:has(> .ref-fing:empty) { width: 100%; grid-template-rows: 120px; }
.ref-row > .ref-fing:empty { display: none; }

/* ───────── v4.59: ブラボーくん（仕様書 v0.1 §5） ─────────
   枠・カード・色の面に入れず、場面の余白に重ねる。
   ホーム: ⚙ の下の空き（題名の列の右）に浮かせる。行の高さを取らない（練習の2枚・おすすめを押し下げない）。
     top/高さは 320/375/430px で実測: ⚙ の下端（78〜82px）から「みんなの声」の行の上端（175〜189px）までに収める
   結果: 高さ --bravo-h だけ決めれば、絵の幅と台詞の空きが決まる */
.home-header-row { position: relative; }
.bravo-float { position: absolute; right: -10px; top: 67px; height: 87px; padding: 0; border: 0; background: none;
  cursor: pointer; z-index: 4; -webkit-tap-highlight-color: transparent; }
.bravo-float img { display: block; height: 100%; width: auto; animation: bravo-float 3.2s ease-in-out infinite; }
.bravo-float:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
@keyframes bravo-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
/* v4.64: 押して動いているあいだだけ 1.2倍（発注元 2026-09-25「他の要素に被っていいので B」）。
   動画の枠には 腕を上げる空きがあり、そのままだと いつもの絵の 約83%に見える（87px → 69〜76px）。
   右下を軸にする: 右へ はみ出すと 横スクロールが出るため。translateY(7px) で 足元を いつもの絵に そろえる
   （動画の下 約6px は 足を上げる分の空き）。⚙ と 下の行に かぶるのは 承知のうえ */
.bravo-float.bravo-playing { transform: translateY(7px) scale(1.2); transform-origin: 100% 100%; }

/* v4.60: 結果カードの中・星のすぐ下（発注元「下すぎて気がつかない」）。カードは中央そろえなので台詞だけ左そろえに戻す
   v4.61: 絵は 動くWebP（133×200・縦横比 0.665）。はねる・ゆれる は動画の中にあるので CSS では動かさない。
   動画は 足元の動く分まで入れた枠なので、v4.60 の静止画（100px）と同じ大きさに見えるよう 120px にする */
.bravo-stage { position: relative; --bravo-h: 120px; min-height: var(--bravo-h); margin: 2px 0 6px;
  overflow: hidden; }   /* 入ってくる動き（横から24px）の間に 横スクロールが出ないように */
.bravo-stage[hidden] { display: none; }
.bravo-fig { position: absolute; right: 0; bottom: 0; height: var(--bravo-h); width: auto;
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;   /* v4.62: 押すと もう1回 動く（長押しの画像メニューは出さない） */
  -webkit-tap-highlight-color: transparent; animation: bravo-in 0.45s ease-out both; }
.bravo-line { margin: 0; padding: calc(var(--bravo-h) * 0.14) calc(var(--bravo-h) * 0.67 + 8px) 0 4px;
  text-align: left; font-size: 0.95rem; font-weight: 700; line-height: 1.7; color: var(--ink);
  word-break: keep-all; overflow-wrap: anywhere; }   /* 分かち書きの空白でだけ折る（「読|もうか」を防ぐ） */
.bravo-name { display: block; font-size: 0.74rem; color: var(--sub); }
.bravo-close { display: block; min-height: 32px; margin-top: 0; padding: 4px 0; border: 0; background: none;
  font-size: 0.82rem; font-weight: 700; color: var(--sub); text-decoration: underline; cursor: pointer; }
@keyframes bravo-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bravo-fig, .bravo-float img { animation: none; } }

/* v4.65: お手本（6割に とどかなかった回だけ出る）。ボタンは2つを1段に並べる（320px でも折り返さない） */
.rhythm-model { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 4px 0 8px; }
.rhythm-model[hidden] { display: none; }
.rhythm-model button { flex: 1 1 0; min-width: 0; max-width: 260px; min-height: 48px; padding: 12px 8px; }
#screen-rhythm-play.model-open .rhythm-tap-btn { display: none; }
@media (orientation: landscape) and (max-height: 540px) {
  #screen-rhythm-play .rhythm-model { grid-column: 2; grid-row: 4; align-self: start; }
}

/* v4.69: 速読みの のこり時間（譜面の枠の下に重ねる・幅が縮む） */
.speed-bar { position: absolute; left: 16px; right: 16px; bottom: 8px; height: 6px; border-radius: 3px;
  background: var(--accent); transform-origin: left center; pointer-events: none; }
.speed-bar[hidden] { display: none; }

/* v4.71: 運指で こたえる */
.finger-answer { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0 16px; }
.finger-valves { display: flex; gap: 12px; justify-content: center; width: 100%; }
.finger-valve, .finger-pos { min-width: 56px; min-height: 56px; border-radius: 50%; border: 3px solid var(--line);
  background: var(--card); font-size: 1.4rem; font-weight: 900; cursor: pointer; }
.finger-valve.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.finger-pos { border-radius: 16px; min-width: 44px; }
.finger-answer.is-slide { gap: 6px; }   /* 1〜7 を1列に（スライドの並び）。320px では 4＋3 に折り返す */
.finger-go { width: 100%; max-width: 360px; min-height: 48px; }
.finger-answer.is-ww { display: grid; grid-template-columns: 1fr; }   /* 木管の図は横長なので1列にして大きく見せる */
.finger-answer.is-ww .finger-go { grid-column: 1 / -1; justify-self: center; }
.finger-choice { background: var(--card); border: 3px solid var(--line); border-radius: 16px; padding: 4px 8px; cursor: pointer; }
.finger-choice svg { width: 100%; height: auto; max-height: 180px; }
.finger-choice.hit, .finger-pos.hit { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok) inset; }
.finger-choice.miss, .finger-pos.miss { border-color: var(--bad); }
.finger-score { font-size: 1.6rem; font-weight: 900; text-align: center; margin: 8px 0; }
