:root {
  --p: #ff4b2b; --p-ink: #fff; --s: #ffb400; --d: #111216;
  --bg: #08090b; --card: #121318; --line: #23252d; --mut: #8b8f9c; --txt: #f3f4f6;
  --brand-font: 'Barlow Condensed', 'Arial Narrow', Impact, sans-serif;
  --ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--txt); font: 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased; overflow: hidden; }
body::before { content: ''; position: fixed; inset: -20%; background: radial-gradient(40% 40% at 70% 20%, color-mix(in srgb, var(--p) 22%, transparent), transparent 70%), radial-gradient(35% 35% at 15% 85%, color-mix(in srgb, var(--s) 12%, transparent), transparent 70%); pointer-events: none; transition: background 0.8s; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* header */
.top { position: relative; z-index: 5; display: flex; align-items: center; gap: 18px; height: 68px; padding: 0 32px; border-bottom: 1px solid var(--line); }
.top-logo { height: 26px; }
.top-tag { color: var(--mut); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; padding-left: 18px; border-left: 1px solid var(--line); }
.top-actions { margin-left: auto; display: flex; gap: 10px; }
.ghost { padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; color: var(--txt); background: #ffffff08; transition: 0.2s; }
.ghost:hover { border-color: #ffffff40; }
.ghost.icon { width: 40px; padding: 8px 0; }

.view { position: relative; z-index: 1; height: calc(100vh - 68px); }
.card { background: color-mix(in srgb, var(--card) 88%, transparent); border: 1px solid var(--line); border-radius: 18px; padding: 22px; backdrop-filter: blur(12px); }
h3 { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mut); font-weight: 600; margin-bottom: 14px; display: flex; justify-content: space-between; }
h3 small { text-transform: none; letter-spacing: 0; color: #5d616c; font-weight: 500; }
label { display: block; font-size: 13px; color: var(--mut); font-weight: 500; margin-bottom: 14px; }
label small { color: #5d616c; }
input { display: block; width: 100%; margin-top: 6px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0b0c10; color: var(--txt); font: 500 17px var(--ui); outline: none; transition: 0.15s; }
input:focus { border-color: var(--p); box-shadow: 0 0 0 3px color-mix(in srgb, var(--p) 25%, transparent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: #6b6f7b; }
.cta { width: 100%; margin-top: 8px; padding: 18px; border-radius: 14px; background: var(--p); color: var(--p-ink); font-weight: 700; font-size: 18px; display: flex; justify-content: center; gap: 10px; transition: transform 0.15s, filter 0.15s; }
.cta:hover { filter: brightness(1.08); } .cta:active { transform: scale(0.98); }
.cta.small { width: auto; padding: 10px 22px; font-size: 15px; margin: 0; }
.link { display: block; margin: 14px auto 0; color: var(--mut); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* form view */
#formView { display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center; gap: 6vw; padding: 0 8vw; }
.eyebrow { color: var(--p); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; margin-bottom: 18px; }
.hero h1 { font: 800 clamp(48px, 5.4vw, 92px)/0.95 var(--brand-font); text-transform: uppercase; letter-spacing: -0.01em; }
.hero h1 em { color: var(--p); font-style: italic; }
.lede { margin-top: 22px; font-size: 19px; color: #b4b7c1; max-width: 34ch; }
.form { padding: 30px; }

/* result view */
#resultView { display: grid; grid-template-columns: minmax(260px, 320px) 1fr minmax(300px, 380px); gap: 28px; padding: 24px 32px; }
.col { display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.left, .right { overflow: auto; }
.centre { align-items: center; justify-content: center; }

.kit-logo { height: 92px; border-radius: 12px; background: #fff; display: grid; place-items: center; padding: 14px; margin-bottom: 14px; }
.kit-logo.on-dark { background: var(--d); }
.kit-logo img { max-width: 100%; max-height: 64px; object-fit: contain; }
.kit-logo .wordmark { font: 800 26px var(--brand-font); color: var(--p); text-transform: uppercase; text-align: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.swatches button { width: 38px; height: 38px; border-radius: 10px; border: 2px solid #ffffff1a; transition: 0.15s; }
.swatches button.on { outline: 2px solid #fff; outline-offset: 2px; }
.swatches label.pick { width: 38px; height: 38px; margin: 0; border-radius: 10px; border: 1px dashed #ffffff40; display: grid; place-items: center; color: var(--mut); cursor: pointer; position: relative; }
.swatches label.pick input { position: absolute; inset: 0; opacity: 0; margin: 0; padding: 0; cursor: pointer; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs button { aspect-ratio: 1; border-radius: 10px; background-size: cover; background-position: center; border: 2px solid transparent; opacity: 0.6; transition: 0.15s; }
.thumbs button.on { border-color: var(--p); opacity: 1; }

/* player */
.player { height: calc(100vh - 68px - 48px - 50px); aspect-ratio: 9 / 16; max-width: 100%; border-radius: 22px; overflow: hidden; position: relative; background: #000; box-shadow: 0 30px 80px #000a, 0 0 0 1px #ffffff14; }
.stage { position: absolute; inset: 0; container-type: size; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #ffffff18; z-index: 20; }
.progress i { display: block; height: 100%; width: 0; background: var(--p); }
.player-ctrl { display: flex; align-items: center; gap: 14px; }

.scene { position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s ease; overflow: hidden; }
.scene.on { opacity: 1; z-index: 2; }
.scene.out { opacity: 1; z-index: 1; transition: none; }
.scene-map { opacity: 1; z-index: 0; }
.brand-font { font-family: var(--brand-font); }
.brand-bg { background: var(--p); color: var(--p-ink); }
.logo-card { background: #fff; border-radius: 4cqw; display: grid; place-items: center; padding: 3.5cqw 5cqw; }
.logo-card.on-dark { background: var(--d); }
.logo-card img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-card .wordmark { font: 800 7cqw/1 var(--brand-font); color: var(--p); text-transform: uppercase; text-align: center; }

/* map scene */
#map { position: absolute; inset: 0; }
.map-vignette { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, #000c 0%, transparent 22%, transparent 70%, #000d 100%); }
.map-top { position: absolute; top: 6cqh; left: 6cqw; right: 6cqw; display: flex; flex-direction: column; align-items: flex-start; gap: 1.2cqh; }
.chip { font: 800 6.5cqw/1 var(--brand-font); text-transform: uppercase; padding: 1.6cqw 3.4cqw; border-radius: 1.6cqw; }
.map-city { font: 600 4cqw var(--ui); letter-spacing: 0.25em; text-transform: uppercase; color: #fff; text-shadow: 0 2px 10px #000; }
.map-bottom { position: absolute; left: 6cqw; bottom: 6cqh; }
.km { font: 800 17cqw/0.9 var(--brand-font); color: #fff; font-variant-numeric: tabular-nums; }
.km small { font-size: 0.35em; color: #ffffffb0; }
.km-label { font: 600 3.4cqw var(--ui); letter-spacing: 0.3em; color: var(--p); margin-top: 1cqh; }
.scene-map .map-top, .scene-map .map-bottom { opacity: 0; transition: opacity 0.4s; }
.scene-map.on .map-top, .scene-map.on .map-bottom { opacity: 1; }

/* intro */
.scene-intro { background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--p) 75%, #000) 0%, var(--d) 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8cqw; }
.stripes { position: absolute; inset: 0; transform: skewY(-14deg); }
.stripes i { position: absolute; left: -10%; width: 120%; height: 7cqh; background: var(--s); opacity: 0.9; transform: translateX(-110%); }
.stripes i:nth-child(1) { top: 16%; } .stripes i:nth-child(2) { top: 27%; height: 2cqh; background: var(--p); opacity: 1; } .stripes i:nth-child(3) { top: 74%; height: 3cqh; background: #fff; opacity: 0.85; }
.scene-intro.on .stripes i { animation: sweep 1.1s cubic-bezier(0.7, 0, 0.2, 1) both; }
.scene-intro.on .stripes i:nth-child(2) { animation-delay: 0.12s; } .scene-intro.on .stripes i:nth-child(3) { animation-delay: 0.25s; }
@keyframes sweep { 0% { transform: translateX(-110%); } 55% { transform: translateX(0); } 100% { transform: translateX(110%); } }
.intro-logo { position: relative; width: 52cqw; height: 26cqw; transform: scale(0.4); opacity: 0; }
.scene-intro.on .intro-logo { animation: pop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) 0.55s both; }
.intro-title { position: relative; margin-top: 5cqh; font-weight: 800; font-size: 14cqw; line-height: 0.88; text-transform: uppercase; color: #fff; text-wrap: balance; text-shadow: 0 4px 30px #0008; }
.intro-sub { position: relative; margin-top: 2.5cqh; font: 600 4cqw var(--ui); letter-spacing: 0.3em; text-transform: uppercase; color: var(--s); }
.scene-intro.on .intro-title { animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) 0.9s both; }
.scene-intro.on .intro-sub { animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) 1.15s both; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; clip-path: inset(0 0 100% 0); } to { transform: none; opacity: 1; clip-path: inset(0 0 0 0); } }

/* athlete */
.photo { position: absolute; inset: -4%; background-size: cover; background-position: center; }
.scene-athlete.on .photo { animation: kb 5s linear both; }
@keyframes kb { from { transform: scale(1.12) translateX(2%); } to { transform: scale(1.0) translateX(-2%); } }
.photo-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--d) 92%, transparent) 88%); }
.ath-logo.small { position: absolute; top: 5cqh; right: 5cqw; width: 28cqw; height: 13cqw; padding: 2cqw 3cqw; border-radius: 2.5cqw; opacity: 0; }
.scene-athlete.on .ath-logo { animation: rise 0.6s ease 0.2s both; }
.lower { position: absolute; left: 6cqw; right: 6cqw; bottom: 8cqh; }
.finisher { display: inline-block; font: 800 4.6cqw/1 var(--ui); letter-spacing: 0.3em; padding: 2cqw 3cqw; transform: skewX(-12deg); opacity: 0; }
.name { margin-top: 2cqh; font-weight: 800; font-style: italic; font-size: 15cqw; line-height: 0.88; color: #fff; text-transform: uppercase; opacity: 0; }
.meta { display: flex; gap: 4cqw; margin-top: 3cqh; opacity: 0; }
.meta span { flex: 1; border-top: 0.8cqw solid var(--p); padding-top: 1.6cqh; }
.meta small { display: block; font: 600 3.2cqw var(--ui); letter-spacing: 0.3em; color: #ffffffa0; }
.meta b { font: 800 11cqw/1 var(--brand-font); color: #fff; font-variant-numeric: tabular-nums; }
.scene-athlete.on .finisher { animation: slide 0.5s cubic-bezier(0.2, 0.9, 0.2, 1) 0.35s both; }
.scene-athlete.on .name { animation: slide 0.6s cubic-bezier(0.2, 0.9, 0.2, 1) 0.55s both; }
.scene-athlete.on .meta { animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.2, 1) 0.85s both; }
@keyframes slide { from { transform: translateX(-60%) skewX(-12deg); opacity: 0; } to { transform: skewX(-12deg); opacity: 1; } }
.scene-athlete .name { transform: none; }
.scene-athlete.on .name { animation-name: slideName; }
@keyframes slideName { from { transform: translateX(-40%); opacity: 0; } to { transform: none; opacity: 1; } }

/* outro */
.scene-outro { background: linear-gradient(160deg, var(--p) 0%, color-mix(in srgb, var(--p) 40%, var(--d)) 45%, var(--d) 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8cqw; gap: 4cqh; }
.outro-congrats { font-weight: 800; font-size: 9cqw; line-height: 0.95; color: #ffffffd0; letter-spacing: 0.04em; }
.outro-congrats span { display: block; font-size: 1.7em; color: #fff; font-style: italic; }
.outro-logo { width: 50cqw; height: 24cqw; }
.outro-event { font: 600 4cqw var(--ui); letter-spacing: 0.25em; text-transform: uppercase; color: #ffffffc0; }
.outro-by { position: absolute; bottom: 6cqh; display: flex; align-items: center; gap: 2.5cqw; font: 500 3cqw var(--ui); color: #ffffff90; }
.outro-by img { height: 4.4cqw; }
.scene-outro.on .outro-congrats { animation: rise 0.6s ease 0.1s both; }
.scene-outro.on .outro-logo { animation: pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) 0.35s both; }
.scene-outro.on .outro-event { animation: rise 0.6s ease 0.55s both; }
.scene-outro.on .outro-by { animation: rise 0.6s ease 0.8s both; }

/* loader */
.loader { position: absolute; inset: 0; z-index: 30; background: #08090bf2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; transition: opacity 0.4s; }
.loader.done { opacity: 0; pointer-events: none; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid #ffffff18; border-top-color: var(--p); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader ol { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #5d616c; }
.loader li::before { content: '○'; display: inline-block; width: 22px; color: #5d616c; }
.loader li.busy { color: #fff; } .loader li.busy::before { content: '◐'; color: var(--p); }
.loader:has(li.err) .spinner { display: none; }
.loader li.err { color: #ff8a80; max-width: 30ch; } .loader li.err::before { content: '✕'; color: #ff5252; }
.loader li.ok { color: #b4b7c1; } .loader li.ok::before { content: '✓'; color: #3ddc84; }

/* impact */
.impact .big { margin: 6px 0 18px; padding: 18px; border-radius: 14px; background: linear-gradient(135deg, var(--p), color-mix(in srgb, var(--p) 45%, var(--d))); color: var(--p-ink); }
.impact .big small, .emv small { display: block; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }
.impact .big b { font: 800 64px/1 var(--brand-font); font-variant-numeric: tabular-nums; }
.row2.tight label { margin-bottom: 10px; }
.row2.tight input { padding: 9px 11px; font-size: 15px; }
.funnel { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.funnel li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; }
.funnel li b { font: 700 20px var(--brand-font); font-variant-numeric: tabular-nums; }
.funnel li span { color: #b4b7c1; }
.funnel li em { grid-column: 1 / -1; display: block; height: 6px; border-radius: 3px; background: #ffffff10; overflow: hidden; font-style: normal; }
.funnel li em i { display: block; height: 100%; width: 0; background: var(--p); border-radius: 3px; transition: width 1.1s cubic-bezier(0.2, 0.9, 0.2, 1); }
.funnel li small { grid-column: 1 / -1; color: #5d616c; font-size: 12px; }
.emv { margin: 18px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.emv b { font: 800 40px/1.1 var(--brand-font); color: var(--s); font-variant-numeric: tabular-nums; }

/* settings drawer */
.drawer { position: fixed; inset: 0; z-index: 50; background: #000a; display: grid; place-items: center; }
.drawer .card { width: 460px; max-height: 86vh; overflow: auto; background: var(--card); }
.drawer label { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 12px; }
.drawer input { margin: 0; padding: 8px 10px; font-size: 15px; }
.drawer-actions { display: flex; justify-content: space-between; margin-top: 10px; }
.maplibregl-ctrl-attrib { font-size: 9px; opacity: 0.6; }
