/* Afterglow Circuit: a single dusk-neon look (no light theme by design).
   Layout: full-bleed WebGL canvas; HUD pinned to the safe-area corners;
   touch pedals bottom-right, floating steering pad bottom-left. */
:root {
  --night: #0b0626;
  --dusk: #2a1052;
  --ember: #ff9a4d;
  --sun: #ffd36b;
  --pink: #ff2e88;
  --cyan: #33f0ff;
  --cream: #fff2e6;
  --cream-dim: rgba(255, 242, 230, 0.66);
  --glass: rgba(18, 8, 40, 0.58);
  --glass-edge: rgba(255, 242, 230, 0.14);
  --good: #3dff9a;
  --bad: #ff4d6a;

  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --ui: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --gutter-t: max(12px, env(safe-area-inset-top, 0px));
  --gutter-b: max(14px, env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--cream);
  font-family: var(--ui);
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------- HUD */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.label,
.lap-sub dt,
.unit,
.lamp,
.setting-name,
.eyebrow,
.records dt {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--cream-dim);
}

.hud-lap {
  display: grid;
  gap: 2px;
  padding: 10px 14px 10px 12px;
  background: linear-gradient(100deg, var(--glass), rgba(18, 8, 40, 0));
  border-left: 3px solid var(--pink);
  min-width: 170px;
}

.lap-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.lap-no {
  font-family: var(--display);
  font-weight: 900;
  font-size: 22px;
  line-height: 1;
}

.lap-time {
  font-family: var(--mono);
  font-size: 30px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(255, 46, 136, 0.55);
}

.lap-sub {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 1px;
  margin: 2px 0 0;
  align-items: baseline;
}

.lap-sub dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.delta {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  border: 1px solid currentColor;
}

.delta.faster {
  color: var(--good);
  background: rgba(61, 255, 154, 0.12);
}

.delta.slower {
  color: var(--bad);
  background: rgba(255, 77, 106, 0.12);
}

.drift-total {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ember);
  letter-spacing: 0.06em;
}

.hud-map {
  position: absolute;
  top: var(--gutter-t);
  right: var(--gutter-r);
  display: grid;
  justify-items: end;
  gap: 8px;
}

.minimap {
  width: 190px;
  height: 84px;
  display: block;
  background: radial-gradient(ellipse at center, rgba(42, 16, 82, 0.55), rgba(11, 6, 38, 0.2));
  border: 1px solid var(--glass-edge);
}

.hud-buttons {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 10px;
  touch-action: manipulation;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:active {
  background: rgba(51, 240, 255, 0.25);
}

.hud-speed {
  position: absolute;
  left: 50%;
  bottom: var(--gutter-b);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    'tach tach'
    'speed gm'
    'aids gm';
  column-gap: 14px;
  align-items: center;
  padding: 8px 16px 10px;
  background: linear-gradient(0deg, var(--glass), rgba(18, 8, 40, 0.15));
  border-bottom: 3px solid var(--cyan);
}

.tach {
  grid-area: tach;
  height: 7px;
  background: rgba(255, 242, 230, 0.1);
  position: relative;
  overflow: hidden;
  /* Redline zone: last 1/8th of the scale. */
  background-image: linear-gradient(90deg, transparent 87.5%, rgba(255, 77, 106, 0.4) 87.5%);
}

.tach-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--cyan), var(--sun) 70%, var(--pink) 90%);
}

/* Calm effects: soft glows instead of hard on/off strobes. */
.tach.shift .tach-fill {
  animation: shift-glow 0.7s ease-in-out infinite alternate;
}

@keyframes shift-flash {
  50% {
    filter: brightness(1.35);
  }
}
@keyframes shift-glow {
  to {
    filter: brightness(1.4);
  }
}

.speed-row {
  grid-area: speed;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.speed {
  font-family: var(--display);
  font-weight: 900;
  font-size: 64px;
  line-height: 0.95;
  min-width: 2.1ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-style: italic;
  transform: skewX(-6deg);
}

.gear {
  margin-left: 6px;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 40px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  color: var(--night);
  background: var(--cyan);
  clip-path: polygon(18% 0, 100% 0, 82% 100%, 0 100%);
}

.aids {
  grid-area: aids;
  display: flex;
  gap: 8px;
}

.lamp {
  padding: 1px 6px;
  font-size: 10px;
  border: 1px solid rgba(255, 242, 230, 0.2);
  color: rgba(255, 242, 230, 0.35);
}

.lamp.on {
  color: var(--night);
  background: var(--sun);
  border-color: var(--sun);
}

.gmeter {
  grid-area: gm;
  width: 64px;
  height: 64px;
}

.drift {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%) skewX(-8deg);
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--display);
  font-weight: 900;
  color: var(--ember);
  text-shadow: 0 0 18px rgba(255, 46, 136, 0.8);
}

#driftPts {
  font-size: 46px;
  font-variant-numeric: tabular-nums;
}

#driftMult {
  font-size: 30px;
  color: var(--pink);
}

.toast {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 8px 18px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--glass);
  border-top: 2px solid var(--cream);
}

.toast.in {
  animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.toast.best {
  border-color: var(--good);
  color: var(--good);
  text-shadow: 0 0 14px rgba(61, 255, 154, 0.6);
}

.toast.warn {
  border-color: var(--bad);
  color: #ffd1d9;
}

.toast.drift {
  border-color: var(--ember);
  color: var(--ember);
}

.toast.small {
  font-size: 18px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.92);
  }
}

