/* ===========================================================================
   Mansfield Teaches Typing — design system
   A love letter to Mario Teaches Typing, dressed in art4quinn editorial calm.
   Vanilla CSS. Light/dark follow the OS, plus a manual override on <html>.
   =========================================================================== */

:root {
  /* dark is the default canvas */
  --ink:    #0b0c10;   /* page background */
  --ink2:   #14161d;   /* raised surface  */
  --ink3:   #1c1f28;   /* hover surface   */
  --paper:  #ece9e2;   /* primary text    */
  --muted:  #9a978f;   /* secondary text  */
  --faint:  #62605b;   /* tertiary text   */
  --line:   rgba(236,233,226,.10);
  --line2:  rgba(236,233,226,.20);

  /* brass/copper accent — the plumbing fittings, lifted from art4quinn's warm tan */
  --brass:  #c2a878;
  --copper: #c06b46;

  /* Mansfield himself: green cap, blue overalls */
  --pipe-green: #3fae6b;
  --pipe-blue:  #3f7fd6;
  --leak:       #58c4dd;  /* water */

  /* feedback */
  --good:  #4ec98a;
  --warn:  #e0b341;
  --bad:   #d9694e;

  --glass:      rgba(20,22,29,.55);
  --glass-line: rgba(236,233,226,.14);
  --glass-hi:   rgba(255,255,255,.06);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px -20px rgba(0,0,0,.7);

  --font-ui:   'Selawik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

:root[data-theme="light"],
html:not([data-theme="dark"]) {
  /* light overrides applied below via media query and explicit attr */
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink:   #f3f1ea;
    --ink2:  #e9e6dd;
    --ink3:  #e1ddd2;
    --paper: #17171d;
    --muted: #5e5b54;
    --faint: #8c8980;
    --line:  rgba(20,20,26,.10);
    --line2: rgba(20,20,26,.18);
    --glass:      rgba(255,255,255,.55);
    --glass-line: rgba(20,20,26,.12);
    --glass-hi:   rgba(255,255,255,.55);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --ink:   #f3f1ea;
  --ink2:  #e9e6dd;
  --ink3:  #e1ddd2;
  --paper: #17171d;
  --muted: #5e5b54;
  --faint: #8c8980;
  --line:  rgba(20,20,26,.10);
  --line2: rgba(20,20,26,.18);
  --glass:      rgba(255,255,255,.55);
  --glass-line: rgba(20,20,26,.12);
  --glass-hi:   rgba(255,255,255,.55);
  color-scheme: light;
}

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

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(120% 90% at 50% -10%, var(--ink2) 0%, var(--ink) 55%),
    var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
  /* this is an app/game — no accidental text selection */
  user-select: none; -webkit-user-select: none;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

::selection { background: var(--brass); color: var(--ink); }

/* ---- shared scaffolding ---------------------------------------------------- */

.shell {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) 22px 56px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; width: 100%;
}
.brand { display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 0; }
.brand .mono {
  font-family: var(--font-mono); font-weight: 700; letter-spacing: .12em;
  font-size: .82rem; color: var(--paper);
  border: 1px solid var(--line2); border-radius: 8px; padding: 5px 9px;
}
.brand .name { font-size: .82rem; letter-spacing: .04em; color: var(--muted); }
.brand:hover .name { color: var(--paper); }

.toolbar { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ink2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px;
  font-size: .72rem; letter-spacing: .04em; color: var(--muted);
  transition: color .2s, border-color .2s, background .2s;
}
.chip:hover { color: var(--paper); border-color: var(--line2); }
.chip svg { width: 15px; height: 15px; }

/* ---- landing hero ---------------------------------------------------------- */

