:root {
  --ink: #0f172a;
  --navy: #1e293b;
  --cream: #fffbeb;
  --green: #22c55e;
  --green-dark: #15803d;
  --gold: #facc15;
  --gold-dark: #ca8a04;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --pink: #ec4899;
  --pink-dark: #be185d;
  --blue: #38bdf8;
  --blue-dark: #0284c7;
  --teal: #14b8a6;
  --teal-dark: #0f766e;
  --bite-color: #22c55e;
  --bite-glow: rgba(34, 197, 94, 0.55);
}

body.cb-mode {
  --bite-color: #38bdf8;
  --bite-glow: rgba(56, 189, 248, 0.65);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f172a;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: #ffffff;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

.stage-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.fx-canvas {
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* ========================================= */
/* SHARED PILLS & SEGMENTED TOGGLES          */
/* (garage coins, pause shifter switch)      */
/* ========================================= */

.stat-pill {
  background: rgba(15, 23, 42, 0.86);
  border: 2px solid #334155;
  border-radius: 999px;
  padding: 4px 11px;
  font-weight: 900;
  font-size: 0.85rem;
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.6);
  white-space: nowrap;
}

.diff-toggle {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #334155;
  border-radius: 999px;
  padding: 3px;
  flex: 1;
  min-width: fit-content;
}

.diff-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, transform 0.08s;
}

.diff-btn:active {
  transform: scale(0.95);
}

.diff-btn.selected {
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
  color: #0f172a;
  box-shadow: 0 2px 0 #0369a1, inset 0 1.5px 0 rgba(255, 255, 255, 0.55);
}

.shifter-toggle .diff-btn.selected {
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: #0f172a;
  box-shadow: 0 2px 0 #b45309, inset 0 1.5px 0 rgba(255, 255, 255, 0.6);
}

@media (hover: hover) {
  .btn-pill:hover,
  .icon-btn:hover,
  .setting-toggle:hover {
    filter: brightness(1.06);
  }
}

/* ========================================= */
/* GAMEPLAY HUD & ANALOG PEDALS              */
/* ========================================= */
.hud-layout {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.hud-top-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

/* Three columns with equal side tracks keep the progress rail (or Endless title) dead-centre,
   however wide the left cluster gets (Tsubi card, heat gauges, strikes...). */
.hud-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-top-left,
.hud-top-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.hud-top-left {
  grid-column: 1;
  justify-self: start;
}

.hud-top > .hud-center-title,
.hud-top > .progress-rail {
  grid-column: 2;
  grid-row: 1;
}

.hud-top-right {
  grid-column: 3;
  justify-self: end;
  justify-content: flex-end;
}

/* Endless has no rail: the long left cluster (distance, timer, strikes...) gets its natural width
   and the small mode label centres in whatever room is left, so nothing wraps to a second row. */
.hud-top:has(> .progress-rail.hidden) {
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr) auto;
}

.hud-top:has(> .progress-rail.hidden) > .hud-center-title {
  justify-self: center;
}

.hud-center-title {
  background: rgba(15, 23, 42, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 900;
  font-size: 0.86rem;
  color: #fde68a;
  white-space: nowrap;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 2.5px solid #0f172a;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.94));
  color: #f8fafc;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #0f172a, inset 0 1.5px 0 rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0f172a, inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.hud-pill {
  background: rgba(15, 23, 42, 0.88);
  border: 2.5px solid #334155;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 900;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.6);
}

.dist-pill {
  font-size: 1.12rem;
  min-width: 78px;
  text-align: center;
}

/* Live Animated TSUBI Chibi Reaction Bubble */
.tsubi-bubble-card {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.88);
  border: 2.5px solid #38bdf8;
  border-radius: 999px;
  padding: 2px 12px 2px 3px;
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.65);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s;
}

.tsubi-bubble-card canvas {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: block;
}

.tsubi-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.tsubi-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.72rem;
  color: #fde047;
  letter-spacing: 0.05em;
}

.tsubi-mood {
  font-size: 0.68rem;
  font-weight: 900;
  color: #e2e8f0;
  white-space: nowrap;
}

.tsubi-bubble-card.mood-perfect {
  border-color: #facc15;
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.6);
}

.tsubi-bubble-card.mood-hillstart {
  border-color: #38bdf8;
}

.tsubi-bubble-card.mood-stalled {
  border-color: #ef4444;
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.65);
}

/* Phone landscape: compact Tsubi card (portrait + mood only) so the top bar keeps room for the rail */
@media (max-height: 500px) {
  .tsubi-bubble-card {
    gap: 5px;
    padding: 2px 9px 2px 2px;
  }
  .tsubi-bubble-card canvas {
    width: 34px;
    height: 34px;
  }
  .tsubi-name {
    display: none;
  }
  .tsubi-mood {
    font-size: 0.62rem;
  }
}

.streak-pill {
  border-color: #f59e0b;
  color: #fde047;
  transition: transform 0.15s;
}

.streak-pill.hot {
  background: linear-gradient(180deg, #f97316, #c2410c);
  color: #ffffff;
  transform: scale(1.06);
}

.hud-pill.danger {
  border-color: #ef4444;
  background: #991b1b;
  animation: pulseFast 0.55s infinite alternate;
}

.coffee-pill {
  border-color: #d97706;
  background: #78350f;
}

.heat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  padding: 5px 11px;
  border-color: #f59e0b;
}

.heat-pill.critical {
  border-color: #ef4444;
  background: #991b1b;
  animation: pulseFast 0.35s infinite alternate;
}

.mini-meter {
  width: 44px;
  height: 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
  display: inline-block;
}

.mini-meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #facc15, #f97316, #ef4444);
  transition: width 0.08s linear;
}

.gear-pill {
  border-color: #22c55e;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trans-tag {
  font-family: 'Nunito', sans-serif;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: rgba(56, 189, 248, 0.18);
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
  border-radius: 6px;
  padding: 1px 5px;
}

.gear-word {
  font-size: 0.78rem;
  color: #cbd5e1;
  letter-spacing: 0.04em;
}

.gear-pill .gear-num {
  color: #4ade80;
  font-size: 1.32rem;
  min-width: 1ch;
  text-align: center;
}

/* Circular RPM Tachometer + Shift Light LED */
.tachometer {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.tach-shift-led {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #0f172a;
  z-index: 4;
  transition: background 0.08s, box-shadow 0.08s;
}

.tach-shift-led.sweet {
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80, 0 0 18px rgba(74, 222, 128, 0.85);
}

.tach-shift-led.redline {
  background: #ef4444;
  box-shadow: 0 0 12px #ef4444, 0 0 22px rgba(239, 68, 68, 0.95);
  animation: ledBlink 0.18s infinite alternate;
}

.tach-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.55));
}

.rpm-needle {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 3.5px;
  height: 27px;
  margin-left: -1.75px;
  background: linear-gradient(180deg, #f87171 0%, #f8fafc 32%);
  border-radius: 99px;
  transform-origin: bottom center;
  transform: rotate(-125deg);
  transition: transform 0.04s linear;
}

.rpm-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #facc15;
  border: 2px solid #0f172a;
}

.rpm-readout {
  position: absolute;
  bottom: 9px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 900;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

/* Contextual Coach Banner */
.coach-pill {
  align-self: center;
  background: rgba(15, 23, 42, 0.88);
  border: 2.5px solid #facc15;
  border-radius: 999px;
  padding: 7px 18px;
  font-weight: 900;
  font-size: clamp(0.8rem, 1.8vw, 0.96rem);
  color: #fef08a;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.45);
  text-align: center;
}

/* Panic Crank Push-to-Start Ignition Button */
.crank-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  /* Right-thumb zone: just inboard of the GAS rail, sitting right above the BRAKE (the shifter
     isn't needed while stalled, so the panel may cover it). Left thumb stays on the clutch. */
  align-items: flex-end;
  justify-content: flex-end;
  padding-right: calc(max(14px, env(safe-area-inset-right)) + clamp(86px, 12vw, 100px) + 8px);
  padding-bottom: calc(max(12px, env(safe-area-inset-bottom)) + 72px);
  pointer-events: none;
  z-index: 12;
}

/* Ignition panel: a little dashboard card holding either a key barrel or a push-button */
.crank-btn {
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 168px;
  padding: 10px 10px 12px;
  border-radius: 26px;
  border: 4px solid #0f172a;
  background: linear-gradient(180deg, #334155 0%, #1e293b 55%, #0f172a 100%);
  color: #ffffff;
  cursor: pointer;
  /* 'none', not 'manipulation': manipulation still allows pinch-zoom, which the two-thumb restart
     (clutch + key) was triggering on iPhone */
  touch-action: none;
  box-shadow:
    0 8px 0 #020617,
    0 16px 32px rgba(15, 23, 42, 0.65),
    inset 0 2px 0 rgba(255, 255, 255, 0.18);
}

.crank-btn::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 32px;
  border: 4px solid #facc15;
  animation: ringPulseGold 0.65s infinite;
  pointer-events: none;
}

.crank-btn.cranking::after,
.crank-btn.fired::after {
  animation: none;
  opacity: 0;
}

.crank-btn.cranking {
  animation: ign-panel-shake 0.16s linear infinite;
}

/* Dash tell-tales: off until the key reaches ON, out again once the engine fires */
.ign-dash {
  display: flex;
  gap: 8px;
  font-style: normal;
}

.ign-tell {
  font-style: normal;
  font-weight: 900;
  font-size: 0.78rem;
  width: 20px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #475569;
  background: #0f172a;
  transition: color 0.12s, text-shadow 0.12s;
}

