:root {
  --ink: #f4f7fb; --dim: #b9c6d4; --accent: #ffd23f; --danger: #ff5a3c;
  --panel: rgba(14, 20, 28, 0.82); --line: rgba(255,255,255,0.12);
  --display: 'Racing Sans One', sans-serif; --body: 'Inter', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { height: 100%; overflow: hidden; background: #9fc6e8; font-family: var(--body); color: var(--ink); }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#hudroot { position: fixed; inset: 0; pointer-events: none; }
.hud-tl { position: absolute; top: calc(0.7rem + env(safe-area-inset-top)); left: 0.9rem; }
.place-box { font-family: var(--display); font-size: clamp(2.6rem, 9vw, 4.2rem); line-height: 0.9; text-shadow: 0 3px 12px rgba(0,0,0,0.55); }
.place-box sup { font-size: 0.4em; color: var(--accent); }
.place-lbl { font-weight: 700; font-size: 0.8rem; color: var(--dim); text-shadow: 0 1px 4px rgba(0,0,0,0.7); margin-top: -0.2rem; }

.hud-tr { position: absolute; top: calc(0.7rem + env(safe-area-inset-top)); right: 0.9rem; display: flex; gap: 0.7rem; }
.stat { text-align: right; font-family: var(--display); font-size: clamp(1.3rem, 4.5vw, 2rem); line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.stat small { display: block; font-family: var(--body); font-weight: 700; font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }

.hud-bar { position: absolute; bottom: calc(0.9rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(70vw, 460px); }
.prog { height: 7px; border-radius: 99px; background: rgba(0,0,0,0.4); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.prog-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #ff8a3c); transition: width 0.2s linear; }
.lod { position: absolute; bottom: calc(0.7rem + env(safe-area-inset-bottom)); right: 0.9rem; font-size: 0.6rem; color: var(--dim); font-weight: 600; letter-spacing: 0.03em; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }

.overlay, .start { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 1.2rem; background: radial-gradient(ellipse at center, rgba(6,10,16,0.4), rgba(6,10,16,0.82)); }
.start-card, .ov-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem 1.4rem; max-width: 420px; width: 100%; text-align: center; backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.logo { font-family: var(--display); font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 0.95; letter-spacing: 0.01em; }
.logo span { display: block; color: var(--accent); }
.tag { color: var(--dim); font-size: 0.9rem; line-height: 1.5; margin: 0.7rem 0 1.1rem; }
.ctrls { text-align: left; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--dim); background: rgba(0,0,0,0.25); border-radius: 12px; padding: 0.8rem 1rem; margin-bottom: 1.1rem; }
.ctrls b { color: var(--ink); }
.ov-card h1 { font-family: var(--display); font-size: clamp(2.4rem, 10vw, 3.8rem); }
.ov-card h1 { color: var(--danger); }
.ov-card p { color: var(--dim); font-size: 0.95rem; margin: 0.5rem 0 1.2rem; line-height: 1.5; }
.ov-card b { color: var(--ink); }
.ov-btn { font-family: var(--display); font-size: 1.1rem; letter-spacing: 0.02em; padding: 0.7rem 1.4rem; border: none; border-radius: 12px; background: var(--accent); color: #23303c; cursor: pointer; pointer-events: auto; margin: 0.3rem; box-shadow: 0 5px 0 #c79a1e; transition: transform 0.1s, box-shadow 0.1s; }
.ov-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c79a1e; }
.ov-btn.big { font-size: 1.35rem; padding: 0.85rem 2.2rem; }
.ov-btn.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); box-shadow: none; }
.ov-btn.ghost:active { transform: translateY(1px); }
[hidden] { display: none !important; }

/* ── title screen ─────────────────────────────────────────────── */
body.title { overflow: auto;
  background: radial-gradient(125% 85% at 50% 6%, #ffd9a3 0%, #f6a76b 20%, #c86a5e 42%, #6b3f6e 70%, #2a2340 100%) fixed; }
.title-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
/* far ridge */
.title-bg::before { content: ''; position: absolute; inset: 0; background: #3a2b52; opacity: 0.55;
  clip-path: polygon(0 66%, 15% 58%, 30% 67%, 46% 55%, 60% 66%, 74% 57%, 88% 65%, 100% 60%, 100% 100%, 0 100%); }
/* near ridge */
.title-bg::after { content: ''; position: absolute; inset: 0; background: #241d38;
  clip-path: polygon(0 78%, 12% 72%, 26% 80%, 40% 70%, 52% 79%, 66% 69%, 80% 78%, 92% 72%, 100% 80%, 100% 100%, 0 100%); }
.title-wrap { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 3rem 1.2rem calc(3rem + env(safe-area-inset-bottom)); gap: 0.2rem; }
.logo.big { font-size: clamp(3rem, 13vw, 6.4rem); letter-spacing: 0.02em; text-align: center;
  text-shadow: 0 6px 26px rgba(0,0,0,0.45); animation: drop 0.7s cubic-bezier(.2,.9,.3,1.2) both; }
.logo.big span { display: inline; color: var(--accent); }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) scale(0.96); } to { opacity: 1; transform: none; } }
.title-wrap .tag { font-size: clamp(0.9rem, 2.8vw, 1.15rem); color: #ffe9d0; margin: 0.3rem 0 2rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.4); animation: drop 0.7s 0.1s cubic-bezier(.2,.9,.3,1.2) both; }
.modes { display: flex; gap: 1.1rem; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 720px; }
.mode-card { pointer-events: auto; text-decoration: none; color: var(--ink); flex: 1 1 300px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem 1.4rem;
  backdrop-filter: blur(10px); box-shadow: 0 18px 50px rgba(0,0,0,0.4); text-align: center;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  animation: rise 0.6s 0.2s cubic-bezier(.2,.9,.3,1.2) both; }
.mode-card:nth-child(2) { animation-delay: 0.32s; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-5px); box-shadow: 0 26px 60px rgba(0,0,0,0.5); border-color: var(--accent); outline: none; }
.mode-card.race:hover { border-color: var(--accent); }
.mode-card.practice:hover { border-color: #5ecbff; }
.mc-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 0.7rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }
.mc-title { font-family: var(--display); font-size: 1.5rem; letter-spacing: 0.01em; margin-bottom: 0.35rem; }
.mode-card.practice .mc-title { color: #9fe0ff; }
.mode-card.race .mc-title { color: var(--accent); }
.mc-sub { font-size: 0.85rem; color: var(--dim); line-height: 1.5; }

/* ── practice HUD ─────────────────────────────────────────────── */
.hud-btn { position: absolute; top: calc(0.7rem + env(safe-area-inset-top)); left: 0.9rem; pointer-events: auto;
  text-decoration: none; font-weight: 700; font-size: 0.85rem; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.75rem; backdrop-filter: blur(8px); }
.hud-btn:active { transform: translateY(1px); }
.telemetry { position: absolute; bottom: calc(3.2rem + env(safe-area-inset-bottom)); left: 0.9rem;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.75rem;
  backdrop-filter: blur(8px); min-width: 128px; text-shadow: none; }
.telemetry .wh { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.28rem; color: var(--dim); }
.telemetry .wh i { display: block; height: 5px; border-radius: 99px; background: var(--accent); box-shadow: 0 0 6px var(--accent); transition: width 0.1s linear; }
.telemetry .wh.off { opacity: 0.4; }
.telemetry .wh.off i { background: var(--dim); box-shadow: none; }
.help { position: absolute; bottom: calc(0.8rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 0.68rem; color: var(--dim); background: rgba(14,20,28,0.6); border-radius: 99px;
  padding: 0.35rem 0.9rem; backdrop-filter: blur(6px); text-shadow: 0 1px 3px rgba(0,0,0,0.6); max-width: 96vw; overflow: hidden; text-overflow: ellipsis; }
.help b { color: var(--ink); }

/* ── track picker (race start card) ───────────────────────────── */
.trackname { margin: 0.2rem 0 0.7rem; }
.trackname b { font-family: var(--display); font-size: 1.25rem; color: var(--accent); }
.trackname span { display: block; font-size: 0.72rem; color: var(--dim); letter-spacing: 0.03em; }
.trackname em { display: inline-block; margin-top: 0.35rem; font-style: normal; font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: #9fe0ff; }
.trackpick { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin-bottom: 1rem; }
.track-chip { pointer-events: auto; text-decoration: none; font-size: 0.72rem; font-weight: 700; color: var(--dim);
  background: rgba(0,0,0,0.28); border: 1px solid var(--line); border-radius: 99px; padding: 0.3rem 0.7rem; transition: all 0.12s; }
.track-chip:hover { color: var(--ink); border-color: var(--dim); }
.track-chip.on { color: #23303c; background: var(--accent); border-color: var(--accent); }

/* ── career page ──────────────────────────────────────────────── */
body.career { overflow: auto; background: radial-gradient(125% 85% at 50% 6%, #ffd9a3 0%, #f6a76b 18%, #c86a5e 40%, #6b3f6e 70%, #2a2340 100%) fixed; }
.career-wrap { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 1.2rem 1rem calc(2.5rem + env(safe-area-inset-bottom)); }
.career-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.3rem; padding-top: calc(0.4rem + env(safe-area-inset-top)); }
.career-head .back { position: static; }
.career-head .logo { font-size: clamp(1.8rem, 6vw, 2.8rem); }
.career-head .logo span { display: inline; color: var(--dim); font-size: 0.5em; -webkit-text-fill-color: initial; }
.career-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 680px) { .career-cols { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.1rem 1.1rem 1.2rem; backdrop-filter: blur(10px); box-shadow: 0 16px 44px rgba(0,0,0,0.4); }
.panel h3 { font-family: var(--display); font-size: 1.15rem; letter-spacing: 0.01em; margin-bottom: 0.7rem; display: flex; justify-content: space-between; align-items: baseline; }
.panel h3 em { font-style: normal; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.standings { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.standings th { text-align: left; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); padding: 0 0.4rem 0.4rem; }
.standings td { padding: 0.33rem 0.4rem; border-top: 1px solid var(--line); }
.standings td:first-child { color: var(--dim); width: 1.4rem; }
.standings td.pts { text-align: right; font-weight: 800; font-family: var(--display); }
.standings td.last { color: var(--dim); font-size: 0.75rem; }
.standings tr.me td { color: var(--accent); font-weight: 700; }
.standings tr.me td.last { color: var(--accent); }
.sched { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.ev { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 11px; background: rgba(0,0,0,0.22); border: 1px solid transparent; }
.ev.now { border-color: var(--accent); background: rgba(255,210,63,0.1); }
.ev.done { opacity: 0.72; }
.ev-n { font-family: var(--display); color: var(--dim); width: 1.1rem; text-align: center; }
.ev-sw { width: 0.9rem; height: 0.9rem; border-radius: 4px; flex: none; }
.ev-name { flex: 1; font-weight: 700; font-size: 0.86rem; line-height: 1.15; }
.ev-name small { display: block; font-weight: 500; font-size: 0.66rem; color: var(--dim); }
.ev-place { font-weight: 800; font-size: 0.8rem; color: var(--ink); }
.ev-go { font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.ev-lock { color: var(--dim); }
.season-done { text-align: center; padding: 0.5rem 0 0.2rem; }
.season-done h2 { font-family: var(--display); font-size: 1.6rem; }
.season-done p { color: var(--dim); font-size: 0.85rem; line-height: 1.5; margin: 0.4rem 0 1rem; }
.panel .ov-btn.big { width: 100%; }
.panel .ov-btn.ghost { width: 100%; margin-top: 0.5rem; }
.mode-card.career:hover { border-color: var(--accent); }
.mode-card.career .mc-title { color: var(--accent); }
