/* KEYS — base styles. Dark "terminal" look: near-black surfaces, neon green + cyan accents, mono labels.
   High contrast, touch targets >= 56px, nothing relies on hover. */

:root {
  color-scheme: dark;
  --bg: #0A0E14;
  --card: #121A25;
  --card-2: #182231;
  --ink: #E6EDF3;
  --muted: #8193A8;
  --line: #243244;
  --primary: #9FEF00;      /* neon green */
  --primary-ink: #0A0E14;
  --accent: #2EE6D6;       /* cyan */
  --good: #9FEF00;
  --bad: #FF3E5F;
  --warn: #FFB547;
  --rh: #2EE6D6;  /* right hand: cyan */
  --lh: #FF9F43;  /* left hand: amber */
  --glow: 0 0 18px rgba(159, 239, 0, .35);
  --radius: 10px;
  --tap: 56px;
  --font: system-ui, -apple-system, "SF Pro Display", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 28px; }
h2 { font-size: 30px; }
h3 { font-size: 22px; margin-top: 1em; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.mono { font-family: var(--mono); font-size: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
[hidden] { display: none !important; }

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); min-width: var(--tap); padding: 0 22px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
  font: 700 20px var(--font); text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.big { min-height: 76px; font-size: 24px; padding: 0 28px; }
.btn.icon { font-size: 40px; padding: 0; width: var(--tap); line-height: 1; }
.btn.choice { justify-content: flex-start; width: 100%; text-align: left; }
.btn.choice.selected { border-color: var(--primary); color: var(--primary); }

/* --- screens --- */
#app { height: 100%; }
.screen {
  display: flex; flex-direction: column; height: 100%;
  /* Same padding on both sides in landscape, whichever side the notch is on, so the app stays centred. */
  --side: max(env(safe-area-inset-left), env(safe-area-inset-right));
  padding: env(safe-area-inset-top) var(--side) env(safe-area-inset-bottom);
}
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.bar h1 { flex: 1; margin: 0; }
.bar-actions { display: flex; gap: 8px; }
.screen-body { flex: 1; overflow: auto; padding: 8px 24px 24px; -webkit-overflow-scrolling: touch; }
.screen-body > h2 { margin-top: 1em; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.footer { margin-top: 2em; font-size: 15px; }

/* --- home --- */
.home { justify-content: center; align-items: center; gap: 28px; padding: 24px; }
.home-hero { text-align: center; }
.logo {
  font-size: 96px; font-weight: 900; letter-spacing: .06em;
  background: linear-gradient(90deg, var(--rh), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { font-size: 24px; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(240px, 320px)); gap: 16px; }
@media (max-width: 600px) { .home-grid { grid-template-columns: 1fr; width: 100%; } }

/* --- gate overlay --- */
.gate {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(10, 14, 20, .88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.gate-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 560px; padding: 40px 48px; margin: 16px;
  border: none; border-radius: 32px;
  background: var(--primary); color: var(--primary-ink);
  font-family: var(--font); cursor: pointer;
  box-shadow: var(--glow);
}
.gate-icon { font-size: 72px; line-height: 1; }
.gate-title { font-size: 34px; font-weight: 800; }
.gate-sub { font-size: 18px; opacity: .9; }

/* --- stage (calibration / test prompts) --- */
.stage { min-height: 240px; padding: 8px 0 16px; }
.steps { font-size: 22px; padding-left: 1.4em; }
.steps li { margin-bottom: 6px; }
.target { font-size: 120px; font-weight: 900; line-height: 1; margin: 4px 0 16px; color: var(--rh); }
.progress { height: 18px; border-radius: 9px; background: var(--line); overflow: hidden; max-width: 520px; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .1s linear; }
.misses { columns: 2; font-size: 17px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 12px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; }
.stats.small { font-size: 15px; }

/* --- level meter --- */
.meter-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.meter { position: relative; flex: 1; height: 16px; border-radius: 8px; background: var(--line); overflow: hidden; min-width: 160px; }
.meter-fill { height: 100%; width: 0; background: var(--muted); }
.meter-fill.over { background: var(--good); }
.meter-tick { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--bad); }

/* --- on-screen keyboard --- */
.kb-scroll { overflow-x: auto; overflow-y: hidden; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.kb {
  position: relative; display: flex; height: 140px;
  min-width: calc(var(--white-count) * 24px);
  margin: 0 8px;
}
.kb-key { transition: background-color .08s; }
.kb-white {
  flex: 1 1 0; position: relative;
  background: linear-gradient(#C9D2DE, #EEF2F7 18%, #E3E8EF); border: 1px solid #0A0E14; border-radius: 0 0 3px 3px; margin-right: -1px;
}
.kb-black {
  position: absolute; top: 0; height: 60%; z-index: 1;
  background: linear-gradient(#05080C, #1B2533); border: 1px solid #000; border-radius: 0 0 2px 2px;
}
.kb-label { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; }
.kb-middle .kb-label { color: var(--ink); }
.kb-expected { background: var(--rh) !important; }
.kb-expected .kb-label { color: var(--primary-ink); }
.kb-played { background: var(--good) !important; }
.kb-wrong { background: var(--bad) !important; }

/* --- debug --- */
.debug .screen-body { display: flex; flex-direction: column; padding-bottom: 0; }
.debug-grid { flex: 1; display: grid; grid-template-columns: 1fr 340px; gap: 16px; min-height: 0; }
.debug-main { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.debug-side { overflow: auto; font-size: 17px; }
.debug-side h3:first-child { margin-top: 0; }
.readout { display: flex; gap: 24px; align-items: center; }
.readout-note { font-size: 84px; font-weight: 900; line-height: 1; min-width: 3.2ch; color: var(--rh); }
.readout-note.dim { opacity: .3; }
.readout-sub { font-family: var(--mono); font-size: 18px; color: var(--muted); }
.readout-right { flex: 1; }
.cents-scale { position: relative; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--line), var(--card-2) 50%, var(--line)); }
.cents-scale::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.cents-needle { position: absolute; top: -5px; width: 6px; height: 24px; margin-left: -3px; border-radius: 3px; background: var(--accent); left: 50%; }
.cents-labels { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin: 2px 0 6px; }
.track { flex: 1; width: 100%; min-height: 220px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); }
.log { margin: 0; padding-left: 1.2em; font-family: var(--mono); font-size: 15px; min-height: 8em; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: center; margin-bottom: 8px; }
.slider input { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 40px; }
@media (max-width: 900px) {
  .debug-grid { grid-template-columns: 1fr; }
  .debug-side { overflow: visible; }
  .track { min-height: 260px; }
}

/* --- settings --- */
.choice-list { display: grid; gap: 10px; max-width: 680px; margin-bottom: 12px; }

/* ================= Phase 2 ================= */
:root { --gold: #FFD23F; }
.text-input { width: 100%; max-width: 480px; min-height: var(--tap); padding: 0 18px; border: 2px solid var(--line); border-radius: var(--radius); font: 700 24px var(--font); color: var(--ink); background: var(--card); margin-bottom: 12px; -webkit-user-select: text; user-select: text; }
.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); font-weight: 700; }
.toggle input { width: 26px; height: 26px; }
.player-card h3 { margin-top: 0; }
.btn.corner { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; }
.logo.small { font-size: 56px; }

/* --- stars --- */
.stars { display: inline-flex; gap: 2px; color: var(--line); font-size: 20px; line-height: 1; }
.stars .star.on { color: var(--gold); }
.stars.big { font-size: 72px; gap: 8px; }
.stars.big .star.on { animation: pop .5s both cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }

/* --- profile picker / new player --- */
.picker { position: relative; justify-content: center; align-items: center; gap: 20px; padding: 24px; text-align: center; }
.avatar-row { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.avatar-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 150px; padding: 18px 8px; border: 3px solid var(--line); border-radius: 28px; background: var(--card); font: 800 22px var(--font); color: var(--ink); text-decoration: none; cursor: pointer; }
.avatar-btn:active { transform: scale(.96); }
.avatar-btn.kid { border-color: var(--rh); }
.avatar-btn.add { border-style: dashed; color: var(--muted); }
.avatar { font-size: 72px; line-height: 1; }
.avatar.small { font-size: 30px; }
.new-profile { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.choice-kind.selected, .avatar-pick.selected { border-color: var(--primary); background: rgba(159, 239, 0, .08); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, 64px); gap: 10px; width: 100%; max-width: 640px; }
.avatar-pick { width: 64px; height: 64px; font-size: 38px; border: 3px solid var(--line); border-radius: 18px; background: var(--card); cursor: pointer; }

/* --- dashboard --- */
.dashboard .bar { flex-wrap: wrap; }
.btn.player { gap: 10px; padding: 0 16px 0 10px; }
.stat-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.stat { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 2px solid var(--line); font-size: 17px; font-weight: 700; white-space: nowrap; }
.units { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.unit { background: var(--card); border: 2px solid var(--line); border-radius: 24px; padding: 14px 16px; }
.unit.soon { opacity: .55; }
.unit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.unit-head h2 { font-size: 24px; margin: 0 0 10px; }
.unit-progress { color: var(--muted); font-weight: 700; font-size: 17px; }
.unit-progress.complete { color: var(--good); }
.lesson-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.lesson-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; min-height: 120px; border: 3px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--ink); text-decoration: none; text-align: center; }
.lesson-tile.done { background: rgba(159, 239, 0, .06); border-color: rgba(159, 239, 0, .35); }
.lesson-tile.next { border-color: var(--primary); box-shadow: var(--glow); animation: nudge 2s ease-in-out infinite; }
.lesson-tile.locked { opacity: .45; }
.lesson-num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); font-weight: 800; }
.lesson-tile.next .lesson-num { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.lesson-title { font-weight: 800; font-size: 17px; line-height: 1.15; }
.lesson-sub { color: var(--muted); font-size: 15px; }
@keyframes nudge { 50% { transform: translateY(-3px); } }

/* --- lesson screen --- */
.lesson .bar { padding: 6px 12px; }
.lesson .bar h1 { font-size: 22px; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { flex: 1; display: flex; gap: 6px; justify-content: flex-end; overflow-x: auto; }
.chip { padding: 4px 12px; border-radius: 999px; border: 2px solid var(--line); font-size: 15px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.chip.now { border-color: var(--primary); color: var(--primary); }
.chip.done { background: transparent; border-color: var(--good); color: var(--good); }
.lesson-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.lesson-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scene { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 16px; }
.scene-staff { flex: 1 1 auto; max-width: 820px; height: 100%; display: flex; align-items: center; }
.scene-hand { height: 100%; max-height: 300px; display: flex; align-items: center; }
.scene-hand .hand { height: 100%; width: auto; max-width: 260px; }
.caption { display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 72px; background: var(--card); border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.caption-text { flex: 1; font-size: 24px; font-weight: 800; line-height: 1.2; }
.adult .caption-text { font-weight: 700; font-size: 21px; }
.caption-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.kb-slot .kb { height: clamp(84px, 22vh, 160px); }
.kb-scroll.kb-zoomed .kb { min-width: 0; }
.kb-badge { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); display: none; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #0A0E14; color: var(--primary); font-family: var(--mono); font-size: 15px; font-weight: 800; }
.kb-badge.on { display: grid; }
.kb-black .kb-badge { bottom: 8px; background: var(--primary); color: var(--primary-ink); width: 22px; height: 22px; font-size: 13px; }
.kb-zoomed .kb-label { font-size: 17px; }
.kb-white { position: relative; }

.intro, .reward { margin: auto; text-align: center; padding: 8px; }
.intro-sticker { font-size: 84px; line-height: 1.1; }
.reward-sticker { display: flex; flex-direction: column; align-items: center; font-weight: 800; color: var(--accent); }
.reward-sticker span { font-size: 80px; line-height: 1; animation: wiggle 1s ease-in-out .8s 2; }
.reward-next { font-size: 22px; font-weight: 800; }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }

.find { flex-direction: column; text-align: center; }
.find-prompt { font-size: 30px; font-weight: 900; max-width: 800px; }
.find-dots { display: flex; gap: 10px; }
.find-dots .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); }
.find-dots .dot.on { background: var(--good); border-color: var(--good); }

.falling-wrap { position: relative; padding: 0; align-items: stretch; }
.falling { display: block; width: 100%; height: 100%; }
.count-in { position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 900; color: var(--accent); pointer-events: none; }
.count-in:empty { display: none; }
.step-tools { display: flex; justify-content: center; gap: 12px; padding: 2px 8px 6px; }
.tempo { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.tempo input { width: 180px; height: 40px; }
.tempo-val { min-width: 3.2em; font-family: var(--mono); }
.result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 16px 32px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--primary); box-shadow: var(--glow); text-align: center; font-size: 22px; font-weight: 800; }
.result p { margin: 4px 0; }