.hero { text-align: center; margin: clamp(28px, 9vh, 84px) 0 0; }
.mascot {
  width: 88px; height: 88px; display: block; margin: 0 auto 8px;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.45));
  animation: mascotBob 1.1s ease-in-out infinite;
}
@keyframes mascotBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.hero .monogram {
  font-weight: 200; font-size: clamp(3.4rem, 14vw, 7.5rem); line-height: .92;
  letter-spacing: .04em; display: inline-block;
}
.hero .monogram .t { color: var(--brass); font-weight: 300; }
.hero .rule { width: 60px; height: 1px; background: var(--brass); margin: 22px auto 16px; opacity: .85; }
.hero .wordmark {
  font-size: .72rem; letter-spacing: .42em; text-transform: uppercase;
  color: var(--muted); margin-left: .42em;
}
.hero .tagline { margin-top: 14px; color: var(--faint); font-size: .96rem; }

/* editorial card grid (art4quinn DNA) */
.cards {
  width: 100%; margin: clamp(34px, 7vh, 64px) auto 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.card {
  text-align: left; background: var(--ink); color: var(--paper);
  padding: 30px 26px 24px; min-height: 196px; position: relative;
  display: flex; flex-direction: column; border: 0;
  transition: background .25s ease;
}
.card:hover { background: var(--ink2); }
.card .num { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .3em; color: var(--brass); }
.card h2 { margin: 14px 0 8px; font-size: 1.42rem; font-weight: 500; letter-spacing: .01em; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.card .go {
  margin-top: auto; padding-top: 18px; display: flex; align-items: center; gap: 8px;
  color: var(--faint); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase;
  transition: color .25s ease;
}
.card:hover .go { color: var(--paper); }
.card .go .arrow { transition: transform .25s ease; }
.card:hover .go .arrow { transform: translateX(5px); color: var(--brass); }
.card::before {
  content: ''; position: absolute; left: 0; top: 0; height: 2px; width: 0;
  background: var(--brass); transition: width .3s ease;
}
.card:hover::before { width: 100%; }
.card[data-tone="green"]::before { background: var(--pipe-green); }
.card[data-tone="green"] .num { color: var(--pipe-green); }
.card[data-tone="blue"]::before { background: var(--pipe-blue); }
.card[data-tone="blue"] .num { color: var(--pipe-blue); }

/* ---- footer ---------------------------------------------------------------- */

.foot {
  margin-top: auto; padding-top: 42px;
  color: var(--faint); font-size: .74rem; letter-spacing: .04em; text-align: center;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line2); }
.foot a:hover { color: var(--paper); }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--muted); border-bottom: 1px solid var(--line2); letter-spacing: inherit;
}
.link-btn:hover { color: var(--paper); }
.link-btn.busy { opacity: .6; cursor: progress; }

/* ---- section header (lesson select / mode select) -------------------------- */

.sec-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.btn-back {
  background: var(--ink2); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: .78rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-back:hover { color: var(--paper); border-color: var(--line2); }
.sec-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.sec-head p { margin: 2px 0 0; font-size: .8rem; color: var(--faint); }

.lesson-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 14px; }
.lesson {
  background: var(--ink2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; text-align: left; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .2s, transform .15s, background .2s;
}
.lesson:hover { border-color: var(--line2); background: var(--ink3); transform: translateY(-2px); }
.lesson .l-title { font-size: 1rem; font-weight: 600; }
.lesson .l-focus { font-family: var(--font-mono); font-size: .74rem; color: var(--brass); }
.lesson .l-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .04em;
  color: var(--muted); background: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 7px;
}

/* ===========================================================================
   GAME STAGE — immersive, no chrome. Each mode mounts a canvas + HUD + keyboard.
   =========================================================================== */