.crank-btn.turning .ign-tell,
.crank-btn.cranking .ign-tell,
.crank-btn.deny .ign-tell {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.9);
}

.crank-btn.turning .ign-tell.oil,
.crank-btn.cranking .ign-tell.oil,
.crank-btn.deny .ign-tell.oil {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.9);
}

.crank-btn.cranking .ign-tell {
  animation: ign-flicker 0.16s steps(2) infinite;
}

/* ---- Key barrel ---- */
.ign-barrel {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #f1f5f9 0%, #94a3b8 45%, #475569 100%);
  border: 4px solid #0f172a;
  box-shadow: inset 0 -4px 8px rgba(15, 23, 42, 0.45), 0 3px 0 #020617;
}

.ign-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #1e293b;
  transform-origin: 0 0;
}

/* Marks sit on a 40px radius at the key's stop angles (0deg = straight up) */
.ign-mark.m-off { transform: rotate(-60deg) translate(-50%, -41px); }
.ign-mark.m-acc { transform: rotate(-20deg) translate(-50%, -41px); }
.ign-mark.m-on { transform: rotate(20deg) translate(-50%, -41px); }
.ign-mark.m-start { transform: rotate(62deg) translate(-50%, -41px); color: #b91c1c; }

.ign-slot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: radial-gradient(circle, #1e293b 0%, #334155 70%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* The key pivots on the barrel centre: OFF -60deg, ON 20deg, START 62deg */
.ign-key {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: rotate(-60deg);
  transition: transform 0.14s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.ign-key-blade {
  position: absolute;
  left: -3px;
  top: -12px;
  width: 6px;
  height: 24px;
  border-radius: 2px;
  background: linear-gradient(90deg, #cbd5e1, #f8fafc, #94a3b8);
}

.ign-key-head {
  position: absolute;
  left: -15px;
  top: -30px;
  width: 30px;
  height: 56px;
  border-radius: 13px 13px 15px 15px;
  background: linear-gradient(180deg, #334155 0%, #0f172a 100%);
  border: 3px solid #020617;
  box-shadow: 0 3px 0 rgba(2, 6, 23, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.ign-key-hole {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.crank-btn.turning .ign-key,
.crank-btn.cranking .ign-key {
  transform: rotate(62deg);
}

.crank-btn.cranking .ign-key-head {
  animation: ign-key-strain 0.16s linear infinite;
}

/* Fired: the key springs back from START to ON */
.crank-btn.fired .ign-key {
  transform: rotate(20deg);
  transition: transform 0.22s cubic-bezier(0.2, 1.8, 0.4, 1);
}

/* Clutch not in: key turns to START, starter just clicks, key springs back */
.crank-btn.deny .ign-key {
  animation: ign-key-deny 0.42s ease-out;
}

/* ---- Push button ---- */
.ign-push {
  display: none;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  place-items: center;
  background: radial-gradient(circle at 40% 30%, #64748b 0%, #1e293b 70%);
  border: 4px solid #0f172a;
  box-shadow: inset 0 -4px 8px rgba(2, 6, 23, 0.6), 0 3px 0 #020617;
}

.ign-push-cap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #e2e8f0;
  background: radial-gradient(circle at 40% 30%, #475569 0%, #0f172a 80%);
  box-shadow: 0 0 0 3px #f59e0b, 0 0 12px rgba(245, 158, 11, 0.55), 0 4px 0 #020617;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.ign-push-txt {
  font-size: 0.5rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-align: center;
}

.crank-btn[data-ignition='button'] .ign-barrel {
  display: none;
}

.crank-btn[data-ignition='button'] .ign-push {
  display: grid;
}

.crank-btn.turning .ign-push-cap,
.crank-btn.cranking .ign-push-cap,
.crank-btn.deny .ign-push-cap {
  transform: translateY(3px) scale(0.95);
}

.crank-btn.cranking .ign-push-cap {
  animation: ign-push-ring 0.16s linear infinite;
}

.crank-btn.fired .ign-push-cap {
  box-shadow: 0 0 0 3px #22c55e, 0 0 16px rgba(34, 197, 94, 0.8), 0 4px 0 #020617;
}

.crank-btn.deny .ign-push-cap {
  animation: crank-deny 0.32s ease-in-out;
}

.crank-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.45);
}

.crank-sub {
  font-weight: 900;
  font-size: 0.7rem;
  color: #fef08a;
  line-height: 1.2;
  text-align: center;
  min-height: 2.4em; /* two lines reserved so the panel doesn't jump as instructions change */
}

.crank-sub.warn {
  color: #fca5a5;
}

@keyframes crank-deny {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(7px);
  }
}

@keyframes ign-key-deny {
  0% {
    transform: rotate(20deg);
  }
  35%,
  55% {
    transform: rotate(62deg);
  }
  100% {
    transform: rotate(20deg);
  }
}

@keyframes ign-key-strain {
  0%,
  100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2deg);
  }
}

@keyframes ign-panel-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-1.5px, 1px);
  }
  75% {
    transform: translate(1.5px, -1px);
  }
}

@keyframes ign-flicker {
  50% {
    opacity: 0.45;
  }
}

@keyframes ign-push-ring {
  0%,
  100% {
    box-shadow: 0 0 0 3px #f59e0b, 0 0 8px rgba(245, 158, 11, 0.5), 0 4px 0 #020617;
  }
  50% {
    box-shadow: 0 0 0 4px #fbbf24, 0 0 20px rgba(251, 191, 36, 0.95), 0 4px 0 #020617;
  }
}

/* Short phones (e.g. 667x375): compact ignition so it clears the top bar */
@media (max-height: 400px) {
  .ign-dash {
    display: none;
  }

  .ign-barrel,
  .ign-push {
    width: 84px;
    height: 84px;
  }

  .ign-push-cap {
    width: 66px;
    height: 66px;
  }

  .ign-mark {
    font-size: 0.5rem;
  }

  .ign-mark.m-off { transform: rotate(-60deg) translate(-50%, -34px); }
  .ign-mark.m-acc { transform: rotate(-20deg) translate(-50%, -34px); }
  .ign-mark.m-on { transform: rotate(20deg) translate(-50%, -34px); }
  .ign-mark.m-start { transform: rotate(62deg) translate(-50%, -34px); }

  .crank-title {
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crank-btn.cranking,
  .crank-btn.cranking .ign-key-head,
  .crank-btn.cranking .ign-tell,
  .crank-btn.cranking .ign-push-cap {
    animation: none;
  }
}

/* ========================================= */
/* CARTOON DIE-CAST FOOTWELL & SHIFTER HUD   */
/* ========================================= */
.hud-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.left-thumb-cluster,
.right-thumb-cluster {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.right-mid-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Die-Cast Pedal Housings (Clutch & Gas) */
.pedal-housing {
  position: relative;
  width: clamp(86px, 12vw, 100px);
  height: clamp(216px, 47vh, 272px);
  padding: 28px 9px 26px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 3.5px solid #0f172a;
  border-radius: 22px;
  touch-action: none;
  cursor: ns-resize;
  overflow: visible;
  box-shadow:
    0 7px 0 rgba(15, 23, 42, 0.75),
    0 14px 26px rgba(15, 23, 42, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.16);
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.gas-housing {
  width: clamp(74px, 10.2vw, 86px);
}

/* Generous invisible thumb cushion so fingers never slip off glass! */
.pedal-housing::before {
  content: '';
  position: absolute;
  inset: -14px -16px;
  z-index: 0;
}

.pedal-header,
.pedal-footer {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #cbd5e1;
  pointer-events: none;
  z-index: 2;
}

.pedal-header {
  top: 6px;
}

.gas-header {
  color: #fde047;
}

.pedal-footer {
  bottom: 5px;
  color: #f8fafc;
}

.clutch-housing .pedal-footer {
  color: #fde047;
}

.pedal-channel {
  position: relative;
  flex: 1;
  width: 100%;
  border-radius: 13px;
  background: linear-gradient(90deg, #090e1a 0%, #151f33 50%, #090e1a 100%);
  border: 2px solid rgba(148, 163, 184, 0.22);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.82);
  overflow: visible;
  perspective: 260px;
}

/* Steel Mechanical Pedal Arms */
.pedal-rod {
  position: absolute;
  left: 50%;
  width: 13px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #475569 0%, #e2e8f0 42%, #94a3b8 68%, #334155 100%);
  border-left: 2px solid #0f172a;
  border-right: 2px solid #0f172a;
  pointer-events: none;
  z-index: 1;
}

.clutch-rod {
  top: 0;
  height: 16%;
  border-radius: 0 0 4px 4px;
}

.gas-rod {
  bottom: 0;
  height: 18%;
  border-radius: 4px 4px 0 0;
}

/* Dynamic Car-Specific Bite Zone Window */
.bite-zone-band {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 22%;
  height: 56%;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.36), rgba(34, 197, 94, 0.16));
  border-top: 2.5px solid var(--bite-color);
  border-bottom: 2.5px solid var(--bite-color);
  border-radius: 9px;
  pointer-events: none;
  z-index: 1;
}

body.cb-mode .bite-zone-band {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.18), rgba(56, 189, 248, 0.4), rgba(56, 189, 248, 0.18));
}

.bite-zone-tag {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #bbf7d0;
  text-shadow: 0 1px 3px #0f172a;
  opacity: 0.92;
}

body.cb-mode .bite-zone-tag {
  color: #bae6fd;
}