/* --- staff --- */
.staff { width: 100%; height: 100%; max-height: 340px; }
.staff-lines line { stroke: var(--ink); stroke-width: 1.6; }
.staff .clef { fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; }
.staff .clef-dot { fill: var(--ink); }
.staff .brace { stroke-width: 3; }
.staff .head { fill: var(--ink); }
.staff .head.hollow { fill: var(--card); stroke: var(--ink); stroke-width: 2.4; }
.staff .stem, .staff .ledger { stroke: var(--ink); stroke-width: 2; }
.staff .flag { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.staff .acc { font: 700 22px var(--font); fill: var(--ink); }
.staff .note-label { font: 800 18px var(--font); fill: var(--muted); }
.staff .note.active .head { fill: var(--rh); }
.staff .note.active .head.hollow { fill: rgba(46, 230, 214, .2); stroke: var(--rh); }
.staff .note.active .note-label { fill: var(--rh); }
.staff .note.good .head { fill: var(--good); }
.staff .note.bad .head { fill: var(--bad); }

/* --- hand --- */
.hand { overflow: visible; filter: drop-shadow(0 0 10px rgba(46, 230, 214, .18)); }
.hand .skin { stroke: rgba(46, 230, 214, .55); stroke-width: 2; }
.hand .palm { stroke: rgba(46, 230, 214, .55); }
.hand .nail { fill: rgba(230, 237, 243, .08); stroke: rgba(230, 237, 243, .35); stroke-width: 1.2; }
.hand .joint { fill: none; stroke: rgba(230, 237, 243, .22); stroke-width: 1.6; stroke-linecap: round; }
.hand .finger { transform-box: fill-box; transform-origin: 50% 100%; }
.hand .finger.on .skin { fill: rgba(46, 230, 214, .32); stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 8px var(--accent)); }
.hand .finger.on .nail { stroke: var(--accent); }
.hand .finger.wiggle { animation: wiggle-finger .32s ease-in-out 6; }
@keyframes wiggle-finger { 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
.hand .finger-num circle { fill: var(--bg); stroke: var(--muted); stroke-width: 1.6; }
.hand .finger-num text { font: 800 15px var(--mono); fill: var(--ink); }
.hand .finger-num.on circle { fill: var(--primary); stroke: var(--primary); filter: drop-shadow(0 0 6px var(--primary)); }
.hand .finger-num.on text { fill: var(--primary-ink); }

/* --- mascot (Pip) --- */
.mascot { width: 64px; flex: 0 0 64px; }
.mascot svg { width: 100%; display: block; overflow: visible; }
.pip-body { fill: var(--card-2); stroke: var(--primary); stroke-width: 4; }
.pip-stem { stroke: var(--primary); stroke-width: 5; stroke-linecap: round; }
.pip-flag { fill: var(--accent); }
.pip-eyes ellipse { fill: var(--ink); }
.pip-glint { fill: #0A0E14; }
.pip-cheek { display: none; }
.pip-mouth { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.mascot.happy svg { animation: bob .6s ease-in-out; }
.mascot.cheer svg { animation: hop .7s cubic-bezier(.3,1.6,.5,1) 2; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
@keyframes hop { 40% { transform: translateY(-14px) rotate(6deg) scale(1.05); } }

/* --- phones in landscape: squeeze vertical space --- */
@media (max-height: 500px) {
  body { font-size: 17px; }
  .bar { padding: 4px 10px; }
  .btn { min-height: 48px; font-size: 17px; padding: 0 14px; }
  .btn.icon { width: 48px; font-size: 32px; }
  .lesson .bar h1 { font-size: 18px; }
  .chip { font-size: 13px; padding: 2px 8px; }
  .caption { min-height: 56px; padding: 4px 10px; }
  .caption-text { font-size: 18px; }
  .mascot { width: 48px; flex-basis: 48px; }
  .kb-slot .kb { height: clamp(70px, 24vh, 112px); }
  .kb-scroll { padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); }
  .find-prompt { font-size: 22px; }
  .stars.big { font-size: 52px; }
  .intro-sticker, .reward-sticker span { font-size: 56px; }
  .count-in { font-size: 80px; }
  .avatar { font-size: 52px; }
  .avatar-btn { width: 120px; padding: 12px 6px; }
  .logo.small { font-size: 40px; }
  .lesson-tile { min-height: 96px; }
  .tempo input { width: 130px; }
}
.scene-say { font-size: 34px; font-weight: 900; text-align: center; max-width: 900px; line-height: 1.2; color: var(--ink); }
@media (max-height: 500px) {
  .scene-say { font-size: 24px; }
  .kb { min-width: calc(var(--white-count) * 21px); }
}
.reward { display: flex; flex-direction: column; align-items: center; gap: 4px; }
@media (max-height: 500px) {
  .reward { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px 28px; }
  .reward .stars.big { font-size: 48px; }
  .reward-sticker { flex-direction: row; gap: 10px; }
  .reward-next { flex-basis: 100%; margin: 0; font-size: 19px; }
}
.lesson:has(.scene-say:not(:empty)) .caption-text { visibility: hidden; } /* narration already shown big */

/* Lesson keyboards keep keys playable-sized (≥ 28px); when the range is wider than the screen, the
   keyboard glides to the active keys instead of shrinking them (keyboard.js follow). */
.kb-slot .kb { min-width: calc(var(--white-count) * var(--kmin, 28px)); }
.kb-scroll { scrollbar-width: none; }
.kb-scroll::-webkit-scrollbar { display: none; }
.lesson-stage, .scene { overflow: hidden; } /* never paint over the caption bar */
@media (max-height: 500px) {
  .intro { display: grid; grid-template-columns: auto auto; align-items: center; gap: 0 18px; text-align: left; }
  .intro-sticker { grid-row: span 2; }
  .intro h2 { margin: 0; font-size: 26px; }
  .intro p { margin: 0; }
}

/* ================= Theme: dark terminal ================= */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% -20%, rgba(46, 230, 214, .10), transparent 60%),
    linear-gradient(rgba(36, 50, 68, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 50, 68, .35) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
  font-weight: 500;
}
h1, h2, h3 { letter-spacing: -.01em; }
.btn { border-width: 1px; font-weight: 650; letter-spacing: .01em; background: var(--card); transition: border-color .15s, box-shadow .15s; }
.btn:active { border-color: var(--accent); }
.btn.primary { box-shadow: var(--glow); font-weight: 750; }
.card, .unit, .lesson-tile, .stat, .chip, .avatar-btn, .avatar-pick, .toggle, .text-input, .caption { border-width: 1px; }
.card, .unit { background: rgba(18, 26, 37, .85); }

/* mono "terminal" labels */
.chip, .stat, .unit-progress, .lesson-sub, .tempo-val, .find-dots, .kb-label, .readout-sub, .stats dt, .footer {
  font-family: var(--mono); letter-spacing: .02em;
}
.chip, .stat { text-transform: uppercase; font-size: 13px; font-weight: 600; }
.chip.now { box-shadow: 0 0 10px rgba(159, 239, 0, .25); border-color: var(--primary); color: var(--primary); }
.unit-head h2 { font-family: var(--mono); font-size: 20px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }

.logo, .logo.small {
  font-family: var(--mono); font-weight: 800; letter-spacing: .12em;
  background: none; color: var(--primary); -webkit-text-fill-color: var(--primary);
  text-shadow: 0 0 24px rgba(159, 239, 0, .45);
}
.logo::after { content: "_"; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.lesson-tile { background: var(--card); }
.lesson-num { background: var(--bg); border-width: 1px; font-family: var(--mono); }
.lesson-tile.done .lesson-num { border-color: var(--primary); color: var(--primary); }
.avatar-btn { background: var(--card); }
.avatar-btn.kid { border-color: var(--line); }
.avatar-btn:active, .avatar-btn:focus-visible { border-color: var(--primary); box-shadow: var(--glow); }
.avatar-btn.add { border-color: var(--line); }

.caption { background: rgba(18, 26, 37, .92); border-color: var(--line); }
.caption-text, .scene-say { letter-spacing: -.01em; }
.scene-say { font-weight: 750; }
.gate-btn { background: var(--card); color: var(--ink); border: 1px solid var(--primary); }
.gate-title { color: var(--primary); }
.target, .readout-note { color: var(--accent); text-shadow: 0 0 20px rgba(46, 230, 214, .35); font-family: var(--mono); }
.count-in { color: var(--primary); font-family: var(--mono); text-shadow: var(--glow); }
.stars .star { color: var(--line); }
.stars .star.on { color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 63, .55); }
.reward-sticker { color: var(--accent); }
.find-dots .dot { border-width: 2px; }
.find-dots .dot.on { box-shadow: var(--glow); }
.track { background: var(--card); }

/* keyboard highlights glow */
.kb-expected { background: var(--accent) !important; box-shadow: 0 0 16px var(--accent); }
.kb-played { background: var(--primary) !important; box-shadow: 0 0 16px var(--primary); }
.kb-wrong { background: var(--bad) !important; box-shadow: 0 0 16px var(--bad); }
.kb-white .kb-label { color: #5A6A7E; }
.kb-middle .kb-label { color: #0A0E14; }

/* staff on dark */
.staff-lines line { stroke: #5B6B80; }
.staff .clef { stroke: var(--ink); }
.staff .head.hollow { fill: var(--bg); }

.btn.corner { right: calc(16px + var(--side, 0px)); }
.picker .btn.corner { right: calc(16px + max(env(safe-area-inset-left), env(safe-area-inset-right))); }
.select { width: 100%; max-width: 640px; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card-2); color: var(--ink); font: 600 18px var(--font); }
.voice-card { display: grid; gap: 12px; max-width: 680px; }
.small-print { font-size: 15px; margin: 0; }

}

/* "Turn your phone sideways" banner (shown by the keyboard when the needed keys can't fit) */
.rotate-toast {
  position: absolute; z-index: 3; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px);
  padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--warn);
  background: rgba(10, 14, 20, .95); color: var(--warn); font-weight: 800; font-size: 18px;
  box-shadow: 0 0 18px rgba(255, 181, 71, .45);
  animation: toast-flash 1.2s ease-in-out infinite;
}
.rotate-icon { display: inline-block; font-size: 26px; animation: tilt 1.2s ease-in-out infinite; }
@keyframes toast-flash { 50% { opacity: .55; box-shadow: 0 0 4px rgba(255, 181, 71, .2); } }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* --- lesson menu: floating ☰ + slide-in tray (replaces the header so lessons use the full height) --- */
.lesson { position: relative; }
.menu-float { position: absolute; z-index: 4; top: calc(8px + env(safe-area-inset-top)); left: calc(8px + var(--side)); display: flex; align-items: center; gap: 10px; pointer-events: none; }
.menu-btn { pointer-events: auto; width: 44px; min-width: 44px; min-height: 44px; font-size: 22px; background: rgba(18, 26, 37, .85); }
.menu-where { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); text-shadow: 0 0 10px rgba(159, 239, 0, .4); }
.lesson-stage { padding-top: 56px; }
@media (max-height: 500px) {
  .lesson-stage { padding-top: 0; }
  .lesson .scene { padding-left: 64px; padding-right: 64px; } /* keep scene clear of the ☰ button */
  .reward .stars.big { font-size: 40px; }
  .reward-sticker span { font-size: 44px; }
}

