:root {
  --bg: #0a0c0d;
  --ink: #eef6f5;
  --dim: #7f8b8a;
  --faint: #2a3231;
  --teal: #00d2be;
  --teal-deep: #0b6b63;
  --gutter: clamp(16px, 3.2vw, 48px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  /* faint asphalt grain */
  background-image: radial-gradient(ellipse at 50% 40%, #121617 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: "Titillium Web", system-ui, sans-serif;
  cursor: pointer;
  user-select: none;
}
.mono { font-family: "Titillium Web", system-ui, sans-serif; font-weight: 600; }
.display { font-family: "Saira", sans-serif; font-stretch: 125%; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { transition: opacity .5s ease; }

#race { position: absolute; top: var(--gutter); left: var(--gutter); max-width: 46vw; }
#count { font-size: 13px; letter-spacing: .18em; color: var(--teal); text-transform: uppercase; }
#title {
  font-family: "Saira", sans-serif; font-stretch: 125%;
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: clamp(30px, 4.4vw, 70px); line-height: .95; letter-spacing: -.01em; margin-top: 10px;
}
#place { color: var(--dim); font-size: clamp(15px, 1.4vw, 20px); font-weight: 400; margin-top: 8px; letter-spacing: .04em; }
#headline {
  display: inline-block; margin-top: 16px; padding: 5px 10px 4px;
  font-family: "Saira", sans-serif; font-stretch: 125%; font-style: italic;
  font-weight: 800; font-size: clamp(13px, 1.15vw, 17px); letter-spacing: .04em; text-transform: uppercase;
  color: var(--bg); background: var(--teal);
}
#headline:empty { display: none; }

#stats { position: absolute; top: var(--gutter); right: var(--gutter); width: min(260px, 30vw); text-align: right; }
#stats dl { display: grid; gap: 14px; }
#stats dt { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
#stats dd { font-family: "Saira", sans-serif; font-stretch: 125%; font-size: clamp(19px, 1.8vw, 28px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; }

/* championship: a single line under the headline */
#champ { margin-top: 22px; }
#c-lead { font: 800 italic clamp(16px, 1.4vw, 21px) "Saira", sans-serif; font-stretch: 125%; text-transform: uppercase; }
#c-lead small { display: block; font: 600 11px "Titillium Web", sans-serif; letter-spacing: .14em; color: var(--dim); margin-bottom: 4px; font-style: normal; }
#c-lead .up { color: var(--teal); }
#c-lead .down { color: var(--dim); }
#c-lead em { display: block; font: 700 11px "Titillium Web", sans-serif; letter-spacing: .12em; color: var(--teal); margin-top: 4px; font-style: normal; }
@media (max-aspect-ratio: 11/10) { #champ { display: none; } }

#telemetry {
  position: absolute; left: var(--gutter); bottom: var(--gutter);
  display: flex; gap: 26px; align-items: flex-end;
}
#telemetry > div { display: flex; flex-direction: column; }
#telemetry span { font-family: "Saira", sans-serif; font-stretch: 125%; font-size: clamp(24px, 2.3vw, 36px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
#t-speed, #t-mph { min-width: 3ch; }
#telemetry .alt span { color: var(--dim); font-size: clamp(18px, 1.6vw, 26px); }
#telemetry small { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-top: 6px; }
#telemetry .bar { width: 90px; }
#telemetry .bar i { display: block; height: 6px; background: var(--faint); position: relative; overflow: hidden; margin-bottom: 4px; }
#telemetry .bar i::after { content: ""; position: absolute; inset: 0; width: var(--v, 0%); background: var(--teal); }
#t-lap { font-size: 11px; color: var(--dim); letter-spacing: .08em; align-self: flex-end; max-width: 26ch; line-height: 1.4; }


#finale {
  position: absolute; right: calc(var(--gutter) * 1.5); top: 50%; transform: translateY(-50%);
  max-width: 34vw; opacity: 0;
}
#f-kicker { color: var(--teal); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; }
#f-name {
  font-family: "Saira", sans-serif; font-stretch: 125%;
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: clamp(36px, 4.6vw, 76px); line-height: .95; margin-top: 12px;
}
#f-title { font-family: "Saira", sans-serif; font-stretch: 125%; font-style: italic; font-size: clamp(16px, 1.7vw, 26px); font-weight: 800; letter-spacing: .02em; text-transform: uppercase; margin-top: 18px; color: var(--teal); }
#f-line { font-size: clamp(16px, 1.5vw, 22px); color: var(--dim); margin-top: 14px; letter-spacing: .03em; }