.floor-detent-line {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 27.2%;
  border-bottom: 1.5px dashed rgba(250, 204, 21, 0.45);
  pointer-events: none;
  z-index: 1;
}

/* Warm Throttle Fill (Gold -> Amber -> Redline) */
.gas-fill {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 0%;
  max-height: calc(100% - 4px);
  border-radius: 9px;
  background: linear-gradient(0deg, rgba(250, 204, 21, 0.3) 0%, rgba(249, 115, 22, 0.58) 65%, rgba(239, 68, 68, 0.8) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Sculpted Die-Cast Pedal Pads */
.pedal-pad {
  position: absolute;
  left: 50%;
  bottom: 12%;
  z-index: 3;
  pointer-events: none;
  border: 3px solid #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, 50%) rotateX(calc(var(--press, 0) * 18deg)) scale(calc(1 - var(--press, 0) * 0.05));
  transition: background 0.1s ease, border-color 0.1s ease;
  will-change: transform, bottom;
}

.clutch-pad {
  width: calc(100% - 6px);
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 20%, #475569 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #1e293b,
    0 9px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
  padding: 5px;
}

.gas-pad {
  width: calc(100% - 8px);
  height: 62px;
  border-radius: 13px 13px 10px 10px;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 32%, #b45309 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #78350f,
    0 9px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
  padding: 6px;
}

/* Rubber Grip Treads */
.pedal-tread {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: repeating-linear-gradient(
    180deg,
    #1e293b 0px,
    #1e293b 5px,
    #334155 5px,
    #334155 9px
  );
  border: 2px solid #0f172a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.gas-tread {
  background: repeating-linear-gradient(
    90deg,
    #451a03 0px,
    #451a03 5px,
    #92400e 5px,
    #92400e 9px
  );
  border-color: #451a03;
}

.pedal-holes {
  display: none;
  width: 100%;
  height: 100%;
  grid-template-columns: repeat(3, 1fr);
  place-items: center;
  padding: 2px;
}

.gas-holes {
  grid-template-columns: repeat(2, 1fr);
}

.pedal-holes span,
.brake-holes span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f172a;
  box-shadow: inset 0 1.5px 2px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Heel-Toe Blip Extension Tab (Hidden by default; shown on Turbo Coupe Rally spec!) */
.heel-toe-tab {
  display: none;
  position: absolute;
  left: -10px;
  bottom: 4px;
  width: 13px;
  height: 22px;
  border-radius: 6px 0 0 8px;
  background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 100%);
  border: 2.5px solid #0f172a;
  border-right: none;
  box-shadow: 0 3px 0 #334155;
}

/* Dynamic Clutch & Gas Telemetry States */
.clutch-housing.in-bite {
  box-shadow:
    0 7px 0 rgba(15, 23, 42, 0.75),
    0 0 0 3px var(--bite-color),
    0 0 26px var(--bite-glow),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.clutch-housing.in-bite .clutch-pad {
  border-color: var(--bite-color);
  box-shadow:
    0 calc(5px - var(--press, 0) * 3px) 0 #14532d,
    0 0 18px var(--bite-glow),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
}

.clutch-housing.lugging {
  box-shadow: 0 7px 0 rgba(15, 23, 42, 0.75), 0 0 0 3px #ef4444, 0 0 24px rgba(239, 68, 68, 0.78);
  animation: lugShudder 0.14s infinite;
}

.clutch-housing.needs-clutch::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  border: 3.5px solid #facc15;
  animation: ringPulseGold 0.75s infinite;
  pointer-events: none;
}

.clutch-housing.grind-flash {
  box-shadow: 0 7px 0 rgba(15, 23, 42, 0.75), 0 0 0 3.5px #fb923c, 0 0 28px rgba(249, 115, 22, 0.9);
  animation: lugShudder 0.1s 4;
}

.clutch-housing.clutch-hot .clutch-pad {
  border-color: #f97316;
  box-shadow: 0 4px 0 #9a3412, 0 0 18px rgba(249, 115, 22, 0.85);
}

.gas-housing.wheelspin {
  box-shadow: 0 7px 0 rgba(15, 23, 42, 0.75), 0 0 0 3px #f59e0b, 0 0 22px rgba(245, 158, 11, 0.8);
}

/* ========================================= */
/* BRAKE PEDAL + PRO HANDBRAKE (P) LED       */
/* ========================================= */
/* "Press this one": pulsing glow on the control the coach hint is talking about */
.cue {
  outline: 3px solid #facc15;
  outline-offset: 3px;
  animation: cue-pulse 0.8s ease-in-out infinite;
}

@keyframes cue-pulse {
  0%,
  100% {
    outline-color: rgba(250, 204, 21, 0.95);
    outline-offset: 3px;
  }
  50% {
    outline-color: rgba(250, 204, 21, 0.35);
    outline-offset: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cue {
    animation: none;
  }
}

/* Invisible touch-area growth so small top-bar icons reach ~44px without changing the layout */
.icon-btn::before {
  content: '';
  position: absolute;
  inset: -5px -3px;
}

/* Hold-to-restart: a ring sweeps round the button while held */
.hold-btn .hold-ring {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: conic-gradient(#facc15 calc(var(--hold, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}

@property --hold {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

.hold-btn.holding .hold-ring {
  opacity: 1;
  animation: hold-fill 0.5s linear forwards;
}

@keyframes hold-fill {
  from {
    --hold: 0;
  }
  to {
    --hold: 1;
  }
}

.brake-pedal {
  position: relative;
  width: clamp(96px, 13.5vw, 116px);
  height: 62px;
  padding: 6px 10px;
  border-radius: 15px;
  border: 3.5px solid #0f172a;
  background: linear-gradient(180deg, #fca5a5 0%, #ef4444 18%, #b91c1c 100%);
  color: #ffffff;
  font-family: 'Fredoka', sans-serif;
  cursor: pointer;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow:
    0 6px 0 #7f1d1d,
    0 10px 18px rgba(15, 23, 42, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

/* Live brake-pressure gauge along the pedal's bottom edge (fed by --brake-press 0..1) */
.brake-pedal::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fde68a, #ffffff);
  transform-origin: left center;
  transform: scaleX(var(--brake-press, 0));
  opacity: calc(var(--brake-press, 0) * 1.6);
  pointer-events: none;
}

.brake-pedal.active,
.brake-pedal:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #7f1d1d,
    0 4px 8px rgba(15, 23, 42, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brake-tread-top,
.brake-tread-bot {
  width: 78%;
  height: 5px;
  border-radius: 3px;
  background: rgba(69, 10, 10, 0.78);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.28);
}

.brake-holes {
  display: none;
  gap: 8px;
}

.brake-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 1.5px 0 rgba(69, 10, 10, 0.7);
}

.handbrake-led {
  position: absolute;
  top: -8px;
  right: -7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid #0f172a;
  background: #334155;
  color: #94a3b8;
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 #0f172a;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.handbrake-led.latched {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 2px 0 #7f1d1d, 0 0 14px rgba(239, 68, 68, 0.9);
}

/* ========================================= */
/* DUAL-MODE SHIFTER DOCK (PADDLES + H-GATE) */
/* ========================================= */
.shifter-dock {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.shift-paddles-view {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shift-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shift-paddle {
  position: relative;
  width: 82px;
  height: 46px;
  padding: 0 10px;
  border-radius: 14px;
  border: 3px solid #0f172a;
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  touch-action: none;
  box-shadow:
    0 5px 0 #0f172a,
    0 8px 14px rgba(15, 23, 42, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.shift-paddle:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0f172a, inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.shift-paddle.clutch-ready {
  border-color: #38bdf8;
  box-shadow:
    0 5px 0 #0369a1,
    0 0 12px rgba(56, 189, 248, 0.45),
    inset 0 2px 0 rgba(186, 230, 253, 0.35);
}

.shift-paddle.shift-glow {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #052e16;
  border-color: #0f172a;
  box-shadow:
    0 5px 0 #14532d,
    0 0 18px rgba(74, 222, 128, 0.75),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

.shift-paddle.shift-glow::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 17px;
  border: 3px solid #4ade80;
  animation: ringPulseGreen 0.75s infinite;
  pointer-events: none;
}

.shift-paddle.shift-glow .paddle-lbl {
  color: #052e16;
  opacity: 0.78;
}

.shift-paddle.shift-glow .paddle-gear {
  background: rgba(5, 46, 22, 0.2);
  color: #052e16;
}

.shift-paddle.at-limit {
  opacity: 0.48;
}

.shift-paddle.grind-flash {
  border-color: #fb923c;
  animation: lugShudder 0.1s 3;
}

.paddle-arrow {
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
}

.paddle-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.paddle-lbl {
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #94a3b8;
  line-height: 1;
}

.paddle-gear {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  background: rgba(15, 23, 42, 0.55);
  padding: 1px 5px;
  border-radius: 5px;
  color: #e2e8f0;
}

/* Mini Live H-Gate Telemetry Diagram (beside Paddles) */
.mini-h-schematic {
  width: 54px;
  height: 98px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.96));
  border: 3px solid #0f172a;
  box-shadow: 0 5px 0 rgba(15, 23, 42, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.14);
  padding: 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.mini-h-title {
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

/* Interactive Magnetic H-Pattern Gate Shifter */
.hgate-bezel {
  width: 144px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 3.5px solid #0f172a;
  box-shadow:
    0 6px 0 rgba(15, 23, 42, 0.78),
    0 12px 22px rgba(15, 23, 42, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.18);
  padding: 6px 8px 8px;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.hgate-bezel.clutch-ready {
  box-shadow:
    0 6px 0 rgba(15, 23, 42, 0.78),
    0 0 0 2.5px #38bdf8,
    0 0 16px rgba(56, 189, 248, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.hgate-bezel.grind-flash {
  box-shadow: 0 6px 0 rgba(15, 23, 42, 0.78), 0 0 0 3px #fb923c, 0 0 22px rgba(249, 115, 22, 0.85);
  animation: lugShudder 0.1s 4;
}

.hgate-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  padding: 0 2px;
}

.hgate-spec-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

.hgate-clutch-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #475569;
  border: 1.5px solid #0f172a;
  transition: background 0.1s, box-shadow 0.1s;
}

.hgate-clutch-led.ready {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.hgate-board::before {
  /* Touch area a little bigger than the gate (not downward, toward BRAKE). Gear choice uses the
     nearest column and clamps to the board, so overshooting the edge still picks the right gear. */
  content: '';
  position: absolute;
  inset: -10px -8px -2px -8px;
}

/* First-time hint: shows how the stick moves until the first successful gate shift */
.hgate-drag-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: #facc15;
  color: #0f172a;
  font-weight: 900;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  animation: hgate-hint-bob 0.9s ease-in-out infinite alternate;
  z-index: 3;
}

@keyframes hgate-hint-bob {
  from {
    transform: translate(-50%, 0);
  }
  to {
    transform: translate(-50%, -3px);
  }
}

.hgate-board {
  position: relative;
  width: 124px;
  height: 92px;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 50%, #1e293b 0%, #090e1a 100%);
  border: 2px solid rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.88);
  touch-action: none;
  cursor: grab;
  overflow: visible;
}

.hgate-board:active {
  cursor: grabbing;
}

.hgate-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hgate-slots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hgate-slot-lbl.neutral {
  font-size: 0.55rem;
  opacity: 0.55;
}

.hgate-slot-lbl {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, background 0.1s, transform 0.1s;
}

.hgate-slot-lbl.active-gear {
  color: #4ade80;
}

.hgate-slot-lbl.suggested-gear {
  color: #052e16;
  background: #4ade80;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.9);
  transform: translate(-50%, -50%) scale(1.12);
}

.hgate-slot-lbl.reverse-dec {
  color: #64748b;
  font-size: 0.62rem;
  opacity: 0.75;
}

/* Tactile Car-Specific Shift Knob */
.hgate-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #0f172a;
  background: radial-gradient(circle at 32% 28%, #f8fafc, #94a3b8);
  box-shadow: 0 5px 0 rgba(15, 23, 42, 0.85), 0 7px 14px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  transition: left 0.085s cubic-bezier(0.22, 1, 0.36, 1), top 0.085s cubic-bezier(0.22, 1, 0.36, 1);
}

.hgate-knob.dragging {
  transition: none;
  transform: translate(-50%, -50%) scale(1.08);
}

.hgate-knob-text {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1.5px 2px rgba(15, 23, 42, 0.9);
}

/* ========================================= */
/* CAR-SPECIFIC ENTHUSIAST HARDWARE SKINS    */
/* ========================================= */

/* 1. CLASSIC MINI COOPER: Chrome-Trimmed British Rubber + Walnut Cue-Ball */
[data-car='mini'] .clutch-pad {
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 35%, #64748b 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #334155,
    0 9px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 #ffffff;
}
[data-car='mini'] .gas-pad {
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 30%, #64748b 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #334155,
    0 9px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 #ffffff;
}
[data-car='mini'] .gas-tread {
  background: repeating-linear-gradient(90deg, #111827 0px, #111827 4px, #374151 4px, #374151 8px);
  border-color: #0f172a;
}
[data-car='mini'] .brake-pedal {
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 16%, #dc2626 17%, #b91c1c 100%);
}
[data-car='mini'] .hgate-knob {
  background: radial-gradient(circle at 30% 26%, #d97706 0%, #92400e 42%, #451a03 100%);
  box-shadow: 0 5px 0 #290e02, 0 8px 14px rgba(0, 0, 0, 0.65), inset 0 2px 3px rgba(254, 243, 199, 0.55);
}

/* 2. RUSTY '88 WAGON: Scuffed Commuter Rubber + Diagonal Treads + '80s Urethane Knob */
[data-car='chugger'] .clutch-pad,
[data-car='chugger'] .gas-pad {
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #090e1a,
    0 9px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
[data-car='chugger'] .pedal-tread {
  background: repeating-linear-gradient(-38deg, #111827 0px, #111827 4px, #334155 4px, #334155 8px);
}
[data-car='chugger'] .clutch-pad::after,
[data-car='chugger'] .brake-pedal::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 11px;
  border-radius: 3px 2px 6px 2px;
  background: linear-gradient(135deg, #cbd5e1 0%, #64748b 100%);
  opacity: 0.72;
  pointer-events: none;
}
[data-car='chugger'] .hgate-knob {
  border-radius: 10px;
  background: linear-gradient(180deg, #3f3f46 0%, #18181b 100%);
  box-shadow: 0 5px 0 #09090b, 0 7px 14px rgba(0, 0, 0, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.22);
}
[data-car='chugger'] .hgate-knob-text {
  color: #fde68a;
}

/* 3. SCOOP SHIFT VAN: Waffle Bus Floor Pedals + Strawberry-Cream Swirl Pool-Ball Knob */
[data-car='icecream'] .clutch-pad,
[data-car='icecream'] .gas-pad {
  border-radius: 16px;
  background: linear-gradient(180deg, #fff1f2 0%, #fda4af 42%, #fb7185 100%);
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #9f1239,
    0 9px 14px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 #ffffff;
}
[data-car='icecream'] .pedal-tread {
  background-color: #3b0764;
  background-image:
    linear-gradient(90deg, rgba(255, 228, 230, 0.22) 1.5px, transparent 1.5px),
    linear-gradient(180deg, rgba(255, 228, 230, 0.22) 1.5px, transparent 1.5px);
  background-size: 8px 8px;
}
[data-car='icecream'] .hgate-knob {
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #fbcfe8 38%, #f43f5e 100%);
  box-shadow: 0 5px 0 #9f1239, 0 8px 14px rgba(0, 0, 0, 0.6), inset 0 2px 2px #ffffff;
}
[data-car='icecream'] .hgate-knob-text {
  color: #0f172a;
  text-shadow: none;
}

/* 4. TURBO COUPE (RALLY 6MT): Drilled CNC Alloy + Heel-Toe Tab + Billet Gate + Titanium Knob */
[data-car='rally'] .clutch-pad,
[data-car='rally'] .gas-pad {
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 44%, #e2e8f0 64%, #64748b 100%);
  border-color: #0f172a;
  box-shadow:
    0 calc(6px - var(--press, 0) * 4px) 0 #1e3a8a,
    0 9px 14px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px #2563eb,
    inset 0 2px 0 #ffffff;
}
[data-car='rally'] .pedal-tread {
  display: none;
}
[data-car='rally'] .pedal-holes {
  display: grid;
}
[data-car='rally'] .heel-toe-tab {
  display: block;
}
[data-car='rally'] .brake-pedal {
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 48%, #94a3b8 100%);
  border-color: #dc2626;
  color: #991b1b;
  box-shadow:
    0 6px 0 #991b1b,
    0 10px 18px rgba(15, 23, 42, 0.55),
    inset 0 2px 0 #ffffff;
}
[data-car='rally'] .brake-pedal.active,
[data-car='rally'] .brake-pedal:active {
  box-shadow: 0 2px 0 #991b1b, 0 4px 8px rgba(15, 23, 42, 0.45);
}
[data-car='rally'] .brake-tread-top,
[data-car='rally'] .brake-tread-bot {
  display: none;
}
[data-car='rally'] .brake-holes {
  display: flex;
}
[data-car='rally'] .brake-label {
  color: #b91c1c;
  text-shadow: none;
  background: rgba(255, 255, 255, 0.72);
  padding: 1px 6px;
  border-radius: 5px;
}
[data-car='rally'] .hgate-bezel {
  background: linear-gradient(155deg, #475569 0%, #1e293b 55%, #0f172a 100%);
  border-color: #0f172a;
}
[data-car='rally'] .hgate-board {
  background: linear-gradient(145deg, #cbd5e1 0%, #94a3b8 50%, #64748b 100%);
  border-color: #0f172a;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.55), inset 0 -3px 6px rgba(15, 23, 42, 0.45);
}
[data-car='rally'] .hgate-slot-lbl {
  color: #0f172a;
}
[data-car='rally'] .hgate-slot-lbl.active-gear {
  color: #1d4ed8;
}
[data-car='rally'] .hgate-knob {
  background: radial-gradient(circle at 32% 25%, #ffffff 0%, #cbd5e1 45%, #475569 100%);
  border-color: #facc15;
  box-shadow: 0 5px 0 #0f172a, 0 8px 14px rgba(0, 0, 0, 0.65), inset 0 0 0 2px #0f172a;
}
[data-car='rally'] .hgate-knob-text {
  color: #0f172a;
  text-shadow: none;
}

/* ========================================= */
/* STALL / VICTORY APPLE-ARCADE SCORECARD    */
/* ========================================= */
.summary-backdrop,
.modal-backdrop {
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}

.summary-card {
  width: min(440px, 96vw);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 20px 22px 16px;
  text-align: center;
  box-shadow: 0 14px 0 rgba(15, 23, 42, 0.35), 0 26px 50px rgba(15, 23, 42, 0.55);
  position: relative;
}

.summary-body {
  display: flex;
  flex-direction: column;
}

.summary-badge {
  display: inline-block;
  margin-top: -10px;
  padding: 7px 22px;
  border-radius: 999px;
  border: 3.5px solid var(--ink);
  color: #ffffff;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  box-shadow: 0 4px 0 rgba(15, 23, 42, 0.35);
}

.summary-badge.stall {
  background: linear-gradient(180deg, #fb923c, #ea580c);
}

.summary-badge.win {
  background: linear-gradient(180deg, #4ade80, #16a34a);
}

.summary-distance {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.2rem;
  line-height: 1.05;
  margin-top: 8px;
  color: var(--ink);
}

.summary-reason {
  margin: 4px 0 12px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #475569;
}

.gap-progress-wrap {
  margin-bottom: 12px;
}

.gap-bar {
  position: relative;
  height: 16px;
  background: #e2e8f0;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  overflow: visible;
}

.gap-bar-fill {
  height: 100%;
  width: 60%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4ade80, #16a34a);
  transition: width 0.4s ease;
}

.gap-flag {
  position: absolute;
  right: -4px;
  top: -12px;
  font-size: 1.15rem;
}

.gap-text {
  margin-top: 6px;
  font-weight: 900;
  font-size: 0.86rem;
  color: #15803d;
}

.emoji-box {
  background: #fef3c7;
  border: 2px solid #fde68a;
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 14px;
}

.emoji-strip {
  font-size: 1.45rem;
  letter-spacing: 0.12em;
}

.summary-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 900;
  color: #475569;
}

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

.btn-pill {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 16px;
  cursor: pointer;
  color: #ffffff;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.1s ease;
}

.btn-retry {
  font-size: 1.25rem;
  padding: 13px 26px;
  background: linear-gradient(180deg, #4ade80, #16a34a);
  box-shadow: 0 5px 0 #14532d, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.btn-retry:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #14532d, inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-gold {
  color: var(--ink);
  background: linear-gradient(180deg, #fde047, #eab308);
  box-shadow: 0 4px 0 #a16207, inset 0 2px 0 rgba(255, 255, 255, 0.45);
}
.btn-gold:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a16207;
}

.btn-blue {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  box-shadow: 0 4px 0 #075985, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.btn-blue:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #075985;
}

.btn-green {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  box-shadow: 0 4px 0 #14532d, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.btn-green:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #14532d;
}

.btn-muted {
  background: #94a3b8;
  box-shadow: 0 3px 0 #475569;
}
.btn-muted:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #475569;
}

.btn-locked {
  background: #cbd5e1;
  color: #64748b;
  box-shadow: 0 3px 0 #94a3b8;
}

.link-home {
  margin-top: 10px;
  background: none;
  border: none;
  color: #64748b;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

/* ========================================= */
/* GARAGE & LEVELS MODALS                    */
/* ========================================= */
.modal-card {
  width: min(640px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 26px;
  padding: 18px 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.6);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
}

.garage-grid,
.levels-grid {
  display: grid;
  gap: 10px;
}

.garage-card,
.level-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 3px solid #cbd5e1;
  border-radius: 18px;
  padding: 12px 14px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}

.garage-card.selected {
  border-color: #22c55e;
  background: #f0fdf4;
}

.garage-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.garage-info {
  flex: 1;
}

.garage-info h3 {
  margin: 0;
  font-size: 1.05rem;
}

.garage-info p {
  margin: 2px 0 6px;
  font-size: 0.82rem;
  color: #475569;
  font-weight: 700;
}

.garage-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 900;
  color: #0284c7;
}

.garage-stats span {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  padding: 2px 7px;
}

.garage-stats .stat-trans {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

.garage-stats .stat-redline {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.garage-stats .stat-hw {
  background: #fef9c3;
  border-color: #fde047;
  color: #854d0e;
}

.level-num {
  background: #facc15;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.level-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.level-meta strong {
  font-size: 1rem;
}

.level-meta span {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 700;
}

.level-stars {
  font-size: 1.25rem;
  color: #f59e0b;
  flex-shrink: 0;
}

@keyframes pulseFast {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.06);
  }
}

@keyframes ringPulseGreen {
  0% {
    opacity: 0.95;
    transform: scale(0.98);
  }
  100% {
    opacity: 0;
    transform: scale(1.13);
  }
}

@keyframes ringPulseGold {
  0% {
    opacity: 0.95;
    transform: scale(0.99);
  }
  100% {
    opacity: 0;
    transform: scale(1.09);
  }
}

@keyframes lugShudder {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2.5px);
  }
  75% {
    transform: translateX(2.5px);
  }
}

@keyframes ledBlink {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.45;
  }
}

/* One-time "plays best sideways" tip (main.js _syncRotateTip toggles .hidden). Sits over the 3D scene
   in the middle of the hub so it never covers the top bar or the dock. */
.rotate-banner {
  display: flex;
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  background: rgba(15, 23, 42, 0.94);
  border: 2.5px solid #facc15;
  color: #fef08a;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 900;
  align-items: center;
  gap: 10px;
  width: min(92vw, 380px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.rotate-banner button {
  background: #facc15;
  color: #0f172a;
  border: none;
  border-radius: 10px;
  padding: 5px 10px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
}

/* Landscape-only runs: full-screen gate over the paused game on upright touch devices */
.rotate-gate {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
}

.rotate-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 320px;
  text-align: center;
  color: #e2e8f0;
}

.rotate-gate-phone {
  width: 54px;
  height: 92px;
  border: 4px solid #facc15;
  border-radius: 12px;
  position: relative;
  margin-bottom: 8px;
  animation: rotate-gate-turn 2.2s ease-in-out infinite;
}

.rotate-gate-phone span {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 14px;
  height: 4px;
  border-radius: 999px;
  background: #facc15;
  transform: translateX(-50%);
}

.rotate-gate-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: #fef08a;
}

.rotate-gate-sub {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  color: #cbd5e1;
}

.rotate-gate .link-home {
  color: #cbd5e1;
  font-size: 0.95rem;
}

@keyframes rotate-gate-turn {
  0%,
  20% {
    transform: rotate(0deg);
  }
  55%,
  85% {
    transform: rotate(-90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-gate-phone {
    animation: none;
    transform: rotate(-90deg);
  }
}

/* ========================================= */
/* SETTINGS & PAUSE SHEETS                   */
/* ========================================= */
.modal-compact {
  width: min(500px, 95vw);
}

.modal-pause-card {
  width: min(360px, 92vw);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  border: 2.5px solid #cbd5e1;
  border-radius: 15px;
  padding: 9px 12px;
}

.settings-label {
  font-weight: 900;
  font-size: 0.86rem;
  color: var(--ink);
}

.settings-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ON = filled green "lit" switch; OFF (.is-off) = quiet white outline. Labels read "Name: State". */
.setting-toggle {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  padding: 6px 12px;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.78rem;
  text-shadow: 0 1px 0 rgba(15, 23, 42, 0.3);
  cursor: pointer;
  box-shadow: 0 3px 0 #14532d;
  transition: transform 0.06s, box-shadow 0.06s, background 0.12s;
}

.setting-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #14532d;
}

.setting-toggle.is-off {
  background: #ffffff;
  color: #64748b;
  border-color: #cbd5e1;
  text-shadow: none;
  box-shadow: 0 3px 0 #e2e8f0;
}

.setting-toggle.is-off:active {
  box-shadow: 0 1px 0 #e2e8f0;
}

.controls-guide-box {
  background: #fef3c7;
  border: 2.5px solid #fde047;
  border-radius: 16px;
  padding: 10px 12px;
}

.guide-heading {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: #92400e;
  margin-bottom: 6px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.guide-item {
  background: #ffffff;
  border: 1.5px solid #fde68a;
  border-radius: 11px;
  padding: 8px 10px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: #334155;
}

.guide-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.guide-item p {
  margin: 0;
  font-weight: 700;
}

.guide-item code {
  background: #0f172a;
  color: #fde047;
  padding: 1px 5px;
  border-radius: 5px;
  font-weight: 900;
  font-size: 0.72rem;
}

.pause-quick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  border: 2.5px solid #cbd5e1;
  border-radius: 15px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.pause-quick-row .diff-toggle {
  flex: 0 0 auto;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
}

.pause-sub-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ========================================= */
/* 4-TIER MULTI-DEVICE RESPONSIVE RULES      */
/* ========================================= */

/* Tier 1: Compact Tablet / Narrow Desktop */
@media (max-width: 900px) {
  .gear-word {
    display: none;
  }
}

/* Tier 2: Compact Mobile Width */
@media (max-width: 720px) {
  .hud-center-title,
  .horn-btn {
    display: none;
  }
  .tachometer {
    width: 54px;
    height: 54px;
  }
  .rpm-needle {
    height: 20px;
  }
  .rpm-readout {
    bottom: 6px;
    font-size: 0.6rem;
  }
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

/* Tier 3: Phone Landscape (Short Viewports e.g. 844×390, 667×375) */
@media (max-height: 500px) {
  .stat-pill {
    padding: 3px 9px;
    font-size: 0.76rem;
  }

  .diff-btn {
    font-size: 0.68rem;
    padding: 4px 8px;
  }

  /* Gameplay HUD: slim top bar + scaled pedals leaving >=50% clear road */
  .hud-layout {
    padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(7px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .hud-top-stack {
    gap: 4px;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .hud-pill {
    padding: 4px 9px;
    font-size: 0.82rem;
  }
  .gear-pill .gear-num {
    font-size: 1.08rem;
  }
  .tachometer {
    width: 48px;
    height: 48px;
  }
  .rpm-needle {
    height: 18px;
  }
  .rpm-readout {
    bottom: 5px;
    font-size: 0.56rem;
  }
  .progress-rail {
    padding: 4px 9px 5px;
    gap: 3px;
    min-width: 170px;
  }
  .rail-header {
    font-size: 0.7rem;
  }
  .rail-clock {
    font-size: 0.8rem;
  }
  .coach-pill {
    padding: 4px 12px;
    font-size: 0.74rem;
  }
  .pedal-housing {
    width: 74px;
    height: clamp(146px, 44dvh, 184px);
    padding: 21px 7px 20px;
    border-radius: 17px;
  }
  .gas-housing {
    width: 64px;
  }
  .pedal-header,
  .pedal-footer {
    font-size: 0.58rem;
  }
  .clutch-pad {
    height: 38px;
  }
  .gas-pad {
    height: 48px;
  }
  .right-mid-column {
    gap: 12px; /* keeps DOWNSHIFT / the gate clear of BRAKE so a panic stop can't hit the wrong one */
  }
  .shift-stack {
    gap: 6px;
  }
  .shift-paddle {
    width: 76px;
    height: 44px; /* 44pt minimum touch target */
    padding: 0 8px;
    border-radius: 12px;
  }
  .mini-h-schematic {
    width: 46px;
    height: 77px;
  }
  .hgate-bezel {
    width: 122px;
    padding: 4px 6px 6px;
    border-radius: 14px;
  }
  .hgate-board {
    width: 104px;
    height: 72px;
  }
  .hgate-knob {
    width: 24px;
    height: 24px;
  }
  .brake-pedal {
    width: 88px;
    height: 46px;
    border-radius: 12px;
  }
  .brake-label {
    font-size: 0.72rem;
  }

  /* Landscape-Safe 2-Column Summary Card (RETRY never clips!) */
  .summary-card {
    width: min(620px, 95vw);
    padding: 12px 16px 10px;
    border-radius: 22px;
  }
  .summary-badge {
    margin-top: -4px;
    padding: 4px 16px;
    font-size: 1rem;
  }
  .summary-body {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 14px;
    align-items: center;
    margin-top: 6px;
  }
  .summary-distance {
    font-size: 2.3rem;
    margin-top: 0;
  }
  .summary-reason {
    margin: 3px 0 8px;
    font-size: 0.8rem;
  }
  .gap-progress-wrap,
  .emoji-box {
    margin-bottom: 8px;
  }
  .emoji-box {
    padding: 7px;
  }
  .emoji-strip {
    font-size: 1.15rem;
  }
  .btn-retry {
    font-size: 1.05rem;
    padding: 9px 18px;
  }
  .btn-pill {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
  .link-home {
    margin-top: 6px;
  }
}

/* Tier 4: Phone Portrait (e.g. 390×844) */
@media (orientation: portrait) and (max-width: 680px) {
  /* Portrait: one column — left cluster, then right cluster, then the full-width rail/title */
  .hud-top,
  .hud-top:has(> .progress-rail.hidden) {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .hud-top-right {
    grid-column: 1;
    grid-row: 2;
  }
  .hud-top > .hud-center-title,
  .hud-top > .progress-rail,
  .hud-top:has(> .progress-rail.hidden) > .hud-center-title {
    grid-column: 1;
    grid-row: 3;
    justify-self: stretch;
  }
  .hud-top > .hud-center-title {
    justify-self: center;
  }
  .progress-rail {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 5px 10px 6px;
  }
  .pedal-housing {
    width: 68px;
    height: 190px;
    padding: 24px 6px 22px;
  }
  .gas-housing {
    width: 60px;
  }
  .clutch-pad {
    height: 40px;
  }
  .gas-pad {
    height: 50px;
  }
  .mini-h-schematic {
    display: none;
  }
  .shift-paddle {
    width: 72px;
    height: 40px;
    padding: 0 7px;
  }
  .hgate-bezel {
    width: 118px;
    padding: 5px 6px 6px;
  }
  .hgate-board {
    width: 100px;
    height: 78px;
  }
  .hgate-knob {
    width: 24px;
    height: 24px;
  }
  .brake-pedal {
    width: 78px;
    height: 52px;
  }
  .brake-label {
    font-size: 0.72rem;
  }
}

/* ========================================= */
/* TIME TRIAL PAR TARGETS, DELTAS & PB UI    */
/* ========================================= */
.par-pill {
  border-color: #38bdf8;
  color: #e0f2fe;
  font-variant-numeric: tabular-nums;
}

.par-pill.under-par {
  border-color: #22c55e;
}

.par-pill.over-par {
  border-color: #f59e0b;
  color: #fde68a;
}

.par-target {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-left: 3px;
}

.split-delta {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  padding: 5px 12px;
  animation: pulseFast 0.35s 2 alternate;
}

.split-delta.ahead {
  border-color: #22c55e;
  background: rgba(21, 128, 61, 0.92);
  color: #dcfce7;
}

.split-delta.behind {
  border-color: #ef4444;
  background: rgba(153, 27, 27, 0.92);
  color: #fee2e2;
}

body.cb-mode .split-delta.ahead {
  border-color: #38bdf8;
  background: rgba(3, 105, 161, 0.92);
  color: #e0f2fe;
}

body.cb-mode .split-delta.behind {
  border-color: #f97316;
  background: rgba(194, 65, 12, 0.92);
  color: #ffedd5;
}

.summary-time-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}

.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e2e8f0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.time-chip.par-chip {
  background: #dbeafe;
  color: #1e3a8a;
}

.time-chip.par-beat {
  background: #dcfce7;
  color: #14532d;
}

.pb-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, #fde047, #f59e0b);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--ink);
}

.level-time-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 0.74rem;
  font-weight: 900;
  color: #0284c7;
}

.level-time-meta .best-tag {
  color: #15803d;
}

/* ========================================= */
/* CONCEPT B: COMMUTE PROGRESS RAIL + GHOST  */
/* ========================================= */
.progress-rail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: clamp(210px, 32vw, 350px);
  max-width: 390px;
  background: rgba(15, 23, 42, 0.86);
  border: 2.5px solid #334155;
  border-radius: 16px;
  padding: 6px 12px 7px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.45);
  transition: border-color 0.18s;
}

.progress-rail.under-par {
  border-color: #22c55e;
}

.progress-rail.over-par {
  border-color: #f59e0b;
}

.progress-rail.cutoff-danger {
  border-color: #ef4444;
  background: rgba(127, 29, 29, 0.9);
  animation: pulseFast 0.55s infinite alternate;
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.1;
}

.rail-title {
  color: #fde68a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Rail owns the centre grid column now, so the name can breathe ("L6 · Rainy Cobblestones") */
  max-width: 200px;
}

.rail-clock {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: #ffffff;
}

.rail-clock-target {
  font-size: 0.72rem;
  color: #94a3b8;
}

.progress-rail.cutoff-danger .rail-clock {
  color: #fecaca;
}

.rail-delta {
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.rail-delta.ahead {
  background: rgba(21, 128, 61, 0.92);
  color: #dcfce7;
}

.rail-delta.behind {
  background: rgba(153, 27, 27, 0.92);
  color: #fee2e2;
}

.rail-delta.flash {
  transform: scale(1.14);
}

body.cb-mode .rail-delta.ahead {
  background: rgba(3, 105, 161, 0.92);
  color: #e0f2fe;
}

body.cb-mode .rail-delta.behind {
  background: rgba(194, 65, 12, 0.92);
  color: #ffedd5;
}

.rail-track-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rail-track {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.9);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
}

.rail-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
}

.rail-lights {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rail-light-pip {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1.5px solid #0f172a;
  background: #ef4444;
  z-index: 2;
}

.rail-light-pip.yellow {
  background: #facc15;
}

.rail-light-pip.green {
  background: #22c55e;
}

.rail-light-pip.next {
  box-shadow: 0 0 0 2px #ffffff, 0 0 10px 2px rgba(239, 68, 68, 0.85);
  animation: pip-glow 0.7s ease-in-out infinite alternate;
}

@keyframes pip-glow {
  from {
    box-shadow: 0 0 0 2px #ffffff, 0 0 4px 1px rgba(239, 68, 68, 0.6);
  }
  to {
    box-shadow: 0 0 0 2px #ffffff, 0 0 12px 4px rgba(239, 68, 68, 0.95);
  }
}

/* Signal-ahead heads-up pinned to the right edge (where the light will appear) */
.signal-ahead {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: 36%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 2.5px solid #ef4444;
  color: #fee2e2;
  font-weight: 900;
  font-size: clamp(0.78rem, 1.7vw, 0.92rem);
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.45);
  pointer-events: none;
  z-index: 6;
}

.signal-ahead-lamp {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  border-radius: 5px;
  background: #0f172a;
}

.signal-ahead-lamp i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #334155;
}

.signal-ahead.red .signal-ahead-lamp i:nth-child(1),
.signal-ahead.yellow .signal-ahead-lamp i:nth-child(1) {
  background: #ef4444;
}

.signal-ahead.yellow .signal-ahead-lamp i:nth-child(2) {
  background: #facc15;
}

.signal-ahead-arrow {
  color: #f87171;
  animation: signal-nudge 0.6s ease-in-out infinite alternate;
}

.signal-ahead.brake {
  background: #dc2626;
  border-color: #ffffff;
  color: #ffffff;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  animation: signal-pulse 0.32s ease-in-out infinite alternate;
}

.signal-ahead.brake .signal-ahead-arrow {
  display: none;
}

@keyframes signal-pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

@keyframes signal-nudge {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .signal-ahead,
  .signal-ahead-arrow,
  .rail-light-pip.next {
    animation: none !important;
  }
}

.rail-light-pip.passed {
  opacity: 0.4;
}

.rail-pin {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -55%);
  font-size: 0.9rem;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

.rail-ghost-pin {
  opacity: 0.78;
  z-index: 3;
  font-size: 0.8rem;
}

.rail-player-pin {
  z-index: 4;
}

.rail-goal-label {
  font-size: 0.7rem;
  font-weight: 900;
  color: #cbd5e1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-height: 500px) {
  .progress-rail {
    padding: 4px 9px 5px;
    gap: 3px;
    min-width: clamp(150px, 28vw, 240px);
  }
  .rail-header {
    font-size: 0.7rem;
  }
  .rail-title {
    max-width: 150px;
  }
  /* Endless: the mode label is redundant on phones (Pause names it); its column goes to the controls */
  .hud-top > .hud-center-title {
    display: none;
  }
  .rail-clock {
    font-size: 0.8rem;
  }
}

/* ========================================= */
/* AAA GHOST RECORDS, SPLITS & TIME HISTORY  */
/* ========================================= */
.rail-delta.purple {
  background: rgba(126, 34, 206, 0.95);
  color: #f3e8ff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.75);
}

.summary-ghost-compare {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px auto 6px;
  padding: 4px 12px;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  font-size: 0.78rem;
  font-weight: 900;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.summary-ghost-compare .ahead {
  color: #15803d;
}

.summary-ghost-compare .behind {
  color: #b91c1c;
}

.summary-ghost-compare .opt {
  color: #7e22ce;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  font-size: 0.76rem;
  padding: 7px 12px;
}

.records-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.rec-tab {
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: #e2e8f0;
  color: var(--ink);
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 10px;
  cursor: pointer;
}

.rec-tab.active {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #ffffff;
  box-shadow: 0 3px 0 #075985;
}

.records-body {
  display: grid;
  gap: 10px;
}

.record-card {
  background: #ffffff;
  border: 2.5px solid #cbd5e1;
  border-radius: 16px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--ink);
}

.record-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.record-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-sub {
  font-size: 0.76rem;
  font-weight: 800;
  color: #475569;
}

.rec-stars {
  color: #f59e0b;
}

.rec-play-btn {
  font-size: 0.78rem;
  padding: 7px 12px;
  flex-shrink: 0;
}

.record-pb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.rec-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.rec-pb {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #f59e0b;
}

.rec-score {
  background: #dbeafe;
  color: #1e40af;
}

.rec-ghost {
  background: #f1f5f9;
  color: #334155;
}

.rec-clean {
  background: #dcfce7;
  color: #166534;
}

.rec-dirty {
  background: #ffedd5;
  color: #9a3412;
}

.rec-pro {
  background: #0f172a;
  color: #fde047;
}

.rec-opt {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1.5px solid #c084fc;
}

.rec-car-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  font-weight: 900;
  color: #334155;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 999px;
  padding: 1px 7px;
}

.rec-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid #0f172a;
  display: inline-block;
}

.record-per-car,
.record-trend {
  font-size: 0.74rem;
  font-weight: 800;
  color: #475569;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.record-trend span {
  color: #0f172a;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.record-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
  border-top: 1.5px dashed #e2e8f0;
  padding-top: 6px;
}

.rec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 8px;
  background: #f8fafc;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.rec-row.dnf {
  opacity: 0.72;
  background: #fff7ed;
}

.rec-diff {
  font-size: 0.66rem;
  font-weight: 900;
  color: #64748b;
}

.rec-empty,
.record-empty-state {
  font-size: 0.8rem;
  font-weight: 800;
  color: #64748b;
  text-align: center;
  padding: 6px;
}

/* ========================================= */
/* LEVEL FLOW & WAYFINDING ("Level N of 6")  */
/* See mockups/screen-flow.html              */
/* ========================================= */

/* HUD rail level tag */
.rail-lvl {
  display: inline-block;
  margin-right: 5px;
  padding: 0 5px;
  border-radius: 5px;
  background: #facc15;
  color: #0f172a;
  font-size: 0.92em;
  line-height: 1.35;
}

/* Level intro card (non-blocking, sits in the coach slot under the top bar) */
.level-intro {
  align-self: center;
  pointer-events: none;
  animation: introIn 0.28s ease-out;
}

.level-intro-card {
  min-width: min(320px, 86vw);
  max-width: 440px;
  padding: 10px 18px 11px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(250, 204, 21, 0.55);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.45);
  text-align: center;
  color: #ffffff;
}

.intro-eyebrow {
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #facc15;
}

.intro-title {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.35rem;
  line-height: 1.15;
  margin-top: 1px;
}

.intro-goal {
  font-size: 0.8rem;
  font-weight: 800;
  color: #e2e8f0;
  margin-top: 2px;
}

.intro-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 7px;
}

.intro-chips:empty {
  display: none;
}

.intro-chips span {
  font-size: 0.66rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.intro-ready {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #bbf7d0;
}

.intro-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.9);
  animation: introPulse 0.9s ease-in-out infinite alternate;
}

@keyframes introIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
}

@keyframes introPulse {
  to {
    opacity: 0.35;
  }
}

/* Pause & results context line */
.pause-context {
  margin: -6px 0 12px;
  font-size: 0.8rem;
  font-weight: 900;
  color: #475569;
}

.summary-eyebrow {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #92400e;
}

.summary-eyebrow:empty {
  display: none;
}

/* Primary "Next" names the level; sits first */
.btn-summary-primary {
  order: -1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.btn-summary-primary small {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin-top: 2px;
  opacity: 0.95;
}

/* Levels sheet: next up + locked */
.level-card.is-next {
  border-color: #facc15;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.35);
}

.level-card.is-locked {
  cursor: not-allowed;
  background: #f1f5f9;
  opacity: 0.6;
}

.level-card.is-locked .level-num {
  background: #cbd5e1;
}

.level-next-tag {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #fde68a;
  color: #92400e;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  vertical-align: 2px;
}

.level-card.shake {
  animation: levelShake 0.3s ease;
}

@keyframes levelShake {
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

@media (max-height: 500px) {
  .level-intro-card {
    padding: 7px 14px 8px;
  }
  .intro-title {
    font-size: 1.1rem;
  }
  .intro-goal {
    font-size: 0.72rem;
  }
  .intro-chips,
  .intro-ready {
    margin-top: 5px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .level-intro,
  .intro-light,
  .level-card.shake {
    animation: none;
  }
}

/* ========================================= */
/* TITLE HUB — GLASS CHROME, ONE LOUD PLAY   */
/* Design: mockups/title-redesign.html       */
/* ========================================= */
.hub {
  --hub-glass: rgba(15, 23, 42, 0.5);
  --hub-line: rgba(255, 255, 255, 0.16);
  --hub-muted: rgba(226, 232, 240, 0.8);
  --hub-ctl-h: 44px;
  --hub-play-h: 60px;
  --hub-car-h: 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  /* Soft scrims only where chrome sits; the hero car's band stays untouched */
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.26) 0%,
    rgba(15, 23, 42, 0) 18%,
    rgba(15, 23, 42, 0) 66%,
    rgba(15, 23, 42, 0.44) 100%
  );
  pointer-events: none;
}

.hub > * {
  pointer-events: auto;
}

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

.hub button:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

.hub-glass {
  background: var(--hub-glass);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--hub-line);
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ---- Top bar ---- */
.hub-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hub-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--gold);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 0 3px 0 #b45309, 0 6px 14px rgba(15, 23, 42, 0.45);
  white-space: nowrap;
}

.hub-hbadge {
  display: inline-grid;
  place-items: center;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  background: linear-gradient(180deg, #f8fafc, #cbd5e1);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}

.hub-hbadge svg {
  width: 62%;
  height: 62%;
}

.hub-stats {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.hub-stats b {
  font-weight: 900;
}

.hub-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.hub-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hub-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  transition: background 0.12s, transform 0.08s;
}

.hub-icon svg {
  width: 18px;
  height: 18px;
}

.hub-setup-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background 0.12s, transform 0.08s;
}

.hub-setup-chip svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hub-setup-chip .hub-chev {
  width: 12px;
  height: 12px;
  opacity: 0.7;
  transition: transform 0.15s;
}

.hub-setup-chip[aria-expanded='true'] .hub-chev {
  transform: rotate(180deg);
}

.hub-pro-tag {
  color: var(--gold);
}

.hub-icon:active,
.hub-setup-chip:active,
.hub-arrow:active {
  transform: scale(0.95);
}

@media (hover: hover) {
  .hub-icon:hover,
  .hub-setup-chip:hover,
  .hub-arrow:hover,
  .hub-car-main:hover {
    background: rgba(30, 41, 59, 0.62);
  }
  .hub-modes button:not([aria-selected='true']):hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.08);
  }
  .hub-link:hover {
    color: #fef08a;
  }
  .hub-play:hover {
    filter: brightness(1.05);
  }
}

/* Drive setup popover */
.hub-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 96px;
  width: 270px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.82);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--hub-line);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform-origin: top right;
  animation: hubPop 0.14s ease-out;
  z-index: 5;
}

@keyframes hubPop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
}

.hub-pop-title {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--hub-muted);
  text-transform: uppercase;
}

.hub-pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.hub-pop-hint {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hub-muted);
}

/* ---- Segmented controls (popover + mode switch) ---- */
.hub-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
}

.hub-seg button {
  border: 0;
  background: transparent;
  color: var(--hub-muted);
  font-weight: 900;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}

.hub-seg button.selected,
.hub-seg button[aria-selected='true'] {
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(2, 6, 23, 0.25);
}

.hub-seg-sm {
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid var(--hub-line);
}

.hub-seg-sm button {
  height: 28px;
  padding: 0 11px;
  font-size: 0.72rem;
}

.hub-seg-sm em {
  font-style: normal;
  margin-left: 2px;
  color: var(--gold);
}

.hub-seg-sm button.selected em {
  color: #b45309;
}

/* ---- Bottom dock ---- */
.hub-dock {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
}

.hub-car {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--hub-car-h);
  padding: 0 5px;
  border-radius: 18px;
  min-width: 0;
}