.countdown {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) skewX(-8deg);
  font-family: var(--display);
  font-weight: 900;
  font-size: min(34vmin, 260px);
  line-height: 1;
  color: var(--bad);
  text-shadow: 0 0 40px rgba(255, 34, 64, 0.8);
}

.countdown.go {
  color: var(--good);
  text-shadow: 0 0 40px rgba(61, 255, 154, 0.9);
}

.countdown.pulse {
  animation: pulse 0.6s ease-out;
}

@keyframes pulse {
  from {
    opacity: 0.2;
    transform: translate(-50%, -50%) skewX(-8deg) scale(1.35);
  }
}

.wrong-way {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  padding: 6px 18px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 40px;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--bad);
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
  50% {
    opacity: 0.7;
  }
}

.hint {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translateX(-50%);
  padding: 8px 14px;
  font-size: 15px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  white-space: nowrap;
}

/* ----------------------------------------------------------- touch */
.touch {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}

.steer-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 52%;
  height: 74%;
  pointer-events: auto;
  touch-action: none;
}

.steer-track {
  --x: calc(var(--gutter-l) + 120px);
  --y: calc(100% - var(--gutter-b) - 70px);
  --range: 90px;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--range) * 2 + 60px);
  height: 60px;
  transform: translate(-50%, -50%);
  opacity: 0.45;
  transition: opacity 0.15s;
}

.steer-track::before {
  content: '';
  position: absolute;
  left: 30px;
  right: 30px;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--pink), rgba(255, 242, 230, 0.3) 50%, var(--cyan));
  border-radius: 2px;
}

.steer-track.active {
  opacity: 1;
}

.steer-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 242, 230, 0.5), rgba(255, 242, 230, 0.12) 60%);
  border: 2px solid var(--cream);
  box-shadow: 0 0 18px rgba(51, 240, 255, 0.6);
}

.steer-hint {
  position: absolute;
  left: var(--gutter-l);
  bottom: calc(var(--gutter-b) + 2px);
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.steer-buttons {
  position: absolute;
  left: var(--gutter-l);
  bottom: var(--gutter-b);
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

body[data-steer='drag'] .steer-buttons,
body[data-steer='buttons'] .steer-zone {
  display: none;
}

.pedals {
  position: absolute;
  right: var(--gutter-r);
  bottom: var(--gutter-b);
  display: grid;
  grid-template-columns: 92px 96px;
  grid-template-rows: 56px 104px;
  grid-template-areas:
    'hand gas'
    'brake gas';
  gap: 12px;
  pointer-events: auto;
}

.pad-btn {
  display: grid;
  place-items: center;
  padding: 0;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(18, 8, 40, 0.42);
  border: 2px solid var(--edge, var(--cream));
  color: var(--edge, var(--cream));
  border-radius: 14px;
  touch-action: none;
  transition: background 0.06s, transform 0.06s;
}

.pad-btn.on {
  background: var(--edge, var(--cream));
  color: var(--night);
  transform: scale(0.97);
  box-shadow: 0 0 24px var(--edge, var(--cream));
}

.pad-btn.gas {
  grid-area: gas;
  --edge: var(--cyan);
  font-size: 17px;
}

.pad-btn.brake {
  grid-area: brake;
  --edge: var(--pink);
}

.pad-btn.hand {
  grid-area: hand;
  --edge: var(--ember);
  font-size: 12px;
}

.pad-btn.arrow {
  width: 86px;
  height: 86px;
  border-radius: 50%;
}

.pad-btn.arrow svg {
  width: 34px;
  height: 34px;
}

/* --------------------------------------------------------- screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: var(--gutter-t) var(--gutter-r) var(--gutter-b) var(--gutter-l);
}

.title-screen {
  background: linear-gradient(90deg, rgba(11, 6, 38, 0.88) 0%, rgba(11, 6, 38, 0.6) 42%, rgba(11, 6, 38, 0) 75%);
}

.title-grid {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(16px, 4vw, 56px);
  align-items: center;
  max-width: 1240px;
}

.title-head {
  display: grid;
  gap: 14px;
  justify-items: start;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
}

.logo {
  margin: 0;
  display: grid;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(54px, min(11.5vw, 17vh), 150px);
  line-height: 0.82;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  transform: skewX(-8deg);
  transform-origin: left bottom;
}

.logo span {
  background: linear-gradient(180deg, var(--sun) 10%, var(--ember) 45%, var(--pink) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 46, 136, 0.45));
}

.logo span + span {
  padding-left: 0.5em;
}

.tagline {
  margin: 0;
  max-width: 34ch;
  font-size: 16px;
  line-height: 1.45;
  color: var(--cream-dim);
  text-wrap: balance;
}

.cta {
  margin-top: 4px;
  padding: 14px 48px 14px 40px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--night);
  background: linear-gradient(90deg, var(--sun), var(--ember) 50%, var(--pink));
  border: 0;
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%);
  touch-action: manipulation;
  transition: filter 0.15s, transform 0.15s;
}

.cta:hover {
  filter: brightness(1.1);
}

.cta:active {
  transform: scale(0.98);
}

/* Race and the party browser sit side by side on the title screen. */
.title-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  margin-top: 4px;
}

.title-actions .cta {
  margin-top: 0;
}

.online-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cyan);
  background: rgba(51, 240, 255, 0.08);
  border: 1px solid rgba(51, 240, 255, 0.5);
  clip-path: polygon(6% 0, 100% 0, 94% 100%, 0 100%);
  touch-action: manipulation;
  transition: background 0.15s, filter 0.15s, transform 0.15s;
}