body.finale #race, body.finale #stats, body.finale #telemetry, body.finale #champ { opacity: 0; }
body.finale #finale { opacity: 1; transition: opacity 1.2s ease 2.6s; }
/* square / vertical: stack the text above and below the track */
@media (max-aspect-ratio: 11/10) {
  #race { max-width: none; right: var(--gutter); }
  #stats { top: auto; bottom: calc(var(--gutter) + 120px); width: auto; left: auto; }
  #stats dl { grid-template-columns: repeat(2, auto); column-gap: 22px; }
  #telemetry { bottom: calc(var(--gutter) + 40px); }
    #finale { top: auto; bottom: calc(var(--gutter) * 1.4); transform: none; left: var(--gutter); max-width: none; }
  #f-name { font-size: clamp(30px, 7.4vw, 64px); }
}

/* ---------- globe ---------- */
#globe-wrap { position: fixed; transition: transform .8s cubic-bezier(.6,0,.3,1), opacity .6s ease; cursor: grab; will-change: transform, opacity; }
#globe-wrap.dive { transform: scale(3.2); opacity: 0; pointer-events: none; }
#globe { width: 100%; height: 100%; display: block; }
#pins { position: absolute; inset: 0; pointer-events: none; }
/* each marker is an invisible hit target; its label only shows on hover / focus */
.pin {
  position: absolute; width: 26px; height: 26px; translate: -50% -50%; border-radius: 50%;
  background: none; border: 0; pointer-events: auto; cursor: pointer; transition: opacity .25s;
}
.pin span {
  position: absolute; left: 50%; bottom: calc(100% + 2px); translate: -50% 0; white-space: nowrap;
  font: 700 italic 13px "Saira", sans-serif; font-stretch: 125%; text-transform: uppercase; letter-spacing: .02em;
  color: var(--bg); background: var(--teal); padding: 3px 8px 2px;
  opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s;
}
.pin small { font: 700 10px "Titillium Web", sans-serif; margin-left: 6px; letter-spacing: .08em; font-style: normal; }
.pin:hover span, .pin.on span { opacity: 1; transform: none; }
.pin:hover { z-index: 2; }

#g-list { list-style: none; margin-top: 26px; display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: 420px; }
#g-list button {
  display: block; padding: 4px 0; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid transparent; color: var(--dim); text-align: left;
  font: 700 italic 15px "Saira", sans-serif; font-stretch: 125%; text-transform: uppercase; pointer-events: auto;
  transition: color .2s, border-color .2s;
}
#g-list b { font: 600 11px "Titillium Web", sans-serif; color: var(--dim); width: 26px; letter-spacing: .06em; }
#g-list small { margin-left: auto; font: 600 11px "Titillium Web", sans-serif; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
#g-list button:hover, #g-list button.on { color: var(--teal); border-color: var(--teal); }

#globe-hud { position: absolute; top: 50%; left: var(--gutter); transform: translateY(-50%); max-width: 34vw; opacity: 0; transition: opacity .5s; }
#globe-hud .kicker { color: var(--teal); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; }
#g-title {
  font-family: "Saira", sans-serif; font-stretch: 125%; font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: clamp(32px, 4vw, 64px); line-height: .95; margin-top: 12px;
}
#pr-wrap { margin-top: 22px; width: min(440px, 34vw); }
#pr-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); min-height: 1.4em; }
#pr-label b { color: var(--teal); font-weight: 700; }
#pr { width: 100%; height: clamp(110px, 18vh, 160px); display: block; margin-top: 6px; }
#globe-hud .sub { color: var(--dim); font-size: clamp(15px, 1.4vw, 20px); margin-top: 16px; }
#lapnav { position: absolute; top: var(--gutter); left: 50%; translate: -50% 0; display: flex; gap: 8px; transition: opacity .5s; }
#lapnav button, #g-summary {
  pointer-events: auto; cursor: pointer;
  background: none; border: 1px solid var(--faint); color: var(--dim); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; padding: 6px 12px;
}
#lapnav button:hover, #g-summary:hover { color: var(--ink); border-color: var(--teal); }
#g-summary { margin-top: 22px; }

body.mode-globe #globe-hud { opacity: 1; }
body.mode-globe #race, body.mode-globe #stats, body.mode-globe #telemetry,
body.mode-globe #lapnav, body.finale #lapnav, body.play #lapnav, body.play #g-summary { opacity: 0; pointer-events: none; }
body.mode-globe #lapnav button, body.finale #lapnav button { pointer-events: none; }
body.mode-globe #stage { pointer-events: none; }
body { cursor: default; }
@media (max-aspect-ratio: 11/10) {
  #globe-hud { top: auto; transform: none; bottom: calc(var(--gutter) + 60px); max-width: none; right: var(--gutter); }
}