/* Landscape phones: the lesson keyboard is display-only, so it can sit right at the bottom edge
   (over the home-indicator strip) instead of floating above it. */
@media (max-height: 500px) {
  .screen.lesson { padding-bottom: 0; }
  .lesson .kb-scroll { padding: 2px 0 18px; } /* ~15px up from the bottom edge */
  .lesson .kb { margin: 0 4px; }
}

/* --- "your next move" buttons: sonar pulse + self-pressing countdown --- */
.btn.pulse { position: relative; overflow: visible; }
.btn.pulse::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--primary);
  pointer-events: none; animation: sonar 1.6s ease-out infinite;
}
@keyframes sonar { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.35, 1.6); } }
.btn.auto { overflow: hidden; }
.btn.auto.pulse { overflow: visible; }
.btn.auto::before {
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; border-radius: 0 0 var(--radius) var(--radius);
  background: var(--primary-ink); opacity: .45; transform-origin: left; animation: countdown var(--auto, 4s) linear forwards;
}
@keyframes countdown { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.btn-label { position: relative; }
@media (prefers-reduced-motion: reduce) { .btn.pulse::after { animation: none; box-shadow: var(--glow); } }
@media (max-height: 500px) {
}

/* --- lesson menu tray: slides in and out --- */
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn .icon { width: 22px; height: 22px; }
.tray {
  position: fixed; inset: 0; z-index: 20; visibility: hidden;
  background: rgba(5, 8, 12, 0); transition: background .25s ease, visibility 0s linear .28s;
}
.tray.open { visibility: visible; background: rgba(5, 8, 12, .62); transition: background .25s ease, visibility 0s; }
.tray-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(420px, 88vw); overflow-y: auto;
  display: flex; flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top)) 22px calc(16px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left));
  background: var(--card); border-right: 1px solid rgba(159, 239, 0, .5); box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  transform: translateX(-104%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.tray.open .tray-panel { transform: none; }
.tray-top { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; }
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tray-head h2 { margin: 0; font-size: 24px; }
.tray-close { width: 40px; min-width: 40px; min-height: 40px; border-radius: 50%; color: var(--muted); }
.tray-top > .muted { margin: 0; font-size: 16px; }
.tray-label { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.tray-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tray-step { justify-content: flex-start; gap: 12px; min-height: 50px; padding: 0 14px; font-size: 17px; white-space: nowrap; }
.tray-step-num { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); font-family: var(--mono); font-size: 13px; }
.tray-step.now { border-color: var(--primary); color: var(--primary); }
.tray-step.now .tray-step-num { border-color: var(--primary); }
.tray-step.done .tray-step-num { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
/* bottom section: an iOS-style grouped list */
.tray-actions {
  margin-top: auto; border-top: 1px solid var(--line); padding-top: 16px;
  display: flex; flex-direction: column;
}
.tray-row {
  display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 14px;
  background: var(--card-2); border: 0; border-bottom: 1px solid var(--line); color: var(--ink);
  font: 600 17px var(--font); text-align: left; text-decoration: none; cursor: pointer;
}
.tray-row:first-child { border-radius: 12px 12px 0 0; }
.tray-row:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
.tray-row:active { background: var(--line); }
.tray-row .icon { color: var(--accent); }
.tray-row-label { flex: 1; white-space: nowrap; }
.tray-row .chev { color: var(--muted); }
.caption-controls .btn .icon { margin-right: 2px; }
@media (max-height: 500px) {
  .tray-panel { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 8px; }
  .tray-head .tray-close { width: 36px; min-width: 36px; min-height: 36px; }
  .tray-top { gap: 8px; padding-bottom: 12px; }
  .tray-top > .muted { display: none; }
  .tray-head h2 { font-size: 20px; }
  .tray-step { min-height: 42px; font-size: 15px; }
  .tray-actions { padding-top: 12px; }
  .tray-row { min-height: 42px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .tray, .tray-panel { transition: none; } }

/* Resume button while a scene is paused: red glow + sonar */
.btn.resume { position: relative; overflow: visible; background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 800; box-shadow: 0 0 18px rgba(255, 62, 95, .55); }
.btn.resume::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--bad); pointer-events: none; animation: sonar 1.4s ease-out infinite; }

/* --- help --- */
.help { display: flex; flex-direction: column; gap: 14px; max-width: 820px; margin: 0 auto; width: 100%; }
.help-card h2 { font-family: var(--mono); font-size: 18px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 10px; }
.help-card > .muted { font-size: 16px; }
.help-item { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 17px; }
.help-lead { display: flex; justify-content: center; }
.help-stars { font-size: 26px; }
.help-emoji { font-size: 28px; }
.help-icon { color: var(--accent); }
.help-icon .icon { width: 28px; height: 28px; }
.chip-like { padding: 4px 12px; border: 1px solid var(--primary); border-radius: 999px; color: var(--primary); font: 700 13px var(--mono); text-transform: uppercase; }
.help-btn { position: relative; padding: 8px 14px; border-radius: var(--radius); font-weight: 750; font-size: 15px; background: var(--primary); color: var(--primary-ink); overflow: hidden; }
.pulse-demo { box-shadow: var(--glow); overflow: visible; }
.pulse-demo::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--primary); animation: sonar 1.6s ease-out infinite; }
.auto-demo::before { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--primary-ink); opacity: .45; transform-origin: left; animation: countdown 3s linear infinite; }
.resume-demo { background: var(--bad); color: #fff; box-shadow: 0 0 14px rgba(255, 62, 95, .5); }
.star-hint { margin: 2px 0 6px; font-size: 18px; font-weight: 700; color: var(--muted); }
.result .star-hint, .result p:last-child { font-size: 17px; color: var(--muted); }
.btn.icon .icon { width: 26px; height: 26px; }
@media (max-height: 500px) {
  .help-item { grid-template-columns: 96px 1fr; font-size: 15px; padding: 6px 0; }
  .star-hint { font-size: 15px; flex-basis: 100%; }
}

/* --- icons in the app's colours (replace emoji) --- */
.icon.icon-fill { fill: currentColor; stroke: none; }
.icon.gold, .gold .icon { color: var(--gold); }
.warm .icon, .icon.warm { color: var(--lh); }
.stat { display: inline-flex; align-items: center; gap: 7px; }
.stat .icon { color: var(--accent); }
.stat.gold .icon { color: var(--gold); filter: drop-shadow(0 0 4px rgba(255, 210, 63, .5)); }
.stat.warm .icon { color: var(--lh); }

/* star rating: solid amber-gold when earned, dark outline-ish when not */
.stars { align-items: center; gap: 3px; }
.stars .star { display: inline-flex; color: var(--line); text-shadow: none; }
.stars .star .icon { width: 1.05em; height: 1.05em; }
.stars .star.on { color: var(--gold); text-shadow: none; }
.stars .star.on .icon { filter: drop-shadow(0 0 5px rgba(255, 210, 63, .55)); }
.stars.big { gap: 10px; }
.lesson-tile .stars { font-size: 18px; }
.help-stars { font-size: 24px; }

/* map polish */
.unit-head { margin-bottom: 12px; }
.unit-head h2 { margin-bottom: 4px; }
.unit-progress { display: inline-flex; align-items: center; gap: 6px; }
.unit-progress.complete .icon:first-child { color: var(--primary); }
.lesson-tile { border-radius: 8px; }
.lesson-num .icon { display: block; }
.lesson-tile.next .lesson-num .icon { color: var(--primary-ink); }
.lesson-tile.locked .lesson-num { color: var(--muted); }
.unit { border-radius: 12px; }
.unit.soon .unit-head { margin-bottom: 0; }
.unit.soon .unit-head h2 { margin-bottom: 0; }

/* --- welcome: Returning player / New player --- */
.picker { justify-content: flex-start; overflow-y: auto; }
.welcome { width: 100%; max-width: 560px; margin: auto; padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.welcome .tagline { font-size: 18px; margin-bottom: 14px; }
.choice-col { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.choice-card {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 76px; padding: 12px 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  font: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.choice-card:active, .choice-card.open { border-color: var(--primary); box-shadow: var(--glow); }
.choice-card.disabled { opacity: .5; }
.choice-icon { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 50%; background: rgba(46, 230, 214, .12); color: var(--accent); }
.choice-icon.new { background: rgba(159, 239, 0, .12); color: var(--primary); }
.choice-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-size: 21px; font-weight: 750; }
.choice-sub { font-size: 15px; color: var(--muted); }
.choice-card .chev { color: var(--muted); transition: transform .2s; }
.choice-card .chev.down { transform: rotate(90deg); }
.choice-card.open .chev.down { transform: rotate(-90deg); }
.player-list { display: flex; flex-direction: column; margin-top: -4px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; animation: drop .2s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.player-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--card-2); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.player-row:last-child { border-bottom: 0; }
.player-row:active { background: var(--line); }
.player-row .avatar { font-size: 38px; }
.player-info { flex: 1; display: flex; flex-direction: column; }
.player-name { font-size: 19px; font-weight: 750; }
.player-meta { font-size: 14px; color: var(--muted); font-family: var(--mono); }
.player-row.recent .player-name::after { content: "LAST PLAYED"; margin-left: 10px; padding: 2px 6px; border: 1px solid var(--primary); border-radius: 4px; font: 700 10px var(--mono); letter-spacing: .08em; color: var(--primary); vertical-align: middle; }
.player-row .chev { color: var(--muted); }
@media (max-height: 500px) {
  .welcome { padding-top: 10px; }
  .welcome .tagline { margin-bottom: 8px; }
  .choice-card { min-height: 62px; }
}
.find-progress { display: flex; align-items: center; gap: 16px; }
.find-dots .dot { width: 26px; height: 26px; }
.find-count { font: 800 22px var(--mono); color: var(--primary); letter-spacing: .04em; }
.find-count:empty { display: none; }

/* --- full-screen button + iPhone "Add to Home Screen" sheet --- */
.fs-float { position: absolute; z-index: 4; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + var(--side)); width: 44px; min-width: 44px; min-height: 44px; background: rgba(18, 26, 37, .85); }
.corner-row { display: flex; gap: 10px; }
.picker .corner-row { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(16px + max(env(safe-area-inset-left), env(safe-area-inset-right))); }
.sheet-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 12, .7); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(520px, 100%); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 22px; border: 1px solid var(--primary); border-radius: 14px; background: var(--card); box-shadow: var(--glow); }
.sheet h2 { margin: 0; font-size: 22px; }
.sheet p { margin: 0; font-size: 16px; }
.sheet-steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; font-size: 18px; }
.icon.inline { vertical-align: -3px; color: var(--accent); }
@media (max-height: 500px) {
  .sheet { padding: 12px 18px; gap: 6px; }
  .sheet h2 { font-size: 19px; }
  .sheet p, .sheet-steps { font-size: 15px; }
  .sheet .btn.primary { min-height: 44px; }
}