.stage {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(120% 120% at 50% 0%, var(--ink2) 0%, var(--ink) 60%),
    var(--ink);
  display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

/* HUD — overlays the game across the top. Back button left, big horizontal
   stats, finger-guide slot right. No wasted stacked boxes. */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; gap: 18px;
  padding: max(8px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8,10,14,.62) 0%, rgba(8,10,14,.28) 60%, rgba(8,10,14,0) 100%);
}
.hud .stats { display: flex; align-items: baseline; gap: clamp(14px, 2.4vw, 30px); flex: 1; flex-wrap: wrap; }
.hud .stat { display: inline-flex; align-items: baseline; gap: 7px; }
.hud .stat .k { font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.hud .stat .v {
  font-family: var(--font-mono); font-weight: 800; font-size: clamp(1.3rem, 3vw, 1.9rem);
  color: #fff; line-height: 1; text-shadow: 0 1px 8px rgba(0,0,0,.7);
}
.hud .stat .v small { font-size: .6em; color: var(--muted); font-weight: 500; }
.hud .stat.goal .v { color: var(--brass); }
.hud .stat.streak.hot .v { color: var(--warn); }
.hud .finger-slot { pointer-events: auto; display: flex; align-items: center; min-height: 28px; }

/* Back button — left-aligned means "go back". */
.btn-back-game {
  pointer-events: auto; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(12,15,22,.55); border: 1px solid var(--glass-line); border-radius: 999px;
  padding: 8px 15px 8px 12px; color: var(--paper); font-size: .82rem; font-weight: 600; letter-spacing: .01em;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.btn-back-game .arrow { font-size: 1.05rem; line-height: 1; }
.btn-back-game:hover { background: rgba(22,26,36,.75); }

/* the playfield canvas wrapper */
.field {
  position: relative; flex: 1 1 auto; min-height: 34vh;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.42));
}
.field canvas { display: block; width: 100%; height: 100%; }

/* the prompt ribbon (what to type), floats over the field */
.ribbon {
  position: absolute; left: 0; right: 0; top: 14px;
  display: flex; justify-content: center; pointer-events: none;
}
.ribbon .words {
  font-family: var(--font-mono); font-size: clamp(1rem, 3.4vw, 1.6rem);
  letter-spacing: .02em; padding: 10px 18px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  max-width: min(92vw, 760px); white-space: pre-wrap; text-align: center;
}
.ribbon .done { color: var(--faint); }
.ribbon .cur  { color: var(--ink); background: var(--brass); border-radius: 3px; padding: 0 1px; }
.ribbon .cur.bad { background: var(--bad); color: #fff; }
.ribbon .rest { color: var(--paper); }

/* encouraging toast (Martinet's rule — never mean) */
.toast {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%,-50%);
  font-weight: 600; font-size: clamp(1.1rem, 4vw, 1.8rem); color: var(--brass);
  text-shadow: 0 2px 18px rgba(0,0,0,.6); pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---- glassmorphic on-screen keyboard --------------------------------------- */

.kb {
  margin-top: 12px; padding: 12px 10px;
  background: rgba(26,38,52,.14); border: 1px solid rgba(200,228,240,.16); border-radius: 18px;
  backdrop-filter: blur(6px) saturate(190%) brightness(1.18); -webkit-backdrop-filter: blur(6px) saturate(190%) brightness(1.18);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.16), inset 0 0 50px rgba(120,170,190,.06);
  user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column; gap: 7px;
  touch-action: manipulation;
}
.kb-row { display: flex; gap: 7px; justify-content: center; }
.key {
  flex: 1 1 0; max-width: 54px; min-width: 0;
  aspect-ratio: 1 / 1; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--glass-line);
  font-size: clamp(.7rem, 2.4vw, .95rem); font-weight: 500; color: var(--paper);
  position: relative; transition: transform .07s ease, background .12s, box-shadow .12s, color .12s;
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 2px 6px rgba(0,0,0,.25);
}
.key.wide   { flex-grow: 1.6; aspect-ratio: auto; }
.key.space  { flex-grow: 7; aspect-ratio: auto; }
.key.mod    { color: var(--muted); font-size: .62rem; letter-spacing: .06em; }
.key:active, .key.press {
  transform: translateY(2px) scale(.96);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
}
/* the lit "next key" indicator */
.key.next {
  color: var(--ink); background: var(--brass);
  box-shadow: 0 0 0 1px var(--brass), 0 0 22px -2px var(--brass);
  animation: keyPulse 1.1s ease-in-out infinite;
}
.key.next.f-l { background: var(--pipe-green); box-shadow: 0 0 0 1px var(--pipe-green), 0 0 22px -2px var(--pipe-green); }
.key.next.f-r { background: var(--pipe-blue);  box-shadow: 0 0 0 1px var(--pipe-blue),  0 0 22px -2px var(--pipe-blue); }
@keyframes keyPulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
/* tap ripple */
.key .ripple {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at center, rgba(255,255,255,.5), transparent 60%);
  opacity: 0; transform: scale(.4);
}
.key.press .ripple { animation: ripple .4s ease-out; }
@keyframes ripple { 0% { opacity: .6; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.2); } }

