/* ==========================================================================
   DAR Trainer — menu system
   Game front-end look: heavy italic condensed caps, deep navy panels with
   blue edges, skewed white plates for whatever is selected, and a skewed
   blue PLAY bar.
   ========================================================================== */

:root {
  --bg-deep: #040a14;
  --navy-1: #0a1729;
  --navy-2: #0f223c;
  --navy-3: #16325a;
  --panel: rgba(9, 21, 39, 0.9);
  --panel-soft: rgba(9, 21, 39, 0.72);
  --line: rgba(96, 160, 255, 0.22);
  --line-strong: rgba(120, 185, 255, 0.5);
  --text: #f2f6ff;
  --muted: #92a8c7;
  --dim: #5f7393;
  --blue: #2a8cff;
  --blue-2: #46b6ff;
  --cyan: #59d6ff;
  --plate: #f4f7fb;
  --ink: #0a1a30;
  --amber: #ffcc33;
  --green: #3ee07f;
  --red: #ff4f4f;

  --font-display: 'Saira Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Saira Semi Condensed', 'Saira Condensed', system-ui, sans-serif;
  --skew: 12px;          /* slant of parallelogram plates */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --gutter: clamp(16px, 3vw, 44px);

  /* consumed by the input-analysis chart */
  --m2-hue1: 208;
  --m2-hue2: 60;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  overscroll-behavior: none;
  overflow: hidden;
}
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input[type=text] { -webkit-user-select: text; user-select: text; }
#gl { position: fixed; inset: 0; z-index: 0; display: block; }
#hud { position: fixed; inset: 0; z-index: 1; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* Shared display type: heavy, slanted, all caps */
.display, .home-item-label, .screen-title, .tile-name, .plate-title, .results-title,
.modal-title, .set-group h3, .picker-title, .brand-name, .play-btn, .board-section-head,
.speed-plate-value, .stat-value, .tab, .back-btn, .btn, .picker-option-label, .pause-level {
  font-family: var(--font-display);
  font-style: italic;
  text-transform: uppercase;
}
/* Small caps labels */
.tile-tag, .plate-tag, .picker-kicker, .results-kicker, .stat-label,
.rail-bumper, .key, .best-table caption {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

body[data-screen="campaign"] #hud,
body[data-screen="arcade"] #hud,
body[data-screen="results"] #hud,
body[data-screen="boot"] #hud { visibility: hidden; }

/* ---------- focus ---------- */
:focus { outline: none; }
:focus-visible, body.using-nav :focus { outline: 2px solid var(--plate); outline-offset: 2px; }

/* ---------- persistent chrome ---------- */
.brand {
  position: fixed;
  z-index: 30;
  top: calc(18px + var(--safe-top));
  left: calc(var(--gutter) + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.brand-logo {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--plate), 0 0 0 4px rgba(70, 182, 255, 0.55), 0 6px 18px rgba(0, 0, 0, 0.45);
}
.brand-text { display: grid; gap: 0; line-height: 0.86; text-shadow: 0 2px 12px rgba(4, 10, 20, 0.55); }
.brand-name { font-weight: 900; font-size: 27px; letter-spacing: 0.02em; color: var(--text); }
.brand-sub {
  font: italic 800 15px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
  padding-left: 1px;
}
.brand-accent { color: var(--blue-2); }
.corner-btn {
  position: fixed;
  z-index: 30;
  top: calc(18px + var(--safe-top));
  right: calc(var(--gutter) + var(--safe-right));
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  color: var(--text);
  cursor: pointer;
}
.corner-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.corner-btn:hover { background: var(--navy-3); }
body[data-screen="playing"] .brand,
body[data-screen="playing"] .corner-btn,
body[data-screen="boot"] .brand { display: none; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen > * { pointer-events: auto; }
.screen.is-leaving { animation: screen-out 240ms var(--ease-out) forwards; pointer-events: none; }
.screen.is-leaving > * { pointer-events: none; }
@keyframes screen-out { to { opacity: 0; transform: translateX(-28px); } }

/* ==========================================================================
   HOME
   ========================================================================== */
#screen-home {
  background: linear-gradient(90deg, rgba(4, 10, 20, 0.6) 0%, rgba(4, 10, 20, 0.12) 38%, rgba(4, 10, 20, 0) 60%);
}
.home-menu {
  position: absolute;
  left: calc(var(--gutter) + var(--safe-left));
  bottom: calc(15vh + var(--safe-bottom));
  width: min(400px, calc(100vw - 2 * var(--gutter)));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0 14px;
}
/* dark slanted band behind the entries */
.home-menu::before {
  content: '';
  position: absolute;
  inset: 0 -60px 0 -24px;
  background: linear-gradient(90deg, rgba(6, 16, 31, 0.92) 0%, rgba(6, 16, 31, 0.78) 60%, rgba(6, 16, 31, 0) 100%);
  clip-path: polygon(24px 0, 100% 0, calc(100% - 24px) 100%, 0 100%);
  border-top: 1px solid var(--line);
  z-index: -1;
}
.home-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 26px 8px 20px;
  margin-right: 34px;
  text-align: left;
  clip-path: polygon(var(--skew) 0, 100% 0, calc(100% - var(--skew)) 100%, 0 100%);
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 200ms var(--ease-out);
}
.home-item-label { font-weight: 800; font-size: clamp(26px, 2.6vw, 34px); line-height: 1; letter-spacing: 0.02em; }
.home-item::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: var(--skew);
  width: 6px;
  background: var(--blue-2);
  transform: skewX(-12deg) scaleY(0);
  transition: transform 180ms var(--ease-out);
}
.home-item:hover, .home-item:focus, .home-item.is-current {
  background: var(--plate);
  color: var(--ink);
  transform: translateX(10px);
  outline: none;
}
.home-item:hover::after, .home-item:focus::after, .home-item.is-current::after { transform: skewX(-12deg) scaleY(1); }

#screen-home.is-entering .home-item { animation: slide-in-left 420ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms + 60ms); }
#screen-home.is-entering .home-menu::before { animation: band-in 380ms var(--ease-out) both; }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-48px); } }
@keyframes band-in { from { opacity: 0; transform: scaleX(0.6); transform-origin: left; } }

/* ==========================================================================
   PANEL SCREENS (campaign / arcade)
   ========================================================================== */
.panel-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: calc(92px + var(--safe-top)) var(--gutter) calc(var(--gutter) + 40px + var(--safe-bottom)) calc(var(--gutter) + var(--safe-left));
  background:
    linear-gradient(180deg, rgba(4, 10, 20, 0.55) 0%, rgba(6, 16, 31, 0.82) 30%, rgba(6, 16, 31, 0.9) 100%);
  overflow: hidden;
}
.screen-head { display: flex; align-items: center; gap: 18px; flex: none; }
.screen-title { margin: 0; font-weight: 900; font-size: clamp(34px, 3.8vw, 48px); line-height: 1; letter-spacing: 0.01em; }
.screen-sub { margin: 0; color: var(--muted); font-size: 16px; font-weight: 500; }
.back-btn {
  appearance: none;
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 6px 18px 7px 14px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.back-btn span { margin-right: 4px; }
.back-btn:hover, .back-btn:focus { background: var(--plate); color: var(--ink); border-color: var(--plate); }

.panel-screen.is-entering .screen-head { animation: slide-in-left 380ms var(--ease-out) both; }
.panel-screen.is-entering .speed-rail { animation: fade-up 380ms var(--ease-out) 60ms both; }
.panel-screen.is-entering .tile,
.level-board.is-swapping .tile { animation: fade-up 340ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 22ms + 90ms); }
.level-board.is-swapping .tile { animation-delay: calc(var(--i, 0) * 14ms); }
.panel-screen.is-entering .plate { animation: slide-in-right 420ms var(--ease-out) 120ms both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(40px); } }

