/* Hallmark · redesign: full (menu, boot, start cue, panels, modals) · scope: app (game UI) · genre: atmospheric · theme: the project's own (late-night studio: brass, cream, needle violet; Barlow Condensed) · signature: the needle's violet marks the selected choice and wipes away the start cue */
/* critique: the lock is the hero, so the 2D layer is one wordmark, three choices and two quiet corner lines; panels and modals use flat dark studio slate with hairline brass rules and no cut-corner boxes */
/* waive 29 (.cue-needle, .boot-needle): the glow is the needle's light, the same beam as the 3D needle, not a depth shadow */
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: block; src: url("../vendor/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: block; src: url("../vendor/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: block; src: url("../vendor/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --navy: #0a0b10;
  --navy-deep: #090a10;
  --surface: #12131c;
  --surface-card: rgba(16, 17, 26, 0.92);
  --surface-row: rgba(20, 22, 34, 0.88);
  --surface-badge: rgba(10, 11, 16, 0.72);
  --backdrop: rgba(6, 7, 12, 0.84);
  --obsidian: rgba(10, 11, 16, 0.94);
  --cream: #efe2c8;
  --cream-strong: rgba(239, 226, 200, 0.82);
  --cream-mid: rgba(239, 226, 200, 0.72);
  --cream-dim: rgba(239, 226, 200, 0.62);
  --cream-muted: rgba(239, 226, 200, 0.52);
  --cream-faint: rgba(239, 226, 200, 0.38);
  --cream-border: rgba(239, 226, 200, 0.35);
  --cream-line: rgba(239, 226, 200, 0.16);
  --brass: #d4a259;
  --brass-deep: #8e6118;
  --brass-dim: rgba(212, 162, 89, 0.45);
  --brass-fill: rgba(212, 162, 89, 0.18);
  --brass-soft: rgba(212, 162, 89, 0.10);
  --brass-hover: rgba(212, 162, 89, 0.28);
  --core-white: #fff1d6;
  --rec-green: #42ffa1;
  --rec-green-deep: #1d9c5a;
  --magenta: #8b7cff;
  --cyan: #d4a259;       /* restrained palette: aged brass replaces neon cyan in UI */
  --gold: #d4a259;
  --red: #ff4d3d;        /* reserved strictly for REC ●, danger, and miss */
  --red-fill: rgba(255, 77, 61, 0.10);
  --red-hover: rgba(255, 77, 61, 0.22);
  --red-line: rgba(255, 77, 61, 0.35);
  --rule: rgba(212, 162, 89, 0.28);
  --font: "Barlow Condensed", "Segoe UI", Arial, sans-serif;

  /* menu, boot and cue */
  --violet: #8b7cff;                       /* the needle's light: the one "you are here" colour */
  --violet-dim: rgba(139, 124, 255, 0.35);
  --violet-fill: rgba(139, 124, 255, 0.12);
  --violet-glow: rgba(139, 124, 255, 0.55);
  --shade: rgba(0, 0, 0, 0.85);
  --shade-soft: rgba(0, 0, 0, 0.6);
  --scrim: rgba(8, 8, 12, 0.72);
  --vignette-ink: rgb(5, 6, 14);
  --miss-red: rgb(255, 60, 45);
  --gutter: clamp(28px, 3.2vw, 64px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: clip;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#stage canvas {
  z-index: -1;              /* under the vignette layers, which sit under every UI layer */
  /* contrast and saturation are graded inside the WebGL shaders (scene.js), not with a CSS filter */
}
/* Vignette and miss tint are fixed images faded by opacity only: changing them never repaints the screen. */
#stage::before,
#stage::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  will-change: opacity;
}
#stage::before {
  background: radial-gradient(ellipse 68% 62% at 50% 50%, transparent 38%, var(--vignette-ink) 100%);
  opacity: var(--vig, 0.45);
}
#stage::after {
  background: radial-gradient(ellipse 75% 75% at 50% 50%, transparent 62%, var(--miss-red) 100%);
  opacity: var(--red-tint, 0);
}