.kb-hint { text-align: center; font-size: .68rem; color: var(--faint); margin-top: 8px; letter-spacing: .04em; }

/* short viewports: shrink the keyboard so the playfield keeps its room */
@media (max-height: 860px) {
  .key { max-width: 46px; border-radius: 9px; }
  .kb { padding: 9px 8px; gap: 6px; } .kb-row { gap: 6px; }
}
@media (max-height: 680px) {
  .key { max-width: 38px; border-radius: 8px; font-size: .72rem; }
  .kb { padding: 7px 6px; gap: 5px; border-radius: 14px; } .kb-row { gap: 5px; }
  .kb-hint { margin-top: 5px; }
  .field { min-height: 30vh; }
}

/* tighten the keyboard on small screens so all keys fit comfortably */
@media (max-width: 560px) {
  .kb { padding: 8px 6px; gap: 5px; border-radius: 14px; }
  .kb-row { gap: 5px; }
  .key { border-radius: 8px; }
  .key .cap { font-size: .66rem; }
  .hud .stat { min-width: 64px; padding: 6px 9px; }
  .hud .stat .v { font-size: .98rem; }
}

/* finger guide pill — a small glass chip, not a banal line of text */
.finger {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-line);
  padding: 4px 13px; border-radius: 999px;
  backdrop-filter: blur(10px) saturate(160%); -webkit-backdrop-filter: blur(10px) saturate(160%);
}
.finger .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brass); box-shadow: 0 0 9px var(--brass); }
.finger .dot.left  { background: var(--pipe-green); box-shadow: 0 0 9px var(--pipe-green); }
.finger .dot.right { background: var(--pipe-blue); box-shadow: 0 0 9px var(--pipe-blue); }

/* ===========================================================================
   FOCUS MODE — the grown-up. No game. Just text, a caret, and honest numbers.
   =========================================================================== */