.online-btn:hover {
  background: rgba(51, 240, 255, 0.18);
  filter: brightness(1.1);
}

.online-btn:active {
  transform: scale(0.98);
}

.records {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

.records div {
  display: grid;
  gap: 2px;
}

.records dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.title-side {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: rgba(11, 6, 38, 0.62);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings {
  display: grid;
  gap: 12px;
}

.setting {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
}

.setting-note {
  grid-column: 2;
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--cream-dim);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg button {
  min-height: 36px;
  padding: 4px 14px;
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  border: 1px solid rgba(255, 242, 230, 0.3);
  touch-action: manipulation;
}

.seg button[aria-pressed='true'] {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--night);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatches button {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--c);
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
}

.swatches button[aria-pressed='true'] {
  border-color: var(--cream);
  box-shadow: 0 0 0 3px rgba(11, 6, 38, 0.9), 0 0 14px var(--c);
}

.help p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--cream-dim);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  margin: 0 1px;
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  color: var(--cream);
  border: 1px solid rgba(255, 242, 230, 0.35);
  border-bottom-width: 2px;
}

.pause-screen {
  display: flex;
  background: rgba(11, 6, 38, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pause-panel {
  /* Auto margins centre it but never push the top out of reach when it
     is taller than a short landscape screen. */
  margin: auto;
  display: grid;
  gap: 16px;
  width: min(760px, 100%);
  padding: 20px;
  background: rgba(11, 6, 38, 0.8);
  border-top: 3px solid var(--pink);
}

.pause-panel h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: 44px;
  text-transform: uppercase;
  line-height: 1;
}

.pause-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pause-actions .cta {
  font-size: 24px;
  padding: 10px 36px 10px 30px;
  margin: 0;
}

.ghost-btn {
  min-height: 44px;
  padding: 6px 18px;
  font-weight: 600;
  background: transparent;
  border: 1px solid rgba(255, 242, 230, 0.4);
  touch-action: manipulation;
}

.error {
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 18px;
  background: var(--night);
}

/* ------------------------------------------------------ menu tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--glass-edge);
}

.tabs button {
  flex: 1 1 0;
  min-height: 40px;
  padding: 6px 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream-dim);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  touch-action: manipulation;
}

.tabs button[aria-selected='true'] {
  color: var(--cream);
  border-bottom-color: var(--pink);
}

.tab-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.race-summary {
  margin: 0;
  font-size: 14px;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.track-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.track-card {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 8px;
  text-align: left;
  background: rgba(255, 242, 230, 0.04);
  border: 1px solid rgba(255, 242, 230, 0.18);
  touch-action: manipulation;
  min-width: 0;
}

.track-card canvas {
  width: 100%;
  height: 46px;
  display: block;
}

.track-card .tc-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.05;
  text-transform: uppercase;
}

.track-card .tc-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
}

.track-card[aria-pressed='true'] {
  border-color: var(--cyan);
  background: rgba(51, 240, 255, 0.1);
  box-shadow: inset 0 -3px 0 var(--cyan);
}

.race-only[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------- garage */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.presets button {
  min-height: 34px;
  padding: 3px 12px;
  font-weight: 600;
  font-size: 13px;
  background: transparent;
  border: 1px solid rgba(255, 242, 230, 0.3);
  touch-action: manipulation;
}

.presets button[aria-pressed='true'] {
  background: var(--ember);
  border-color: var(--ember);
  color: var(--night);
}

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.stats div {
  display: grid;
  gap: 1px;
  padding: 6px 8px;
  background: rgba(255, 242, 230, 0.05);
  border-top: 2px solid var(--ember);
  min-width: 0;
}

.stats dt {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats dd .delta-up {
  color: var(--good);
}

.stats dd .delta-down {
  color: var(--bad);
}

.stats-note {
  margin: -4px 0 0;
  font-size: 11px;
  color: var(--cream-dim);
}

.sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  min-width: 0;
}

.slider label {
  font-size: 13px;
  font-weight: 600;
}

.slider output {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.slider input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 2px 0;
  height: 28px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-y;
}

.slider input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(90deg, var(--pink), var(--ember) 50%, var(--cyan));
  border-radius: 2px;
}

.slider input[type='range']::-moz-range-track {
  height: 4px;
  background: linear-gradient(90deg, var(--pink), var(--ember) 50%, var(--cyan));
  border-radius: 2px;
}

.slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--cream);
  border: 3px solid var(--night);
  box-shadow: 0 0 0 1px var(--cream);
}

.slider input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cream);
  border: 3px solid var(--night);
}

.slider input[type='range']:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.slider .ends {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

/* ------------------------------------------------------- race HUD */
.pos {
  display: inline-flex;
  align-items: baseline;
  margin-right: 8px;
  padding: 0 8px;
  font-family: var(--display);
  font-weight: 900;
  color: var(--night);
  background: var(--ember);
  clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
}

#pos {
  font-size: 24px;
  line-height: 1.1;
}

.pos-of {
  font-size: 14px;
}