/* --- Pip as a clear eighth note --- */
.pip-stem { stroke: var(--primary); stroke-width: 6; stroke-linecap: round; }
.pip-flag { fill: var(--accent); }
.pip-body { fill: #1B2A1A; stroke: var(--primary); stroke-width: 4; }
.pip-shine { fill: rgba(159, 239, 0, .25); }
.mascot svg { filter: drop-shadow(0 0 6px rgba(159, 239, 0, .35)); }

/* --- target hint: outline + faint letter on the key to play --- */
.kb-ghost { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; font: 800 22px var(--font); color: rgba(10, 14, 20, .28); pointer-events: none; }
.kb-black .kb-ghost { bottom: 10px; font-size: 15px; color: rgba(230, 237, 243, .35); }
.kb-target { box-shadow: inset 0 0 0 3px var(--accent), 0 0 14px rgba(46, 230, 214, .55); z-index: 2; animation: target-glow 1.4s ease-in-out infinite; }
.kb-black.kb-target { z-index: 3; }
@keyframes target-glow { 50% { box-shadow: inset 0 0 0 3px var(--accent), 0 0 4px rgba(46, 230, 214, .2); } }
.kb-target.kb-played, .kb-target.kb-wrong { animation: none; }

/* --- tiny lesson HUD next to ☰ --- */
.hud { display: flex; flex-direction: column; gap: 3px; font: 700 10.5px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); max-width: min(52vw, 420px); }
.hud-line { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
.hud-avatar { font-size: 13px; }
.hud-name { color: var(--ink); }
.hud-sep { color: var(--line); }
.hud-lesson { overflow: hidden; text-overflow: ellipsis; }
.hud-step { color: var(--primary); text-shadow: 0 0 8px rgba(159, 239, 0, .4); }
.hud-bar { position: relative; width: 70px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.hud-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--accent), var(--primary)); box-shadow: 0 0 6px var(--primary); }
.hud-pct { color: var(--accent); }

