:root {
  --ink: #05070c;
  --deep: #080b12;
  --panel: #0b0e14;
  --cyan: #2fd8ff;
  --cyan-dim: rgba(47, 216, 255, 0.42);
  --red: #ff2d55;
  --white: #eaf2ff;
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --ph: clamp(56px, 16.5vh, 86px);
  --edge: 14px;
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-text: "Chakra Petch", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background: radial-gradient(120% 90% at 50% 72%, #0a1620 0%, #05070c 62%, #03050a 100%);
}

#scene, #fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#scene { z-index: 0; touch-action: none; }
#fx { z-index: 3; pointer-events: none; }

.hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s ease;
}

body[data-state="intro"] .hud,
body[data-state="loading"] .hud { opacity: 0; }
body[data-state="finished"] .hud { opacity: 0.16; }

button {
  font-family: var(--font-text);
  color: var(--white);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: none;
}

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

/* HUD top */
.hud-track {
  position: absolute;
  top: calc(var(--st) + 12px);
  left: calc(var(--sl) + 16px);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 10px;
}

.hud-track::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: linear-gradient(180deg, var(--cyan), rgba(47, 216, 255, 0));
  box-shadow: 0 0 10px rgba(47, 216, 255, 0.55);
}

.hud-track-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--white);
  text-shadow: 0 0 10px rgba(47, 216, 255, 0.35);
}

.hud-track-sub {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: rgba(234, 242, 255, 0.42);
}

.hud-top {
  position: absolute;
  top: calc(var(--st) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.plate {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 14px 3px;
  background: linear-gradient(180deg, rgba(11, 14, 20, 0.72), rgba(11, 14, 20, 0.32));
  border: 1px solid rgba(47, 216, 255, 0.28);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.plate::before, .plate::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border: 1px solid rgba(234, 242, 255, 0.5);
}

.plate::before { top: 2px; right: 2px; border-left: 0; border-bottom: 0; }
.plate::after { bottom: 2px; left: 2px; border-right: 0; border-top: 0; }

.plate-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: rgba(234, 242, 255, 0.55);
}

.plate-value {
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  text-shadow: 0 0 12px rgba(47, 216, 255, 0.4);
  min-width: 88px;
  text-align: right;
}

.hud-distance {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: rgba(234, 242, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.hud-distance em {
  font-style: normal;
  font-size: 7px;
  color: rgba(47, 216, 255, 0.7);
}

/* Speedometer */
.speedo {
  position: absolute;
  right: calc(var(--sr) + var(--edge));
  bottom: calc(var(--sb) + var(--ph) * 2.72);
  width: clamp(94px, 26vh, 140px);
  height: clamp(94px, 26vh, 140px);
  pointer-events: none;
}

.speedo svg { width: 100%; height: 100%; overflow: visible; }

.ring-base {
  fill: none;
  stroke: rgba(47, 216, 255, 0.17);
  stroke-width: 1.4;
}

.ring-fill {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 4px rgba(47, 216, 255, 0.9));
}

#speedTicks line {
  stroke: rgba(234, 242, 255, 0.4);
  stroke-width: 0.8;
}

#speedTicks line.major { stroke: rgba(234, 242, 255, 0.82); stroke-width: 1.2; }

.speed-read {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 8px;
}

.speed-num {
  font-family: var(--font-text);
  font-size: clamp(26px, 7.4vh, 40px);
  font-weight: 700;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--white);
  text-shadow: 0 0 16px rgba(47, 216, 255, 0.45);
}

.speed-unit {
  margin-top: 3px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: rgba(234, 242, 255, 0.55);
}

/* Boost */
.boost {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sb) + 14px);
  transform: translateX(-50%);
  width: min(28vw, 300px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}

.boost-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: rgba(234, 242, 255, 0.55);
  text-align: center;
}

.boost-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  height: 9px;
}

.boost-bar i {
  position: relative;
  display: block;
  border: 1px solid rgba(47, 216, 255, 0.3);
  background: rgba(11, 14, 20, 0.55);
  overflow: hidden;
}

.boost-bar i::before {
  content: "";
  position: absolute;
  inset: 1px;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgba(47, 216, 255, 0.35), var(--cyan));
  box-shadow: 0 0 8px rgba(47, 216, 255, 0.8);
  transition: transform 0.06s linear;
}

