/* ===== The Fast and the Crustaceous — 80s shrimp synthwave UI =====
 * Palette: crustacean neon on a deep-purple night — shrimp pink/coral as the
 * hot accent, sunset gold as the warm, aqua as the cool sea tone.
 * Typography: Orbitron (retro-futuristic display) + system sans for reading.
 * Geometry, class names and animation timing are unchanged from before —
 * JS (ui.js / phone.js / mirrors.js) hooks into all of them.
 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #150a30;
  --panel-hi: #251348;
  --panel-lo: #150a30;
  --ink: #ffedf7;
  --ink-dim: #bda6e0;
  --ink-faint: #8d76b8;
  --pink: #ff4d9d;
  --pink-hot: #ff2e79;
  --pink-soft: #ff8ac2;
  --coral: #ff7e5f;
  --orange: #ffb347;
  --gold: #ffd166;
  --aqua: #2ee6c8;
  --danger: #ff3b5c;
  --panel-line: rgba(255, 77, 157, 0.38);
  --font-display: "Orbitron", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  user-select: none;
}

#game { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }

/* ---------- Crash flash ---------- */
#crash-flash {
  position: fixed; inset: 0; z-index: 40;
  background: radial-gradient(ellipse at center, rgba(255,60,60,0.55), rgba(150,20,60,0.75));
  opacity: 0; pointer-events: none;
}
#crash-flash.active { animation: crashFlash 0.6s ease-out; }
@keyframes crashFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
/* white-hot burst on top of the red, gone first */
#crash-flash::before {
  content: ""; position: absolute; inset: 0;
  background: #fff6e0; opacity: 0;
}
#crash-flash.active::before { animation: crashWhite 0.2s ease-out; }
@keyframes crashWhite { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* ---------- Speed vignette (opacity driven by js/drivefx.js) ---------- */
#speed-vignette {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(10,4,24,0) 42%, rgba(10,4,24,0.5) 78%, rgba(10,4,24,0.9) 100%);
  opacity: 0; will-change: opacity;
}

/* ---------- Death vignette (hot on the screen edges) ---------- */
#death-vignette {
  position: fixed; inset: 0; z-index: 35;
  box-shadow: inset 0 0 180px 60px rgba(255,59,92,0.8);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease-in;
}
#death-vignette.active { opacity: 1; }

/* ---------- Wake ("it's waking up": AFK / too slow; opacity + --wk set by UI.wake) ---------- */
#wake-vignette {
  position: fixed; inset: 0; z-index: 36; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 30%, rgba(0,0,0,0.85) 72%, rgba(150,0,12,0.95) 100%);
  opacity: 0; will-change: opacity;
}
#wake-text {
  position: fixed; top: 40%; left: 0; right: 0; z-index: 37; pointer-events: none;
  text-align: center; font-family: var(--font-display);
  font-size: 46px; font-weight: 900; letter-spacing: 6px; color: #ff2a3a;
  text-shadow: 0 0 14px rgba(255, 20, 40, 0.8);
  opacity: 0; --wk: 0;
  animation: wakeShake 0.12s steps(1, end) infinite;
}
@keyframes wakeShake {
  0%  { transform: translate(calc(var(--wk) * 1px), calc(var(--wk) * -0.6px)) rotate(-1deg); }
  25% { transform: translate(calc(var(--wk) * -0.8px), calc(var(--wk) * 0.7px)) rotate(0.8deg); }
  50% { transform: translate(calc(var(--wk) * 0.5px), calc(var(--wk) * 0.9px)) rotate(-0.4deg); }
  75% { transform: translate(calc(var(--wk) * -1px), calc(var(--wk) * -0.4px)) rotate(1.2deg); }
}
#wake-out {
  position: fixed; inset: 0; z-index: 1000; background: #000;
  display: flex; align-items: center; justify-content: center;
}
#wake-out.hidden { display: none; }
#wake-out span {
  font-family: var(--font-display); font-size: 64px; font-weight: 900; letter-spacing: 8px;
  color: #ff0a1e; text-shadow: 0 0 24px rgba(255, 0, 30, 0.9);
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 14px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 18px;
  pointer-events: none;
  z-index: 10;
}
/* No backdrop-filter anywhere over the canvas: it re-blurs the live WebGL
   frame every frame. Slightly more opaque backgrounds instead. */
