:root {
  color-scheme: dark;
  --ink: #f4f0ea;
  --muted: rgba(244, 240, 234, 0.62);
  --dim: rgba(244, 240, 234, 0.38);
  --pink: #ff4ec8;
  --cyan: #36e8ff;
  --sun: #ffc46b;
  --void: #07040c;
  --glass: rgba(8, 4, 14, 0.42);
  --line: rgba(255, 255, 255, 0.18);
  --edge: clamp(20px, 3.4vw, 56px);
  --nitro: 0;
  --rate: 1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--void);
  color: var(--ink);
}

body {
  font-family: Syne, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}

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

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0.15em 0.4em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.stage {
  position: relative;
  isolation: isolate;
  min-height: 540px;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--void);
}

.film,
.poster,
#race,
.grade,
.shade,
.speed-fx,
.scanlines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.film {
  z-index: -1;
  background: var(--void);
}

.poster,
#race {
  object-fit: cover;
  object-position: 50% 42%;
}

.poster { filter: brightness(0.72) saturate(1.15); }

#race {
  opacity: 0;
  transition: opacity 0.45s ease;
  filter:
    contrast(1.05)
    saturate(calc(1.08 + var(--nitro) * 0.35))
    brightness(calc(1 + var(--nitro) * 0.08));
  transform: scale(calc(1 + var(--nitro) * 0.04));
  transition:
    opacity 0.45s ease,
    filter 0.2s ease,
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.is-ready #race { opacity: 1; }

.grade {
  background:
    radial-gradient(ellipse 80% 60% at 70% 30%, rgba(255, 78, 200, 0.16), transparent 55%),
    radial-gradient(ellipse 70% 50% at 15% 80%, rgba(54, 232, 255, 0.12), transparent 50%),
    linear-gradient(115deg, rgba(255, 78, 200, 0.08), transparent 40%, rgba(54, 232, 255, 0.07));
  mix-blend-mode: screen;
  pointer-events: none;
  opacity: calc(0.7 + var(--nitro) * 0.5);
  transition: opacity 0.25s ease;
}

.shade {
  background:
    linear-gradient(180deg, rgba(7, 4, 12, 0.62), rgba(7, 4, 12, 0.08) 22%, transparent 42%, rgba(7, 4, 12, 0.12) 66%, rgba(7, 4, 12, 0.82)),
    radial-gradient(ellipse at center, transparent 42%, rgba(7, 4, 12, 0.38) 100%);
  pointer-events: none;
}

.speed-fx {
  pointer-events: none;
  opacity: 0;
  background:
    repeating-linear-gradient(
      100deg,
      transparent 0 14px,
      rgba(255, 255, 255, 0.035) 14px 15px
    );
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  transition: opacity 0.2s ease;
}

.is-boosting .speed-fx {
  opacity: calc(0.35 + var(--nitro) * 0.65);
  animation: streak 0.35s linear infinite;
}

.scanlines {
  pointer-events: none;
  opacity: 0.08;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.35) 2px,
    rgba(0, 0, 0, 0.35) 3px
  );
  mix-blend-mode: multiply;
}

@keyframes streak {
  from { transform: translateX(0); }
  to { transform: translateX(-16px); }
}

/* Countdown */
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.countdown.is-on { opacity: 1; }

.countdown-num {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(96px, 22vw, 220px);
  line-height: 0.85;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff, #ffb8ec 45%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(255, 78, 200, 0.35);
  animation: pulse-count 0.9s ease;
}

@keyframes pulse-count {
  0% { transform: scale(1.35); opacity: 0; filter: blur(8px); }
  35% { opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}

/* Header */
.header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: calc(var(--edge) + env(safe-area-inset-top, 0px)) var(--edge) 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: var(--ink);
  flex: none;
}

.brand-mark svg { display: block; width: 100%; height: 100%; }

.brand-name {
  display: block;
  font-family: "Bebas Neue", sans-serif;
  font-size: 28px;
  letter-spacing: 0.06em;
  line-height: 1;
}

.ticker {
  display: block;
  margin-top: 5px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 78, 200, 0.35);
  border-radius: 999px;
  background: rgba(255, 78, 200, 0.08);
  backdrop-filter: blur(10px);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #ffd0ef;
}

.live-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 12px var(--pink);
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* HUD / nitro */
.hud {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: var(--edge);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 18px;
  width: min(220px, 42vw);
}

.speedo {
  width: 132px;
  text-align: center;
}

.speedo-ring {
  position: relative;
  width: 132px;
  height: 132px;
}

.speedo-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-120deg);
}