.hub-arrow {
  width: 34px;
  height: calc(var(--hub-car-h) - 12px);
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s, transform 0.08s;
}

.hub-arrow svg {
  width: 14px;
  height: 14px;
}

.hub-arrow.hub-arrow-off {
  visibility: hidden;
  width: 8px;
}

.hub-car-main {
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--hub-car-h) - 12px);
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  min-width: 0;
  transition: background 0.12s;
}

.hub-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.hub-car-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hub-car-text small {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--hub-muted);
  text-transform: uppercase;
}

.hub-car-text strong {
  font-size: 0.95rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-launch {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  flex-shrink: 0;
}

.hub-context {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(2, 6, 23, 0.7), 0 0 10px rgba(2, 6, 23, 0.35);
  white-space: nowrap;
}

.hub-dim {
  color: rgba(241, 245, 249, 0.82);
}

.hub-dim:empty {
  display: none;
}

.hub-link {
  border: 0;
  background: none;
  padding: 0;
  font-size: inherit;
  font-weight: 900;
  color: var(--gold) !important;
  text-shadow: inherit;
}

.hub-pips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: center;
}

.hub-pips:empty {
  display: none;
}

.hub-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.5);
}

.hub-pip.done {
  background: var(--gold);
}

.hub-pip.next {
  background: var(--cream);
  box-shadow: 0 0 0 2px rgba(255, 251, 235, 0.35), 0 0 8px rgba(255, 251, 235, 0.7);
}