/* ---------- floating text ---------- */
#floats { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: clamp(18px, 2.4vw, 40px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 0 12px currentColor, 0 2px 0 var(--shade-soft);
  animation: float-up 0.9s linear forwards;
}
.float.big { font-size: clamp(26px, 3.6vw, 60px); animation-duration: 1.2s; }
@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  12%  { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  25%  { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  65%  { opacity: 1; transform: translate(-50%, -110%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* camera-flash pop */
#flash { position: fixed; inset: 0; pointer-events: none; background: var(--core-white); opacity: 0; }
#flash.pop { animation: flash 0.22s ease-out; }
@keyframes flash { 0% { opacity: 0.22; } 100% { opacity: 0; } }

/* ---------- controls (bottom right, in-game only) ---------- */
body[data-mode="title"] #controls,
body[data-paused="true"] #controls { display: none; }
#controls {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
#controls button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--cream-mid);
  font: 600 clamp(14px, 1.15vw, 20px) var(--font);
  text-shadow: 0 1px 3px var(--shade);
  cursor: pointer;
  transition: color 0.15s, transform 0.08s;
}
#controls button:hover, #controls button:focus-visible { color: var(--cream); outline: none; }
#controls button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; transition: none; }
#controls button:active, #controls button.on { color: var(--brass); transform: translateX(-3px); }
#controls kbd {
  font: 500 0.75em var(--font);
  color: var(--brass-dim);
  opacity: 0;
  transition: opacity 0.2s;
}
#controls:hover kbd, #controls button:focus-visible kbd { opacity: 1; }

/* phones: big touch targets, hide keyboard hints */
@media (pointer: coarse) {
  #controls { left: 12px; right: 12px; flex-direction: row-reverse; justify-content: space-between; align-items: stretch; }
  #controls button { padding: 12px 16px; }
  #btn-pick { flex: 1; justify-content: center; }
  #controls kbd { display: none; }
}

#perf {
  position: fixed;
  top: 12px;
  left: 12px;
  font: 600 12px ui-monospace, Consolas, monospace;
  color: var(--brass);
  pointer-events: none;
}

/* ---------- live visual & performance settings panel ---------- */
#settings-panel {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: 132px;
  width: 312px;
  max-width: calc(100% - 24px);
  padding: 16px 20px;
  background: var(--obsidian);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  color: var(--cream);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#settings-panel[hidden] { display: none; }
.sp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--brass);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
}
.sp-head button {
  background: none;
  border: 0;
  color: var(--cream-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.sp-head button:hover { color: var(--cream); }
.sp-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--cream-strong);
}
.sp-row span { display: flex; justify-content: space-between; }
.sp-row em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--brass);
}
.sp-row input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
  cursor: pointer;
  margin: 0;
}
.sp-row select {
  background: var(--surface);
  color: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 4px 8px;
  font: 600 14px var(--font);
  cursor: pointer;
}
.sp-row.sp-check {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
}
.sp-row.sp-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brass);
  cursor: pointer;
}
.sp-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.sp-actions button {
  background: transparent;
  color: var(--brass);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 4px 12px;
  font: 600 13px var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sp-actions button:hover {
  background: var(--brass-fill);
  border-color: var(--brass);
  color: var(--cream);
}

/* ---------- Main menu: wordmark, three choices, the lock centre stage ---------- */
#title-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#title-ui[hidden] { display: none; }
/* a soft shade on the left so the type reads over the lamp and camera, never a box */
#title-ui::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--scrim) 0%, transparent 38%);
}

#brand {
  position: absolute;
  left: max(var(--gutter), env(safe-area-inset-left));
  top: max(clamp(24px, 4.5vh, 56px), env(safe-area-inset-top));
  text-shadow: 0 2px 14px var(--shade);
}
.brand-studio {
  margin: 0 0 4px 4px;
  font-size: clamp(16px, 1.15vw, 20px);
  font-weight: 600;
  color: var(--brass);
}
.brand-title {
  margin: 0;
  font-size: clamp(56px, 4.9vw, 84px);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--cream);
  overflow-wrap: break-word;
  min-width: 0;
}