/* ---------- speed rail ---------- */
.speed-rail { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
.speed-plates {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 2px;
  min-width: 0;
}
.speed-plates::-webkit-scrollbar { display: none; }
.rail-bumper {
  appearance: none;
  flex: none;
  width: 42px;
  height: 30px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px 8px 3px 3px;
}
.rail-bumper:hover { background: var(--navy-3); }
.speed-plate {
  appearance: none;
  flex: 0 0 104px;
  width: 104px;
  padding: 7px 14px 8px;
  border: 0;
  background: var(--navy-2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 5px;
  clip-path: polygon(var(--skew) 0, 100% 0, calc(100% - var(--skew)) 100%, 0 100%);
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.speed-plate-value { font-weight: 800; font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 5px; }
.speed-plate-meter { transform: translateX(calc(var(--skew) * -0.32)); /* centre within the slanted shape at the bar's height */ height: 3px; background: rgba(150, 190, 255, 0.18); position: relative; overflow: hidden; }
.speed-plate-meter > span { position: absolute; inset: 0 auto 0 0; background: var(--blue-2); }
.speed-plate.is-complete .speed-plate-meter > span { background: var(--green); }
.speed-plate.is-locked { color: var(--dim); background: rgba(15, 34, 60, 0.6); }
.speed-plate.is-locked svg { color: var(--amber); }
.speed-plate:hover:not(.is-selected) { background: var(--navy-3); }
.speed-plate.is-selected { background: var(--plate); color: var(--ink); }
.speed-plate.is-selected .speed-plate-meter { background: rgba(10, 26, 48, 0.18); }
.speed-plate.is-selected .speed-plate-meter > span { background: var(--blue); }
/* A finished game speed is green whether or not it is selected, focused or hovered (a touch deeper on the light selected plate). */
.speed-plate.is-complete .speed-plate-meter > span,
.speed-plate.is-complete:hover .speed-plate-meter > span,
.speed-plate.is-complete:focus .speed-plate-meter > span { background: var(--green); }
.speed-plate.is-complete.is-selected .speed-plate-meter > span { background: #1fbf62; }

/* ---------- campaign: Tutorials / Missions tabs ---------- */
.camp-tabs { display: flex; gap: 6px; flex: none; margin-top: -4px; }
.camp-tab {
  appearance: none;
  position: relative;
  min-width: 200px;
  padding: 8px 22px 9px 20px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: var(--navy-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 2px;
  clip-path: polygon(var(--skew) 0, 100% 0, calc(100% - var(--skew)) 100%, 0 100%);
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.camp-tab-label { font: 800 21px/1 var(--font-display); font-style: italic; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 7px; }
.camp-tab-label svg { color: var(--green); }
.camp-tab-meta { font: 600 12px/1.2 var(--font-body); color: var(--muted); }
.camp-tab:hover:not(.is-selected) { background: var(--navy-3); }
.camp-tab.is-selected { background: var(--plate); color: var(--ink); border-bottom-color: var(--blue); }
.camp-tab.is-selected .camp-tab-meta { color: #3d5476; }
.camp-tab.is-selected .camp-tab-label svg { color: #12a457; }
.camp-tab-badge {
  margin-left: 4px;
  padding: 3px 7px 3px;
  font-style: normal;
  font: 800 10.5px/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--amber);
  animation: next-pulse 1.6s ease-in-out infinite;
}
.camp-tab.has-next { box-shadow: inset 0 0 0 1px rgba(255, 204, 51, 0.55); }
/* Pad / keyboard focus. The plates are clipped (skewed), so outlines can't
   show; the focused plate lifts, brightens and gets a cyan rail instead. */
.speed-plate:focus-visible, body.using-nav .speed-plate:focus,
.camp-tab:focus-visible, body.using-nav .camp-tab:focus {
  outline: none;
  background: #2a74b0;
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--cyan), inset 0 -5px 0 var(--cyan);
  transform: translateY(-3px);
}
.speed-plate.is-selected:focus-visible, body.using-nav .speed-plate.is-selected:focus,
.camp-tab.is-selected:focus-visible, body.using-nav .camp-tab.is-selected:focus {
  background: #e3f7ff;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--cyan), inset 0 -6px 0 var(--cyan);
}
.speed-plate, .camp-tab { transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out); }
@keyframes next-pulse { 50% { opacity: 0.55; } }

/* guide banner at the top of the board */
.camp-guide {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  padding: 12px 14px 12px 16px;
  border: 1px solid rgba(255, 204, 51, 0.55);
  border-left: 4px solid var(--amber);
  background: linear-gradient(90deg, rgba(255, 204, 51, 0.14), rgba(255, 204, 51, 0.03));
}
.camp-guide.is-next { border-color: rgba(89, 214, 255, 0.5); border-left-color: var(--cyan); background: linear-gradient(90deg, rgba(89, 214, 255, 0.14), rgba(89, 214, 255, 0.03)); }
.camp-guide-icon { flex: none; display: grid; color: var(--amber); }
.camp-guide.is-next .camp-guide-icon { color: var(--cyan); }
.camp-guide-text { flex: 1; min-width: 0; }
.camp-guide-title { margin: 0 0 2px; font: 800 18px/1.1 var(--font-display); font-style: italic; text-transform: uppercase; letter-spacing: 0.03em; }
.camp-guide-body { margin: 0; font-size: 14px; line-height: 1.35; color: var(--muted); }
.camp-guide-btn { flex: none; font-size: 15px; }
.camp-note { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.section-lock { display: grid; color: var(--amber); }
.board-section.is-locked .board-section-head .section-lock svg { color: var(--amber); }
.section-lock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: -2px 0 9px; font-size: 13.5px; color: var(--amber); }
.link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 0;
  color: var(--cyan);
  font: 700 13.5px/1.2 var(--font-body);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: #fff; }
body.using-nav .link-btn:focus { outline: 2px solid var(--plate); outline-offset: 2px; color: #fff; }
.play-btn.is-guide { background: linear-gradient(90deg, #c58f00 0%, #f0b400 55%, #ffcc33 100%); color: var(--ink); font-size: 18px; letter-spacing: 0.08em; }
@media (max-width: 760px) {
  .camp-tab { min-width: 0; flex: 1; padding: 7px 14px 8px; }
  .camp-guide { flex-wrap: wrap; }
}

/* ---------- body: board + plate ---------- */
.screen-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: clamp(16px, 2vw, 30px);
}
.level-board {
  overflow-y: auto;
  min-height: 0;
  padding: 4px 10px 24px 4px;
  margin: -4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 185, 255, 0.35) transparent;
}
.board-section + .board-section { margin-top: 20px; }
.board-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.03em;
  color: var(--text);
}
.board-section-head .count { font: 600 13px/1 var(--font-body); font-style: normal; text-transform: none; letter-spacing: 0; color: var(--muted); }
.board-section-head svg { color: var(--green); }
.board-section.is-locked .board-section-head { color: var(--dim); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.tile {
  appearance: none;
  position: relative;
  min-height: 78px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #13294a 0%, #0c1c34 100%);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.tile-text { display: grid; gap: 3px; min-width: 0; }
.tile-number { font: 700 12px/1 var(--font-display); letter-spacing: 0.1em; color: var(--blue-2); }
.tile-name { font-weight: 700; font-size: 19px; line-height: 1.05; letter-spacing: 0.02em; text-transform: none; }
.tile-tag { font-size: 10.5px; color: var(--dim); }
.tag-green { color: var(--green); }
.tag-cyan { color: var(--cyan); }
.tag-red { color: var(--red); }
.tag-amber { color: var(--amber); }
.tile-icon { flex: none; color: #a8d3ff; opacity: 0.9; display: grid; }
.tile-lock { position: absolute; top: 10px; left: 12px; color: var(--amber); display: grid; }
.tile.is-locked { background: rgba(12, 26, 46, 0.7); }
.tile.is-locked .tile-name, .tile.is-locked .tile-icon { color: var(--dim); }
.tile.is-locked .tile-number { color: var(--dim); padding-left: 16px; }
.tile-lock + .tile-text .tile-number { padding-left: 16px; }
.tile:hover { border-color: var(--line-strong); background: linear-gradient(160deg, #183563 0%, #0f2342 100%); }
.tile.is-selected { border-color: var(--plate); box-shadow: inset 0 0 0 1px var(--plate), 0 0 18px rgba(89, 214, 255, 0.18); }

/* Cleared levels: the card turns to polished gold, with a slow shine sweep. */
.tile.is-complete {
  overflow: hidden;
  border-color: #ffe08a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0) 42%),
    linear-gradient(160deg, #ffe38c 0%, #f6bd2b 34%, #d99410 68%, #f3c447 100%);
  color: #2a1a00;
  box-shadow: inset 0 0 0 1px rgba(255, 246, 210, 0.55), inset 0 -3px 0 rgba(122, 72, 0, 0.35), 0 0 16px rgba(255, 196, 40, 0.22);
}
.tile.is-complete::after {
  content: '';
  position: absolute;
  top: -20%; bottom: -20%;
  left: -60%;
  width: 40%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-20deg);
  pointer-events: none;
  animation: gold-shine 5.5s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 180ms + 600ms);
}
@keyframes gold-shine {
  0% { left: -60%; }
  22%, 100% { left: 130%; }
}
.tile.is-complete .tile-number { color: #7a4b00; }
.tile.is-complete .tile-name { color: #241600; text-shadow: 0 1px 0 rgba(255, 244, 205, 0.6); }
.tile.is-complete .tile-tag.tag-green { color: #5c3800; display: inline-flex; align-items: center; gap: 4px; }
.tile.is-complete .tile-icon { color: #5c3800; opacity: 0.8; filter: drop-shadow(0 1px 0 rgba(255, 244, 205, 0.6)); }
.tile.is-complete:hover {
  border-color: #fff3c4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0) 45%),
    linear-gradient(160deg, #fff0b0 0%, #ffcc3d 34%, #e8a516 68%, #ffd45e 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 246, 210, 0.7), inset 0 -3px 0 rgba(122, 72, 0, 0.35), 0 0 22px rgba(255, 204, 51, 0.38);
}
.tile.is-complete.is-selected {
  border-color: var(--plate);
  box-shadow: inset 0 0 0 2px var(--plate), inset 0 -3px 0 rgba(122, 72, 0, 0.35), 0 0 24px rgba(255, 204, 51, 0.5);
}
/* Rings 3D Test: a night-city shot of the course behind the tile (rendered from the game) */
.tile[data-game="3d-rings-test"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.92) 0%, rgba(8, 18, 34, 0.6) 40%, rgba(8, 18, 34, 0.12) 72%, rgba(8, 18, 34, 0.4) 100%),
    url('../assets/arcade/rings-3d-test.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="3d-rings-test"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.85) 0%, rgba(8, 18, 34, 0.45) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.3) 100%),
    url('../assets/arcade/rings-3d-test.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="3d-rings-test"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="3d-rings-test"] .tile-tag { color: var(--muted); }
.tile[data-game="3d-rings-test"] .tile-icon { filter: drop-shadow(0 1px 6px rgba(4, 10, 20, 0.9)); }
/* Cherry Blossom: a daytime shot of the grove and its spiral (rendered from the game) */
.tile[data-game="blossom-rings"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.9) 0%, rgba(8, 18, 34, 0.55) 40%, rgba(8, 18, 34, 0.05) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/cherry-blossom.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="blossom-rings"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.82) 0%, rgba(8, 18, 34, 0.4) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.15) 100%),
    url('../assets/arcade/cherry-blossom.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="blossom-rings"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="blossom-rings"] .tile-tag { color: #dbe6f5; }
/* Edge of Space: the capsule, its balloon and the dive down toward the curve of the Earth (rendered from the game) */
.tile[data-game="space-dive"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.9) 0%, rgba(8, 18, 34, 0.55) 40%, rgba(8, 18, 34, 0.05) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/edge-of-space.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="space-dive"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.82) 0%, rgba(8, 18, 34, 0.4) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.15) 100%),
    url('../assets/arcade/edge-of-space.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="space-dive"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="space-dive"] .tile-tag { color: #dbe6f5; }
/* Neon Heights Rings: rings threading the neon towers (rendered from the game) */
.tile[data-game="neon-rings"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.92) 0%, rgba(8, 18, 34, 0.6) 40%, rgba(8, 18, 34, 0.1) 72%, rgba(8, 18, 34, 0.35) 100%),
    url('../assets/arcade/neon-rings.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="neon-rings"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.85) 0%, rgba(8, 18, 34, 0.45) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/neon-rings.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="neon-rings"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="neon-rings"] .tile-tag { color: #dbe6f5; }
/* Giant Rings: rings over the frozen sea between icebergs (rendered from the game) */
.tile[data-game="giant-rings"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.92) 0%, rgba(8, 18, 34, 0.6) 40%, rgba(8, 18, 34, 0.1) 72%, rgba(8, 18, 34, 0.35) 100%),
    url('../assets/arcade/giant-rings.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="giant-rings"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.85) 0%, rgba(8, 18, 34, 0.45) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/giant-rings.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="giant-rings"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="giant-rings"] .tile-tag { color: #dbe6f5; }
/* Laser Dojo: fruit in flight in front of the paper screen (rendered from the game) */
.tile[data-game="laser-dojo"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.94) 0%, rgba(8, 18, 34, 0.7) 40%, rgba(8, 18, 34, 0.12) 75%, rgba(8, 18, 34, 0.3) 100%),
    url('../assets/arcade/laser-dojo.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="laser-dojo"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.88) 0%, rgba(8, 18, 34, 0.55) 40%, rgba(8, 18, 34, 0) 75%, rgba(8, 18, 34, 0.2) 100%),
    url('../assets/arcade/laser-dojo.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="laser-dojo"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="laser-dojo"] .tile-tag { color: #dbe6f5; }

/* Flare Corridor: the neon test tunnel with a zone ahead (rendered from the game) */
.tile[data-game="flare-corridor"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.92) 0%, rgba(8, 18, 34, 0.6) 40%, rgba(8, 18, 34, 0.1) 72%, rgba(8, 18, 34, 0.35) 100%),
    url('../assets/arcade/flare-corridor.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="flare-corridor"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.85) 0%, rgba(8, 18, 34, 0.45) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/flare-corridor.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="flare-corridor"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="flare-corridor"] .tile-tag { color: #dbe6f5; }

/* Pipe Corridor: the tall neon tunnel with green pipes ahead (rendered from the game) */
.tile[data-game="pipe-corridor"] {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.92) 0%, rgba(8, 18, 34, 0.6) 40%, rgba(8, 18, 34, 0.1) 72%, rgba(8, 18, 34, 0.35) 100%),
    url('../assets/arcade/pipe-corridor.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="pipe-corridor"]:hover {
  background:
    linear-gradient(90deg, rgba(8, 18, 34, 0.85) 0%, rgba(8, 18, 34, 0.45) 40%, rgba(8, 18, 34, 0) 72%, rgba(8, 18, 34, 0.25) 100%),
    url('../assets/arcade/pipe-corridor.webp') center / cover no-repeat,
    #0c1c34;
}
.tile[data-game="pipe-corridor"] .tile-text { text-shadow: 0 1px 8px rgba(4, 10, 20, 0.9); }
.tile[data-game="pipe-corridor"] .tile-tag { color: #dbe6f5; }

/* ---------- detail plate ---------- */
.plate {
  align-self: start;
  position: relative;
  background: linear-gradient(170deg, rgba(19, 41, 74, 0.96), rgba(9, 21, 39, 0.96));
  border: 1px solid var(--line-strong);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}
.plate::-webkit-scrollbar { display: none; }
.plate::before {
  content: '';
  position: absolute;
  left: -1px; right: -1px; top: -1px;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}
.plate-head { display: flex; align-items: center; gap: 14px; }
.plate-icon {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: rgba(70, 182, 255, 0.08);
  color: var(--cyan);
}
.plate-tag { margin: 0 0 2px; font-size: 11px; color: var(--cyan); }
.plate-title { margin: 0; font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: 0.01em; text-transform: none; }
.plate-sub { margin: 0; font-size: 15px; line-height: 1.4; color: var(--muted); }
.plate-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 15px; }
.plate-facts dt { color: var(--muted); }
.plate-facts dd { margin: 0; font-weight: 600; }
.plate-status { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.plate-status.is-locked { color: var(--amber); }
.plate-status.is-done { color: var(--green); }
.best-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.best-table caption { text-align: left; font-size: 11px; color: var(--cyan); padding-bottom: 4px; }
.best-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 5px 0; }
.best-table td { text-align: right; font: 700 16px/1 var(--font-display); font-style: italic; padding: 5px 0; font-variant-numeric: tabular-nums; }
.best-table tr + tr th, .best-table tr + tr td { border-top: 1px solid var(--line); }

/* the big skewed PLAY bar */
.play-btn {
  appearance: none;
  border: 0;
  width: 100%;
  padding: 13px 20px 14px;
  background: linear-gradient(90deg, #1f6fff 0%, #2f94ff 55%, #49b8ff 100%);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.14em;
  cursor: pointer;
  clip-path: polygon(var(--skew) 0, 100% 0, calc(100% - var(--skew)) 100%, 0 100%);
  transition: filter 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.play-btn:hover, .play-btn:focus { filter: brightness(1.15); }
body.using-nav .play-btn:focus { outline: none; box-shadow: none; filter: brightness(1.2); background: linear-gradient(90deg, #fff 0%, #dff1ff 100%); color: var(--ink); }
.play-btn:disabled { background: rgba(60, 84, 120, 0.5); color: var(--dim); cursor: not-allowed; filter: none; }

/* ---------- generic buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(70, 140, 255, 0.08);
  color: var(--text);
  padding: 8px 18px 9px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-align: center;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.btn:hover { background: var(--navy-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.active { border-color: var(--blue-2); color: var(--ink); background: var(--plate); }
.btn-primary { background: linear-gradient(90deg, #1f6fff, #49b8ff); border-color: transparent; color: #fff; font-size: 20px; letter-spacing: 0.12em; padding: 12px 20px 13px; }
.btn-primary:hover { background: linear-gradient(90deg, #1f6fff, #49b8ff); filter: brightness(1.15); }
body.using-nav .btn:focus { outline: none; background: var(--plate); color: var(--ink); border-color: var(--plate); filter: none; }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--muted); }

/* ==========================================================================
   AIR ROLL PICKER
   ========================================================================== */
.picker {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.picker-window {
  position: relative;
  width: min(760px, 100%);
  background: linear-gradient(170deg, rgba(19, 41, 74, 0.97), rgba(8, 19, 36, 0.97));
  border: 1px solid var(--line-strong);
  padding: 22px 24px 22px;
  display: grid;
  gap: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.picker-window::before { content: ''; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.picker.is-open .picker-window { animation: pop-in 260ms var(--ease-out); }
.picker.is-open .picker-option { animation: rise 300ms var(--ease-out) both; }
@keyframes rise { from { transform: translateY(14px); } }
.picker.is-open .picker-option:nth-child(2) { animation-delay: 50ms; }
.picker.is-open .picker-option:nth-child(3) { animation-delay: 100ms; }
@keyframes pop-in { from { transform: scale(0.94) translateY(12px); } }
.picker-kicker { margin: 0; font-size: 12px; color: var(--cyan); }
.picker-title { margin: -8px 0 0; font-weight: 900; font-size: 38px; line-height: 1; }
.picker-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.picker-option {
  appearance: none;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #13294a 0%, #0c1c34 100%);
  color: var(--text);
  padding: 18px 12px 16px;
  display: grid;
  justify-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.picker-option-icon { color: var(--cyan); display: grid; }
.picker-option-label { font-weight: 800; font-size: 22px; line-height: 1; }
.picker-option-best { font-size: 13px; color: var(--muted); }
.picker-option:hover, .picker-option:focus { background: var(--plate); color: var(--ink); transform: translateY(-2px); outline: none; }
.picker-option:hover .picker-option-icon, .picker-option:focus .picker-option-icon { color: var(--blue); }
.picker-option:hover .picker-option-best, .picker-option:focus .picker-option-best { color: #4c6385; }
.picker-cancel { justify-self: start; }

/* ==========================================================================
   RESULTS
   ========================================================================== */
#screen-results {
  display: grid;
  place-items: center;
  padding: calc(var(--gutter) + var(--safe-top)) var(--gutter) calc(var(--gutter) + 40px + var(--safe-bottom));
  background: radial-gradient(ellipse at center, rgba(4, 10, 20, 0.55), rgba(4, 10, 20, 0.88));
}
.results-card {
  position: relative;
  width: min(1060px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  background: linear-gradient(170deg, rgba(19, 41, 74, 0.95), rgba(8, 19, 36, 0.95));
  border: 1px solid var(--line-strong);
}
.results-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.results-card.is-failed::before { background: linear-gradient(90deg, #c22, var(--red)); }
.results-card.no-chart { grid-template-columns: 1fr; width: min(580px, 100%); }
#screen-results.is-entering .results-card { animation: pop-in 320ms var(--ease-out); }
#screen-results.is-entering .results-title { animation: slide-in-left 420ms var(--ease-out) 80ms both; }
.results-main { padding: 26px 30px 30px; display: flex; flex-direction: column; gap: 16px; }
.results-kicker { margin: 0; font-size: 12px; color: var(--cyan); }
.results-title { margin: -6px 0 0; font-weight: 900; font-size: clamp(52px, 6.6vw, 88px); line-height: 0.9; letter-spacing: 0.01em; }
.results-card.is-failed .results-title { color: var(--red); }
.results-card.is-record .results-title { color: var(--amber); }
.results-stats { display: flex; flex-wrap: wrap; gap: 10px 34px; }
.stat { display: grid; gap: 4px; }
.stat-value { font-weight: 800; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat.is-record .stat-value { color: var(--amber); }
.results-note { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); border-left: 3px solid var(--blue-2); padding-left: 12px; }
.results-note.is-warning { border-left-color: var(--amber); }
.results-actions { display: grid; gap: 8px; margin-top: 4px; }
/* Briefly locked after a level so a still-tapped boost button can't skip the recap */
.results-actions { transition: opacity 250ms var(--ease-out); }
#screen-results.is-input-locked .results-actions { opacity: 0.5; pointer-events: none; }
.results-actions .btn { text-align: left; padding-left: 22px; }
.results-actions .play-btn { text-align: left; padding-left: 26px; font-size: 20px; letter-spacing: 0.1em; }
.results-chart {
  position: relative;
  background: radial-gradient(circle at 50% 46%, rgba(42, 140, 255, 0.12), rgba(4, 10, 20, 0) 62%), rgba(4, 10, 20, 0.35);
  border-left: 1px solid var(--line);
  padding: 18px;
  color: #dce9ff;
  /* keep the chart vertically centred when the card is taller than the chart */
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.results-chart[hidden] { display: none; }
.results-chart .m2-recap-analysis-title,
.results-chart h4 {
  margin: 0 0 4px;
  font: italic 800 18px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.results-chart svg { display: block; width: 100%; height: auto; color: inherit; }

/* ==========================================================================
   SETTINGS / PAUSE POPUP
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(56px + var(--safe-bottom));
}
.modal-scrim { position: absolute; inset: 0; background: rgba(2, 6, 12, 0.6); }
.modal-window {
  position: relative;
  width: min(940px, 100%);
  height: min(720px, 100%);
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, #10223d 0%, #08132a 100%);
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.modal-window::before { content: ''; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.modal.is-open .modal-window { animation: pop-in 240ms var(--ease-out); }
.modal-head { display: flex; align-items: center; gap: 18px; padding: 14px 14px 0 24px; border-bottom: 1px solid var(--line); flex: none; }
.modal-title { margin: 0 0 12px; font-weight: 900; font-size: 30px; line-height: 1; }
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; align-self: stretch; align-items: flex-end; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px 14px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab:focus-visible, body.using-nav .tab:focus { outline: none; color: var(--text); background: rgba(70, 182, 255, 0.12); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; background: var(--blue-2); }
.modal-close { appearance: none; border: 0; background: transparent; color: var(--muted); font-size: 30px; line-height: 1; width: 40px; height: 40px; margin-bottom: 10px; cursor: pointer; }
.modal-close:hover { background: var(--navy-3); color: var(--text); }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 24px 28px; scrollbar-width: thin; scrollbar-color: rgba(120, 185, 255, 0.35) transparent; }
.pane { display: none; }
.pane.is-active { display: block; animation: fade-up 220ms var(--ease-out); }

.set-group { padding: 18px 0 6px; border-bottom: 1px solid var(--line); }
.set-group:last-child { border-bottom: 0; }
.set-group h3 { margin: 0 0 10px; font-weight: 800; font-size: 20px; letter-spacing: 0.04em; color: var(--text); }
.set-row { display: grid; grid-template-columns: minmax(160px, 260px) minmax(0, 1fr); align-items: center; gap: 8px 18px; min-height: 44px; padding: 4px 0; }
.set-row > :last-child { justify-self: start; }
.set-label, .set-row > label { color: var(--muted); font-size: 15px; }
.slider-row { grid-template-columns: minmax(160px, 260px) minmax(0, 1fr) 64px; }
.slider-row > :last-child { justify-self: end; }
.set-note { margin: 4px 0 10px; font-size: 14px; color: var(--dim); line-height: 1.45; max-width: 64ch; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { padding: 6px 16px 7px; font-size: 15px; }

.tag {
  display: inline-block;
  min-width: 52px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: rgba(70, 140, 255, 0.06);
  font: 600 14px/1 var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text);
}
.tag[contenteditable="true"] { cursor: text; -webkit-user-select: text; user-select: text; }
.tag-static { border-color: transparent; background: transparent; color: var(--muted); }
.tag-static.active { color: var(--amber); }

select, input[type=text] {
  appearance: none;
  background: var(--navy-2);
  color: var(--text);
  border: 1px solid var(--line-strong);
  padding: 8px 34px 8px 12px;
  font: 500 15px/1.1 var(--font-body);
  max-width: 100%;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select option { background: var(--navy-1); }
input[type=text] { padding-right: 12px; width: 220px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: rgba(150, 190, 255, 0.22); }
input[type=range]::-moz-range-track { height: 4px; background: rgba(150, 190, 255, 0.22); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 18px; margin-top: -7px; background: var(--plate); border: 0; transform: skewX(-12deg); }
input[type=range]::-moz-range-thumb { width: 12px; height: 18px; background: var(--plate); border: 0; border-radius: 0; }
input[type=range]:focus::-webkit-slider-thumb { background: var(--cyan); }

/* bindings */
.bindings { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.binding-col h4 { margin: 0 0 8px; font: italic 700 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.binding-col .btn-quiet { margin-top: 10px; }
.controls-category { margin-bottom: 12px; }
.controls-category-label { font: 700 11px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; color: var(--cyan); margin: 0 0 6px; }
.controls-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.controls-action-label { font-size: 14px; color: var(--text); }
.controls-binding-cell { display: flex; align-items: center; gap: 6px; }
.binding-label { min-width: 72px; padding: 3px 8px; text-align: center; font: 600 13px/1.2 var(--font-body); background: rgba(70, 140, 255, 0.1); color: var(--text); }
.controls-remap-btn { appearance: none; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); padding: 4px 10px; font: 600 13px/1 var(--font-body); cursor: pointer; }
.controls-remap-btn:hover { color: var(--text); border-color: var(--plate); }
.controls-binding-cell.remapping .binding-label { color: var(--amber); }
.right-stick-select { padding: 6px 30px 6px 10px; font-size: 14px; }

/* pause tab */
.pause-panel { padding: 26px 0; display: grid; gap: 18px; max-width: 440px; }
.pause-level { margin: 0; font-weight: 800; font-size: 26px; line-height: 1.1; color: var(--text); }
.pause-actions { display: grid; gap: 8px; }
.pause-ghost { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pause-ghost[hidden] { display: none; }
.pause-ghost-label { font: 700 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pause-actions .btn { text-align: left; padding-left: 22px; }

/* ==========================================================================
   IN-GAME, HINTS, TOAST, VEIL
   ========================================================================== */
.pause-btn {
  position: fixed;
  z-index: 20;
  top: calc(14px + var(--safe-top));
  right: calc(14px + var(--safe-right));
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pause-btn span { width: 4px; height: 16px; background: var(--text); }

.hint-bar {
  position: fixed;
  z-index: 250;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 2 * var(--gutter));
  bottom: calc(14px + var(--safe-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
  padding: 6px 16px;
  background: rgba(4, 10, 20, 0.7);
  border-top: 1px solid var(--line);
  pointer-events: none;
  font: 600 13px/1 var(--font-body);
  color: var(--muted);
}
.hint { display: inline-flex; align-items: center; gap: 7px; }
.key {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  background: var(--navy-2);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--text);
}
.key.round { border-radius: 50%; padding: 0; width: 22px; }
body[data-screen="playing"] .hint-bar, .hint-bar:empty { display: none; }

.toast {
  position: fixed;
  z-index: 300;
  top: calc(18px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 18px;
  background: var(--plate);
  color: var(--ink);
  font: 600 15px/1.35 var(--font-body);
  border-left: 5px solid var(--amber);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: fade-up 220ms var(--ease-out);
}

.veil { position: fixed; inset: 0; z-index: 400; background: #02060c; opacity: 0; pointer-events: none; }
.veil.is-flashing { animation: veil-fade 650ms var(--ease-out); }
@keyframes veil-fade { 0%, 25% { opacity: 1; } 100% { opacity: 0; } }

/* touch hints from the input tracker */
#joyHint, #darHint {
  position: fixed; z-index: 2; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 9px; font-size: 13px; white-space: nowrap;
  transform: translate(-50%, -50%); opacity: 0; transition: opacity .25s ease;
}
#joyHint.show, #darHint.show { opacity: 1; }
body.minimal-ui #joyHint, body.minimal-ui #darHint { display: none !important; }

/* ==========================================================================
   IN-LEVEL HUD (js/ui/gameHud.js)
   ========================================================================== */
.game-hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.ghud-plate {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: min(560px, calc(100vw - 140px));
  padding: 9px 26px 11px;
  display: grid;
  justify-items: center;
  gap: 3px;
  text-align: center;
  background: linear-gradient(180deg, rgba(9, 21, 39, 0.88), rgba(9, 21, 39, 0.72));
  border: 1px solid var(--line);
  border-top: 2px solid var(--blue-2);
  text-shadow: 0 1px 6px rgba(4, 10, 20, 0.6);
}
.ghud-kicker { margin: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 700 10.5px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.16em; color: var(--cyan); }
.ghud-title {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: italic 800 17px/1.1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}
.ghud-kicker:empty, .ghud-title:empty { display: none; }
.ghud-stats { display: flex; align-items: flex-end; justify-content: center; gap: 0; margin-top: 2px; }
.ghud-timer, .ghud-objective { display: grid; justify-items: center; gap: 1px; padding: 0 16px; }
.ghud-plate.has-both .ghud-objective { border-left: 1px solid var(--line-strong); }
.ghud-value {
  font: italic 800 30px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text);
}
.ghud-label { display: flex; gap: 6px; font: 700 10px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.ghud-sub { color: var(--cyan); }
.ghud-sub:empty { display: none; }
.ghud-timer.is-low .ghud-value { color: #ff7a6b; animation: ghud-pulse 1s ease-in-out infinite; }
@keyframes ghud-pulse { 50% { opacity: 0.65; } }
.ghud-bar { width: 100%; height: 3px; margin-top: 6px; background: rgba(150, 190, 255, 0.16); overflow: hidden; }
.ghud-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); transform-origin: left; transform: scaleX(0); transition: transform 180ms var(--ease-out); }

/* Start gate: "Ready · Press [Boost] to start", shown before every run (in-level HUD and Rhythm Mode). */
.start-gate {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 34px 16px;
  white-space: nowrap;
  text-align: center;
  background: linear-gradient(180deg, rgba(10, 26, 48, 0.94), rgba(6, 16, 30, 0.9));
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--cyan);
  box-shadow: 0 0 0 1px rgba(4, 10, 20, 0.6), 0 14px 40px rgba(0, 0, 0, 0.45), 0 0 34px rgba(89, 214, 255, 0.18);
  color: var(--text);
  text-shadow: 0 1px 8px rgba(4, 10, 20, 0.7);
  pointer-events: none;
}
.start-gate-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 12px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.34em;
  color: var(--cyan);
}
/* little chevron rules either side of READY */
.start-gate-kicker::before, .start-gate-kicker::after {
  content: '';
  width: 26px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan));
}
.start-gate-kicker::after { transform: scaleX(-1); }
.start-gate-main {
  display: flex;
  align-items: center;
  font: italic 800 28px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ghud-key {
  display: inline-block;
  margin: 0 6px;
  padding: 3px 9px 4px;
  background: var(--plate);
  color: var(--ink);
  font-style: normal;
  font-size: 15px;
  letter-spacing: 0.06em;
  vertical-align: 2px;
  border-radius: 4px;
}
/* The key itself: a big bright cap that pulses, like a button waiting to be pressed. */
.start-gate-key {
  position: relative;
  margin: 0 14px;
  padding: 7px 16px 8px;
  font: 800 22px/1 var(--font-display);
  letter-spacing: 0.08em;
  clip-path: none;
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(89, 214, 255, 0.9), 0 0 22px rgba(89, 214, 255, 0.55);
  animation: start-gate-press 1.6s var(--ease-out) infinite;
}
.start-gate-key::after {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2px solid var(--cyan);
  opacity: 0;
  animation: start-gate-ring 1.6s var(--ease-out) infinite;
}
@keyframes start-gate-press {
  0%, 60%, 100% { transform: translateY(0); }
  70% { transform: translateY(2px); }
}
@keyframes start-gate-ring {
  0% { opacity: 0.9; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.45, 1.9); }
}

/* In-level placement: below the car, entering with a short rise. */
.ghud-prompt {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translateX(-50%);
  animation: start-gate-in 320ms var(--ease-out) both;
}
@keyframes start-gate-in {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
/* Rhythm Mode: centred on screen. */
.start-gate-fixed {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%);
}

/* Countdown: 3 · 2 · 1 · GO, one beat each (0.375 s; see startCountdown.js). */
.ghud-go {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  font: italic 900 120px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  text-shadow: 0 0 20px rgba(89, 214, 255, 0.95), 0 0 56px rgba(70, 182, 255, 0.5), 0 3px 0 rgba(4, 10, 20, 0.85);
  opacity: 0;
  pointer-events: none;
}
.ghud-go.is-on { animation: count-beat 375ms var(--ease-out) forwards; }
.ghud-go[data-step="3"] {
  font-size: 150px;
  color: #eafff1;
  text-shadow: 0 0 22px rgba(61, 255, 122, 0.95), 0 0 70px rgba(61, 255, 122, 0.55), 0 3px 0 rgba(4, 10, 20, 0.85);
}
.ghud-go.is-on[data-step="3"] { animation: count-go 375ms var(--ease-out) forwards; }
@keyframes count-beat {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(0.94); }
  40% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0.15; transform: translate(-50%, -50%) scale(0.9); }
}
@keyframes count-go {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
}
@media (max-width: 640px) {
  .ghud-plate { padding: 7px 18px 9px; min-width: 0; max-width: calc(100vw - 120px); }
  .ghud-title { font-size: 14px; }
  .ghud-value { font-size: 23px; }
  .ghud-timer, .ghud-objective { padding: 0 10px; }
  /* phones: the stick and buttons fill the bottom, so prompt under the plate */
  .ghud-prompt { top: calc(128px + var(--safe-top)); }
  .start-gate { padding: 10px 22px 12px; gap: 6px; }
  .start-gate-main { font-size: 20px; }
  .start-gate-key { font-size: 17px; padding: 6px 12px 7px; margin: 0 10px; }
  .start-gate-kicker { font-size: 10.5px; letter-spacing: 0.28em; }
  .ghud-go { font-size: 84px; top: 42%; }
  .ghud-go[data-step="3"] { font-size: 100px; }
  .ghud-kicker { letter-spacing: 0.1em; }
  .ghud-key { font-size: 12px; }
}
/* Short landscape phones: the stick, speedo and buttons fill the lower half, so the gate goes under the plate. */
@media (max-height: 500px) and (min-width: 641px) {
  .ghud-prompt { top: calc(112px + var(--safe-top)); }
  .start-gate { padding: 8px 20px 10px; gap: 5px; }
  .start-gate-main { font-size: 18px; }
  .start-gate-key { font-size: 15px; padding: 5px 11px 6px; margin: 0 9px; }
  .start-gate-kicker { font-size: 10px; letter-spacing: 0.26em; }
  .ghud-go { font-size: 76px; top: 52%; }
  .ghud-go[data-step="3"] { font-size: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  .ghud-timer.is-low .ghud-value, .ghud-prompt, .start-gate-key, .start-gate-key::after { animation: none; }
  .ghud-go.is-on, .ghud-go.is-on[data-step="3"] { animation: count-plain 375ms linear forwards; }
}
@keyframes count-plain { 0%, 75% { opacity: 1; } 100% { opacity: 0; }
}

/* Speedometer (Rings 3D Test) */
.ghud-speedo {
  /* left/top are set from the stick display's position (gameHud.js); this is the fallback */
  position: absolute;
  left: calc(250px + var(--safe-left));
  top: calc(100% - 130px - var(--safe-bottom));
  transform: translateY(-58%);   /* dial centre (y 100 of 172) level with the stick's centre */
  width: 156px;
  aspect-ratio: 200 / 172;
  filter: drop-shadow(0 2px 8px rgba(4, 10, 20, 0.55));
}
.ghud-speedo svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ghud-speedo path { fill: none; }
.speedo-bg { fill: rgba(6, 14, 27, 0.5); }
.speedo-ticks { stroke: rgba(150, 190, 255, 0.55); stroke-width: 6; stroke-dasharray: 1.6 28.4; stroke-dashoffset: 0.8; }
.speedo-zone { stroke: rgba(255, 204, 51, 0.55); stroke-width: 5; stroke-dasharray: 4.35 100; stroke-dashoffset: -95.65; }
.speedo-track { stroke: rgba(150, 190, 255, 0.16); stroke-width: 9; }
.speedo-track-inner { stroke-width: 4; }
.speedo-now {
  stroke: var(--cyan); stroke-width: 9; stroke-linecap: butt;
  stroke-dasharray: 100 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 90ms linear, stroke 200ms ease;
}
.speedo-avg {
  stroke: var(--amber); stroke-width: 4;
  stroke-dasharray: 100 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 200ms linear;
}
.speedo-mark { stroke: var(--amber); stroke-width: 3; stroke-linecap: round; transition: transform 200ms linear; }
.ghud-speedo.is-supersonic .speedo-now { stroke: #eafaff; filter: drop-shadow(0 0 4px rgba(89, 214, 255, 0.9)); }
.speedo-readout {
  position: absolute; left: 0; right: 0; top: 34%;
  display: grid; justify-items: center; gap: 1px;
  text-shadow: 0 1px 6px rgba(4, 10, 20, 0.7);
}
.speedo-value { font: italic 800 34px/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--text); }
.speedo-unit { font: 700 10px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.speedo-average { margin-top: 5px; font: 700 10.5px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.speedo-average b { margin-left: 3px; font: italic 800 15px/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--amber); }
@media (max-width: 640px) {
  .ghud-speedo { width: 112px; }
  .speedo-value { font-size: 25px; }
  .speedo-average b { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .speedo-now, .speedo-avg, .speedo-mark { transition: none; }
}

/* ==========================================================================
   LEVEL TRANSITION (menus → level)
   Dark navy only: no light flashes. Panel sweeps in, content settles, panel
   sweeps out. Durations come from levelTransition.js (--lt-in/--lt-hold/--lt-out).
   ========================================================================== */
.level-transition {
  position: fixed;
  inset: 0;
  z-index: 500;
  overflow: hidden;
  pointer-events: auto;
  display: grid;
  place-items: center;
}
.lt-panel {
  position: absolute;
  inset: -5% -30%;
  background:
    radial-gradient(ellipse 55% 50% at 50% 46%, rgba(22, 50, 90, 0.55), rgba(22, 50, 90, 0) 70%),
    linear-gradient(105deg, #03070f 0%, #071224 45%, #0a1830 100%);
  transform: skewX(-12deg) translateX(-125%);
}
/* thin blue leading edge so the sweep reads without a bright flash */
.lt-panel::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 2px;
  background: rgba(70, 182, 255, 0.5);
  box-shadow: 0 0 22px 4px rgba(42, 140, 255, 0.22);
}
.lt-content {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  opacity: 0;
}
.lt-logo {
  width: clamp(84px, 11vw, 124px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(244, 247, 251, 0.85), 0 0 0 6px rgba(70, 182, 255, 0.4), 0 14px 40px rgba(0, 0, 0, 0.55);
}
.lt-name {
  margin-top: 6px;
  font: italic 900 clamp(40px, 6vw, 72px)/0.9 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text);
}
.lt-rule { width: 64px; height: 2px; background: rgba(70, 182, 255, 0.45); margin: 2px 0; }
.lt-kicker {
  margin: 0;
  font: 700 12px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #6f93bd;
}
.lt-title {
  margin: -4px 0 0;
  font: italic 800 clamp(20px, 2.4vw, 28px)/1.05 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #c9d8ee;
}
.lt-title:empty, .lt-kicker:empty { display: none; }
.lt-bar { width: 180px; height: 2px; background: rgba(120, 170, 230, 0.15); overflow: hidden; margin-top: 6px; }
.lt-bar > span { display: block; height: 100%; background: rgba(70, 182, 255, 0.7); transform-origin: left; transform: scaleX(0); }

.level-transition.is-in .lt-panel { animation: lt-sweep-in var(--lt-in, 460ms) cubic-bezier(0.7, 0, 0.2, 1) forwards; }
.level-transition.is-in .lt-content { animation: lt-content-in 420ms var(--ease-out) calc(var(--lt-in, 460ms) * 0.55) forwards; }
.level-transition.is-in .lt-bar > span { animation: lt-bar calc(var(--lt-hold, 760ms) + var(--lt-in, 460ms) * 0.45) cubic-bezier(0.4, 0, 0.2, 1) calc(var(--lt-in, 460ms) * 0.55) forwards; }
.level-transition.is-out .lt-panel { animation: lt-sweep-out var(--lt-out, 520ms) cubic-bezier(0.7, 0, 0.2, 1) forwards; }
.level-transition.is-out .lt-content { animation: lt-content-out calc(var(--lt-out, 520ms) * 0.6) ease-in forwards; }
@keyframes lt-sweep-in { from { transform: skewX(-12deg) translateX(-125%); } to { transform: skewX(-12deg) translateX(0); } }
@keyframes lt-sweep-out { from { transform: skewX(-12deg) translateX(0); } to { transform: skewX(-12deg) translateX(125%); } }
@keyframes lt-content-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes lt-content-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(36px); } }
@keyframes lt-bar { to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  /* a short dark fade instead of the sweep */
  .level-transition.is-in .lt-panel, .level-transition.is-out .lt-panel,
  .level-transition.is-in .lt-content, .level-transition.is-out .lt-content,
  .level-transition.is-in .lt-bar > span { animation: none !important; }
  .level-transition .lt-panel { transform: none; }
  .level-transition .lt-content { opacity: 1; }
  .level-transition .lt-bar { display: none; }
  .level-transition.is-in { animation: lt-fade-in var(--lt-in) linear both !important; }
  .level-transition.is-out { animation: lt-fade-out var(--lt-out) linear both !important; }
}
@keyframes lt-fade-in { from { opacity: 0; } }
@keyframes lt-fade-out { to { opacity: 0; } }

/* ==========================================================================
   LEGAL (fan content disclaimer + terms)
   ========================================================================== */
.legal-footer {
  position: absolute;
  right: calc(var(--gutter) + var(--safe-right));
  bottom: calc(58px + var(--safe-bottom));   /* sits above the hint bar */
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  display: grid;
  justify-items: stretch;
  gap: 6px;
  padding: 9px 12px 10px;
  text-align: left;
  background: linear-gradient(270deg, rgba(6, 16, 31, 0.82), rgba(6, 16, 31, 0.6));
  border-right: 2px solid var(--blue-2);
}
.legal-line { margin: 0; font: 500 11.5px/1.45 var(--font-body); color: rgba(220, 232, 250, 0.72); }
.legal-line strong { display: block; margin-bottom: 3px; color: var(--text); font-weight: 600; }
.legal-link {
  justify-self: end;
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 0;
  font: italic 700 12px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cyan);
  cursor: pointer;
  border-bottom: 1px solid rgba(89, 214, 255, 0.4);
}
.legal-link:hover, .legal-link:focus { color: var(--text); border-bottom-color: var(--text); outline: none; }
.legal-disclaimer {
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--blue-2);
  background: rgba(70, 182, 255, 0.07);
  font: 600 15px/1.5 var(--font-body);
  color: var(--text);
  max-width: 70ch;
}
.legal-terms { margin: 4px 0 12px; padding-left: 20px; display: grid; gap: 10px; max-width: 72ch; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.legal-terms strong { color: var(--text); font-weight: 600; }
.legal-terms a { color: var(--cyan); }
.legal-terms code { font-size: 13px; color: var(--text); }
body:not([data-screen="home"]) .legal-footer { display: none; }
#screen-home.is-entering .legal-footer { animation: fade-up 420ms var(--ease-out) 200ms both; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .screen-body { display: flex; flex-direction: column; overflow-y: auto; padding-bottom: 24px; }
  .level-board { overflow: visible; min-height: auto; flex: none; padding-bottom: 0; }
  .plate { max-height: none; flex: none; overflow: visible; }
  .results-card { grid-template-columns: 1fr; }
  .results-chart { border-left: 0; border-top: 1px solid var(--line); }
  .bindings { grid-template-columns: 1fr; }
  .screen-sub { display: none; }
}
@media (max-width: 640px) {
  .set-row { grid-template-columns: 1fr; gap: 4px; }
  .slider-row { grid-template-columns: 1fr 56px; }
  .slider-row > label { grid-column: 1 / -1; }
  .modal { padding: 0; }
  .modal-window { height: 100%; width: 100%; border: 0; }
  .modal-head { flex-wrap: wrap; padding-left: 16px; }
  .modal-title { display: none; }
  .modal-body { padding: 4px 16px 24px; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .picker-options { grid-template-columns: 1fr; }
  .brand-name { font-size: 22px; }
  .brand-sub { font-size: 13px; }
  .brand-logo { width: 44px; height: 44px; }
  .hint-bar { display: none; }
  .legal-footer { left: var(--gutter); right: var(--gutter); width: auto; justify-items: start; text-align: left; bottom: calc(8px + var(--safe-bottom)); }
  .legal-line { font-size: 10.5px; }
}
@media (max-aspect-ratio: 19/20) {
  #screen-home { background: linear-gradient(0deg, rgba(4, 10, 20, 0.8) 0%, rgba(4, 10, 20, 0.3) 45%, rgba(4, 10, 20, 0) 65%); }
  .home-menu { bottom: calc(112px + var(--safe-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Settings → Camera: temporary car cam turn curve chart */
.curve-chart {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  aspect-ratio: 640 / 240;
  margin: 8px 0 4px;
  background: rgba(4, 10, 20, 0.55);
  border: 1px solid var(--line);
}

/* Settings → Camera tuning panel: sliders the chosen curve type doesn't use */
.set-row.is-unused { opacity: 0.4; }

/* Settings → Camera tuning panels: one-line description under each option */
.set-subhead {
  display: flex;
  align-items: center;
  margin: 18px 0 8px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.set-help {
  margin: -4px 0 10px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  max-width: 62ch;
}

/* ==========================================================================
   SAVED RUNS — Arcade plate "Ghosts & replays", results "This run"
   (js/ui/runsUi.js)
   ========================================================================== */
.plate-main { display: contents; }
.best-table-rewind th.best-col { text-align: right; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); padding-left: 10px; }
.best-table-rewind td { padding-left: 10px; white-space: nowrap; }

.runs { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); min-width: 0; }
.runs-top, .runs-list, .runs-import { display: grid; gap: 8px; min-width: 0; }
.runs-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.runs-title { margin: 0; font: italic 800 19px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.runs-usage { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.runs-row { display: grid; gap: 5px; }
.runs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.runs-field { display: grid; gap: 5px; min-width: 0; }
.runs-field-label { font: 700 11px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; color: var(--cyan); }
.runs-hint, .runs-preview { margin: 0; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.runs-hint.is-warning, .runs-preview.is-warning { color: var(--amber); }
.runs-empty { margin: 0; font-size: 14px; line-height: 1.4; color: var(--muted); }
.runs-msg { margin: 0; font-size: 13.5px; line-height: 1.35; color: var(--muted); border-left: 3px solid var(--blue-2); padding-left: 10px; }
.runs-msg.is-ok { border-left-color: var(--green); color: var(--text); }
.runs-msg.is-error { border-left-color: var(--red); color: #ffb3b3; }

/* small buttons (skewed like .btn, tighter) */
.btn.btn-sm { padding: 5px 12px 6px; font-size: 13.5px; letter-spacing: 0.05em; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
.btn.btn-sm.active { background: var(--blue); border-color: var(--blue-2); color: #fff; }
body.using-nav .btn.btn-sm:focus { background: var(--plate); border-color: var(--plate); color: var(--ink); }
.btn.btn-go { background: linear-gradient(90deg, #1f6fff, #49b8ff); border-color: transparent; color: #fff; }
.btn.btn-go:disabled { background: rgba(60, 84, 120, 0.5); color: var(--dim); }
.btn.is-danger { border-color: var(--red); background: rgba(255, 79, 79, 0.16); color: #ffd0d0; }
body.using-nav .btn.is-danger:focus { background: var(--red); border-color: var(--red); color: #fff; }

/* one saved run */
.run-row { display: grid; gap: 6px; padding: 9px 10px 10px; border: 1px solid var(--line); background: rgba(4, 10, 20, 0.32); min-width: 0; }
.run-row.is-ghost { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.run-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.run-label { font: italic 800 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.run-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.run-details { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.run-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.run-tag {
  display: inline-block;
  padding: 2px 6px 3px;
  border: 1px solid currentColor;
  font: 700 10px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.run-tag.tag-cyan { color: var(--cyan); }
.run-tag.tag-amber { color: var(--amber); }
.run-tag.tag-green { color: var(--green); }

/* import / export / save panels */
.runs-panel { display: grid; gap: 9px; padding: 10px 12px 12px; border: 1px solid var(--line-strong); background: rgba(4, 10, 20, 0.45); min-width: 0; }
.runs-panel-title { margin: 0; font: italic 800 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--cyan); }
.runs-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.runs-input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  background: var(--navy-1);
  color: var(--text);
  font: 500 15px/1.3 var(--font-body);
  -webkit-user-select: text;
  user-select: text;
}
input[type=text].runs-input { width: 100%; padding-right: 10px; }
.runs-input:focus { outline: 2px solid var(--plate); outline-offset: 1px; }
.runs-code { resize: vertical; min-height: 64px; max-height: 160px; font-size: 12.5px; word-break: break-all; }
.runs-file { width: 100%; min-width: 0; font: 500 13px/1.3 var(--font-body); color: var(--muted); }
.runs-file::file-selector-button {
  margin-right: 10px;
  padding: 5px 12px 6px;
  border: 1px solid var(--line-strong);
  background: rgba(70, 140, 255, 0.08);
  color: var(--text);
  font: italic 700 13.5px/1.2 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.runs-file:focus { outline: 2px solid var(--plate); outline-offset: 2px; }
.runs-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.runs-slot { display: grid; gap: 2px; text-align: left; min-width: 0; }
.runs-slot-what { font: 500 12px/1.2 var(--font-body); font-style: normal; text-transform: none; letter-spacing: 0; color: inherit; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* results screen */
.results-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.results-tags .run-tag { font-size: 11px; padding: 3px 8px 4px; }
.results-run { padding-top: 12px; }
#screen-results.is-input-locked .results-run-box { opacity: 0.5; pointer-events: none; }

@media (max-width: 640px) {
  .runs-slots { grid-template-columns: 1fr; }
}

/* ============================================================
   INPUT GLYPHS (assets/input, Kenney Input Prompts, CC0)
   ============================================================ */
.start-gate-key.has-glyph {
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  vertical-align: middle;
  line-height: 0;
}
.start-gate-key.has-glyph::after { border-radius: 50%; }
.start-gate-key .input-glyph { width: 46px; height: 46px; }
@media (max-width: 760px) { .start-gate-key .input-glyph { width: 38px; height: 38px; } }

/* Menu hint bar: one icon per key / button, pairs sit close together */
.hint .hint-glyph { width: 24px; height: 24px; }
.hint .hint-glyph + .hint-glyph { margin-left: -4px; }
.hint .input-glyph-text.hint-glyph { width: auto; height: auto; }

/* Settings > Controls: bindings show their icon */
.binding-label.has-glyph { display: inline-grid; place-items: center; padding: 2px 8px; line-height: 0; }
.binding-label .binding-glyph { width: 28px; height: 28px; }

/* ==========================================================================
   LEADERBOARD — Arcade plate and results (js/ui/leaderboardUi.js)
   ========================================================================== */
.lb-account { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; min-width: 0; }
.lb-account-name { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.lb-submit { margin-top: 10px; }
.lb-invite { justify-self: start; text-decoration: none; }

/* Arcade shortcuts: import a run, switch the level card */
.arcade-import-btn { margin-left: auto; align-self: center; }
.plate-switch { align-self: flex-end; flex: none; }
.import-window { width: min(520px, calc(100vw - 32px)); }
.import-fields { display: grid; gap: 10px; margin-bottom: 14px; min-width: 0; }

/* ---------- Replays & ghosts popup (Y / G on the Arcade) ---------- */
.replays-modal .modal-scrim { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.replays-window {
  width: min(680px, 100%);
  max-height: min(720px, calc(100dvh - 32px - var(--safe-top, 0px) - var(--safe-bottom, 0px)));
  padding: 0;
  gap: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.replays-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.replays-heading { display: grid; gap: 12px; min-width: 0; }
.replays-title { margin: 0; font-size: 32px; }
.replays-close { flex: none; margin-top: 2px; }
.replays-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 22px 22px;
  scroll-padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
/* The card inside: the popup already has the title and frame. */
.replays-body .runs { border-top: 0; padding-top: 0; gap: 14px; }
.replays-body .runs-title { display: none; }
.replays-body .runs-head { justify-content: flex-start; }
/* Bigger targets: this popup is mostly driven with a controller. */
.replays-body .btn.btn-sm { min-height: 36px; padding: 7px 14px 8px; font-size: 14px; }
.replays-body .run-row { padding: 12px 14px; gap: 8px; }
.replays-body .runs-list { gap: 10px; }

/* In: the scrim fades, the window rises and settles. Out: the reverse, a bit quicker. */
.replays-modal.is-open .modal-scrim { animation: replays-scrim-in 200ms var(--ease-out) both; }
.replays-modal.is-open .replays-window { animation: replays-in 240ms var(--ease-out) both; }
.replays-modal.is-open .replays-body > * { animation: fade-up 280ms var(--ease-out) 60ms both; }
.replays-modal.is-closing { pointer-events: none; }
.replays-modal.is-closing .modal-scrim { animation: replays-scrim-out 170ms ease-in both; }
.replays-modal.is-closing .replays-window { animation: replays-out 170ms ease-in both; }
.replays-modal.is-closing .replays-body > * { animation: none; }
@keyframes replays-scrim-in { from { opacity: 0; } }
@keyframes replays-scrim-out { to { opacity: 0; } }
@keyframes replays-in { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
@keyframes replays-out { to { opacity: 0; transform: translateY(12px) scale(0.98); } }
@media (max-width: 640px) {
  .replays-head { padding: 16px 16px 12px; }
  .replays-title { font-size: 26px; }
  .replays-body { padding: 14px 16px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .replays-modal.is-open .modal-scrim, .replays-modal.is-open .replays-window, .replays-modal.is-open .replays-body > *,
  .replays-modal.is-closing .modal-scrim, .replays-modal.is-closing .replays-window { animation: none; }
}
.hint-bar { width: max-content; }

/* Workshop maps: announces a new level as the car moves on (workshopRings.js) */
.workshop-level-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  z-index: 120;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-display);
  color: #fff;
  text-shadow: 0 2px 10px rgba(4, 8, 22, 0.75);
}
.workshop-level-banner.is-showing { display: flex; animation: workshop-level-banner 2.2s ease-out both; }
.workshop-level-banner .wlb-level { font: italic 800 clamp(34px, 5vw, 56px)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.workshop-level-banner .wlb-title { font: 600 clamp(15px, 2vw, 21px)/1.2 var(--font-display); letter-spacing: 0.06em; }
@keyframes workshop-level-banner {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  12%, 72% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .workshop-level-banner.is-showing { animation-name: workshop-level-banner-fade; }
  @keyframes workshop-level-banner-fade { 0%, 100% { opacity: 0; } 12%, 72% { opacity: 1; } }
}

/* ==========================================================================
   GARAGE — options on the left, the car in its tube stays visible on the right
   ========================================================================== */
body[data-screen="garage"] #hud { visibility: hidden; }
.panel-screen.garage-screen {
  background: linear-gradient(90deg, rgba(4, 10, 20, 0.86) 0%, rgba(4, 10, 20, 0.62) 30%, rgba(4, 10, 20, 0.08) 52%, rgba(4, 10, 20, 0) 70%);
  align-items: flex-start;
}
.garage-screen > * { width: min(470px, 100%); }
.garage-screen .screen-head { flex-wrap: wrap; row-gap: 4px; }
.garage-tabs { width: min(470px, 100%); }
.garage-tab { min-width: 0; flex: 1; }
.garage-tab .camp-tab-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.garage-body { flex: 1; min-height: 0; display: flex; }
.garage-panel { flex: 1; align-self: flex-start; width: 100%; }
.garage-panel.is-swapping > * { animation: fade-up 260ms var(--ease-out) both; }
.garage-screen.is-entering .garage-tabs { animation: fade-up 380ms var(--ease-out) 60ms both; }
.garage-head { flex-wrap: wrap; align-items: flex-end; }
.garage-head .plate-title { text-transform: none; }
.garage-sub { flex-basis: 100%; }

/* colour swatches */
.garage-swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.garage-swatch {
  appearance: none;
  position: relative;
  aspect-ratio: 1.35;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: rgba(4, 10, 20, 0.55);
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: transform 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.garage-swatch-chip {
  position: absolute;
  inset: 5px 9px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.28) 100%),
    var(--swatch, #888);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.garage-swatch.is-stock .garage-swatch-chip {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 6px, rgba(255, 255, 255, 0) 6px 12px),
    linear-gradient(135deg, #dfe5ef 0%, #8d98aa 100%);
}
.garage-swatch.is-stock::after {
  content: 'Stock';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: italic 800 12px/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.garage-swatch:hover, .garage-swatch:focus { transform: translateY(-2px); border-color: var(--plate); }
body.using-nav .garage-swatch:focus { outline: none; box-shadow: inset 0 0 0 2px var(--plate); }
.garage-swatch.is-selected { border-color: var(--blue-2); background: var(--plate); }
.garage-swatch.is-selected::before {
  content: '';
  position: absolute;
  right: 6px; bottom: 4px;
  width: 14px; height: 14px;
  z-index: 1;
  border-radius: 50%;
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 10px no-repeat;
  box-shadow: 0 0 0 2px var(--plate);
}

/* custom colour */
.garage-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(70, 140, 255, 0.06);
  cursor: pointer;
}
.garage-custom:hover, .garage-custom:focus-within { border-style: solid; border-color: var(--plate); }
.garage-color-input {
  flex: none;
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: none;
  cursor: pointer;
}
.garage-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.garage-color-input::-webkit-color-swatch { border: 0; }
.garage-color-input::-moz-color-swatch { border: 0; }
.garage-custom-text { display: grid; gap: 2px; }
.garage-custom-title { font: italic 800 16px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.garage-custom-value { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* boost cards */
.garage-boosts { display: grid; gap: 6px; }
.garage-boost {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px 8px 14px;
  border: 1px solid var(--line);
  background: var(--navy-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  clip-path: polygon(var(--skew) 0, 100% 0, calc(100% - var(--skew)) 100%, 0 100%);
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}
.garage-boost:hover, .garage-boost:focus { background: var(--navy-3); transform: translateX(4px); }
body.using-nav .garage-boost:focus { outline: none; background: var(--navy-3); box-shadow: inset 0 0 0 2px var(--plate); }
.garage-boost.is-selected { background: var(--plate); color: var(--ink); border-color: var(--plate); }
.garage-boost-preview {
  flex: none;
  position: relative;
  width: 112px;
  height: 34px;
  overflow: hidden;
  background: #050b16;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.garage-boost-flame {
  position: absolute;
  left: 8px; top: 50%;
  width: 92px; height: 18px;
  transform: translateY(-50%);
  border-radius: 50% 0 0 50% / 50%;
  background:
    radial-gradient(ellipse 30% 45% at 10% 50%, var(--core) 0%, transparent 100%),
    linear-gradient(90deg, var(--core) 0%, var(--flame) 30%, color-mix(in srgb, var(--flame) 40%, transparent) 70%, transparent 100%);
  filter: blur(0.6px) drop-shadow(0 0 6px var(--glow));
  clip-path: polygon(0 15%, 100% 45%, 100% 55%, 0 85%);
  animation: garage-flicker 140ms steps(2) infinite alternate;
}
.garage-boost.is-none .garage-boost-flame { display: none; }
.garage-boost.is-none .garage-boost-preview::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--dim);
  border-radius: 50%;
  background: linear-gradient(45deg, transparent 44%, var(--dim) 44% 56%, transparent 56%);
}
@keyframes garage-flicker { from { transform: translateY(-50%) scaleX(0.94); opacity: 0.88; } to { transform: translateY(-50%) scaleX(1.04); opacity: 1; } }
.garage-boost-text { display: grid; gap: 2px; min-width: 0; }
.garage-boost-name { font: italic 800 20px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.03em; }
.garage-boost-tag { font: 700 11px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; color: var(--cyan); }
.garage-boost.is-selected .garage-boost-tag { color: #1f6fd6; }
.garage-note { margin: 0; font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.garage-foot { display: flex; justify-content: flex-end; padding-top: 2px; }

@media (max-aspect-ratio: 19/20), (max-width: 640px) {
  /* Portrait: the car sits at the top, options below. */
  .panel-screen.garage-screen {
    background: linear-gradient(180deg, rgba(4, 10, 20, 0) 0%, rgba(4, 10, 20, 0.2) 36%, rgba(6, 16, 31, 0.9) 52%, rgba(6, 16, 31, 0.94) 100%);
    justify-content: flex-end;
  }
  .garage-screen > * { width: 100%; }
  .garage-body { flex: none; max-height: 46vh; }
  .garage-panel { max-height: 46vh; }
  .garage-swatches { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .garage-boost-flame { animation: none; }
  .garage-panel.is-swapping > * { animation: none; }
}