.gap {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.gap.ahead {
  color: var(--good);
}

.gap.behind {
  color: var(--bad);
}

/* --------------------------------------------------------- finish */
.finish-screen {
  display: flex;
  background: rgba(11, 6, 38, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.finish-panel {
  margin: auto;
  display: grid;
  gap: 12px;
  width: min(560px, 100%);
  padding: 20px;
  background: rgba(11, 6, 38, 0.85);
  border-top: 3px solid var(--ember);
}

.finish-place {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: 84px;
  line-height: 0.9;
  text-transform: uppercase;
  transform: skewX(-8deg);
  transform-origin: left bottom;
  background: linear-gradient(180deg, var(--sun), var(--ember) 55%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.finish-place.second {
  background: linear-gradient(180deg, var(--cream), #b8b0d8);
  -webkit-background-clip: text;
  background-clip: text;
}

.finish-line {
  margin: 0;
  font-size: 17px;
}

.results {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.results th,
.results td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--glass-edge);
}

.results thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.results td {
  font-family: var(--mono);
  font-size: 16px;
}

/* ------------------------------------------------------- responsive */

/* Touch: the bottom belongs to thumbs, so the speed cluster moves up. */
.touch-ui .hud-speed {
  top: var(--gutter-t);
  bottom: auto;
  background: linear-gradient(180deg, var(--glass), rgba(18, 8, 40, 0.1));
  border-bottom: 0;
  border-top: 3px solid var(--cyan);
  padding: 6px 12px 6px;
}

.touch-ui .speed {
  font-size: 50px;
}

.touch-ui .gmeter {
  width: 52px;
  height: 52px;
}

/* Short landscape phones. */
@media (max-height: 500px) {
  .hud-lap {
    padding: 6px 10px;
    min-width: 0;
  }
  .lap-time {
    font-size: 24px;
  }
  .lap-sub dd {
    font-size: 13px;
  }
  .minimap {
    width: 150px;
    height: 64px;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
  .toast {
    font-size: 21px;
    top: 30%;
  }
  .drift {
    top: 42%;
  }
  .title-grid {
    gap: 16px;
  }
  .title-head {
    gap: 8px;
  }
  .tagline {
    font-size: 14px;
  }
  .cta {
    font-size: 26px;
    padding: 10px 40px 10px 32px;
  }
  .online-btn {
    padding: 9px 22px;
    font-size: 21px;
  }
  .title-side {
    padding: 12px;
    gap: 10px;
  }
  .settings {
    gap: 8px;
  }
  .setting-note {
    display: none;
  }
  .seg button {
    min-height: 34px;
    padding: 3px 12px;
  }
  .track-card canvas {
    height: 34px;
  }
  .tabs button {
    min-height: 36px;
    font-size: 17px;
  }
  .finish-place {
    font-size: 60px;
  }
  .finish-panel {
    padding: 14px 18px;
    gap: 8px;
  }
  .stats dd {
    font-size: 15px;
  }
}

/* Portrait / narrow: stack everything. */
@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .title-screen {
    background: linear-gradient(180deg, rgba(11, 6, 38, 0.2) 0%, rgba(11, 6, 38, 0.75) 38%, rgba(11, 6, 38, 0.92) 100%);
  }
  .title-grid {
    grid-template-columns: minmax(0, 1fr);
    align-items: end;
    padding-block: 16px;
  }
  .logo {
    font-size: clamp(56px, 19vw, 120px);
  }
  .touch-ui .hud-speed {
    top: calc(var(--gutter-t) + 118px);
  }
  .minimap {
    width: 128px;
    height: 58px;
  }
  .hud-lap {
    min-width: 0;
  }
  .lap-time {
    font-size: 24px;
  }
  .steer-zone {
    width: 56%;
    height: 46%;
  }
  .pedals {
    grid-template-columns: 76px 80px;
    grid-template-rows: 50px 96px;
    gap: 10px;
  }
  .pad-btn.arrow {
    width: 74px;
    height: 74px;
  }
  .toast {
    font-size: 19px;
    top: 34%;
  }
  .drift {
    top: 44%;
  }
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sliders {
    grid-template-columns: minmax(0, 1fr);
  }
  .track-card .tc-name {
    font-size: 15px;
  }
  .finish-place {
    font-size: 64px;
  }
}

/* Wide but short (landscape phones): settings in two columns while paused. */
@media (min-width: 640px) and (max-height: 500px) {
  .pause-panel {
    padding: 14px 18px;
    gap: 12px;
  }
  .pause-panel h2 {
    font-size: 34px;
  }
  .pause-panel .settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
  }
  .pause-panel .setting {
    grid-template-columns: 74px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.in,
  .countdown.pulse,
  .tach.shift .tach-fill,
  .wrong-way {
    animation: none;
  }
}

/* ---------------------------------------------------- v2 additions */
.standings {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  min-width: 168px;
}
.st-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 8px;
  font-size: 14px;
  background: linear-gradient(90deg, rgba(18, 8, 40, 0.7), rgba(18, 8, 40, 0.15));
  border-left: 3px solid var(--c);
}
.st-row.you {
  background: linear-gradient(90deg, rgba(255, 154, 77, 0.35), rgba(18, 8, 40, 0.15));
}
.st-row.out {
  opacity: 0.4;
  text-decoration: line-through;
}
.st-pos {
  font-family: var(--display);
  font-weight: 900;
  font-size: 17px;
}
.st-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.st-gap {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
}
.hud-speed {
  grid-template-areas:
    'tach tach'
    'speed gm'
    'nitro gm'
    'aids gm';
}
.nitro {
  grid-area: nitro;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 4px;
}
.nitro .label {
  font-size: 10px;
  color: var(--cyan);
}
.nitro-bar {
  position: relative;
  flex: 1;
  height: 9px;
  min-width: 120px;
  background: rgba(255, 242, 230, 0.1);
  overflow: hidden;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}
.nitro-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #2f6bff, var(--cyan) 70%, #e6fdff);
  transition: transform 0.08s linear;
}
.nitro.full .nitro-fill {
  box-shadow: 0 0 12px var(--cyan);
  animation: shift-glow 1.2s ease-in-out infinite alternate;
}
.nitro.active .nitro-fill {
  background: linear-gradient(90deg, var(--pink), #ffb3ff 60%, #fff);
}
.medal {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  vertical-align: -0.05em;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.35), 0 0 8px currentColor;
}
.medal.m0 { background: #ffd23d; color: rgba(255, 210, 61, 0.6); }
.medal.m1 { background: #d8dcf0; color: rgba(216, 220, 240, 0.5); }
.medal.m2 { background: #d0874a; color: rgba(208, 135, 74, 0.5); }
.medal-targets {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--cream-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.track-cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.track-card .tc-name {
  font-size: 15px;
}
.car-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.car-card {
  display: grid;
  gap: 3px;
  align-content: start;
  padding: 8px;
  text-align: left;
  background: rgba(255, 242, 230, 0.04);
  border: 1px solid rgba(255, 242, 230, 0.18);
  touch-action: manipulation;
  min-width: 0;
}
.car-card[aria-pressed='true'] {
  border-color: var(--ember);
  background: rgba(255, 154, 77, 0.12);
  box-shadow: inset 0 -3px 0 var(--ember);
}
.cc-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.05;
  text-transform: uppercase;
}
.cc-blurb {
  font-size: 12px;
  line-height: 1.3;
  color: var(--cream-dim);
}
.cc-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
}
.pedals {
  grid-template-rows: 46px 52px 96px;
  grid-template-areas:
    'nos gas'
    'hand gas'
    'brake gas';
}
.pad-btn.nos {
  grid-area: nos;
  --edge: #6fa8ff;
  font-size: 12px;
}
.finish-panel {
  width: min(760px, 100%);
}
.results .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
  vertical-align: 1px;
}
.results tr.you th,
.results tr.you td {
  color: var(--sun);
}
.results th[scope='row'] {
  font-weight: 600;
  white-space: nowrap;
}
.results td.muted {
  color: var(--cream-dim);
  font-family: var(--ui);
  font-size: 13px;
}
.results td.pts {
  color: var(--good);
}
.cup-box {
  display: grid;
  gap: 6px;
}
.cup-box h3 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  text-transform: uppercase;
  color: var(--cyan);
}
@media (max-height: 500px) {
  .standings {
    gap: 1px;
    min-width: 126px;
  }
  .st-row {
    font-size: 11px;
    padding: 0 6px 0 5px;
    grid-template-columns: 16px 1fr auto;
  }
  .st-pos {
    font-size: 13px;
  }
  .st-gap {
    font-size: 11px;
  }
  .car-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cc-blurb {
    display: none;
  }
  .pedals {
    grid-template-rows: 40px 46px 84px;
  }
}
@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .track-cards,
  .car-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .standings {
    min-width: 118px;
  }
  .st-row {
    font-size: 12px;
    padding: 1px 6px 1px 5px;
  }
  .st-gap {
    display: none;
  }
  /* Portrait: speed cluster tucks under the map, right-aligned. */
  .touch-ui .hud-speed {
    top: calc(var(--gutter-t) + 114px);
    left: auto;
    right: var(--gutter-r);
    transform: scale(var(--ui-s, 1));
    transform-origin: top right;
    grid-template-columns: auto;
    grid-template-areas:
      'tach'
      'speed'
      'nitro'
      'aids';
  }
  .touch-ui .speed {
    font-size: 44px;
  }
  .touch-ui .gmeter {
    display: none;
  }
  .nitro-bar {
    min-width: 90px;
  }
  .toast {
    top: 41%;
    font-size: 17px;
    white-space: normal;
    text-align: center;
    max-width: calc(100vw - 48px);
  }
  .wrong-way {
    top: 41%;
  }
  .drift {
    top: 49%;
  }
  .results .col-car {
    display: none;
  }
}

/* ------------------------------------------- layout + scaling (v2.1) */
/* --ui-s is set from script: 1 on laptops and phones, bigger on large screens. */
.hud-left {
  position: absolute;
  top: var(--gutter-t);
  left: var(--gutter-l);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  transform: scale(var(--ui-s, 1));
  transform-origin: top left;
}
.hud-map {
  transform: scale(var(--ui-s, 1));
  transform-origin: top right;
}
.hud-speed {
  transform: translateX(-50%) scale(var(--ui-s, 1));
  transform-origin: bottom center;
}
.touch-ui .hud-speed {
  transform-origin: top center;
}
.toast,
.wrong-way,
.hint {
  transform: translateX(-50%) scale(var(--ui-s, 1));
  transform-origin: top center;
}
.drift {
  transform: translateX(-50%) skewX(-8deg) scale(var(--ui-s, 1));
  transform-origin: top center;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(calc(var(--ui-s, 1) * 0.92));
  }
}
.title-grid,
.pause-panel,
.finish-panel {
  zoom: var(--ui-s, 1);
}
.title-head,
.title-side {
  container-type: inline-size;
}
.logo {
  font-size: clamp(38px, min(15.5cqi, 19vh), 150px);
  padding-top: 0.06em;
}
.track-card .tc-name,
.car-card .cc-name {
  overflow-wrap: anywhere;
}
@container (min-width: 600px) {
  .track-cards {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .track-card canvas {
    height: 38px;
  }
}
@container (max-width: 560px) {
  .track-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .car-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container (max-width: 400px) {
  .track-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tabs button {
    font-size: 16px;
    padding: 6px 4px;
  }
  .setting {
    grid-template-columns: 64px minmax(0, 1fr);
  }
}
/* Results: table and cup side by side when there is room; buttons stay visible. */
.finish-body {
  display: grid;
  gap: 12px 22px;
  align-items: start;
}
.finish-body.with-cup {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}
.finish-panel {
  width: min(1000px, 100%);
}
.finish-panel .pause-actions {
  position: sticky;
  bottom: 0;
  padding: 10px 0 2px;
  background: linear-gradient(0deg, rgba(11, 6, 38, 0.97) 70%, rgba(11, 6, 38, 0));
}
@media (max-width: 760px) {
  .finish-body.with-cup {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 420px) {
  .results .col-best {
    display: none;
  }
}
@media (max-height: 560px) {
  .finish-place {
    font-size: 48px;
  }
  .finish-panel {
    padding: 10px 16px;
    gap: 6px;
  }
  .results th,
  .results td {
    padding: 3px 6px;
  }
  .results td {
    font-size: 14px;
  }
  .cup-box h3 {
    font-size: 17px;
    margin: 0;
  }
}
/* Short landscape phones: keep the top band clear for the speed cluster. */
@media (max-height: 500px) {
  .toast {
    top: calc(var(--gutter-t) + 118px);
    font-size: 16px;
    white-space: normal;
    text-align: center;
    max-width: min(46vw, 420px);
  }
  .touch-ui .speed {
    font-size: 42px;
  }
  .wrong-way {
    top: 46%;
    font-size: 28px;
  }
  .drift {
    top: 56%;
  }
}
@media (max-height: 420px) {
  .drift-total {
    display: none;
  }
  .touch-ui .gmeter {
    display: none;
  }
  .touch-ui .hud-speed {
    grid-template-areas:
      'tach tach'
      'speed speed'
      'nitro nitro'
      'aids aids';
    padding: 4px 10px;
  }
  .lap-time {
    font-size: 21px;
  }
}
@media (max-height: 500px) {
  .touch-ui .toast {
    max-width: max(150px, calc(100vw - 2 * (var(--gutter-r) + 218px)));
    font-size: 15px;
  }
}
@media (max-height: 380px) {
  .finish-panel .cta {
    font-size: 18px;
    padding: 6px 26px 6px 22px;
  }
  .finish-panel .ghost-btn {
    min-height: 34px;
    padding: 4px 12px;
  }
  .finish-place {
    font-size: 36px;
  }
  .finish-line {
    font-size: 14px;
  }
  .finish-panel .eyebrow {
    font-size: 10px;
  }
}
@media (max-height: 360px) {
  .minimap {
    width: 120px;
    height: 50px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  .pedals {
    grid-template-rows: 34px 40px 72px;
    gap: 8px;
  }
}

/* ---------------------------------------------------------- combat */
.combat-box {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 4px 12px 4px 10px;
  background: linear-gradient(90deg, rgba(18, 8, 40, 0.72), rgba(18, 8, 40, 0.2));
  border-left: 3px solid var(--good);
  font-family: var(--mono);
}
.cb-money { color: var(--good); font-size: 19px; }
.cb-money.bump { animation: shift-glow 0.4s ease-in-out 2 alternate; }
.cb-kills { color: var(--cream-dim); font-size: 14px; }
.hull { grid-area: hull; display: flex; align-items: center; gap: 8px; }
.hull .label { font-size: 10px; color: var(--pink); }
.hull-bar {
  position: relative;
  flex: 1;
  height: 10px;
  min-width: 110px;
  background: rgba(255, 242, 230, 0.1);
  overflow: hidden;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}
.hull-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: #7dffb0;
  transition: transform 0.12s linear, background-color 0.2s;
}
.hull.mid .hull-fill { background: #ffd23d; }
.hull.low .hull-fill { background: #ff3d6a; animation: shift-glow 1s ease-in-out infinite alternate; }
.hull-num { font-family: var(--mono); font-size: 13px; min-width: 28px; text-align: right; }
.weap {
  grid-area: weap;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.weap-pri { color: var(--cyan); }
.weap-sec { color: var(--sun); }
body.combat-on .hud-speed {
  grid-template-areas:
    'tach tach'
    'speed gm'
    'hull gm'
    'weap weap'
    'nitro nitro'
    'aids aids';
}
.kill-feed {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
  justify-items: end;
}
.kill-feed li {
  padding: 2px 8px;
  font-size: 13px;
  background: rgba(18, 8, 40, 0.66);
  border-right: 3px solid var(--pink);
  white-space: nowrap;
  animation: feed-fade 4.5s forwards;
}
.kill-feed li.mine { border-right-color: var(--good); color: var(--good); }
.kill-feed li.me { border-right-color: var(--warn); color: var(--warn); }
@keyframes feed-fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}
.hp-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hpbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: 5px;
  margin-left: -23px;
  background: rgba(10, 4, 30, 0.7);
  border: 1px solid rgba(255, 242, 230, 0.35);
  will-change: transform;
}
.hpbar i {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: var(--c, #7dffb0);
}
.reticle {
  position: absolute;
  left: 0;
  top: 0;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 2px solid var(--pink);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--pink), inset 0 0 8px rgba(255, 46, 136, 0.5);
  pointer-events: none;
  will-change: transform;
}
.reticle::before,
.reticle::after {
  content: '';
  position: absolute;
  background: var(--pink);
}
.reticle::before { left: 50%; top: -9px; width: 2px; height: 12px; margin-left: -1px; }
.reticle::after { top: 50%; left: -9px; width: 12px; height: 2px; margin-top: -1px; }
.reticle.lock { border-color: var(--sun); box-shadow: 0 0 12px var(--sun); }
/* City Run: wanted level, distance to the nearest unit, evade/bust meters. */
.pursuit-on #standings,
.pursuit-on .hud-lap { display: none; }
.chase-hud {
  position: absolute;
  left: 50%;
  top: calc(var(--gutter-t, 12px) + 8px);
  transform: translateX(-50%);
  width: min(340px, 78vw);
  box-sizing: border-box;
  padding: 10px 14px 12px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 6px;
  pointer-events: none;
  font-family: var(--display);
  color: var(--cream);
}
.ch-top { display: flex; align-items: baseline; gap: 10px; }
.ch-label { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cream-dim); }
.ch-heat { font-size: 20px; color: var(--sun); letter-spacing: 2px; }
.ch-time { margin-left: auto; font-family: 'Share Tech Mono', monospace; font-size: 18px; }
.ch-near { font-family: 'Chakra Petch', sans-serif; font-size: 13px; margin: 2px 0 8px; color: var(--cream-dim); white-space: nowrap; }
.ch-meter { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 10px; margin-top: 6px; }
.ch-mlabel { font-family: 'Chakra Petch', sans-serif; font-weight: 700; font-size: 12px; line-height: 1; letter-spacing: 0.1em; text-transform: uppercase; }
.ch-evade .ch-mlabel { color: #7affc8; }
.ch-bust .ch-mlabel { color: #ff8a7a; }
.ch-track { position: relative; height: 10px; background: rgba(255, 242, 230, 0.12); border: 1px solid rgba(255, 242, 230, 0.16); border-radius: 6px; overflow: hidden; }
.ch-track i { position: absolute; inset: 0; border-radius: 6px; transform-origin: left center; transform: scaleX(0); transition: transform 0.15s linear; }
.ch-evade i { background: linear-gradient(90deg, #1fbf7c, #7affc8); }
.ch-bust i { background: linear-gradient(90deg, #b81a24, #ff6a5a); }
/* In the cockpit the car's own dials show speed, revs and gear. */
.cockpit-cam .hud-speed .speed-row,
.cockpit-cam .hud-speed .tach,
.cockpit-cam .hud-speed .gmeter,
.cockpit-cam .hud-speed .aids {
  display: none;
}
.reticle.locking { border-color: var(--sun); border-style: dashed; box-shadow: none; }
.msl-warn {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(200, 32, 40, 0.82);
  border: 1px solid rgba(255, 242, 230, 0.4);
  pointer-events: none;
}
.hit-mark {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  opacity: 0;
  pointer-events: none;
  background:
    linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%);
  -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px);
  mask: radial-gradient(circle, transparent 7px, #000 8px);
}
.hit-mark.on { animation: hitmark 0.2s ease-out; }
.hit-mark.kill { background:
    linear-gradient(45deg, transparent 43%, var(--pink) 43%, var(--pink) 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--pink) 43%, var(--pink) 57%, transparent 57%); }
@keyframes hitmark {
  from { opacity: 1; transform: scale(1.3); }
  to { opacity: 0; transform: scale(0.9); }
}
.pad-btn.fire { grid-area: fire; --edge: #ff3d6a; }
.pad-btn.alt { grid-area: alt; --edge: #ffd23d; font-size: 11px; }
body.combat-on .pedals {
  grid-template-columns: 76px 92px 96px;
  grid-template-areas:
    'fire nos gas'
    'fire hand gas'
    'alt brake gas';
}
.earnings { margin: 0; font-family: var(--mono); font-size: 15px; color: var(--good); }
.earnings b { color: var(--sun); font-weight: 400; }
.bank {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid rgba(125, 255, 176, 0.35);
  background: rgba(125, 255, 176, 0.07);
}
.bank-label { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cream-dim); }
/* Garage: a studio turntable showing the car you have picked. */
.garage-bank { margin-bottom: 10px; }
.car-preview {
  position: relative;
  height: 230px;
  margin-bottom: 10px;
  border: 1px solid var(--glass-edge);
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, #2a2440 0%, #120d22 55%, #07050f 100%);
}
.car-preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.car-preview canvas:active { cursor: grabbing; }
.cp-info { position: absolute; left: 12px; top: 10px; display: grid; gap: 2px; pointer-events: none; }
.cp-name { font-family: var(--display); font-weight: 900; font-size: 24px; line-height: 1; text-transform: uppercase; }
.cp-meta { font-family: 'Share Tech Mono', monospace; font-size: 13px; color: var(--cyan); }
.cp-action { position: absolute; right: 12px; bottom: 10px; display: flex; align-items: center; gap: 10px; }
.cp-state { font-family: var(--display); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--good); }
.cp-state.locked { color: var(--sun); }
.cp-hint { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: var(--cream-dim); pointer-events: none; }
.car-card.viewing { border-color: var(--sun); border-style: dashed; }
.cc-price { font-family: 'Share Tech Mono', monospace; font-size: 12px; color: var(--sun); }
.cc-price.owned { color: var(--good); }
.bank-money { font-family: var(--mono); font-weight: 400; font-size: 26px; color: var(--good); }
.arm-h {
  margin: 4px 0 -2px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cyan);
}
.arm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.arm-card {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 8px;
  min-width: 0;
  background: rgba(255, 242, 230, 0.04);
  border: 1px solid rgba(255, 242, 230, 0.18);
}
.arm-card.equipped { border-color: var(--good); box-shadow: inset 0 -3px 0 var(--good); }
.arm-card .a-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.05;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.arm-card .a-blurb { font-size: 12px; line-height: 1.3; color: var(--cream-dim); }
.arm-card .a-stats { font-family: var(--mono); font-size: 12px; color: var(--cyan); }
.arm-card button,
.arm-armor button {
  margin-top: 2px;
  min-height: 34px;
  padding: 4px 8px;
  font: 600 13px/1 var(--ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(255, 242, 230, 0.08);
  border: 1px solid rgba(255, 242, 230, 0.3);
  touch-action: manipulation;
}
.arm-card button.buy,
.arm-armor button.buy { color: #0b0626; background: var(--good); border-color: var(--good); }
.arm-card button:disabled,
.arm-armor button:disabled { opacity: 0.45; }
.arm-armor { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.arm-pips { display: flex; gap: 5px; }
.arm-pips i { flex: 1; height: 10px; background: rgba(255, 242, 230, 0.12); }
.arm-pips i.on { background: var(--good); box-shadow: 0 0 8px rgba(125, 255, 176, 0.5); }
.arm-armor .a-stats { grid-column: 1 / -1; font-family: var(--mono); font-size: 13px; color: var(--cream-dim); }
@container (max-width: 560px) {
  .arm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 500px) {
  body.combat-on .pedals { grid-template-columns: 64px 76px 80px; }
  .kill-feed li { font-size: 11px; }
  .cb-money { font-size: 16px; }
  .touch-ui .hull-bar { min-width: 80px; }
}
@media (max-height: 420px) {
  body.combat-on .touch-ui .hud-speed,
  body.combat-on.touch-ui .hud-speed {
    grid-template-areas:
      'tach tach'
      'speed speed'
      'hull hull'
      'weap weap'
      'nitro nitro'
      'aids aids';
  }
  .weap { font-size: 10px; }
}
@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  body.combat-on.touch-ui .hud-speed {
    grid-template-areas:
      'tach'
      'speed'
      'hull'
      'weap'
      'nitro'
      'aids';
  }
  body.combat-on .pedals { grid-template-columns: 60px 70px 80px; }
}

.wrecked {
  position: absolute;
  left: 50%;
  top: 30%;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: translateX(-50%) scale(var(--ui-s, 1));
  transform-origin: top center;
  pointer-events: none;
  text-align: center;
}
.wrecked span {
  font-family: var(--display);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(38px, 9vmin, 84px);
  line-height: 0.9;
  text-transform: uppercase;
  color: #ff3d6a;
  text-shadow: 0 0 18px rgba(255, 61, 106, 0.8), 0 3px 0 #2a0820;
  animation: wreck-in 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.wrecked small {
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 0 1px 3px #000;
}
@keyframes wreck-in {
  from { transform: scale(1.6); opacity: 0; }
}
@media (max-height: 500px) {
  .kill-feed li:nth-child(n + 3) { display: none; }
  .wrecked { top: 47%; }
}
@media (max-height: 360px) {
  .kill-feed li:nth-child(n + 2) { display: none; }
}
@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .wrecked { top: 50%; }
}

/* ------------------------------------------------- instructions tab */
.lbl-short { display: none; }
@container (max-width: 520px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
}
.tabs button {
  font-size: 17px;
  padding: 6px 6px;
  white-space: nowrap;
}
.guide {
  display: grid;
  gap: 16px;
}
.g-sec {
  display: grid;
  gap: 8px;
}
.g-steps,
.g-tips {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--cream);
}
.g-steps li::marker {
  font-family: var(--display);
  font-weight: 900;
  color: var(--sun);
}
.g-tips li::marker {
  color: var(--pink);
}
.g-steps b,
.g-tips b,
.g-list dt {
  color: var(--sun);
  font-weight: 600;
}
.g-keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.g-keys th,
.g-keys td {
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 242, 230, 0.1);
}
.g-keys thead th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.g-keys tbody th {
  font-weight: 600;
  white-space: nowrap;
  color: var(--cream);
}
.g-keys td {
  color: var(--cream-dim);
}
.g-keys kbd {
  font-size: 12px;
}
.g-list {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-size: 14px;
  line-height: 1.45;
}
.g-list dd {
  margin: 0;
  color: var(--cream-dim);
}
.g-note {
  margin: 0;
  font-size: 13px;
  color: var(--cyan);
}
.g-lamp {
  padding: 0 5px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0b0626;
  background: var(--sun);
}
@container (max-width: 470px) {
  .g-keys .col-pad { display: none; }
  .g-list { grid-template-columns: 1fr; gap: 2px; }
  .g-list dd { margin-bottom: 6px; }
  .g-keys tbody th { white-space: normal; }
}
/* the guide inside the pause panel */
.pause-guide {
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding-right: 6px;
  container-type: inline-size;
}

/* five tabs must always fit on one line */
.tabs {
  min-width: 0;
}
.tabs button {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
@container (max-width: 470px) {
  .tabs button {
    flex: 1 1 auto;
    font-size: 14px;
    letter-spacing: 0.03em;
    padding: 6px 2px;
  }
}
@container (max-width: 340px) {
  .tabs button {
    font-size: 12.5px;
    letter-spacing: 0;
  }
}
@container (max-width: 290px) {
  .tabs { gap: 0; }
  .tabs button {
    font-size: 11.5px;
    padding: 6px 1px;
  }
}
.title-side,
.tab-panel,
.guide,
.g-sec {
  min-width: 0;
}