#menu-rail {
  position: absolute;
  left: max(var(--gutter), env(safe-area-inset-left));
  top: 52%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: auto;
}
.rail-btn {
  position: relative;
  padding: 4px 12px 4px 28px;
  margin-left: -28px;
  background: none;
  border: 0;
  border-radius: 2px;
  color: var(--cream-dim);
  font: 600 clamp(24px, 2vw, 34px) / 1.1 var(--font);
  text-align: left;
  text-shadow: 0 2px 12px var(--shade);
  cursor: pointer;
  transition: color 0.16s ease, transform 0.22s var(--ease-out);
}
.rail-btn.is-primary {
  margin-bottom: 12px;
  font-size: clamp(52px, 4.8vw, 84px);
  font-weight: 700;
  line-height: 0.95;
  color: var(--cream);
}
/* the marker: a short sliver of the needle's violet light */
.rail-btn::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 22%;
  bottom: 22%;
  width: 4px;
  border-radius: 2px;
  background: var(--violet);
  box-shadow: 0 0 12px var(--violet-glow);
  opacity: 0;
  transform: scaleY(0.2);
  transition: opacity 0.14s ease, transform 0.22s var(--ease-out);
}
.rail-btn.active { color: var(--cream); transform: translateX(8px); }
.rail-btn.active::before { opacity: 1; transform: scaleY(1); }
.rail-btn:active { transform: translateX(8px) scale(0.98); }
.rail-btn:focus { outline: none; }
.rail-btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; transition: none; }

#menu-keys {
  position: absolute;
  left: max(var(--gutter), env(safe-area-inset-left));
  bottom: max(clamp(22px, 4vh, 44px), env(safe-area-inset-bottom));
  margin: 0;
  display: flex;
  gap: 24px;
  font-size: 17px;
  font-weight: 500;
  color: var(--cream-dim);
  text-shadow: 0 1px 6px var(--shade);
}
#menu-keys span { display: inline-flex; align-items: center; gap: 8px; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border: 1px solid var(--brass-dim);
  border-radius: 4px;
  font: 600 0.88em / 1.45 var(--font);
  text-align: center;
  color: var(--cream);
}
#credit {
  position: absolute;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: max(clamp(22px, 4vh, 44px), env(safe-area-inset-bottom));
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--cream-faint);
}

/* the menu settles in each time it appears */
#title-ui:not([hidden]) #brand,
#title-ui:not([hidden]) .rail-btn,
#title-ui:not([hidden]) #menu-keys,
#title-ui:not([hidden]) #credit { animation: menu-in 0.5s var(--ease-out) both; }
#title-ui:not([hidden]) .rail-btn:nth-child(1) { animation-delay: 0.06s; }
#title-ui:not([hidden]) .rail-btn:nth-child(2) { animation-delay: 0.1s; }
#title-ui:not([hidden]) .rail-btn:nth-child(3) { animation-delay: 0.14s; }
#title-ui:not([hidden]) .rail-btn:nth-child(4) { animation-delay: 0.18s; }
#title-ui:not([hidden]) #menu-keys,
#title-ui:not([hidden]) #credit { animation-delay: 0.2s; }
#title-ui:not([hidden])::before { animation: fade-in 0.5s ease both; }
@keyframes menu-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade-in { from { opacity: 0; } }
/* rail buttons animate their own transform, so their entrance only fades */
#title-ui:not([hidden]) .rail-btn { animation-name: fade-in; }

h1, h2, h3 { text-wrap: balance; }
button:disabled, input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }

/* keyboard-only booth: every control shows where focus is, instantly */
.modal-card button:focus-visible,
#gameover-panel button:focus-visible,
#player-name:focus-visible,
.acct-input:focus-visible,
#settings-panel :is(button, select, input):focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; transition: none; }

/* ---------- Start cue: "Press Space to start", wiped away by the needle ---------- */
#ready-cue {
  position: fixed;
  left: 50%;
  bottom: max(16px, 2.6vh, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 14;
  pointer-events: none;
}
/* a soft pool of shade so the line reads over the desk and the lock's base */
#ready-cue::before {
  content: "";
  position: absolute;
  inset: -60% -30%;
  background: radial-gradient(closest-side, var(--scrim), transparent);
  animation: fade-in 0.4s ease both;
}
#ready-cue.is-leaving::before { opacity: 0; transition: opacity 0.4s ease 0.3s; }
#ready-cue[hidden] { display: none; }
.cue-line {
  position: relative;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.32em;
  font-size: clamp(26px, 2.2vw, 38px);
  font-weight: 600;
  color: var(--cream);
  text-shadow: 0 2px 16px var(--shade);
  white-space: nowrap;
}
.cue-text { display: inline-flex; }
.cue-ch { display: inline-block; white-space: pre; animation: cue-in 0.5s var(--ease-out) both; animation-delay: calc(var(--i) * 18ms); }
.cue-key {
  display: inline-block;
  padding: 0.04em 0.5em 0.08em;
  border: 2px solid var(--brass);
  border-radius: 8px;
  box-shadow: 0 4px 0 var(--brass-dim);
  font-size: 0.82em;
  font-weight: 700;
  color: var(--brass);
  text-shadow: none;
  animation: cue-in 0.5s var(--ease-out) both, key-tap 1.8s ease-in-out 0.8s infinite;
  animation-delay: calc(var(--i) * 18ms), 0.8s;
}
@keyframes cue-in { from { opacity: 0; transform: translateY(0.4em); } }
@keyframes key-tap {
  0%, 70%, 100% { transform: translateY(0); }
  78% { transform: translateY(3px); }
}
.cue-needle {
  position: absolute;
  inset: -45% 0;
  opacity: 0;
}
.cue-needle::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--cream);
  box-shadow: 0 0 10px var(--violet), 0 0 26px var(--violet-glow);
}
/* leaving: the needle sweeps left to right; each glyph it passes is knocked up and out */
#ready-cue.is-leaving .cue-needle { animation: needle-sweep 0.56s cubic-bezier(0.5, 0, 0.3, 1) forwards; }
#ready-cue.is-leaving .cue-ch,
#ready-cue.is-leaving .cue-key {
  animation: cue-out 0.36s var(--ease-out) forwards;
  animation-delay: calc(var(--i) / var(--n) * 420ms + 40ms);
}
#ready-cue.is-leaving .cue-ch:nth-child(even) { --tilt: 7deg; }
#ready-cue.is-leaving .cue-key { animation-name: key-out; }
@keyframes cue-out {
  to { opacity: 0; transform: translateY(-0.7em) rotate(var(--tilt, -6deg)) scale(0.92); }
}
@keyframes key-out {
  30% { opacity: 1; transform: translateY(4px) scale(0.96); }
  to { opacity: 0; transform: translateY(0.3em) scale(0.86); }
}
@keyframes needle-sweep {
  0% { opacity: 0; transform: translateX(0); }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateX(100%); }
}