.hud-box {
  background: rgba(24, 11, 50, 0.82);
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 10px 16px;
  box-shadow: 0 0 18px rgba(255, 77, 157, 0.16), inset 0 0 14px rgba(255, 77, 157, 0.05);
}
.hud-label {
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 3px;
  color: var(--pink-soft); text-transform: uppercase;
}
.hud-sub { font-size: 10px; letter-spacing: 2px; color: var(--ink-faint); margin-top: 2px; }
.hud-big {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 800; line-height: 1.1; color: #fff;
  text-shadow: 0 0 14px rgba(255, 77, 157, 0.85), 0 0 34px rgba(255, 77, 157, 0.4);
}
.hud-miles {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700; margin: 3px 0 6px;
}
.progress-track {
  width: 220px; height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 77, 157, 0.25);
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--pink-hot), var(--coral) 55%, var(--gold));
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 126, 95, 0.8);
  transform-origin: left center;
  transform: scaleX(0);
}
.hud-left { min-width: 110px; text-align: center; }
.hud-center { min-width: 250px; text-align: center; }

/* stopwatch (top-right, no box) */
.hud-stopwatch {
  min-width: 190px; text-align: left;
  font-family: var(--font-display);
  font-size: 30px; font-weight: 800; letter-spacing: 1px; color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 14px rgba(255, 77, 157, 0.85), 0 0 34px rgba(255, 77, 157, 0.4);
}

/* speedometer (bottom-right, no box): segmented 270deg ring, --f = fill 0..1 */
#speedo {
  position: fixed; right: 26px; bottom: 22px;
  width: 176px; height: 176px;
  --speedo-col: var(--pink-hot);
  --speedo-glow: rgba(255, 46, 121, 0.8);
}
#speedo.shield { --speedo-col: var(--aqua); --speedo-glow: rgba(46, 230, 200, 0.9); }
.speedo-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 225deg, var(--speedo-col) 0deg calc(var(--f, 0) * 270deg),
    rgba(255, 255, 255, 0.16) calc(var(--f, 0) * 270deg) 270deg, transparent 270deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 13px)),
    repeating-conic-gradient(from 225deg, #000 0deg 7deg, transparent 7deg 9deg);
  -webkit-mask-composite: source-in;
  mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 13px)),
    repeating-conic-gradient(from 225deg, #000 0deg 7deg, transparent 7deg 9deg);
  mask-composite: intersect;
  filter: drop-shadow(0 0 6px var(--speedo-glow));
}
.speedo-read {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 14px var(--speedo-glow);
}
.speedo-val { font-size: 46px; font-weight: 900; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.speedo-unit { font-size: 11px; font-weight: 800; letter-spacing: 4px; color: var(--speedo-col); margin-top: 4px; }
.speedo-shell {
  position: absolute; bottom: -2px; white-space: nowrap;
  font-size: 11px; font-weight: 900; letter-spacing: 2px; color: var(--aqua);
}
@media (max-width: 700px), (max-height: 520px) {
  #speedo { width: 128px; height: 128px; right: 14px; bottom: 14px; }
  .speedo-val { font-size: 34px; }
  .hud-stopwatch { font-size: 22px; min-width: 140px; }
}

/* HARD SHELL: aqua screen-edge glow, flickers as it runs out (DriveFX) */
#shield-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0;
  box-shadow: inset 0 0 90px 18px rgba(46, 230, 200, 0.55);
  transition: opacity 0.2s ease;
}
#shield-vignette.active { opacity: 1; animation: shieldPulse 0.7s ease-in-out infinite alternate; }
#shield-vignette.warn { animation: shieldWarn 0.25s steps(2, jump-none) infinite; }
@keyframes shieldPulse { from { opacity: 0.65; } to { opacity: 1; } }
@keyframes shieldWarn { 0% { opacity: 1; } 100% { opacity: 0.15; } }

/* ---------- Banner ---------- */
#banner {
  position: fixed; top: 26%; left: 0; right: 0;
  text-align: center; z-index: 20; pointer-events: none;
}
#banner-text {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 54px; font-weight: 900; letter-spacing: 8px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 237, 247, 0.6), 0 0 26px rgba(255, 46, 121, 0.9), 0 0 70px rgba(255, 126, 95, 0.55);
  animation: bannerPop 2.2s ease forwards;
}
/* run-ending crash: bigger, hotter, slams in */
#banner.crash #banner-text {
  font-size: 84px; color: #fff0f2;
  text-shadow: 0 0 22px rgba(255, 59, 92, 0.95), 0 0 70px rgba(255, 46, 121, 0.8);
  animation: crashPop 2.4s ease forwards;
}
@keyframes crashPop {
  0%   { transform: scale(2.8) rotate(-8deg); opacity: 0; }
  9%   { transform: scale(0.88) rotate(3deg); opacity: 1; }
  15%  { transform: scale(1.1) rotate(-2deg); }
  22%  { transform: scale(1) rotate(0deg); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.12); }
}
@keyframes bannerPop {
  0%   { transform: scale(0.4); opacity: 0; }
  15%  { transform: scale(1.12); opacity: 1; }
  25%  { transform: scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05) translateY(-14px); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30, 14, 66, 0.88), rgba(13, 6, 34, 0.96));
  padding: 20px;
}
/* faint CRT scanlines over every panel — cheap, no backdrop-filter */
.panel {
  position: relative; z-index: 1;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 4px),
    linear-gradient(160deg, rgba(40, 20, 80, 0.95), rgba(20, 9, 46, 0.97));
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 34px 40px;
  max-width: 520px; width: 100%;
  text-align: center;
  box-shadow: 0 0 60px rgba(255, 77, 157, 0.14), 0 0 0 4px rgba(255, 77, 157, 0.06), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.panel-wide { max-width: 620px; }