.boost-bar i.on::before { transform: scaleX(1); }
.boost-bar i.hot::before { background: linear-gradient(90deg, rgba(47, 216, 255, 0.8), #c9f6ff); }
.boost-bar.boosting i.on::before { animation: boostpulse 0.18s infinite alternate; }

@keyframes boostpulse {
  from { opacity: 0.72; }
  to { opacity: 1; }
}

/* Steering pads */
.ctrl-left {
  position: absolute;
  left: calc(var(--sl) + var(--edge));
  bottom: calc(var(--sb) + 12px);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.pad, .btn-accel, .btn-brake, .btn-boost {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--white);
  background:
    radial-gradient(80% 70% at 50% 30%, rgba(47, 216, 255, 0.13), rgba(47, 216, 255, 0) 70%),
    linear-gradient(180deg, rgba(16, 22, 32, 0.5), rgba(8, 11, 17, 0.62));
  border: 1px solid rgba(47, 216, 255, 0.5);
  box-shadow:
    inset 0 0 18px rgba(47, 216, 255, 0.1),
    0 0 10px rgba(47, 216, 255, 0.12);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: transform 0.07s ease, box-shadow 0.07s ease, background 0.07s ease;
  -webkit-user-select: none;
  user-select: none;
}

.pad::before, .pad::after,
.btn-accel::before, .btn-accel::after,
.btn-brake::before, .btn-brake::after,
.btn-boost::before, .btn-boost::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 1px solid var(--red);
  opacity: 0.8;
}

.pad::before, .btn-accel::before, .btn-brake::before, .btn-boost::before {
  top: 5px;
  right: 5px;
  border-left: 0;
  border-bottom: 0;
}

.pad::after, .btn-accel::after, .btn-brake::after, .btn-boost::after {
  bottom: 5px;
  left: 5px;
  border-right: 0;
  border-top: 0;
}

.pad {
  width: calc(var(--ph) * 1.04);
  height: calc(var(--ph) * 1.04);
  border-radius: 22px;
}

.pad:first-child { transform: rotate(6deg); }
.pad:last-child { transform: rotate(-6deg); }

.pad svg, .btn-accel svg, .btn-brake svg, .btn-boost svg {
  width: 34%;
  height: auto;
  fill: none;
  stroke: var(--white);
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(47, 216, 255, 0.7));
}

.pad svg .thin, .btn-brake svg .thin { opacity: 0.42; }
.btn-accel svg, .btn-boost svg { fill: rgba(234, 242, 255, 0.92); stroke: none; }
.btn-boost svg { fill: var(--cyan); filter: drop-shadow(0 0 5px rgba(47, 216, 255, 0.9)); }

.pad span, .btn-accel span, .btn-brake span, .btn-boost span {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(234, 242, 255, 0.86);
}

.pad.down, .btn-accel.down, .btn-brake.down, .btn-boost.down {
  background:
    radial-gradient(80% 70% at 50% 30%, rgba(47, 216, 255, 0.3), rgba(47, 216, 255, 0.04) 72%),
    linear-gradient(180deg, rgba(20, 34, 48, 0.7), rgba(8, 11, 17, 0.7));
  box-shadow:
    inset 0 0 26px rgba(47, 216, 255, 0.28),
    0 0 18px rgba(47, 216, 255, 0.35);
  border-color: rgba(180, 244, 255, 0.9);
}

.pad.down { transform: rotate(6deg) translateY(2px); }
.pad:last-child.down { transform: rotate(-6deg) translateY(2px); }
.btn-accel.down, .btn-brake.down, .btn-boost.down { transform: translateY(2px); }

.ctrl-right {
  position: absolute;
  right: calc(var(--sr) + var(--edge));
  bottom: calc(var(--sb) + 12px);
  width: calc(var(--ph) * 2.86);
  height: calc(var(--ph) * 1.95);
  pointer-events: none;
}

.btn-accel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: calc(var(--ph) * 1.42);
  height: calc(var(--ph) * 1.42);
  border-radius: 50%;
  background:
    radial-gradient(80% 70% at 50% 34%, rgba(47, 216, 255, 0.16), rgba(47, 216, 255, 0) 70%),
    linear-gradient(180deg, rgba(16, 22, 32, 0.42), rgba(8, 11, 17, 0.6));
}