/* ---------- Boot: the needle sweeps the dial as the studio loads ---------- */
#boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--navy);
  transition: opacity 0.6s ease;
}
#boot.is-done { opacity: 0; pointer-events: none; }
.boot-dial { position: relative; width: 136px; height: 136px; margin-bottom: 8px; }
.boot-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.boot-track { fill: none; stroke: var(--rule); stroke-width: 2; }
.boot-arc {
  fill: none;
  stroke: var(--brass);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.25s linear;
}
.boot-needle {
  position: absolute;
  left: calc(50% - 1px);
  top: 10%;
  height: 40%;
  width: 2px;
  border-radius: 1px;
  background: var(--cream);
  box-shadow: 0 0 8px var(--violet), 0 0 18px var(--violet-glow);
  transform-origin: 50% 100%;
  transition: transform 0.25s linear;
}
.boot-dial::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--brass);
  background: var(--navy);
}
.boot-pct {
  margin: -8px 0 0;
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--cream-faint);
}
.boot-pct::after { content: "%"; }
.boot-word {
  margin: 0;
  font-size: clamp(34px, 3vw, 48px);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--cream);
}
.boot-step { margin: 0; min-height: 1.3em; font-size: 17px; font-weight: 500; color: var(--cream-dim); }
#boot.is-failed .boot-arc { stroke: var(--red); }
#boot.is-failed .boot-step { color: var(--cream); }
.boot-noscript {
  position: fixed;
  inset: auto 0 18vh;
  z-index: 60;
  text-align: center;
  font-size: 18px;
  color: var(--cream);
}

@media (prefers-reduced-motion: reduce) {
  #boot, .boot-arc, .boot-needle, .rail-btn, .rail-btn::before { transition: none; }
  #title-ui:not([hidden]) *, #title-ui:not([hidden])::before, .cue-ch, .cue-key { animation: none !important; }
  .rail-btn.active { transform: none; }
  #ready-cue.is-leaving .cue-needle { animation: none; }
  #ready-cue.is-leaving { opacity: 0; transition: opacity 0.15s ease; }
  #ready-cue.is-leaving .cue-ch, #ready-cue.is-leaving .cue-key { animation: none !important; }
}

/* ---------- Contextual Tutorial Broadcast Ticker ---------- */
#tutorial-banner {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 20px;
  background: var(--obsidian);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--cream);
  font-size: clamp(14px, 1.2vw, 18px);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  z-index: 12;
  white-space: nowrap;
}
#tutorial-banner[hidden] { display: none; }
#tutorial-banner strong { color: var(--brass); }