.title {
  font-family: var(--font-display);
  font-size: 46px; font-weight: 900; letter-spacing: 5px;
  /* solid fallback first — the title must never render invisible if
     background-clip:text is unsupported; the gradient is layered on top
     inside @supports below. */
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 46, 121, 0.8), 0 0 60px rgba(255, 77, 157, 0.5);
}
.title-crash {
  color: #fff0f2;
  text-shadow: 0 0 22px rgba(255, 59, 92, 0.9), 0 0 70px rgba(255, 46, 121, 0.7);
}
/* Chrome-gradient title. Scoped so it never leaks onto the crash title's
   <span class="badge"> (which keeps its own dark-on-gold styling). */
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .title {
    background: linear-gradient(180deg, #fff 0%, #ffe3f2 30%, #ff8ac2 48%, #ff2e79 66%, #b14dff 88%, #5f2bff 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent; text-shadow: none;
    filter: drop-shadow(0 0 16px rgba(255, 46, 121, 0.55));
  }
  .title-ftc span {
    background: linear-gradient(180deg, #fff 0%, #d8fff7 35%, var(--aqua) 60%, #0f9d8a 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
  }
  .title-ftc { filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 16px rgba(255, 46, 121, 0.55)); }
  /* own gradient (top of .title's): an animated child drops out of its parent's text clip and vanishes */
  .title-ftc small {
    background: linear-gradient(180deg, #fff 0%, #ffe3f2 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
  }
  .title-crash {
    background: linear-gradient(180deg, #fff 0%, #ffd9e0 30%, #ff3b5c 62%, #b31345 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent; text-shadow: none;
    filter: drop-shadow(0 0 18px rgba(255, 59, 92, 0.6));
  }
}
/* menu title: small "THE FAST AND THE" over a big "CRUSTACEOUS" */
.title-ftc { line-height: 1; }
.title-ftc small { display: block; font-size: 17px; letter-spacing: 7px; margin-bottom: 6px; }
.title-ftc span { display: block; font-size: clamp(26px, 8vw, 38px); letter-spacing: 3px; }
.tagline { color: var(--ink-dim); margin: 10px 0 20px; font-size: 15px; }

/* ---------- Rules popup ---------- */
.popup-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 900; letter-spacing: 4px;
  margin-bottom: 16px;
  color: #fff;
  text-shadow: 0 0 16px rgba(255, 77, 157, 0.7);
}
.rules-list {
  text-align: left; margin: 0 auto 18px; width: fit-content;
  font-size: 14px; color: var(--ink-dim); line-height: 1.7;
  padding-left: 20px;
}
.rules-list li { margin-bottom: 8px; }
.rules-list b { color: var(--pink-soft); }

.btn {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 16px; font-weight: 800; letter-spacing: 3px;
  padding: 14px 34px; border-radius: 8px; border: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(3px) scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--coral) 0%, var(--pink) 55%, var(--pink-hot) 100%);
  color: #2a0930;
  box-shadow: 0 4px 0 #8f1d5c, 0 0 24px rgba(255, 77, 157, 0.5);
}
.btn-primary:hover {
  box-shadow: 0 4px 0 #8f1d5c, 0 0 38px rgba(255, 77, 157, 0.8);
  transform: translateY(-2px);
}
.btn-ghost {
  background: rgba(255, 77, 157, 0.04);
  color: #ffc4e3;
  border: 1px solid rgba(255, 138, 194, 0.5);
}
.btn-ghost:hover {
  background: rgba(255, 77, 157, 0.14);
  box-shadow: 0 0 18px rgba(255, 77, 157, 0.35);
}
.btn small { display: block; font-size: 10px; font-weight: 600; letter-spacing: 1px; opacity: .8; margin-top: 2px; }
.btn-row { display: flex; gap: 14px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Crash screen ----------
 * Docked left like the garage: the crash cam keeps the wreck center-frame,
 * so a narrow side column leaves it unobstructed. Narrow screens dock bottom. */
#crash-screen {
  justify-content: flex-start;
  padding: 16px 0 16px 16px;
  background: linear-gradient(to right, rgba(13, 6, 34, 0.94) 0%, rgba(13, 6, 34, 0.78) 24%, rgba(13, 6, 34, 0) 46%);
}
#crash-screen .panel {
  max-width: 360px; max-height: 100%;
  display: flex; flex-direction: column;
  padding: 16px 18px 18px;
  animation: crashDock 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes crashDock { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
#crash-screen .title { font-size: 30px; letter-spacing: 3px; }
#crash-screen .badge { display: block; width: fit-content; margin: 8px auto 0; padding: 4px 12px; font-size: 11px; }
#crash-screen .stats { margin: 12px 0; gap: 6px; }
#crash-screen .stat { padding: 7px 2px; }
#crash-screen .stat-val { font-size: 18px; }
#crash-screen .stat-label { font-size: 9px; letter-spacing: 1px; }
#crash-screen .stat-prawnfessionalism { grid-column: 1 / -1; }
#crash-screen .lb-wrap { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-bottom: 12px; }
#crash-screen .lb-tab { padding: 7px 2px; font-size: 9px; letter-spacing: 1px; }
#crash-screen .lb-list { flex: 1 1 auto; min-height: 90px; max-height: none; }
#crash-screen .btn-row { gap: 8px; margin-top: 0; }
#crash-screen .btn { padding: 10px 8px; font-size: 13px; letter-spacing: 2px; }
#crash-screen .btn-primary { flex: 1 1 100%; padding: 13px 8px; font-size: 15px; }
#crash-screen .btn-ghost { flex: 1 1 0; }
@media (max-width: 700px) {
  #crash-screen {
    align-items: flex-end; justify-content: center;
    padding: 0 8px 8px;
    background: linear-gradient(to top, rgba(13, 6, 34, 0.96) 0%, rgba(13, 6, 34, 0.7) 40%, rgba(13, 6, 34, 0) 70%);
  }
  #crash-screen .panel { max-width: 440px; max-height: 70vh; }
}