.btn-accel svg { width: 38%; height: 38%; }
.btn-accel span { font-size: 9px; letter-spacing: 0.2em; }

.btn-brake {
  position: absolute;
  right: calc(var(--ph) * 0.03);
  bottom: calc(var(--ph) * 1.5);
  width: calc(var(--ph) * 0.94);
  height: calc(var(--ph) * 0.94);
  border-radius: 20px;
  border-color: rgba(47, 216, 255, 0.36);
}

.btn-boost {
  position: absolute;
  left: 0;
  bottom: 2px;
  width: calc(var(--ph) * 1.32);
  height: calc(var(--ph) * 1.32);
  border-radius: 24px;
}

.btn-boost.down { box-shadow: inset 0 0 26px rgba(47, 216, 255, 0.5), 0 0 26px rgba(47, 216, 255, 0.65); }

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  top: 21%;
  transform: translate(-50%, -50%) scale(0.96);
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--cyan);
  border-top: 1px solid rgba(47, 216, 255, 0.55);
  border-bottom: 1px solid rgba(47, 216, 255, 0.55);
  background: rgba(5, 7, 12, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-shadow: 0 0 12px rgba(47, 216, 255, 0.7);
}

.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
}

.screen[hidden] { display: none; }

/* Loading */
.loader {
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(90% 60% at 50% 86%, rgba(20, 72, 100, 0.35), rgba(5, 7, 12, 0) 62%),
    radial-gradient(60% 50% at 50% 50%, rgba(9, 20, 32, 0.9), rgba(3, 5, 10, 0.98) 76%),
    #03050a;
  transition: opacity 0.55s ease, visibility 0.55s;
}

.loader::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(47, 216, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 216, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 60% at 50% 60%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 60%, #000 20%, transparent 78%);
  opacity: 0.7;
}

.loader.done { opacity: 0; visibility: hidden; }

.loader-inner {
  position: relative;
  width: min(320px, 64vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.load-track {
  width: 100%;
  height: 2px;
  background: rgba(47, 216, 255, 0.16);
  overflow: hidden;
}

.load-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(47, 216, 255, 0.5), var(--cyan));
  box-shadow: 0 0 12px rgba(47, 216, 255, 0.9);
  transition: width 0.25s ease;
}

.load-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.26em;
  color: rgba(234, 242, 255, 0.45);
}

/* Brand lockup */
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.brand-line { display: flex; overflow: hidden; }

.brand-main {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: clamp(24px, 4.6vw, 52px);
  letter-spacing: 0.115em;
  line-height: 1.06;
  background: linear-gradient(180deg, #f4f9ff 0%, #c6dcea 34%, #5e7d91 52%, #22323f 58%, #a7c6d8 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(47, 216, 255, 0.22));
  white-space: nowrap;
}

.brand-rule {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--red), rgba(255, 45, 85, 0.14));
  box-shadow: 0 0 8px rgba(255, 45, 85, 0.65);
  position: relative;
}

.brand-rule::after {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 26%;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), rgba(47, 216, 255, 0));
}

.brand-sub {
  font-size: clamp(7px, 1.05vw, 11px);
  font-weight: 400;
  letter-spacing: 0.42em;
  color: rgba(234, 242, 255, 0.72);
  text-transform: uppercase;
}

.brand-loader { align-items: center; }
.brand-loader .brand-sub { color: rgba(234, 242, 255, 0.6); }

/* Intro */
.intro {
  z-index: 9;
  pointer-events: auto;
  background: radial-gradient(100% 100% at 50% 100%, rgba(5, 7, 12, 0.2), rgba(5, 7, 12, 0.72) 72%);
  opacity: 1;
  transition: opacity 0.4s ease;
}

.intro.hide {
  opacity: 0;
  pointer-events: none;
}

.intro-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 7, 12, 0.38) 0%, rgba(5, 7, 12, 0.06) 28%, rgba(5, 7, 12, 0) 55%, rgba(5, 7, 12, 0.5) 100%),
    radial-gradient(56% 50% at 16% 16%, rgba(5, 7, 12, 0.68), rgba(5, 7, 12, 0) 70%);
  pointer-events: none;
}