.focus-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 20px; max-width: 880px; margin: 0 auto; width: 100%;
}
.focus-text {
  font-family: var(--font-mono); font-size: clamp(1.15rem, 3.2vw, 1.7rem); line-height: 1.8;
  letter-spacing: .01em; text-align: left; color: var(--faint);
  max-width: 760px; white-space: pre-wrap; word-break: break-word;
}
.focus-text .done { color: var(--paper); }
.focus-text .bad  { color: var(--bad); background: rgba(217,105,78,.15); border-radius: 2px; }
.focus-text .cur {
  position: relative; color: var(--muted);
  border-bottom: 2px solid var(--brass);
}
.focus-text .cur::after {
  content: ''; position: absolute; left: -1px; top: 0; bottom: 2px; width: 2px;
  background: var(--brass); animation: caret 1s step-end infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ===========================================================================
   RESULTS — quiet, editorial summary.
   =========================================================================== */

.results { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; }
.results .seal {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line2); background: var(--ink2);
  font-size: 1.5rem;
}
.results h3 { margin: 0; font-size: 1.1rem; letter-spacing: .02em; }
.results .verdict { color: var(--good); }
.results .verdict.miss { color: var(--warn); }
.results .blurb { color: var(--muted); font-size: .9rem; max-width: 460px; text-align: center; line-height: 1.6; }
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(76px,1fr)); gap: 10px; width: 100%; max-width: 520px; }
@media (max-width: 460px) { .result-grid { grid-template-columns: repeat(2, 1fr); } }
.result-grid .cell {
  background: var(--ink2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center;
}
.result-grid .cell .k { font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); display: block; }
.result-grid .cell .v { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 600; display: block; margin-top: 4px; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn {
  border: 1px solid var(--line2); background: var(--ink2); border-radius: 12px;
  padding: 11px 20px; font-size: .82rem; font-weight: 600; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 8px; transition: background .2s, border-color .2s, transform .12s;
}
.btn:hover { background: var(--ink3); transform: translateY(-1px); }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn.primary:hover { filter: brightness(1.05); }

/* pause veil */
.veil {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(8,9,12,.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-align: center;
}
.veil .panel { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.veil h4 { margin: 0; letter-spacing: .2em; text-transform: uppercase; color: var(--brass); font-size: 1rem; }

/* utility */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ===========================================================================
   GUITAR GOD — 3D neon fretboard (three.js) with a glassmorphic HUD.
   =========================================================================== */
.gg-stage { padding: 0; }
.gg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; }
.gg-fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }

.gg-hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
}
.gg-hud .btn-exit { background: rgba(10,12,20,.45); }
.gg-stat {
  background: rgba(12,14,22,.4); border: 1px solid var(--glass-line); border-radius: 12px;
  padding: 6px 14px; backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
}
.gg-stat .k { display: block; font-size: .56rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.gg-stat .v { display: block; font-family: var(--font-mono); font-size: 1.3rem; font-weight: 800; color: #fff; line-height: 1.1; }
.gg-stat .v small { font-size: .7rem; color: #ec4899; }
.gg-prog { flex: 1; height: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.08); border: 1px solid var(--glass-line); }
.gg-prog-bar { height: 100%; width: 0; background: linear-gradient(90deg, #ec4899, #8b5cf6); transition: width .1s linear; }

.gg-count {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-mono); font-weight: 900; font-size: clamp(4rem, 18vw, 9rem); color: #fff;
  text-shadow: 0 0 50px #ec4899, 0 0 16px #fff; opacity: 0; transition: opacity .15s;
}
.gg-count.show { opacity: 1; }

.gg-pop {
  position: absolute; bottom: 30%; transform: translateX(-50%);
  font-family: var(--font-mono); font-weight: 800; letter-spacing: .12em;
  font-size: clamp(1.1rem, 4vw, 1.9rem); text-shadow: 0 0 14px currentColor;
  animation: ggpop .75s ease-out forwards;
}
@keyframes ggpop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.8); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1.12); }
}