.badge {
  display: inline-block; vertical-align: middle;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 800; letter-spacing: 2px;
  color: #2a1600; background: linear-gradient(180deg, var(--gold), var(--orange));
  border-radius: 6px; padding: 6px 14px; margin-left: 14px;
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.6), 0 2px 0 #9c6b12;
  animation: badgePulse 1s ease infinite alternate;
}
@keyframes badgePulse { from { transform: scale(1); } to { transform: scale(1.08); } }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 20px 0;
}
.stat {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 77, 157, 0.22);
  border-radius: 8px; padding: 12px 6px;
}
.stat-val {
  display: block; font-size: 24px; font-weight: 800;
  font-family: var(--font-display);
  color: var(--aqua); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(46, 230, 200, 0.5);
}
.stat-label { font-size: 10px; letter-spacing: 2px; color: var(--ink-faint); text-transform: uppercase; }

/* ---------- Leaderboard ---------- */
.lb-wrap { text-align: left; margin-bottom: 18px; }
.lb-title { font-size: 14px; letter-spacing: 3px; color: var(--pink-soft); margin-bottom: 8px; text-align: center; }
#lb-name {
  width: 100%; padding: 10px 14px; margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 77, 157, 0.45);
  border-radius: 6px; color: #fff;
  font-family: var(--font-display); font-size: 14px; letter-spacing: 3px; text-transform: uppercase;
  text-align: center; outline: none;
}
#lb-name:focus { box-shadow: 0 0 14px rgba(255, 77, 157, 0.4); }
#lb-name::placeholder { color: var(--ink-faint); }

/* leaderboard qualifier tabs */
.lb-tabs {
  display: flex; gap: 6px; justify-content: center;
  margin-bottom: 10px;
}
.lb-tab {
  flex: 1;
  cursor: pointer;
  font-family: var(--font-display); font-size: 10.5px; font-weight: 800; letter-spacing: 2px;
  padding: 8px 6px; border-radius: 6px;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all .12s ease;
}
.lb-scope { margin-bottom: 6px; }
.ts-box { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9999; }
.lb-tab:hover { color: #ffc4e3; background: rgba(255, 77, 157, 0.12); }
.lb-tab.active {
  color: #2a0930;
  background: linear-gradient(90deg, var(--pink-hot), var(--coral));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(255, 77, 157, 0.5);
}
.lb-list { list-style: none; max-height: 170px; overflow-y: auto; }
.lb-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; margin-bottom: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
}
.lb-list li .lb-rank { width: 24px; color: var(--pink-soft); font-weight: 800; font-size: 13px; }
.lb-list li .lb-name { flex: 1; font-weight: 700; letter-spacing: 1px; }
.lb-list li .lb-score { font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.lb-list li.lb-new {
  background: linear-gradient(90deg, rgba(255, 209, 102, 0.22), rgba(255, 209, 102, 0.06));
  border: 1px solid rgba(255, 209, 102, 0.5);
}
.lb-list li.lb-new .lb-name { color: var(--gold); }
.lb-empty { color: var(--ink-faint); font-size: 13px; text-align: center; padding: 8px; }

/* ---------- Oncoming warning ---------- */
#warn-oncoming {
  position: fixed; top: 118px; left: 50%;
  transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 900; letter-spacing: 6px;
  color: var(--danger);
  text-shadow: 0 0 18px rgba(255, 59, 92, 0.95), 0 0 44px rgba(255, 59, 92, 0.5);
  opacity: 0;
}
#warn-oncoming.active { animation: warnBlink 0.5s steps(2, jump-none) infinite; }
#warn-median {
  position: fixed; top: 150px; left: 50%;
  transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  font-family: var(--font-display);
  font-size: 20px; font-weight: 900; letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.95), 0 0 44px rgba(255, 179, 71, 0.5);
  opacity: 0;
}
#warn-median.active { animation: warnBlink 0.4s steps(2, jump-none) infinite; }
@keyframes warnBlink { from { opacity: 1; } to { opacity: 0.15; } }