.brand-intro {
  position: absolute;
  top: calc(var(--st) + 22px);
  left: calc(var(--sl) + 24px);
  max-width: 62vw;
}

.intro-meta {
  position: absolute;
  left: calc(var(--sl) + 26px);
  top: calc(var(--st) + 22px + clamp(64px, 12vw, 132px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 3px 9px 2px;
  border: 1px solid rgba(47, 216, 255, 0.55);
  background: rgba(5, 7, 12, 0.4);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(47, 216, 255, 0.5);
}

.intro-line {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.24em;
  color: rgba(234, 242, 255, 0.52);
}

.intro-best {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.start-btn {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sb) + 54px);
  transform: translateX(-50%);
  min-width: min(320px, 64vw);
  padding: 12px 38px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background:
    linear-gradient(180deg, rgba(18, 40, 56, 0.62), rgba(7, 12, 19, 0.78));
  border: 1px solid rgba(47, 216, 255, 0.75);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  box-shadow: inset 0 0 24px rgba(47, 216, 255, 0.16), 0 0 26px rgba(47, 216, 255, 0.14);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.start-btn:hover, .start-btn:active {
  background: linear-gradient(180deg, rgba(28, 62, 82, 0.75), rgba(9, 18, 28, 0.82));
  box-shadow: inset 0 0 30px rgba(47, 216, 255, 0.3), 0 0 34px rgba(47, 216, 255, 0.28);
}

.start-kicker {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: rgba(234, 242, 255, 0.55);
}

.start-word {
  font-family: var(--font-text);
  font-size: clamp(16px, 2.6vw, 24px);
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--white);
  text-shadow: 0 0 16px rgba(47, 216, 255, 0.55);
}

.intro-hints {
  position: absolute;
  left: calc(var(--sl) + 26px);
  bottom: calc(var(--sb) + 20px);
  display: flex;
  gap: 14px;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: rgba(234, 242, 255, 0.42);
}

.intro-hints b {
  margin-right: 4px;
  font-weight: 600;
  color: rgba(47, 216, 255, 0.75);
}

.intro-note {
  position: absolute;
  right: calc(var(--sr) + 24px);
  bottom: calc(var(--sb) + 20px);
  font-size: 8px;
  letter-spacing: 0.3em;
  color: rgba(234, 242, 255, 0.32);
}

/* Results */
.results {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(90% 90% at 50% 50%, rgba(5, 7, 12, 0.64), rgba(5, 7, 12, 0.92) 78%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.results.show { opacity: 1; }

.result-panel {
  position: relative;
  width: min(560px, 86vw);
  max-height: 88vh;
  overflow: auto;
  padding: calc(var(--st) + 18px) 26px 18px;
  background: linear-gradient(180deg, rgba(12, 18, 27, 0.86), rgba(6, 9, 15, 0.94));
  border: 1px solid rgba(47, 216, 255, 0.4);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  box-shadow: inset 0 0 40px rgba(47, 216, 255, 0.06), 0 0 60px rgba(0, 0, 0, 0.6);
}

.result-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), rgba(47, 216, 255, 0.1) 60%, var(--red));
  box-shadow: 0 0 16px rgba(47, 216, 255, 0.5);
}

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(47, 216, 255, 0.16);
}

.result-kicker {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--cyan);
}

.result-title {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: rgba(234, 242, 255, 0.6);
}

.result-time {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 8px;
}

.rlabel {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(234, 242, 255, 0.5);
}

.rtime {
  font-size: clamp(26px, 5.4vh, 44px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--white);
  text-shadow: 0 0 22px rgba(47, 216, 255, 0.5);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: rgba(47, 216, 255, 0.16);
  border: 1px solid rgba(47, 216, 255, 0.16);
  margin: 6px 0 14px;
}