/* --- lessons run edge to edge: bars and keyboard fill the width; only text/buttons keep clear of the notch --- */
.screen.lesson { padding-left: 0; padding-right: 0; }
.lesson .caption { padding-left: max(12px, var(--side)); padding-right: max(12px, var(--side)); border-left: 0; border-right: 0; }
.lesson .kb-slot { padding: 0 max(6px, calc(var(--side) - 24px)); }
.lesson .kb { margin: 0; }
.menu-float { left: max(10px, calc(var(--side) - 30px)); }
.fs-float { right: max(10px, calc(var(--side) - 30px)); }
.stat.course { color: var(--accent); }
.stat.course .hud-bar { width: 56px; }

/* --- lesson top bar: [☰ HUD] [step mini-map] [⏸ ⛶] --- */
.top-right { position: absolute; z-index: 4; top: calc(6px + env(safe-area-inset-top)); right: max(10px, calc(var(--side) - 30px)); display: flex; gap: 8px; }
.top-right .btn.icon { width: 40px; min-width: 40px; min-height: 40px; background: rgba(18, 26, 37, .85); }
.top-right .btn.icon .icon { width: 20px; height: 20px; }
.menu-float { top: calc(6px + env(safe-area-inset-top)); }
.menu-btn { width: 40px; min-width: 40px; min-height: 40px; }
.hud { max-width: 24vw; }
.stepbar {
  position: absolute; z-index: 4; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(18, 26, 37, .85); max-width: 46vw; overflow-x: auto; scrollbar-width: none;
}
.stepbar::-webkit-scrollbar { display: none; }
.stepbar-item {
  display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 9px 0 4px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font: 700 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; cursor: pointer;
}
.stepbar-num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); font-size: 10px; }
.stepbar-item.done { color: var(--ink); }
.stepbar-item.done .stepbar-num { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.stepbar-item.now { background: rgba(159, 239, 0, .12); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.stepbar-item.now .stepbar-num { border-color: var(--primary); }
.stepbar-item:active { background: var(--line); }
.lesson .lesson-stage { padding-top: calc(50px + env(safe-area-inset-top)); }

/* --- paused --- */
.paused-overlay { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(10, 14, 20, .72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.paused-label { font: 800 14px var(--mono); letter-spacing: .3em; text-transform: uppercase; color: var(--bad); }
.paused-overlay .btn.resume { min-height: 56px; padding: 0 28px; font-size: 20px; gap: 8px; }
.is-paused .pause-btn { color: var(--bad); border-color: var(--bad); }
.is-paused .caption-controls { visibility: hidden; }
@media (max-height: 500px) {
  .lesson .lesson-stage { padding-top: 46px; }
  .stepbar-name { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; }
}