/* ---------- Best run on start screen ---------- */
.best-run {
  margin: -10px 0 18px;
  font-size: 13px; font-weight: 700; letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.55);
}

/* ---------- HUD mirrors (F to toggle) ----------
 * Framed live windows: a wide rear mirror (bottom-center) and two tall
 * vertical side mirrors (left / right edges). The view is drawn into the
 * main canvas under the frame (js/mirrors.js), so the center stays clear;
 * keep border 2px + padding 5px in sync with Mirrors.layout's inset. */
.mirror {
  position: fixed; z-index: 12; pointer-events: none;
  padding: 5px;
  overflow: hidden;
  border: 2px solid rgba(255, 77, 157, 0.55);
  border-radius: 8px;
  box-shadow: 0 0 22px rgba(255, 77, 157, 0.28), 0 8px 22px rgba(0, 0, 0, 0.6);
}
/* bezel: rounds the view's corners and fills the padding ring */
.mirror::after {
  content: ""; position: absolute; inset: 5px;
  border-radius: 5px;
  box-shadow: 0 0 0 8px #241245, inset 0 0 8px rgba(0, 0, 0, 0.7);
}
.mirror-rear {
  bottom: 16px; left: 50%; transform: translateX(-50%);
  width: 314px; height: 179px;
}
.mirror-left  { top: 50%; left: 14px;  transform: translateY(-50%); width: 154px; height: 214px; }
.mirror-right { top: 50%; right: 14px; transform: translateY(-50%); width: 154px; height: 214px; }

/* ---------- Phone (bottom-left; docked bar = Prawnfessionalism status, slides up on a text) ---------- */
#phone-screen {
  position: fixed; bottom: 0; left: 18px; z-index: 25;
  width: 340px;
  background: linear-gradient(180deg, #221244 0%, #14092e 100%);
  border: 2px solid #43307e;
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 34px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 5px #0c0620, 0 0 22px 5px rgba(255, 77, 157, 0.12);
  display: flex; flex-direction: column;
  pointer-events: auto;
  /* docked: only the 46px status bar shows */
  transform-origin: 30% 100%;
  transform: translateY(calc(100% - 46px)) rotate(0deg);
  transition: transform 0.5s cubic-bezier(0.34, 1.6, 0.5, 1);
}
/* open: springs up with a wobble and rests slightly tilted */
#phone-screen.open,
#phone-screen.sent { transform: translateY(0) rotate(-1.5deg); }
#phone-screen.open { animation: phoneUp 0.8s cubic-bezier(0.3, 0.9, 0.4, 1) both; }
@keyframes phoneUp {
  0%   { transform: translateY(calc(100% - 46px)) rotate(5deg) scale(0.95); }
  42%  { transform: translateY(-24px) rotate(-5deg) scale(1.03); }
  62%  { transform: translateY(8px) rotate(3deg) scale(0.99); }
  80%  { transform: translateY(-4px) rotate(-2.5deg); }
  100% { transform: translateY(0) rotate(-1.5deg); }
}
/* closing (timeout / done): little lift, drop past the dock, settle */
#phone-screen.closing { animation: phoneDown 0.62s cubic-bezier(0.45, 0, 0.3, 1) both; }
@keyframes phoneDown {
  0%   { transform: translateY(0) rotate(-1.5deg); }
  18%  { transform: translateY(-10px) rotate(-3deg); }
  70%  { transform: translateY(calc(100% - 38px)) rotate(1.2deg); }
  86%  { transform: translateY(calc(100% - 50px)) rotate(-0.4deg); }
  100% { transform: translateY(calc(100% - 46px)) rotate(0deg); }
}
/* a text is waiting: the docked bar glows */
#phone-screen.ringing { box-shadow: 0 -6px 34px rgba(0, 0, 0, 0.65), 0 0 0 5px #0c0620, 0 0 30px 8px rgba(255, 77, 157, 0.4); }

