:root {
  color-scheme: dark;
  --ink: #f3f7ff;
  --muted: #b2c2da;
  --accent: #b5eaff;
  --line: #adc5ef29;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: #0b1429; color: var(--ink); }
button, select, input { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:is(button, select, input):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .45; }
p, h1, h2, h3 { margin: 0; }

.wordmark { display: inline-flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 730; letter-spacing: -.045em; }
.mark { display: inline-block; width: 22px; height: 15px; border: 1.5px solid currentColor; border-radius: 100px; color: var(--accent); transform: skewX(-20deg) rotate(-15deg); position: relative; }
.mark::after { content: ''; position: absolute; inset: 2px 3px; border: 1px solid currentColor; border-radius: inherit; }
.app-shell {
  --content-inset: max(17px, env(safe-area-inset-left), env(safe-area-inset-right), calc((100% - 660px) / 2));
  --safe-top: max(4px, env(safe-area-inset-top));
  --top-space: calc(var(--safe-top) + 49px);
  --dock-lift: max(0px, calc(env(safe-area-inset-bottom) - 9px));
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  background: radial-gradient(ellipse at 65% 16%, #324c77, transparent 70%), #121f38;
}
.app-bar { z-index: 3; position: absolute; inset: var(--safe-top) var(--content-inset) auto; display: flex; justify-content: space-between; align-items: center; height: 43px; pointer-events: none; }
.app-bar .wordmark, .profile-link { padding: 0 10px; height: 36px; border-radius: 100px; }
.profile-link { pointer-events: auto; font-size: 13px; letter-spacing: -.01em; }

.glass, .app-bar .wordmark, .profile-link, nav {
  border: 1px solid #c0ddff37;
  background: linear-gradient(148deg, #bad8ff36, #8db7f313 70%), #16254173;
  -webkit-backdrop-filter: blur(22px) saturate(148%);
  backdrop-filter: blur(22px) saturate(148%);
  box-shadow: inset 0 1px #e4f3ff33, 0 5px 20px #07132c2b;
}
main { position: relative; flex: 1; min-height: 0; overflow: auto; scrollbar-width: none; padding: calc(var(--top-space) + 6px) var(--content-inset) 105px; }
main::-webkit-scrollbar { display: none; }
main:focus { outline: none; }
main[data-page=race] { padding: 0; }
.eyebrow { display: block; color: var(--accent); font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.screen-title { font-size: clamp(31px, 8.8vw, 40px); line-height: 1.025; font-weight: 720; letter-spacing: -.071em; margin: 3px 0; }
.race-date { color: var(--muted); font-size: 13px; margin-top: 7px; }

.race-intro { height: calc(var(--view) + 64px); }
.race-scene {
  --dissolve: 0;
  display: flex;
  flex-direction: column;
  height: var(--view);
  position: sticky;
  top: 0;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse at 76% 27%, #6c97bf85, transparent 44%), radial-gradient(ellipse at 1% 62%, #3d6897, transparent 52%), linear-gradient(168deg, #344a73 0%, #182b4c 45%, #0e1a32 84%);
  opacity: calc(1 - var(--dissolve));
  transform: scale(calc(1 - var(--dissolve) * .045));
  filter: blur(calc(var(--dissolve) * 6px));
}
.race-heading { z-index: 1; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 11px; margin: calc(var(--top-space) + 8px) var(--content-inset) 0; }
.race-heading .screen-title { font-size: clamp(29px, 8.85vw, 40px); line-height: .99; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.activity-trigger { display: grid; gap: 3px; border-radius: 17px; min-width: 110px; padding: 8px 9px; text-align: left; }
.activity-trigger strong { font-size: 17px; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.activity-trigger small, .activity-trigger > span { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0; }
.week-dots { display: flex; gap: 4px; align-items: center; }
.week-dots i { width: 8px; height: 8px; border: 1px solid #accdee9c; border-radius: 50%; background: var(--day-color); }
.race-field { position: absolute; inset: calc(var(--top-space) + 88px) 0 117px; width: min(100%, 850px); margin-inline: auto; }
.race-field::before { content: ''; position: absolute; inset: 14% -14% 10%; background: repeating-radial-gradient(ellipse at 100% 8%, transparent 0 20px, #c3ebff20 21px, transparent 22px 32px); transform: rotate(-11deg); opacity: .51; }
#race-field, #profile-racer { display: block; width: 100%; height: 100%; position: relative; }
.arena-controls { z-index: 1; position: absolute; inset: auto var(--content-inset) 93px; display: flex; align-items: center; pointer-events: none; min-height: 38px; }
.race-status { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 999px; color: #e9f4ff; font-size: 13px; font-weight: 660; }
.race-status span { border-left: 1px solid var(--line); padding-left: 9px; color: var(--muted); }
.leaderboard-link { position: absolute; inset: auto 0 66px; margin: auto; width: max-content; min-height: 26px; padding: 2px 10px; display: flex; align-items: center; gap: 8px; color: #dfeafb; font-size: 12px; border-radius: 999px; }
.leaderboard-link span { width: 6px; height: 6px; border-bottom: 1px solid currentColor; border-right: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }

.leaderboard { z-index: 1; position: relative; min-height: var(--view); padding: 20px var(--content-inset) 105px; border-radius: 28px 28px 0 0; border-top: 1px solid #97b9ee38; background: linear-gradient(148deg, #2c436c, #142441 38%, #101d34); }
.rank-title { display: flex; justify-content: space-between; align-items: end; gap: 5px; margin-bottom: 19px; }
.rank-title h2 { font-size: clamp(30px, 8.1vw, 38px); }
#leaderboard-title:focus { outline: 0; }
.mode { display: flex; align-items: center; border-radius: 999px; padding: 3px; flex-shrink: 0; }
.mode button { border: 0; border-radius: inherit; background: transparent; color: var(--muted); padding: 6px 8px; min-height: 33px; font-weight: 630; font-size: 13px; }
.mode [aria-pressed=true] { background: #bad8ff38; color: #fff; box-shadow: inset 0 1px #e9f4ff31; }
.pace { display: grid; grid-template-columns: 1fr 1fr; margin: 11px 0 17px; }
.pace div { padding: 2px 0 2px 3px; }
.pace div + div { border-left: 1px solid var(--line); padding-left: 13px; }
.pace strong { display: block; color: var(--accent); font-size: 18px; font-weight: 720; letter-spacing: -.045em; }
.pace span { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.rank-list, .history { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 17px 36px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 52px; padding: 5px 7px; border-bottom: 1px solid var(--line); font-size: 15px; }
.rank-list .my-rank { background: #9bcdf52d; border-bottom-color: transparent; border-radius: 13px; }
.place { color: var(--muted); font-size: 13px; text-align: center; }
.mini { display: block; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: #a3c1fa20; }
.racer-thumbnail { display: block; width: 100%; height: 100%; }
.champion-tag { display: inline-block; padding: 2px 5px; color: #ffe2a0; background: #8160395c; border: 1px solid #dbb06d61; border-radius: 999px; font-size: 10px; vertical-align: 1px; }
.total { font-variant-numeric: tabular-nums; font-weight: 710; }
.freshness { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.race-note { font-size: 14px; color: var(--accent); margin-top: 12px; }

nav { z-index: 3; position: absolute; inset: auto 0 max(9px, env(safe-area-inset-bottom)); margin: auto; width: calc(100% - 34px); max-width: 326px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 999px; }
nav button { border: 0; min-height: 43px; background: transparent; color: #d0def3; border-radius: 999px; font-size: 11px; font-weight: 650; }
nav [aria-current=page] { color: #fff; background: linear-gradient(150deg, #cfe5ff59, #9ac4fd22); box-shadow: inset 0 1px #edf6ff4d; }
.nav-icon { position: relative; display: block; width: 36px; height: 22px; margin: 0 auto; }
.nav-icon::before, .nav-icon::after { position: absolute; content: ''; }
.flag::before { top: 4px; left: 12px; width: 2px; height: 15px; background: currentColor; border-radius: 2px; }
.flag::after { top: 4px; left: 14px; width: 10px; height: 7px; border: 1.5px solid currentColor; border-left: 0; border-radius: 0 3px 3px 0; }
.group::before, .person::before { top: 3px; left: 15px; width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 50%; }
.group::after, .person::after { top: 12px; left: 11px; width: 14px; height: 6px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 10px 10px 1px 1px; }
.group::before { left: 10px; box-shadow: 11px 1px 0 -1px #344967, 11px 1px 0 currentColor; }
.group::after { left: 7px; width: 12px; box-shadow: 9px 1px 0 -1px #344967, 10px 1px 0 currentColor; }

.section { margin-top: 17px; padding: 0 0 14px; border-bottom: 1px solid var(--line); }
.section h3 { font-size: 19px; font-weight: 710; letter-spacing: -.045em; }
.section p, dialog p { color: var(--muted); font-size: 14px; line-height: 1.46; margin: 5px 0 11px; }
.section label { display: block; font-size: 14px; font-weight: 650; margin: 11px 0 5px; }
.section input, .section select { width: 100%; padding: 10px 11px; min-height: 43px; border: 1px solid var(--line); border-radius: 12px; background: #b4caef13; }
.primary { border: 1px solid #d9eeffac; border-radius: 999px; background: #c5e3fb; color: #152846; min-height: 42px; font-weight: 710; padding: 8px 15px; }
.primary:hover { background: #e2f2ff; }
.section .primary { margin-top: 9px; }
.club-card { border: 1px solid var(--line); border-radius: 24px; padding: 15px; background: linear-gradient(135deg, #91b9ed46, #6a8cbd16); box-shadow: inset 0 1px #edf6ff35; }
.club-card h3 { font-size: 24px; overflow-wrap: anywhere; }
.roster { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.roster .mini { outline: 1px solid #b9dafa56; background: #5d7fac; }
.roster .mini + .mini { margin-left: -4px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; color: var(--muted); font-size: 14px; }
.history strong { color: var(--ink); }

.racer-stage { height: 174px; margin-top: 13px; position: relative; isolation: isolate; overflow: hidden; border-radius: 24px; background: radial-gradient(ellipse at 50% 82%, #458ca888, transparent 52%), linear-gradient(146deg, #5489bb79, #344467b5); }
.racer-stage::before { content: ''; position: absolute; inset: 68% -8% -44%; border-radius: 50%; border: 1px solid #d7eeff62; box-shadow: 0 0 0 9px #b8defa1d, 0 0 0 19px #b8defa13; }
.photo-button { position: absolute; bottom: 9px; right: 9px; padding: 8px 10px; border-radius: 999px; font-size: 13px; cursor: pointer; }
#selfie { position: absolute; bottom: 9px; right: 9px; opacity: 0; width: 1px; height: 1px; }
.racer-stage:focus-within .photo-button { outline: 2px solid var(--accent); }
.locker-champion { position: absolute; top: 11px; left: 11px; }
.photo-privacy { margin-top: 7px; color: var(--muted); font-size: 12px; }
.quiet-button { padding: 6px 1px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.locker-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.locker-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.locker-links button { min-height: 47px; border-radius: 15px; font-weight: 700; }
.catalog-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.catalog-tabs button { padding: 8px 11px; min-height: 40px; border-radius: 999px; font-size: 13px; }
.catalog-tabs [aria-pressed=true], .try-on-grid [aria-pressed=true] { border-color: var(--accent); background-color: #4b6389; }
.try-on-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.try-on-tile { display: grid; align-content: start; gap: 4px; padding: 5px 5px 7px; min-width: 0; min-height: 109px; border-radius: 15px; text-align: center; }
.try-on-tile strong { font-size: 12px; overflow-wrap: anywhere; }
.try-on-tile > span:not(.tile-art) { color: #d6e5f9; font-size: 11px; line-height: 1.2; }
.try-on-tile:disabled { opacity: .63; }
.tile-art { display: block; height: 78px; background: var(--tile-background, radial-gradient(ellipse at 50% 90%, #a5d3eb33, #7da6dc13)); border-radius: 11px; }
.tile-art canvas { display: block; width: 100%; height: 100%; }
.lane-color { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.lane-color input { width: 44px; min-height: 35px; padding: 3px 4px; border: 1px solid var(--line); border-radius: 9px; background: transparent; }
.medals { display: flex; gap: 7px; margin-top: 8px; }
.medals span { display: grid; place-items: center; width: 32px; height: 32px; color: #62491b; border: 1px solid #e9b848; background: #ffda78; border-radius: 50%; font-size: 17px; }

.activity-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.activity-totals strong { display: block; font-size: 25px; letter-spacing: -.05em; }
.activity-totals span, .week-grid button > span { color: var(--muted); font-size: 12px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.week-grid button { display: grid; justify-items: center; gap: 6px; padding: 0; border: 0; background: transparent; }
.day-circle { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid #accdee9c; border-radius: 50%; background: var(--day-color); font-size: 12px; }
.day-circle.filled { color: #0c263b; }
.week-grid [aria-pressed=true] .day-circle { outline: 2px solid #e1f1ff; outline-offset: 2px; }
.day-detail { min-height: 18px; }

dialog { width: min(350px, calc(100% - 34px)); padding: 21px; background: #263c62; color: var(--ink); border: 1px solid #b3d4fa42; border-radius: 25px; box-shadow: 0 14px 80px #0913289e; }
dialog::backdrop { background: #0c163376; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
dialog h2 { font-size: 24px; letter-spacing: -.05em; }
.close-demo { position: absolute; right: 10px; top: 8px; width: 36px; height: 36px; color: var(--muted); border: 0; border-radius: 50%; background: transparent; font-size: 23px; }
output { display: block; color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }
output:not(:empty) { margin-top: 8px; }

@media (min-width: 650px) {
  .try-on-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-height: 590px) {
  .race-field { inset-block-end: 114px; }
  .arena-controls { bottom: 88px; }
  .leaderboard-link { bottom: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  .race-scene { filter: none; transform: none; }
}
.race-field, .arena-controls, .leaderboard-link { translate: 0 calc(-1 * var(--dock-lift)); }