.result-grid > div {
  background: rgba(8, 12, 19, 0.9);
  padding: 8px 10px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-grid span {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(234, 242, 255, 0.45);
}

.result-grid b {
  font-size: clamp(13px, 2.6vh, 20px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  letter-spacing: 0.02em;
}

.result-grid em {
  font-style: normal;
  font-size: 7px;
  letter-spacing: 0.18em;
  color: rgba(47, 216, 255, 0.65);
}

.result-actions { display: flex; gap: 10px; }

.action {
  flex: 1;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--white);
  border: 1px solid rgba(47, 216, 255, 0.5);
  background: rgba(12, 22, 32, 0.5);
  transition: background 0.12s ease;
}

.action.primary {
  background: linear-gradient(180deg, rgba(47, 216, 255, 0.22), rgba(47, 216, 255, 0.06));
  border-color: rgba(120, 235, 255, 0.9);
  box-shadow: inset 0 0 22px rgba(47, 216, 255, 0.16), 0 0 18px rgba(47, 216, 255, 0.12);
}

.action:active { background: rgba(47, 216, 255, 0.3); }

.result-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.24em;
  color: rgba(234, 242, 255, 0.32);
}

.fatal {
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #03050a;
}

.fatal-inner { width: min(480px, 80vw); text-align: center; }
.fatal-inner p {
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.18em;
  line-height: 1.8;
  color: rgba(234, 242, 255, 0.55);
}

/* Narrow landscape */
@media (max-height: 400px) {
  .brand-main { font-size: clamp(20px, 4vw, 34px); }
  .brand-sub { font-size: 7px; }
  .intro-meta { top: calc(var(--st) + 96px); }
  .intro-hints { display: none; }
  .start-btn { bottom: calc(var(--sb) + 26px); }
  .result-panel { padding-top: 14px; }
  .result-grid { margin-bottom: 10px; }
}

@media (max-height: 330px) {
  .hud-track-sub { display: none; }
  .brand-intro { top: calc(var(--st) + 12px); }
  .intro-meta { top: calc(var(--st) + 58px); }
  .intro-note { display: none; }
  .start-btn { bottom: calc(var(--sb) + 16px); padding: 8px 24px 9px; }
  .result-time { padding: 8px 0 6px; }
}

@media (max-height: 280px) {
  .result-panel { max-height: 94vh; }
  .result-grid span { display: none; }
  .rtime { font-size: 24px; }
}

/* Portrait and square screens: the same HUD, packed for a tall view */
@media (orientation: portrait) {
  :root {
    --ph: clamp(50px, 15vw, 70px);
    --edge: 10px;
  }

  .hud-track {
    top: calc(var(--st) + 10px);
    left: calc(var(--sl) + 10px);
  }

  .hud-track-sub { display: none; }
  .hud-track-name { font-size: 10px; letter-spacing: 0.22em; }

  .hud-top { top: calc(var(--st) + 8px); }
  .plate-value { font-size: 15px; min-width: 76px; }

  .speedo {
    right: calc(var(--sr) + 10px);
    bottom: calc(var(--sb) + var(--ph) * 2.72);
    width: clamp(84px, 24vw, 116px);
    height: clamp(84px, 24vw, 116px);
  }

  .speed-num { font-size: clamp(22px, 6.4vw, 30px); }

  .boost {
    left: calc(var(--sl) + 10px);
    bottom: calc(var(--sb) + var(--ph) + 24px);
    transform: none;
    width: min(34vw, 150px);
  }

  .boost-label { font-size: 7px; letter-spacing: 0.24em; }

  .ctrl-left {
    left: calc(var(--sl) + 10px);
    bottom: calc(var(--sb) + 10px);
    gap: 8px;
  }

  .ctrl-right {
    right: calc(var(--sr) + 10px);
    bottom: calc(var(--sb) + 10px);
    width: calc(var(--ph) * 2.86);
    height: calc(var(--ph) * 1.9);
  }

  .brand-intro { max-width: 74vw; }
  .brand-main { font-size: clamp(19px, 6vw, 40px); }
  .intro-meta { top: calc(var(--st) + 104px); }
  .intro-hints {
    left: calc(var(--sl) + 16px);
    right: calc(var(--sr) + 16px);
    bottom: calc(var(--sb) + 16px);
    flex-wrap: wrap;
    gap: 6px 14px;
    max-width: 76vw;
  }
  .intro-note { display: none; }
  .start-btn { bottom: calc(var(--sb) + 56px); }

  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .toast { top: 16%; }
}