/* --- status bar: time · prawnfessionalism · signal --- */
.phone-statusbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  height: 46px; box-sizing: border-box; flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer; user-select: none;
}
.sb-time {
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.sb-status {
  flex: 1; text-align: center;
  font-family: var(--font-display);
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--pink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 10px rgba(255, 77, 157, 0.55);
}
.sb-status.bump { animation: statusBump 0.6s ease; }
@keyframes statusBump {
  0% { transform: scale(1); } 30% { transform: scale(1.18); color: #fff; } 100% { transform: scale(1); }
}
.sb-right { display: flex; align-items: center; gap: 7px; }
.sb-signal { font-size: 10px; color: var(--ink-faint); letter-spacing: -0.5px; }
.sb-battery { font-size: 11px; color: var(--ink-faint); font-weight: 700; }
.sb-badge {
  display: none;
  min-width: 18px; height: 18px;
  background: var(--danger);
  border-radius: 9px;
  font-size: 11px; font-weight: 800; color: #fff;
  align-items: center; justify-content: center;
  padding: 0 5px;
  box-shadow: 0 0 8px rgba(255, 59, 92, 0.6);
}
.sb-badge.visible { display: flex; }
#phone-screen.open .sb-badge,
#phone-screen.sent .sb-badge { display: none; }

/* --- chat --- */
.phone-chat { padding: 14px 16px 12px; }
.phone-contact {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.phone-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45), var(--contact, var(--pink-hot)) 70%);
  box-shadow: 0 0 12px var(--contact, rgba(255, 77, 157, 0.5));
}
/* the cargo texting you: the chat goes dim and wrong */
#phone-screen.contact-cargo .phone-bubble-in { background: #2a1a10; color: #ffd9a8; font-family: Consolas, "Courier New", monospace; }
#phone-screen.contact-cargo .phone-name { letter-spacing: 4px; }
.phone-who { display: flex; flex-direction: column; }
.phone-name { font-size: 15px; font-weight: 800; letter-spacing: 1px; color: #fff; }
.phone-sub { font-size: 11px; color: var(--ink-faint); margin-top: 1px; }

.phone-msgs {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 44px;
}
.phone-bubble {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px; line-height: 1.4;
  max-width: 86%;
  word-wrap: break-word;
  color: var(--ink);
}
.phone-bubble-in {
  align-self: flex-start;
  background: #322062;
  border-bottom-left-radius: 5px;
}
.phone-bubble-out {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--coral), var(--pink-hot));
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 10px rgba(255, 77, 157, 0.35);
}

.phone-replies {
  margin-top: 12px;
  display: flex; flex-direction: column; gap: 7px;
}
.phone-reply-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #ecd9f5;
  font-family: inherit; font-size: 14px; font-weight: 600;
  text-align: left; line-height: 1.35;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.phone-reply-btn .key {
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 900; color: #2a1600;
  background: linear-gradient(180deg, var(--gold), var(--orange));
  box-shadow: 0 1px 0 #9c6b12;
}
.phone-reply-btn:hover {
  background: rgba(255, 77, 157, 0.14);
  border-color: rgba(255, 77, 157, 0.55);
  color: #fff;
}

/* --- entrance animation --- */
.animate-in { animation: msgIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
@keyframes msgIn {
  0%   { opacity: 0; transform: translateY(12px) scale(0.8) rotate(-5deg); }
  55%  { opacity: 1; transform: translateY(-3px) scale(1.07) rotate(2deg); }
  80%  { transform: translateY(1px) scale(0.98) rotate(-0.8deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}
/* reply buttons pop in one after another */
#phone-screen.open .phone-reply-btn { animation: msgIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
#phone-screen.open .phone-reply-btn:nth-child(1) { animation-delay: 0.28s; }
#phone-screen.open .phone-reply-btn:nth-child(2) { animation-delay: 0.36s; }
#phone-screen.open .phone-reply-btn:nth-child(3) { animation-delay: 0.44s; }

/* --- typing indicator --- */
.phone-typing {
  align-self: flex-start;
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  background: #322062;
}
.phone-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255, 138, 194, 0.7);
  opacity: 0.3;
}
.phone-typing.active span { animation: typingBounce 1.2s ease-in-out infinite; }
.phone-typing.active span:nth-child(2) { animation-delay: 0.15s; }
.phone-typing.active span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}