/* ---------- Game Over Studio Debrief ---------- */
#gameover-panel {
  position: fixed;
  left: max(32px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  width: 368px;
  max-width: calc(100% - 32px);
  padding: 24px;
  background: var(--obsidian);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-variant-numeric: tabular-nums;
}
#gameover-panel[hidden] { display: none; }
.go-tag {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
}
.go-tag.high { color: var(--brass); }
.go-score {
  margin: -4px 0 0;
  font-size: clamp(46px, 4.6vw, 66px);
  font-weight: 700;
  line-height: 0.92;
  color: var(--cream);
}
.go-reason {
  font-size: 14px;
  font-weight: 600;
  color: var(--brass);
}
.go-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.go-stats div { display: flex; flex-direction: column; gap: 4px; }
.go-stats span {
  font-size: 12px;
  font-weight: 600;
  color: var(--cream-muted);
}
.go-stats strong { font-size: 22px; font-weight: 700; color: var(--cream); }
#score-form { display: flex; flex-direction: column; gap: 8px; }
#score-form[hidden], #avatar-picker[hidden], .sf-row[hidden], #score-saved-msg[hidden] { display: none; }
#score-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brass);
}
.sf-row { display: flex; gap: 8px; }
#player-name {
  flex: 1;
  background: var(--surface);
  color: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 12px;
  font: 600 16px var(--font);
  user-select: text;
  -webkit-user-select: text;
}
#player-name:focus { outline: none; border-color: var(--brass); }
#btn-save-score {
  background: var(--brass);
  color: var(--navy);
  border: 0;
  border-radius: 2px;
  padding: 8px 16px;
  font: 700 15px var(--font);
  cursor: pointer;
}
#btn-save-score:hover { background: var(--cream); }
#score-saved-msg {
  font-size: 14px;
  font-weight: 700;
  color: var(--brass);
}
.go-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.go-actions button, .modal-foot button {
  white-space: nowrap;
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 16px;
  font: 700 15px var(--font);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.go-actions button.primary, .modal-foot button.primary {
  flex: 1;
  background: var(--brass-fill);
  border-color: var(--brass);
  color: var(--brass);
}
.go-actions button:hover, .modal-foot button:hover {
  background: var(--brass-hover);
  border-color: var(--brass);
  color: var(--cream);
}
.go-actions kbd, .modal-foot kbd { font-size: 0.78em; opacity: 0.7; margin-left: 4px; }

/* ---------- Studio Console Modals (How to Play & Leaderboard) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--obsidian);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--brass);
  border-radius: 4px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-card.lb-card { width: min(680px, 100%); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 12px;
}
.modal-head h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  color: var(--cream);
}
.modal-close {
  background: none;
  border: 1px solid transparent;
  color: var(--cream-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--cream); border-color: var(--rule); }

.tut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.tut-item {
  background: var(--surface-card);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tut-diagram {
  height: 58px;
  background: var(--navy-deep);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.diag-pick .diag-zone {
  width: 96px; height: 20px;
  background: linear-gradient(90deg, var(--brass-deep), var(--brass), var(--brass-deep));
}
.diag-pick .diag-core {
  position: absolute; width: 26px; height: 20px;
  background: var(--core-white); box-shadow: 0 0 10px var(--core-white);
}
.diag-pick .diag-needle {
  position: absolute; width: 3px; height: 44px;
  background: var(--core-white); box-shadow: 0 0 10px var(--violet), 0 0 18px var(--violet-glow);
}
.diag-rec .diag-ghost {
  width: 3px; height: 34px; background: var(--red);
  box-shadow: 0 0 8px var(--red); margin-right: 24px;
}
.diag-rec .diag-rec-zone {
  width: 72px; height: 20px;
  background: linear-gradient(90deg, var(--rec-green-deep), var(--rec-green), var(--rec-green-deep));
}
.diag-flow .diag-flow-badge {
  font-size: 20px; font-weight: 700;
  color: var(--brass);
}
.tut-item h3 {
  margin: 4px 0 0;
  font-size: 19px;
  color: var(--cream);
}
.tut-item p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--cream-mid);
}
.tut-item strong { color: var(--brass); }

/* ---------- Avatar Picker on Game Over ---------- */
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.av-opt {
  aspect-ratio: 1;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.av-opt svg { width: 100%; height: 100%; display: block; border-radius: 2px; }
.av-opt:hover { border-color: var(--cream); transform: translateY(-2px); }
.av-opt.active { border: 2px solid var(--brass); background: var(--brass-fill); }

/* ---------- Studio Ranking: Hanging Podium + Ranked List + Pinned Footer ---------- */
.lb-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: 12px;
}
.pod-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 12px 16px;
  background: var(--surface-card);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.pod-banner.rank-1 {
  background: linear-gradient(180deg, var(--brass-fill) 0%, var(--surface-card) 100%);
  border-color: var(--brass);
  padding-top: 16px;
  padding-bottom: 20px;
}
.pod-banner.rank-2 {
  background: linear-gradient(180deg, var(--violet-fill) 0%, var(--surface-card) 100%);
  border-color: var(--violet-dim);
  margin-top: 8px;
}
.pod-banner.rank-3 {
  background: var(--surface-card);
  border-color: var(--rule);
  margin-top: 8px;
}
.pod-crown {
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
  background: var(--surface-badge);
  border: 1px solid var(--cream-border);
  border-radius: 2px;
  padding: 4px 12px;
  margin-bottom: 8px;
}
.pod-banner.rank-1 .pod-crown { color: var(--brass); border-color: var(--brass); }
.pod-avatar-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 4px;
  background: var(--navy);
  border: 2px solid var(--cream-border);
  border-radius: 6px;
  margin-bottom: 8px;
}
.pod-banner.rank-1 .pod-avatar-wrap {
  width: 64px;
  height: 64px;
  border-color: var(--brass);
}
.pod-avatar-wrap svg { width: 100%; height: 100%; display: block; border-radius: 3px; }
.pod-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--cream);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pod-score {
  font-size: 23px;
  font-weight: 700;
  color: var(--brass);
  line-height: 1.1;
}
.pod-meta {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cream-mid);
}