.gg-pads {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; gap: 10px; justify-content: center;
  padding: 12px 12px max(14px, env(safe-area-inset-bottom));
}
.gg-pad {
  flex: 1 1 0; max-width: 130px; min-height: 60px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--paper); cursor: pointer;
  background: rgba(16,18,26,.4); border: 1px solid var(--glass-line); border-bottom: 3px solid var(--c);
  backdrop-filter: blur(40px) saturate(200%); -webkit-backdrop-filter: blur(40px) saturate(200%);
  box-shadow: inset 0 1px 0 var(--glass-hi); transition: transform .08s, box-shadow .12s, background .12s;
}
.gg-pad-key { font-weight: 800; font-size: 1.3rem; }
.gg-pad-fret { width: 44px; height: 7px; border-radius: 4px; background: var(--c); box-shadow: 0 0 14px var(--c); }
.gg-pad-name { font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.gg-pad.on, .gg-pad:active {
  transform: translateY(2px); background: rgba(255,255,255,.1);
  box-shadow: 0 0 26px -2px var(--c), inset 0 0 0 1px var(--c);
}

.gg-loading {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; text-align: center; padding: 24px;
  background: rgba(5,5,16,.94); color: var(--paper); font-size: .95rem; letter-spacing: .02em;
}

/* ===========================================================================
   a11y + landing fit (no scrollbar on the front page)
   =========================================================================== */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.card:focus-visible { outline-offset: -2px; }
.key:focus-visible, .gg-pad:focus-visible { outline-offset: -2px; }

/* The landing centers in the viewport and compacts so the cards sit above the
   fold — no page scroll. Falls back to scrolling only on very short screens. */
.shell.landing {
  min-height: 100vh; min-height: 100dvh; justify-content: center;
  gap: clamp(8px, 2.2vh, 24px); padding-block: clamp(12px, 2.6vh, 30px);
}
.shell.landing .hero { margin: 0; }
.shell.landing .mascot { width: clamp(52px, 8vh, 78px); margin-bottom: 2px; }
.shell.landing .monogram { font-size: clamp(2.4rem, 8.5vh, 5rem); }
.shell.landing .rule { margin: clamp(8px, 1.4vh, 16px) auto clamp(6px, 1vh, 12px); }
.shell.landing .wordmark { font-size: clamp(.6rem, 1.3vh, .72rem); }
.shell.landing .tagline { margin-top: 6px; font-size: clamp(.8rem, 1.5vh, .95rem); }
.shell.landing .cards { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); }
.shell.landing .card { min-height: clamp(116px, 17vh, 176px); padding: clamp(14px, 2.2vh, 26px) 20px clamp(10px, 1.6vh, 20px); }
.shell.landing .card h2 { margin: 10px 0 6px; font-size: clamp(1.1rem, 2.2vh, 1.42rem); }
.shell.landing .card p { font-size: clamp(.78rem, 1.5vh, .9rem); }
.shell.landing .foot { padding-top: clamp(12px, 2.2vh, 30px); font-size: clamp(.66rem, 1.3vh, .74rem); }
@media (max-height: 620px) { .shell.landing { justify-content: flex-start; } }

/* ===========================================================================
   KEY RAIN — letters fall onto their real keys; the acrylic keyboard overlaps
   the playfield (you can read the notes through the glass).
   =========================================================================== */
.stage.immerse .field { overflow: hidden; }
.rain-glass { position: absolute; inset: 0; z-index: 1; display: block; }
.stage.immerse .kb-mount {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; margin: 0;
  display: flex; justify-content: center;
  padding: 0 12px max(10px, env(safe-area-inset-bottom));
  pointer-events: auto;
}
.stage.immerse .kb { width: 100%; max-width: 1000px; margin: 0; }

.rain-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.rain-note {
  position: absolute; top: 0; left: 0; transform: translate(-50%, 0);
  display: inline-flex; padding: 6px 11px; border-radius: 11px; white-space: nowrap;
  font-family: var(--font-mono); font-weight: 800; line-height: 1; letter-spacing: .02em;
  font-size: clamp(1.25rem, 3.6vw, 2.1rem); color: var(--paper);
  background: rgba(6,16,22,.42); border: 1px solid rgba(180,220,235,.14);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.6); will-change: transform;
}
.rain-note .done { opacity: .35; }
.rain-note .cur { color: var(--c); text-shadow: 0 0 12px var(--c); }
.rain-note.active { border-color: rgba(194,168,120,.7); box-shadow: 0 0 0 1px rgba(194,168,120,.5), 0 0 26px -6px var(--brass); }
.rain-note.shake { outline: 2px solid var(--bad); outline-offset: 1px; }
.rain-note.pop { transition: opacity .18s ease, filter .18s ease; opacity: 0; filter: brightness(2.2); }
.rain-note.leak { transition: opacity .22s ease; opacity: 0; border-color: var(--bad); }