/* --- REPLY!! alert (flashes while a text waits) and reply result --- */
#reply-alert, #reply-result {
  position: fixed; top: 13%; left: 0; right: 0; z-index: 22;
  text-align: center; pointer-events: none;
  font-family: var(--font-display);
  font-size: 64px; font-weight: 900; letter-spacing: 8px;
}
#reply-alert {
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 77, 157, 0.95), 0 0 50px rgba(255, 46, 121, 0.6);
  animation: replyFlash 0.5s steps(2, jump-none) infinite, replyPulse 0.5s ease-in-out infinite alternate;
}
@keyframes replyFlash { 0% { opacity: 1; } 100% { opacity: 0.25; } }
@keyframes replyPulse { from { transform: scale(0.94); } to { transform: scale(1.06); } }
#reply-result { animation: resultPop 1.4s ease forwards; }
#reply-result.good { color: var(--aqua); text-shadow: 0 0 18px rgba(46, 230, 200, 0.9), 0 0 50px rgba(46, 230, 200, 0.5); }
#reply-result.bad  { color: var(--danger); text-shadow: 0 0 18px rgba(255, 59, 92, 0.9), 0 0 50px rgba(255, 59, 92, 0.6); }
@keyframes resultPop {
  0%   { transform: scale(0.4); opacity: 0; }
  15%  { transform: scale(1.15); opacity: 1; }
  25%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}

/* --- Debug readout (backquote, js/perf.js) --- */
#perf-hud {
  position: fixed; right: 8px; bottom: 6px;
  z-index: 60; pointer-events: none;
  padding: 4px 10px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.75); color: var(--aqua);
  font: 11px/1.4 Consolas, "Courier New", monospace; white-space: pre;
}

/* --- Prawnfessionalism stat on crash screen --- */
.stat-prawnfessionalism .stat-val {
  font-size: 0.85em;
  letter-spacing: 1px;
  color: var(--orange);
  text-shadow: 0 0 12px rgba(255, 179, 71, 0.5);
}

/* ---------- Main menu ----------
 * Docked left over the live game (the menu world is the run's world: START
 * just hides it). Title floats above the panel; ::before = left scrim. */
#start-screen {
  justify-content: flex-start;
  background: none;
  padding-left: clamp(20px, 4vw, 64px);
}
#start-screen::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(to right, rgba(13, 6, 34, 0.82) 0%, rgba(13, 6, 34, 0.5) 30%, rgba(13, 6, 34, 0) 56%);
  transition: opacity 0.5s ease;
}
.menu-col {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 18px;
}
.menu-col .title-ftc { text-align: center; transition: opacity 0.3s ease; }
.menu-col .title-ftc span { font-size: clamp(28px, 4.4vw, 46px); }
.menu-panel { padding: 26px 34px 20px; transition: opacity 0.45s ease 0.1s, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s; }
.menu-panel .tagline { margin-top: 0; }
/* intro: everything hidden until intro.js drops the title (titled), then the menu slides in */
#start-screen.intro, #start-screen.intro *,
#start-screen.intro-lock, #start-screen.intro-lock * { pointer-events: none !important; }
#start-screen.intro::before { opacity: 0; }
#start-screen.intro .menu-panel { opacity: 0; transform: translateX(-36px); }
#start-screen.intro:not(.titled) .title-ftc { opacity: 0; }
.menu-buttons {
  display: flex; flex-direction: column; gap: 10px;
  margin: 6px auto 18px; max-width: 300px;
}
.menu-buttons .btn { width: 100%; }
.menu-buttons .btn small { color: var(--pink-soft); }

/* ---------- Boot intro (js/ui/intro.js): letterbox bars over the live game; black until the first shot ---------- */
#intro { position: fixed; inset: 0; z-index: 45; pointer-events: none; }
#intro.black { background: #000; }
.intro-bar {
  position: absolute; left: 0; right: 0; height: 12vh; background: #000;
  transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}
