/* やれば読める！ 〜楽譜よみトレーニング〜
   デザイン: 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);
}

* { 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);
}
.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;
}

/* ───── チャンネル選択画面 ───── */
.home-header { display: flex; flex-direction: column; gap: 6px; padding: 14px 0 6px; text-align: center; }

/* 設定は右上に固定（将来の項目追加は screen-settings 側に増やす） */
.btn-gear.btn-gear-fixed {
  position: absolute;
  top: 16px; right: 14px;
  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;
}

/* ───── ヒーローカード（マスコット＋きろく） ───── */
.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: 16px; margin: 20px 0 22px; }
.channel-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  border: 3px solid transparent;
  background: var(--card);
  border-radius: 28px;
  padding: 24px 22px;
  text-align: left;
  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-title { font-size: 1.25rem; font-weight: 900; color: var(--ink); letter-spacing: -0.02em; margin-top: 4px; }
.channel-desc { font-size: 0.82rem; color: var(--sub); font-weight: 800; }
.channel-start {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 0.95rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 11px 26px;
  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; }
.stage-card .stage-info { flex: 1; }
.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; }

/* ───── プレイ ───── */
.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 10px;
}

/* 楽譜カード: 白 + 赤枠（参考サイトの menu-card 流儀） */
.stave-card {
  position: relative;
  background: #ffffff;
  border: 3px solid var(--accent);
  border-radius: 28px;
  padding: 8px;
  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: 14px 0;
  /* 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: 10px;
}
.answer-buttons.few { grid-template-columns: repeat(3, 1fr); }
.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); }
.answer-buttons.many .note-btn { font-size: 1.15rem; padding: 12px 2px 10px; }
.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;
}
.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; }
.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;
  opacity: 0; z-index: 60;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast.show { animation: toastPop 2.4s ease forwards; }
@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: 10px; margin-top: 16px; }

.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;
  animation: reviewFade 0.3s ease;
}
@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;
}
.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;
}

/* ───── おしらせ（v2.2） ───── */
/* 🔔 は左上（⚙ の反対がわ）。⚙ の左どなりに置くと、
   幅の狭い端末でロゴの「る！」に かぶった（320px で実測） */
.btn-gear.btn-news-fixed {
  position: absolute;
  top: 16px; left: 14px;
  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) {
  /* さらに狭い端末では、ロゴの左はしまで 59px しかない */
  .btn-gear.btn-news-fixed { width: 42px; height: 42px; left: 10px; 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; }

/* 配信が新しくなったときの案内。画面の下に出して、プレイの邪魔をしない */
.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);
}
/* 帯の中では折り返さない ── 折り返すと丸帯の中で文字が縦に積まれて読めない */
.update-bar span, .update-bar .btn-small { white-space: nowrap; }
.update-bar .btn-small { flex: none; padding: 6px 14px; font-size: 0.8rem; }
@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;
}
#screen-rhythm-play .stave-card { padding-top: 40px; }
/* トーストが画面下の「押す帯」に重ならないように上へ逃がす */
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;
  touch-action: manipulation;
  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 {
    --tap-h: clamp(96px, 17vh, 132px);
    --ball-h: clamp(56px, 11vh, 84px);
  }
  #screen-rhythm-play .stave-card { padding-top: 30px; }
}

/* 横向きは画面が低いので、帯とボールを薄くして本文の場所を残す */
@media (orientation: landscape) and (max-height: 540px) {
  #screen-rhythm-play {
    --tap-h: clamp(74px, 26vh, 120px);
    --ball-h: clamp(56px, 20vh, 96px);
    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; }
}

/* ───── レスポンシブ ─────
   〜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; }
  .result-buttons { flex-direction: row; justify-content: center; }
  .result-buttons button { min-width: 170px; }
  .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 改訂） ═══ */

/* ───── リズム: 画面下に固定した「押す帯」＋その上を跳ねるボール ─────
   円ボタンだと機種によっては画面の下に隠れ、ボールの着地点まで見えなくなる。
   帯の全幅をタップ領域にし、その上端をボールの床にする（＝どこを押してもよい）。
   本文には帯のぶんの余白を確保して、下に隠れる要素が出ないようにする */
#screen-rhythm-play {
  --tap-h: clamp(132px, 26vh, 210px);
  --ball-h: clamp(84px, 15vh, 132px);
  padding-bottom: calc(var(--tap-h) + var(--ball-h) + 14px);
}
.rhythm-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  pointer-events: none;   /* 帯のボタンだけが受ける */
}
.rhythm-ball-layer {
  position: relative;
  width: 100%;
  height: var(--ball-h);
  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; }

/* ───── 運指: トロンボーンのスライド図・金管のピストン図 ───── */
.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: 10px; margin: 4px 0 18px; }
.ref-row {
  display: grid;
  grid-template-columns: 88px minmax(64px, auto) 1fr 44px;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
}
.ref-stave { width: 88px; }
.ref-stave svg { width: 100%; height: auto; display: block; }
.ref-name { display: flex; flex-direction: column; line-height: 1.15; }
.ref-label { font-size: 1.35rem; font-weight: 900; color: var(--ink); }
.ref-kana { font-size: 0.68rem; font-weight: 800; color: var(--sub); }
/* トロンボーンのスライド図など、幅の決まった図が入る。
   狭い画面で列からはみ出して横スクロールバーを出さないよう、縮めて収める */
.ref-fing { min-width: 0; overflow: hidden; }
.ref-fing svg { max-width: 100%; height: auto; }
.ref-fing .fingering { justify-content: flex-start; gap: 5px; }
/* 木管のキー配置図・トロンボーンの2段は、行の幅をぜんぶ使う（折り返して読めなくなるため） */
.ref-row.has-keys { grid-template-columns: 72px minmax(56px, auto) 1fr 40px; }
.ref-row.has-keys .ref-fing {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 4px;
  overflow: visible;
}
/* 入りきらない端末では、指のグループ単位で折り返す（グループごとに名前が付くので読める） */
.ref-row.has-keys .ref-fing .fingering { justify-content: center; flex-wrap: wrap; row-gap: 6px; }
.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; }
.ref-fing .f-note { display: none; }
.ref-fing-none { font-size: 0.66rem; font-weight: 800; color: var(--sub); }
.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); }
@media (max-width: 380px) {
  .ref-row { grid-template-columns: 72px minmax(56px, auto) 1fr 40px; gap: 7px; }
  .ref-stave { width: 72px; }
  .ref-play { width: 40px; height: 40px; }
}
/* 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）で「つぎへ」が画面の外に落ちる */
.tutorial-inst { max-height: 40vh; overflow-y: auto; margin: 4px 0 10px; }
.tutorial-card { max-height: 92vh; overflow-y: auto; }