.lb-tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 236px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.lb-track {
  display: grid;
  grid-template-columns: 38px 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-row);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
}
.lb-track .trk-rk {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-badge);
  border: 1px solid var(--cream-line);
  border-radius: 2px;
  font-size: 17px;
  font-weight: 700;
  color: var(--cream);
}
.lb-track.top-1 .trk-rk { color: var(--brass); border-color: var(--brass); }
.lb-av {
  width: 40px;
  height: 40px;
  padding: 4px;
  background: var(--navy);
  border: 1px solid var(--cream-border);
  border-radius: 4px;
}
.lb-av svg { width: 100%; height: 100%; display: block; border-radius: 2px; }
.trk-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.trk-nm {
  font-size: 17px;
  font-weight: 700;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trk-sc {
  font-size: 15px;
  font-weight: 700;
  color: var(--brass);
}
.trk-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trk-lv { font-size: 14px; font-weight: 700; color: var(--cream); }
.trk-sub { font-size: 12px; font-weight: 600; color: var(--cream-muted); }

/* Pinned Current-Player Footer Bar */
.lb-self {
  display: grid;
  grid-template-columns: 44px 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--brass-fill), var(--brass-soft));
  border: 1px solid var(--brass);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.lb-self[hidden] { display: none; }
.lb-self .self-rk {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--brass);
}
.lb-empty {
  text-align: center;
  padding: 24px 12px;
  font-size: 15px;
  color: var(--cream-muted);
}
@media (max-width: 640px) {
  .lb-podium { grid-template-columns: 1fr; }
  .pod-banner.rank-2, .pod-banner.rank-3 { margin-top: 0; }
}
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; }
.modal-foot.lb-foot { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.lb-admin-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-foot button.danger-btn {
  background: var(--red-fill);
  border-color: var(--red-line);
  color: var(--red);
  flex: 0 0 auto;
}
.modal-foot button.danger-btn:hover {
  background: var(--red-hover);
  color: var(--cream);
}

/* ---------- Leaderboard Scope Tabs, Live Counts & Account Modal ---------- */
.lb-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.lb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lb-tab {
  background: var(--surface);
  color: var(--cream-dim);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  padding: 4px 12px;
  font: 600 14px var(--font);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.lb-tab:hover { color: var(--cream); border-color: var(--brass-dim); }
.lb-tab.active {
  background: var(--brass-fill);
  border-color: var(--brass);
  color: var(--brass);
}
.lb-stats {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--cream-muted);
}

.modal-card.acct-card { width: min(460px, 100%); }
.acct-note {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--cream-mid);
}
.acct-tabs { margin-bottom: 12px; }
.acct-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.acct-input {
  width: 100%;
  background: var(--surface);
  color: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 12px;
  font: 600 15px var(--font);
  user-select: text;
  -webkit-user-select: text;
}
.acct-input:focus { outline: none; border-color: var(--brass); }
.acct-msg {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
}
.acct-msg[hidden], #acct-signed-out[hidden], #acct-signed-in[hidden], #auth-name-wrap[hidden], #auth-av-wrap[hidden] { display: none; }
.acct-profile { grid-template-columns: 42px 1fr auto; margin-bottom: 16px; }
.acct-server {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  margin-top: 4px;
}
.acct-server button {
  white-space: nowrap;
  background: transparent;
  color: var(--brass);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 16px;
  font: 700 14px var(--font);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.acct-server button:hover {
  background: var(--brass-hover);
  border-color: var(--brass);
  color: var(--cream);
}

@media (max-width: 900px) {
  #gameover-panel { left: 50%; transform: translate(-50%, -50%); }
}