.intro-bar-top { top: 0; }
.intro-bar-bot { bottom: 0; }
#intro.out .intro-bar-top { transform: translateY(-100%); }
#intro.out .intro-bar-bot { transform: translateY(100%); }
.intro-load {
  position: absolute; left: 0; right: 0; top: 50%; text-align: center;
  font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 6px; color: var(--ink-faint);
}
#intro:not(.black) .intro-load { display: none; }
/* the phone dock is HUD: hidden through the intro and under the menu */
body.intro #phone-screen,
body:has(#start-screen:not(.hidden)) #phone-screen { visibility: hidden; }

/* ---------- Garage (docked left so the live car shows on the right) ---------- */
.overlay-side {
  justify-content: flex-start;
  background: linear-gradient(to right, rgba(13, 6, 34, 0.96) 0%, rgba(13, 6, 34, 0.86) 28%, rgba(13, 6, 34, 0) 52%);
}
.side-panel {
  max-width: 400px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  padding: 24px 24px 20px;
}
.garage-best { font-size: 12px; letter-spacing: 3px; color: var(--ink-faint); margin: -8px 0 12px; }
.garage-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  overflow-y: auto; min-height: 0;
}
.garage-card {
  cursor: pointer;
  padding: 10px 10px 9px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ecd9f5; font-family: inherit; text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.garage-card:hover { background: rgba(255, 77, 157, 0.1); border-color: rgba(255, 77, 157, 0.5); }
.garage-card .gc-name { display: block; font-family: var(--font-display); font-size: 12px; font-weight: 800; letter-spacing: 1.5px; }
.garage-card .gc-tag { display: block; font-size: 10.5px; color: var(--ink-faint); margin-top: 3px; letter-spacing: 1px; }
.garage-card.selected { border-color: var(--pink); background: rgba(255, 77, 157, 0.14); box-shadow: 0 0 14px rgba(255, 77, 157, 0.3); }
.garage-card.selected .gc-tag { color: var(--pink-soft); }
.garage-card.locked { opacity: 0.5; }
.garage-card.legend .gc-name { color: var(--pink-soft); }
.garage-detail { text-align: left; margin: 14px 0 16px; min-height: 150px; }
.gd-name { font-family: var(--font-display); font-size: 17px; font-weight: 900; letter-spacing: 2px; }
.gd-blurb { font-size: 12.5px; color: var(--ink-dim); margin: 3px 0 10px; }
.gd-row { display: flex; align-items: center; gap: 10px; font-size: 10.5px; letter-spacing: 2px; color: var(--ink-faint); margin: 5px 0; }
.gd-row span:first-child { width: 78px; }
.gd-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.gd-bar i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--pink), var(--coral) 60%, var(--gold));
  box-shadow: 0 0 8px rgba(255, 126, 95, 0.7);
}
.gd-lock { font-size: 12px; color: var(--pink-soft); margin-top: 8px; letter-spacing: 1px; }

/* ---------- Settings ---------- */
.toggle-row {
  display: flex; align-items: center; gap: 16px;
  text-align: left; cursor: pointer;
  padding: 14px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.toggle-row:last-of-type { margin-bottom: 20px; }
.settings-scroll .toggle-row:last-of-type { margin-bottom: 0; }
.toggle-text { flex: 1; font-size: 16px; font-weight: 800; letter-spacing: 1px; }
.toggle-text small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-dim); letter-spacing: 0; margin-top: 3px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle {
  position: relative; flex-shrink: 0;
  width: 46px; height: 26px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.15s ease;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform 0.15s ease;
}
.toggle-row input:checked + .toggle { background: linear-gradient(90deg, var(--pink-hot), var(--coral)); box-shadow: 0 0 12px rgba(255, 77, 157, 0.5); }
.toggle-row input:checked + .toggle::after { transform: translateX(20px); }
.toggle-row input:focus-visible + .toggle { outline: 2px solid var(--pink); outline-offset: 2px; }

.settings-panel { max-width: 440px; }
.settings-scroll { overflow-y: auto; min-height: 0; padding-right: 6px; margin-bottom: 14px; }
.settings-scroll .toggle-row { padding: 10px 4px; }
.settings-scroll .toggle-text { font-size: 14px; }
.settings-scroll .toggle-text small { font-size: 11.5px; }
.set-group {
  font-family: var(--font-display); font-size: 11px; font-weight: 800; letter-spacing: 4px;
  color: var(--pink-soft); text-align: left; margin: 18px 4px 2px;
}
.set-group:first-child { margin-top: 0; }
.set-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  text-align: left; padding: 10px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.set-row input[type="range"] { grid-column: 1 / -1; }
.set-val { font-size: 13px; font-weight: 800; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.set-row.changed .set-val { color: var(--gold); }
.set-row input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer;
}
.set-row input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); }
.set-row input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); }
.set-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-hot), var(--coral)); box-shadow: 0 0 10px rgba(255, 77, 157, 0.6);
}
.set-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-hot), var(--coral)); box-shadow: 0 0 10px rgba(255, 77, 157, 0.6);
}
.set-row input[type="range"]:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 6px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 11px; font-weight: 800; letter-spacing: 1px; color: var(--ink-dim);
  background: transparent; border: 0; padding: 6px 9px; cursor: pointer;
}
.seg button + button { border-left: 1px solid rgba(255, 255, 255, 0.12); }
.seg button.on { color: #fff; background: linear-gradient(90deg, var(--pink-hot), var(--coral)); }
.seg button:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
.settings-actions { display: flex; gap: 10px; }
.settings-actions .btn { flex: 1; }

/* ---------- Banner sub-line (car unlocks) ---------- */
#banner-sub {
  display: block; margin-top: 6px;
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800; letter-spacing: 4px; color: var(--pink-soft);
  text-shadow: 0 0 14px rgba(255, 77, 157, 0.8);
  animation: bannerPop 2.2s ease forwards;
}
#banner-sub:empty { display: none; }