.speedo-track,
.speedo-arc {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.speedo-track { stroke: rgba(255, 255, 255, 0.12); }

.speedo-arc {
  stroke: url(#unused);
  stroke: var(--cyan);
  stroke-dasharray: 218;
  stroke-dashoffset: 218;
  filter: drop-shadow(0 0 8px rgba(54, 232, 255, 0.55));
  transition: stroke-dashoffset 0.15s linear, stroke 0.2s ease;
}

.is-boosting .speedo-arc { stroke: var(--pink); filter: drop-shadow(0 0 10px rgba(255, 78, 200, 0.7)); }

.speedo-readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 2px;
}

.speedo-value {
  font-family: "Bebas Neue", sans-serif;
  font-size: 42px;
  line-height: 0.9;
  letter-spacing: 0.02em;
}

.speedo-unit {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.speedo-label {
  margin: 8px 0 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.drive-panel {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.panel-kicker {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--dim);
}

.nitro {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 78, 200, 0.45);
  background:
    linear-gradient(135deg, rgba(255, 78, 200, 0.22), rgba(54, 232, 255, 0.08));
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
}

.nitro:hover {
  border-color: rgba(255, 78, 200, 0.8);
  box-shadow: 0 0 28px rgba(255, 78, 200, 0.25);
}

.nitro[aria-pressed="true"],
.is-boosting .nitro {
  transform: scale(0.985);
  border-color: #fff;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 40px rgba(255, 78, 200, 0.45);
}

.nitro-glow {
  position: absolute;
  inset: -40%;
  background: conic-gradient(from 180deg, transparent, rgba(255, 78, 200, 0.35), transparent 40%);
  opacity: 0;
  transition: opacity 0.2s ease;
  animation: spin 2.4s linear infinite;
  pointer-events: none;
}

.is-boosting .nitro-glow { opacity: 1; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.nitro-key {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.35);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  flex: none;
}

.nitro-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
  text-align: left;
}

.nitro-copy strong {
  font-family: "Bebas Neue", sans-serif;
  font-size: 22px;
  letter-spacing: 0.08em;
  font-weight: 400;
}

.nitro-copy em {
  font-style: normal;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.hint-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--dim);
}

/* Footer */
.footer {
  position: absolute;
  z-index: 2;
  left: var(--edge);
  right: var(--edge);
  bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--cyan);
}

.tagline {
  margin: 0 0 16px;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(40px, 6.4vw, 84px);
  line-height: 0.92;
  letter-spacing: 0.02em;
  font-weight: 400;
  max-width: 12ch;
  text-wrap: balance;
}

.tagline span {
  background: linear-gradient(90deg, var(--pink), var(--sun) 55%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ca-row { margin-bottom: 10px; }

.ca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, 92vw);
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.ca:hover {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.ca-label {
  color: var(--pink);
  letter-spacing: 0.14em;
  flex: none;
}

.ca-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  max-width: 42ch;
}

.ca-action {
  margin-left: 4px;
  letter-spacing: 0.14em;
  color: var(--ink);
  flex: none;
}

.credit {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--dim);
  max-width: 42ch;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 4, 14, 0.45);
  backdrop-filter: blur(12px);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.control:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.45);
}

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

.control svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  flex: none;
}

.sound-waves,
.play-icon { display: none; }

.is-audible .sound-waves,
.is-paused .play-icon { display: block; }

.is-audible .sound-cross,
.is-paused .pause-icon { display: none; }

.buy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(95, 203, 136, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(110deg, #10241c, #0b1813 55%, #143028);
  color: #edf8f1;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.buy:hover {
  transform: translateY(-1px);
  border-color: rgba(95, 203, 136, 0.85);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(95, 203, 136, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.buy-logo {
  width: 22px;
  height: 22px;
  flex: none;
  display: block;
  border-radius: 6px;
}

.buy-label {
  font-family: Syne, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

.paused-veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(7, 4, 12, 0.42);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.paused-veil span {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(48px, 10vw, 96px);
  letter-spacing: 0.18em;
  padding: 0.18em 0.5em;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 40px rgba(54, 232, 255, 0.15);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hud {
    top: auto;
    bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    right: var(--edge);
    transform: none;
    width: min(200px, 58vw);
  }

  .speedo { width: 108px; }
  .speedo-ring { width: 108px; height: 108px; }
  .speedo-value { font-size: 34px; }
}

@media (max-width: 700px) {
  :root { --edge: 18px; }

  .header { gap: 12px; }
  .brand-name { font-size: 24px; }
  .brand-mark { width: 36px; height: 36px; }

  .hud {
    top: auto;
    bottom: calc(210px + env(safe-area-inset-bottom, 0px));
    right: var(--edge);
    left: var(--edge);
    width: auto;
    transform: none;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
  }

  .drive-panel { flex: 1; }

  .footer {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .tagline {
    font-size: clamp(36px, 12vw, 56px);
    max-width: 11ch;
  }

  .actions { justify-content: flex-start; }

  .ca { max-width: 100%; }
  .ca-value { max-width: 28ch; }

  .shade {
    background:
      linear-gradient(180deg, rgba(7, 4, 12, 0.86), rgba(7, 4, 12, 0.1) 28%, transparent 48%, rgba(7, 4, 12, 0.55) 72%, rgba(7, 4, 12, 0.96));
  }
}

@media (max-width: 420px) {
  .control { padding: 10px 11px; font-size: 10px; }
  .buy { padding: 0 14px 0 10px; }
  .buy-label { font-size: 12px; }
  .live-chip { display: none; }
  .hint-row { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #race,
  .control,
  .nitro,
  .speed-fx,
  .countdown-num,
  .live-chip i {
    animation: none !important;
    transition: none !important;
  }
}
