:root {
  --ink: #231910;
  --ivory: #f3e6cf;
  --cream: rgba(244, 230, 205, 0.92);
  --forest: #2c4a34;
  --orange: #c45c28;
  --gold: #e0a24a;
  --indigo: #161226;
  --glass: rgba(16, 10, 18, 0.72);
  --line: rgba(243, 230, 207, 0.18);
  --shadow: 0 18px 50px rgba(12, 8, 16, 0.38);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --ink: #2a1c12;
    --cream: rgba(255, 246, 230, 0.94);
    --glass: rgba(255, 244, 226, 0.78);
    --line: rgba(42, 28, 18, 0.12);
    color-scheme: light;
  }

  .pill,
  .tape,
  .speed-wrap {
    color: var(--ink);
    background: var(--glass);
  }

  .stall {
    color: #5a1608;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #140c14;
  color: var(--ivory);
  font-family: Outfit, "Segoe UI", sans-serif;
}

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

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

.hud-top {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(920px, 94vw);
}

.pill,
.tape,
.speed-wrap,
.card {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--shadow);
  text-shadow: 0 1px 8px rgba(8, 4, 8, 0.55);
}

.pill-k,
.tape-label,
.meta-k,
.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}

.pill-v,
.tape-value,
.meta-v {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.pill-sub {
  font-size: 0.75rem;
  opacity: 0.7;
}

.tape {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 78px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--glass);
  text-align: center;
  text-shadow: 0 1px 8px rgba(8, 4, 8, 0.55);
}

.tape-track {
  height: 160px;
  margin: 8px auto;
  width: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}

.tape-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  background: linear-gradient(180deg, #f0c36a, #c45c28);
}

.tape-value {
  font-size: 0.95rem;
}

.speed-wrap {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 88px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--glass);
  text-align: center;
  text-shadow: 0 1px 8px rgba(8, 4, 8, 0.55);
}

.speed-wrap .tape-value {
  font-size: 1.7rem;
  line-height: 1.1;
}

.speed-unit {
  font-size: 0.72rem;
  opacity: 0.65;
}

.stall,
.hint,
.crash-note {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
}

.stall {
  bottom: 92px;
  color: #ffd2b0;
  background: rgba(140, 32, 16, 0.72);
}

.hint {
  bottom: 28px;
}

.thermal-hint {
  bottom: 62px;
}

.crash-note {
  top: 28%;
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffd7a8;
}

.ring-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
}

.chevron {
  display: block;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 20px solid #f3c56a;
  filter: drop-shadow(0 0 8px rgba(255, 170, 70, 0.85));
  transform-origin: 50% 60%;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 140, 70, 0.16), transparent 36%),
    rgba(10, 6, 12, 0.34);
}

.overlay.dim {
  background: rgba(8, 5, 10, 0.46);
}

.card {
  width: min(560px, 100%);
  padding: 32px 34px 28px;
  border: 1px solid rgba(243, 230, 207, 0.2);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(36, 22, 24, 0.82), rgba(18, 12, 18, 0.88));
  box-shadow: var(--shadow);
  color: var(--ivory);
}

.card.slim {
  text-align: center;
  width: min(360px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
}

h1,
h2 {
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.3rem);
}

.goal {
  margin: 0 0 20px;
  font-size: 1.08rem;
  line-height: 1.45;
}

.controls {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  color: rgba(243, 230, 207, 0.88);
}

.meta {
  display: flex;
  gap: 28px;
  margin-bottom: 18px;
}

.meta-v {
  display: block;
  font-size: 1.25rem;
}

.launch {
  margin: 0;
  opacity: 0.86;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.08em 0.38em;
  border-radius: 6px;
  border: 1px solid rgba(243, 230, 207, 0.22);
  background: rgba(255, 255, 255, 0.06);
  font: 600 0.82em Outfit, sans-serif;
  text-align: center;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin: 8px 0 22px;
}

.results div {
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

dt {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.66;
}

dd {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.medal {
  min-height: 1.4em;
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 650;
}

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

button {
  pointer-events: auto;
  appearance: none;
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(243, 230, 207, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ivory);
  font: 650 1rem Outfit, sans-serif;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #c45c28;
  border-color: #e08a48;
  outline: none;
}

button:focus-visible {
  box-shadow: 0 0 0 3px rgba(224, 162, 74, 0.45);
}

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

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .card,
  .pill,
  .crash-note {
    transition: none;
  }

  .stall {
    animation: none;
  }
}