.hub-launch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hub-modes {
  height: var(--hub-ctl-h);
  align-items: stretch;
}

.hub-modes button {
  position: relative;
  padding: 0 15px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hub-new-dot {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.6);
}

.hub-modes button[aria-selected='true'] .hub-new-dot {
  display: none;
}

/* The one loud thing on screen */
.hub-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: var(--hub-play-h);
  min-width: 210px;
  padding: 0 22px 0 18px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #ffffff !important;
  box-shadow: 0 5px 0 #14532d, 0 12px 26px rgba(22, 163, 74, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.1s;
}

.hub-play:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #14532d, 0 5px 12px rgba(22, 163, 74, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hub-play svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 0 rgba(15, 23, 42, 0.35));
}

.hub-play-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  gap: 3px;
}

.hub-play-text b {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(15, 23, 42, 0.35);
}

.hub-play-text small {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: rgba(240, 253, 244, 0.92);
  text-transform: uppercase;
}

/* Short viewports (phone landscape, e.g. 844×390) */
@media (max-height: 500px) {
  .hub {
    --hub-ctl-h: 36px;
    --hub-play-h: 46px;
    --hub-car-h: 44px;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .hub-wordmark {
    font-size: 1.25rem;
  }
  .hub-stats {
    height: 28px;
    font-size: 0.74rem;
    gap: 8px;
    padding: 0 10px;
  }
  .hub-icon {
    width: 36px;
    height: 36px;
  }
  .hub-setup-chip {
    height: 36px;
    font-size: 0.72rem;
  }
  .hub-popover {
    right: 88px;
  }
  .hub-car-text strong {
    font-size: 0.86rem;
  }
  .hub-context {
    font-size: 0.68rem;
  }
  .hub-launch {
    gap: 4px;
  }
  .hub-pip {
    width: 7px;
    height: 7px;
  }
  .hub-modes button {
    padding: 0 12px;
    font-size: 0.68rem;
  }
  .hub-play {
    min-width: 170px;
    border-radius: 16px;
  }
  .hub-play-text b {
    font-size: 1.25rem;
  }
  .hub-play-text small {
    font-size: 0.6rem;
  }
}

/* Narrow landscape (e.g. 667×375) */
@media (max-width: 760px) {
  .hub-dim {
    display: none;
  }
  .hub-modes button {
    padding: 0 9px;
    letter-spacing: 0.04em;
  }
  .hub-play {
    min-width: 140px;
    padding: 0 14px;
  }
  .hub-setup-text {
    display: none;
  }
  .hub-popover {
    right: 84px;
  }
}

/* Portrait phones: stack the dock so nothing overflows */
@media (orientation: portrait) and (max-width: 680px) {
  .hub-top {
    flex-wrap: wrap;
  }
  .hub-dock {
    flex-direction: column;
    align-items: stretch;
  }
  .hub-launch {
    align-items: stretch;
  }
  .hub-context {
    flex-wrap: wrap;
    white-space: normal;
  }
  .hub-launch-row {
    flex-direction: column;
    align-items: stretch;
  }
  .hub-modes button {
    flex: 1;
  }
  .hub-popover {
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hub-popover {
    animation: none;
  }
}

/* ========================================= */
/* TITLE VISUAL STYLE PILL & GARAGE GLB LAB  */
/* ========================================= */
.hub-art-chip {
  font-weight: 900;
  letter-spacing: 0.02em;
  border-color: rgba(56, 189, 248, 0.55) !important;
}

.hub-art-chip.is-anime {
  border-color: rgba(250, 204, 21, 0.72) !important;
  background: rgba(30, 41, 59, 0.86);
  color: #fde68a;
}

.garage-glb-lab {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.08);
  border: 2px dashed rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.glb-lab-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
}

.glb-lab-head strong {
  font-size: 0.84rem;
  font-weight: 900;
  color: var(--ink);
}

.glb-status {
  font-size: 0.74rem;
  font-weight: 800;
  color: #475569;
}

.glb-status code {
  background: rgba(15, 23, 42, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
  font-weight: 900;
}

.glb-lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.glb-ref-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* ========================================= */
/* SIZE-CLASS LAYOUTS (body[data-layout])    */
/* Set by main.js on every resize:           */
/*   short-landscape · compact-portrait ·    */
/*   regular. See docs/orientation-          */
/*   sharpness-plan.md (Phase 3)             */
/* ========================================= */

/* Compact portrait (phones upright, folded iPhone Duo): the run HUD is a "cockpit" with the road in
   the middle band and the pedals along the bottom edge. The base portrait media block (Tier 4) already
   sizes the pedals and shifter; these rules tighten the top stack so more road shows. */
body[data-layout='compact-portrait'] .tsubi-bubble-card {
  gap: 5px;
  padding: 2px 9px 2px 2px;
}

body[data-layout='compact-portrait'] .tsubi-bubble-card canvas {
  width: 34px;
  height: 34px;
}

body[data-layout='compact-portrait'] .tsubi-name {
  display: none;
}

body[data-layout='compact-portrait'] .tsubi-mood {
  font-size: 0.62rem;
}

body[data-layout='compact-portrait'] .coach-pill {
  padding: 5px 12px;
  font-size: 0.72rem;
  line-height: 1.3;
}

/* Stall ignition panel: centred in the road view above the cockpit, never over CLUTCH / GAS / BRAKE or
   the shifter column (overrides any thumb-zone anchoring meant for landscape) */
body[data-layout='compact-portrait'] .crank-overlay {
  inset: 0 0 34% 0;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
}

/* Signal-ahead warning: keep it in the road band, clear of the top stack and the controls */
body[data-layout='compact-portrait'] .signal-ahead {
  top: 40%;
}

/* Narrow phones sideways (e.g. 667×375): the rail's centre column leaves ~200px for the left cluster,
   so the Tsubi card shrinks to just her portrait (expression + border colour still show the mood)
   and the top bar stays on one row. */
@media (max-width: 720px) {
  body[data-layout='short-landscape'] .tsubi-meta,
  body[data-layout='regular'] .tsubi-meta {
    display: none;
  }
  body[data-layout='short-landscape'] .tsubi-bubble-card,
  body[data-layout='regular'] .tsubi-bubble-card {
    padding: 2px;
  }
}

/* Regular (unfolded iPhone Duo held upright ~669 wide, tablets): wide enough for the one-row,
   rail-centred top bar, so undo the stacked phone-portrait top bar from the Tier 4 media block */
body[data-layout='regular'] .hud-top {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

body[data-layout='regular'] .hud-top-right {
  grid-column: 3;
  grid-row: 1;
}

body[data-layout='regular'] .hud-top > .hud-center-title,
body[data-layout='regular'] .hud-top > .progress-rail {
  grid-column: 2;
  grid-row: 1;
  justify-self: auto;
}

body[data-layout='regular'] .progress-rail {
  width: auto;
  max-width: 390px;
  min-width: clamp(210px, 32vw, 350px);
}

body[data-layout='regular'] .hud-top:has(> .progress-rail.hidden) {
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr) auto;
}

body[data-layout='regular'] .hud-top:has(> .progress-rail.hidden) > .hud-center-title {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}
