:root {
  --bg: #090b0e;
  --panel: rgba(13, 16, 21, 0.82);
  --panel-solid: #12161c;
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef1f5;
  --dim: #98a2b0;
  --accent: #ff2a2a;
  --accent2: #ffb400;
  --good: #31d17a;
  --purple: #b36bff;
  --u: min(1vw, 1.78vh);
  --font: 'Titillium Web', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.38) 100%); }
#app { position: fixed; inset: 0; pointer-events: none; }
#app > * { pointer-events: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }

/* ------------------------------------------------------------ screens / menus */
#screens { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; pointer-events: auto; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.screen.dim { overflow-y: auto; background: linear-gradient(90deg, rgba(5,7,10,0.92) 0%, rgba(5,7,10,0.7) 45%, rgba(5,7,10,0.25) 100%); }
.screen.full { background: rgba(5,7,10,0.94); backdrop-filter: blur(12px); }
.menu-col { width: min(34rem, 92vw); padding: 7vh 4vw; display: flex; flex-direction: column; justify-content: center; gap: 0.6rem; }
.logo { font-weight: 900; font-style: italic; font-size: clamp(2.6rem, 6vw, 4.6rem); line-height: 0.9; letter-spacing: -0.02em; text-transform: uppercase; }
.logo span { color: var(--accent); }
.tagline { color: var(--dim); font-size: 1rem; margin: 0.6rem 0 1.6rem; letter-spacing: 0.04em; }
.btn { background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-left: 4px solid transparent; padding: 0.9rem 1.2rem; font-size: 1.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; text-align: left; transition: all 0.15s; clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%); }
.btn:hover, .btn:focus-visible { background: rgba(255,255,255,0.14); border-left-color: var(--accent); transform: translateX(6px); outline: none; }
.btn small { display: block; font-size: 0.78rem; color: var(--dim); font-weight: 400; letter-spacing: 0.03em; text-transform: none; margin-top: 2px; }
.btn.primary { background: linear-gradient(90deg, var(--accent), #c40d0d); border-left-color: #fff; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.sm { padding: 0.5rem 0.9rem; font-size: 0.95rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.row { display: flex; gap: 0.7rem; align-items: center; }
.grow { flex: 1; }
.version { position: absolute; left: 4vw; bottom: 2.5vh; color: var(--dim); font-size: 0.8rem; }

.panel-screen { flex-direction: column; padding: 3.5vh 4vw; gap: 1rem; overflow: auto; }
.panel-screen h2 { font-size: 2rem; font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: 0.01em; }
.panel-screen h2 span { color: var(--accent); }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab { padding: 0.5rem 1.1rem; background: rgba(255,255,255,0.05); border: 1px solid var(--line); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.95rem; }
.tab.active { background: var(--accent); border-color: var(--accent); }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 1.1rem 1.3rem; backdrop-filter: blur(10px); }
.panel h3 { font-size: 0.85rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 0.7rem; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.footer { display: flex; gap: 0.8rem; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 0.5rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field label { font-size: 0.82rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; display: flex; justify-content: space-between; }
.field label b { color: var(--text); font-weight: 700; letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { padding: 0.4rem 0.8rem; background: rgba(255,255,255,0.06); border: 1px solid var(--line); font-size: 0.9rem; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); }
.chip.dot::before { content: ''; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.45em; background: var(--c, #fff); vertical-align: -0.05em; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: pointer; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--line); font-size: 0.98rem; }
.toggle:last-child { border-bottom: 0; }
.switch { width: 2.7rem; height: 1.45rem; background: rgba(255,255,255,0.15); border-radius: 1rem; position: relative; transition: 0.15s; flex: none; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; transition: 0.15s; }
.switch.on { background: var(--good); }
.switch.on::after { left: calc(100% - 3px - 1.1rem); }
.hint { color: var(--dim); font-size: 0.82rem; line-height: 1.35; }

/* track cards */
.tracks { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.8rem; }
.tcard { background: rgba(255,255,255,0.05); border: 2px solid var(--line); padding: 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; text-align: left; transition: 0.15s; }
.tcard:hover { background: rgba(255,255,255,0.1); }
.tcard.on { border-color: var(--accent); background: rgba(255,42,42,0.12); }
.tcard svg { width: 100%; height: 6.5rem; }
.tcard h4 { font-size: 1.05rem; font-weight: 700; text-transform: uppercase; }
.tcard .meta { font-size: 0.8rem; color: var(--dim); display: flex; justify-content: space-between; }
.tcard p { font-size: 0.82rem; color: var(--dim); line-height: 1.3; min-height: 2.2em; }

/* team grid */
.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.5rem; }
.team { display: flex; gap: 0.6rem; align-items: center; background: rgba(255,255,255,0.05); border: 2px solid var(--line); padding: 0.55rem 0.7rem; text-align: left; transition: 0.15s; }
.team:hover { background: rgba(255,255,255,0.1); }
.team.on { border-color: var(--accent); background: rgba(255,42,42,0.12); }
.team i { width: 0.5rem; align-self: stretch; background: var(--c); border-radius: 2px; box-shadow: 0 0 0 2px var(--c2) inset; }
.team b { display: block; font-size: 0.95rem; text-transform: uppercase; }
.team .bar { height: 4px; background: rgba(255,255,255,0.14); margin-top: 4px; width: 7rem; }
.team .bar span { display: block; height: 100%; background: var(--accent2); }

/* controls table */
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.5rem 1.5rem; }
.key { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
kbd { background: #242a33; border: 1px solid #3a4350; border-bottom-width: 3px; border-radius: 4px; padding: 0.1rem 0.5rem; font-family: var(--font); font-weight: 700; font-size: 0.88rem; margin-left: 0.3rem; }

/* loading */
.loading { align-items: center; justify-content: center; flex-direction: column; gap: 1.2rem; background: radial-gradient(circle at center, #151a22, #06080b); }
.loading .bar { width: min(26rem, 70vw); height: 5px; background: rgba(255,255,255,0.12); overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* results */
table.results { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.results th { text-align: left; font-size: 0.75rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); font-weight: 600; }
table.results td { padding: 0.32rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.06); font-variant-numeric: tabular-nums; }
table.results tr.me td { background: rgba(255,42,42,0.18); font-weight: 700; }
table.results .pos { font-weight: 900; width: 2.3rem; }
table.results .tc { display: inline-block; width: 4px; height: 1em; vertical-align: -0.15em; margin-right: 0.5rem; background: var(--c); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin: 0.5rem 0 1rem; }
.pod { text-align: center; padding: 0.8rem 1.2rem; background: var(--panel); border-top: 4px solid var(--c); min-width: 9.5rem; }
.pod b { display: block; font-size: 1.5rem; font-weight: 900; }
.pod.p1 { padding-bottom: 2.2rem; }
.pod.p2 { padding-bottom: 1.3rem; }

/* ------------------------------------------------------------ HUD */
#hud { position: absolute; inset: 0; font-size: calc(var(--u) * 1.2); }
.hud-box { position: absolute; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); }
#tower { left: calc(var(--u) * 1.4); top: calc(var(--u) * 1.4); width: calc(var(--u) * 17); font-variant-numeric: tabular-nums; }
#tower .hd { padding: 0.35em 0.7em; font-weight: 900; font-style: italic; text-transform: uppercase; background: rgba(255,255,255,0.06); display: flex; justify-content: space-between; font-size: 0.95em; letter-spacing: 0.03em; }
#tower .r { display: grid; grid-template-columns: 1.7em 0.3em 2.5em 1fr auto; align-items: center; gap: 0.45em; padding: 0.15em 0.6em 0.15em 0.4em; height: 1.55em; font-weight: 600; font-size: 0.95em; border-bottom: 1px solid rgba(255,255,255,0.04); }
#tower .r.me { background: linear-gradient(90deg, rgba(255,42,42,0.55), rgba(255,42,42,0.15)); font-weight: 900; }
#tower .r .p { text-align: right; opacity: 0.9; }
#tower .r .c { height: 1.05em; background: var(--c); }
#tower .r .g { text-align: right; color: #dbe1ea; font-size: 0.9em; }
#tower .r .t { width: 1.1em; height: 1.1em; border-radius: 50%; font-size: 0.6em; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; color: #111; margin-left: 0.4em; }
#tower .r.out { opacity: 0.4; }
#tower .r .pit { color: var(--accent2); font-weight: 900; font-size: 0.8em; }
#tower .gap-sep { height: 0.4em; }

#topbar { top: calc(var(--u) * 1.4); left: 50%; transform: translateX(-50%); text-align: center; padding: 0.3em 1.2em; display: flex; gap: 1.2em; align-items: baseline; }
#topbar .lap { font-size: 1.6em; font-weight: 900; font-style: italic; text-transform: uppercase; }
#topbar .lap small { font-size: 0.55em; color: var(--dim); font-weight: 600; margin-right: 0.3em; }
#topbar .wx { font-size: 0.95em; color: #7cc4ff; font-weight: 700; }
#topbar .radar { display: flex; gap: 2px; align-items: center; }
#topbar .radar small { color: var(--dim); font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.08em; margin-right: 0.3em; }
#topbar .radar i { width: 0.75em; height: 0.75em; border-radius: 2px; background: rgba(255,255,255,0.14); }
#topbar .radar i.r1 { background: #5ab4ff; } #topbar .radar i.r2 { background: #2a6cff; } #topbar .radar i.r3 { background: #7a3cff; }
#topbar .clock { font-size: 1.05em; color: var(--dim); font-variant-numeric: tabular-nums; }

#timing { right: calc(var(--u) * 1.4); top: calc(var(--u) * 1.4); width: calc(var(--u) * 19); padding: 0.6em 0.9em; font-variant-numeric: tabular-nums; }
#timing .cur { font-size: 2.3em; font-weight: 900; line-height: 1; letter-spacing: -0.01em; }
#timing .delta { font-size: 1.15em; font-weight: 700; margin-left: 0.5em; }
#timing .delta.neg { color: var(--good); }
#timing .delta.pos { color: var(--accent); }
#timing .lines { display: grid; grid-template-columns: auto 1fr; gap: 0.1em 0.8em; margin-top: 0.4em; font-size: 0.95em; }
#timing .lines span:nth-child(odd) { color: var(--dim); text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.1em; align-self: center; }
#timing .lines span:nth-child(even) { text-align: right; font-weight: 700; }
#timing .sectors { display: flex; gap: 0.3em; margin-top: 0.5em; }
#timing .sectors i { flex: 1; height: 0.4em; background: rgba(255,255,255,0.18); }
#timing .sectors i.green { background: var(--good); }
#timing .sectors i.purple { background: var(--purple); }
#timing .sectors i.yellow { background: var(--accent2); }
#timing .sectors i.cur { box-shadow: 0 0 0 1px #fff inset; }
#minimap { right: calc(var(--u) * 1.4); top: calc(var(--u) * 14.8); width: calc(var(--u) * 19); height: calc(var(--u) * 13); padding: 0; overflow: hidden; }
#minimap canvas { width: 100%; height: 100%; display: block; }

#dash { bottom: calc(var(--u) * 1.2); left: 50%; transform: translateX(-50%); width: calc(var(--u) * 36); padding: 0.4em 1em 0.7em; display: grid; grid-template-columns: 1fr auto 1fr; gap: 1em; align-items: end; background: linear-gradient(180deg, rgba(13,16,21,0.55), rgba(13,16,21,0.9)); }
#dash .revs { grid-column: 1 / 4; display: flex; gap: 0.25em; justify-content: center; margin-bottom: 0.2em; }
#dash .revs i { width: 1.9em; height: 0.55em; border-radius: 0.3em; background: rgba(255,255,255,0.1); }
#dash .revs i.g.on { background: #3be37c; box-shadow: 0 0 8px #3be37c; }
#dash .revs i.r.on { background: #ff3b3b; box-shadow: 0 0 8px #ff3b3b; }
#dash .revs i.b.on { background: #3b9bff; box-shadow: 0 0 10px #3b9bff; }
#dash .revs.flash i { background: #3b9bff; box-shadow: 0 0 12px #3b9bff; }
#dash .mid { text-align: center; line-height: 1; }
#dash .gear { font-size: 4.6em; font-weight: 900; font-style: italic; line-height: 0.85; }
#dash .spd { font-size: 2.1em; font-weight: 900; font-variant-numeric: tabular-nums; }
#dash .spd small { font-size: 0.4em; color: var(--dim); margin-left: 0.2em; font-weight: 600; }
#dash .side { display: flex; flex-direction: column; gap: 0.35em; font-size: 0.9em; }
#dash .side.r { align-items: flex-end; }
.bar-h { height: 0.55em; background: rgba(255,255,255,0.12); position: relative; width: 100%; overflow: hidden; }
.bar-h i { position: absolute; inset: 0 auto 0 0; background: var(--c, #fff); width: 0%; }
.lbl { display: flex; justify-content: space-between; font-size: 0.72em; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.2em; }
.pedals { display: flex; gap: 0.4em; height: 3.6em; }
.pedal { width: 0.7em; background: rgba(255,255,255,0.12); position: relative; }
.pedal i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--c); }
.pill { padding: 0.15em 0.7em; font-weight: 900; font-size: 0.95em; letter-spacing: 0.08em; background: rgba(255,255,255,0.1); color: var(--dim); }
.pill.on { background: var(--good); color: #04120a; box-shadow: 0 0 14px rgba(49,209,122,0.6); }
.pill.avail { background: var(--accent2); color: #1a1000; animation: pulse 0.8s infinite alternate; }
.pill.boost.on { background: var(--accent2); color: #1a1000; box-shadow: 0 0 14px rgba(255,180,0,0.6); }
@keyframes pulse { to { filter: brightness(1.35); } }
.stack { display: flex; gap: 0.4em; }

#tyres { left: calc(var(--u) * 1.4); bottom: calc(var(--u) * 1.2); padding: 0.6em 0.8em; display: flex; gap: 0.9em; align-items: center; }
#tyres .grid { display: grid; grid-template-columns: repeat(2, 1.9em); gap: 0.35em 0.35em; }
#tyres .tyre { height: 2.6em; border-radius: 0.35em; border: 2px solid rgba(255,255,255,0.25); position: relative; overflow: hidden; background: #222; }
#tyres .tyre i { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55); }
#tyres .info { font-size: 0.9em; line-height: 1.3; }
#tyres .badge { display: inline-flex; width: 1.7em; height: 1.7em; border-radius: 50%; align-items: center; justify-content: center; font-weight: 900; color: #111; font-size: 1.1em; margin-right: 0.4em; box-shadow: 0 0 0 2px #000 inset; }
#tyres .dmg { color: var(--accent); font-weight: 700; }
#tyres .dmgcar { height: 4.4em; width: auto; flex: none; }
#tyres .dmgcar path { fill: #31d17a; stroke: rgba(0,0,0,0.6); stroke-width: 0.8; transition: fill 0.4s; }
#tyres .dmgcar path.nose { fill: rgba(255,255,255,0.25); }
.dbar { position: relative; width: 160px; max-width: 100%; height: 6px; margin-top: 0.3em; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; }
.dbar i { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; transition: width 0.12s linear, left 0.12s linear; }
.dbar b { position: absolute; top: -1px; bottom: -1px; left: calc(50% - 1px); width: 2px; background: rgba(255,255,255,0.8); }
#mfd { right: calc(var(--u) * 1.4); bottom: calc(var(--u) * 9.2); width: calc(var(--u) * 15); min-width: 15em; padding: 0.5em 0.7em; font-size: 0.85em; }
#mfd .mfd-h { display: flex; justify-content: space-between; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent2); margin-bottom: 0.35em; }
#mfd .mfd-h i { color: var(--dim); font-style: normal; }
#mfd .mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35em; }
#mfd .mc { display: flex; flex-direction: column; background: rgba(255,255,255,0.06); padding: 0.3em 0.45em; border-radius: 0.3em; line-height: 1.25; }
#mfd .mc b { font-size: 1.25em; }
#mfd .mc span { color: var(--dim); font-size: 0.85em; }
#mfd .mrow { display: flex; justify-content: space-between; gap: 1em; padding: 0.12em 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
#mfd .mhint { margin-top: 0.35em; color: var(--dim); font-size: 0.85em; }
#mfd .ok { color: #31d17a; } #mfd .warn { color: #ffb400; } #mfd .hot { color: #ff3b3b; } #mfd .cold { color: #5ab4ff; }

#gmeter { right: calc(var(--u) * 1.4); bottom: calc(var(--u) * 1.2); width: calc(var(--u) * 7); height: calc(var(--u) * 7); border-radius: 50%; }
#gmeter canvas { width: 100%; height: 100%; display: block; border-radius: 50%; }

#msgs { position: absolute; left: 50%; top: calc(var(--u) * 9); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.4em; width: 60%; }
.msg { padding: 0.35em 1.2em; background: rgba(8,10,14,0.88); border-left: 4px solid var(--accent2); font-weight: 700; font-size: 1.15em; text-transform: uppercase; letter-spacing: 0.04em; animation: msgin 0.25s ease; }
.msg.bad { border-left-color: var(--accent); }
.msg.good { border-left-color: var(--good); }
.msg.purple { border-left-color: var(--purple); }
.msg small { display: block; font-weight: 400; text-transform: none; color: var(--dim); letter-spacing: 0; font-size: 0.8em; }
@keyframes msgin { from { transform: translateY(-8px); opacity: 0; } }
#lights { left: 50%; top: calc(var(--u) * 7); transform: translateX(-50%); display: flex; gap: 0.9em; padding: 0.7em 1.1em; }
#lights i { width: 3.6em; height: 3.6em; border-radius: 50%; background: #1a0707; border: 3px solid #000; box-shadow: inset 0 0 8px #000; }
#lights i.on { background: radial-gradient(circle at 35% 30%, #ff8a8a, #ff1a1a 55%, #b00); box-shadow: 0 0 22px #f00, inset 0 0 8px #700; }
#pit { left: 50%; bottom: calc(var(--u) * 12); transform: translateX(-50%); padding: 0.5em 1.4em; text-align: center; font-weight: 900; text-transform: uppercase; }
#pit .big { font-size: 1.8em; font-style: italic; color: var(--accent2); }
#pit.service .big { color: var(--good); font-size: 2.8em; }
#radio { left: calc(var(--u) * 1.4); bottom: calc(var(--u) * 12); max-width: calc(var(--u) * 28); padding: 0.5em 0.9em; font-size: 0.95em; border-left: 4px solid var(--accent2); }
#radio b { color: var(--accent2); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.1em; display: block; }
#flag { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; font-size: calc(var(--u) * 6); font-weight: 900; font-style: italic; text-transform: uppercase; text-shadow: 0 4px 30px #000; opacity: 0; transition: opacity 0.4s; }
#flag.show { opacity: 1; }
#flag.chequered { background: repeating-conic-gradient(rgba(255,255,255,0.0) 0 25%, rgba(255,255,255,0.12) 0 50%) 0 0 / 5rem 5rem; }
.touch { position: absolute; inset: auto 0 0 0; height: 40%; display: none; pointer-events: none; }
.touch.show { display: block; }
.touch button { position: absolute; bottom: 5vh; width: 18vmin; height: 18vmin; border-radius: 50%; background: rgba(255,255,255,0.14); border: 2px solid rgba(255,255,255,0.35); font-size: 4vmin; font-weight: 900; pointer-events: auto; touch-action: none; }
.touch .l { left: 4vw; } .touch .r { left: calc(4vw + 21vmin); }
.touch .sm { width: 11vmin; height: 11vmin; font-size: 2.6vmin; bottom: calc(5vh + 21vmin); }
.touch .s1 { left: 4vw; } .touch .s2 { left: calc(4vw + 12.5vmin); } .touch .s3 { left: calc(4vw + 25vmin); }
.touch .s4 { right: 4vw; } .touch .s5 { right: calc(4vw + 12.5vmin); } .touch .s6 { right: calc(4vw + 25vmin); }
.touch .g { right: 4vw; background: rgba(60,220,120,0.25); } .touch .b { right: calc(4vw + 21vmin); background: rgba(255,60,60,0.25); }
#keyhint { left: 50%; bottom: calc(var(--u) * 15); transform: translateX(-50%); padding: 0.7em 1.3em; text-align: center; font-size: 1em; line-height: 1.7; transition: opacity 0.6s; white-space: nowrap; }
#keyhint kbd { font-size: 0.85em; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
#finish { position: absolute; left: 50%; top: 31%; transform: translate(-50%, -50%); text-align: center; pointer-events: auto; cursor: pointer; padding: 1.4em 2.6em 1.2em; background: linear-gradient(180deg, rgba(8,10,14,0.0), rgba(8,10,14,0.78) 30%, rgba(8,10,14,0.78) 78%, rgba(8,10,14,0.0)); animation: finin 0.7s cubic-bezier(.2,.8,.2,1); min-width: calc(var(--u) * 46); }
@keyframes finin { from { opacity: 0; transform: translate(-50%, -40%) scale(0.92); } }
#finish .eyebrow { font-size: 0.95em; text-transform: uppercase; letter-spacing: 0.18em; color: var(--dim); }
#finish .big { display: flex; justify-content: center; align-items: flex-start; font-weight: 900; font-style: italic; line-height: 0.85; text-shadow: 0 6px 40px rgba(0,0,0,0.8); }
#finish .pos { font-size: 7.5em; background: linear-gradient(180deg, #fff, var(--tone, #cfd5de)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#finish .ord { font-size: 2.4em; margin-top: 0.25em; color: var(--tone, #cfd5de); }
#finish .title { font-size: 2em; font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.1em; border-bottom: 4px solid var(--c); display: inline-block; padding: 0 0.6em 0.1em; }
#finish.tone-gold { --tone: #ffc933; }
#finish.tone-podium { --tone: #dfe5ee; }
#finish.tone-points { --tone: #31d17a; }
#finish .facts { display: flex; gap: 2.2em; justify-content: center; margin-top: 1em; }
#finish .facts span { display: block; font-size: 0.72em; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; }
#finish .facts b { font-size: 1.35em; font-variant-numeric: tabular-nums; }
#finish .cont { margin-top: 1.1em; opacity: 0; transition: opacity 0.6s; color: var(--accent2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
#finish .cont.show { opacity: 1; }
#hud.cine #dash, #hud.cine #tyres, #hud.cine #gmeter, #hud.cine #minimap, #hud.cine #msgs, #hud.cine #radio, #hud.cine #keyhint, #hud.cine #pit { display: none; }
#toast { position: absolute; top: 2vh; left: 50%; transform: translateX(-50%); background: #000d; padding: 0.6rem 1.2rem; border: 1px solid var(--line); opacity: 0; transition: opacity 0.3s; font-weight: 600; }
#toast.show { opacity: 1; }
/* over the menus and results the heading owns the top of the screen: the toast sits at the bottom instead */
body.in-menu #toast { top: auto; bottom: 3vh; }

@media (max-width: 900px) {
  #tower { width: calc(var(--u) * 22); }
  #minimap, #gmeter { display: none; }
  #timing { width: calc(var(--u) * 24); }
  #dash { width: calc(var(--u) * 46); }
}
@media (max-height: 800px) {
  .menu-col { padding-top: 3vh; padding-bottom: 3vh; gap: 0.35rem; justify-content: flex-start; min-height: min-content; }
  .menu-col .logo { font-size: 2.2rem; margin-bottom: 0; }
  .menu-col .tagline { display: none; }
  .btn { padding: 0.5rem 1rem; font-size: 1.02rem; }
  .btn small { font-size: 0.7rem; margin-top: 0; }
  .version { display: none; }
}
@media (max-height: 560px) { .btn small { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* career */
.upg { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.upg:last-child { border-bottom: 0; }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 1.2rem; height: 0.42rem; background: rgba(255,255,255,0.14); border-radius: 1px; }
.pips i.on { background: var(--accent2, #ffd24a); }
.hubtrack { display: flex; gap: 1rem; align-items: center; }
.hubtrack svg { width: 9rem; height: 6rem; flex: none; }
.bigstats { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.bigstats div { display: flex; flex-direction: column; }
.bigstats small { color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; }
.bigstats b { font-size: 2rem; font-style: italic; }

/* interactive pit stop */
#pitgame { left: 50%; bottom: 31%; transform: translateX(-50%); padding: 0.7em 1.1em; text-align: center; min-width: 26em; }
#pitgame .pgt { font-size: 0.85em; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.6em; }
#pitgame .pgw { display: flex; gap: 0.7em; justify-content: center; }
#pitgame .nut { flex: 1; }
#pitgame .nut span { display: block; font-weight: 800; font-size: 0.9em; margin-top: 0.25em; opacity: 0.7; }
#pitgame .trk { position: relative; height: 1.5em; background: rgba(255,255,255,0.1); border: 1px solid var(--line); overflow: hidden; }
#pitgame .trk .gd { position: absolute; top: 0; bottom: 0; left: 55%; width: 34%; background: rgba(255,210,74,0.35); }
#pitgame .trk .pf { position: absolute; top: 0; bottom: 0; left: 65%; width: 14%; background: rgba(49,209,122,0.75); }
#pitgame .trk b { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 8px #fff; opacity: 0; }
#pitgame .nut.live b { opacity: 1; }
#pitgame .nut.r-perfect .trk { outline: 2px solid #31d17a; }
#pitgame .nut.r-good .trk { outline: 2px solid #ffd24a; }
#pitgame .nut.r-miss .trk { outline: 2px solid #ff4b4b; background: rgba(255,60,60,0.28); }
#pitgame .nut.r-perfect b, #pitgame .nut.r-good b, #pitgame .nut.r-miss b { opacity: 1; }
#pitgame .pgr { margin-top: 0.6em; font-weight: 800; font-size: 1.15em; min-height: 1.4em; }

/* telemetry */
.telemetry .charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0.8rem; }
.telemetry canvas { width: 100%; height: 11.5rem; background: rgba(255,255,255,0.03); border: 1px solid var(--line); }

/* replay */
#replay { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 0 0 max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
#replay.hidden { display: none; }
#replay .rbar { pointer-events: auto; display: flex; gap: 0.6rem; align-items: center; background: rgba(8,10,14,0.82); border: 1px solid var(--line); padding: 0.55rem 0.9rem; backdrop-filter: blur(8px); max-width: 96vw; flex-wrap: wrap; justify-content: center; }
#replay b { color: var(--accent); letter-spacing: 0.12em; font-style: italic; }
#replay span { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 0.85rem; }
#replay input[type=range] { width: min(26rem, 40vw); display: block; }
#replay .rscrub { position: relative; padding-top: 0.7rem; }
#r-marks { position: absolute; left: 0; right: 0; top: 0; height: 0.7rem; pointer-events: none; }
#replay .rmark { position: absolute; top: 0; width: 0.62rem; height: 0.62rem; padding: 0; margin-left: -0.31rem; border-radius: 50%; border: 1px solid rgba(0,0,0,0.6); background: #fff; pointer-events: auto; cursor: pointer; }
#replay .rmark.pass { background: #31d17a; } #replay .rmark.lost { background: #ff8a3b; } #replay .rmark.contact { background: #ff2a2a; }
#replay .rmark.pit { background: #5ab4ff; } #replay .rmark.fastest { background: #b65cff; } #replay .rmark.sc, #replay .rmark.penalty { background: #ffd400; } #replay .rmark.out { background: #888; }
#replay button { background: rgba(255,255,255,0.08); border: 1px solid var(--line); color: #fff; padding: 0.35rem 0.7rem; font-weight: 700; font-size: 0.85rem; }
#replay button:hover { background: rgba(255,255,255,0.18); }
#replay button.exit { background: var(--accent); border-color: transparent; }

/* photo mode */
#photo { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#photo.hidden { display: none; }
#photo .pbar { pointer-events: auto; position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 0.7rem; align-items: center; background: rgba(8,10,14,0.78); border: 1px solid var(--line); padding: 0.5rem 0.9rem; backdrop-filter: blur(8px); flex-wrap: wrap; justify-content: center; max-width: 96vw; opacity: 0.55; transition: opacity 0.2s; }
#photo .pbar:hover { opacity: 1; }
#photo b { color: var(--accent); letter-spacing: 0.12em; font-style: italic; }
#photo span { color: var(--dim); font-size: 0.8rem; }
#photo button { background: rgba(255,255,255,0.08); border: 1px solid var(--line); color: #fff; padding: 0.35rem 0.7rem; font-weight: 700; font-size: 0.85rem; }
#photo button.exit { background: var(--accent); border-color: transparent; }
#photo .pflash { position: absolute; inset: 0; background: #fff; opacity: 0; transition: opacity 0.25s; pointer-events: none; }

/* profile */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.6rem; }
.stat { background: rgba(255,255,255,0.04); border: 1px solid var(--line); padding: 0.6rem 0.8rem; }
.stat small { display: block; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; }
.stat b { font-size: 1.5rem; font-style: italic; }
.achs { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.45rem; }
.ach { border: 1px solid var(--line); padding: 0.5rem 0.7rem; opacity: 0.45; }
.ach b { display: block; font-size: 0.95rem; }
.ach span { font-size: 0.78rem; color: var(--dim); }
.ach.got { opacity: 1; border-color: #ffd24a; background: rgba(255,210,74,0.08); }
.ach.got b::before { content: "★ "; color: #ffd24a; }

/* accessibility */
body.bighud #hud { zoom: 1.2; }
body.calm *, body.calm *::before, body.calm *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }

/* driving school */
#lesson { left: 50%; top: calc(var(--u) * 5.2); transform: translateX(-50%); min-width: calc(var(--u) * 22); padding: 0.5em 1em; font-size: 0.95em; border-top: 3px solid var(--accent2); }
#lesson b { display: block; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent2); margin-bottom: 0.2em; }
#lesson .goal { opacity: 0.9; } #lesson .goal.ok { color: var(--good); } #lesson .goal i { color: #aab; font-style: normal; }
.lessons { display: flex; flex-direction: column; gap: 0.6rem; }
.lesson { display: flex; gap: 1rem; align-items: center; padding: 0.7rem 1rem; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; }
.lesson.done { border-color: rgba(60,220,120,0.5); }
.lesson .lno { width: 2.2rem; height: 2.2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.1); font-weight: 900; flex: none; }
.lesson.done .lno { background: rgba(60,220,120,0.3); color: #7dffb0; }
.lesson .goals { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; color: #cfd3dc; }

#livetele { left: calc(var(--u) * 1.4); top: 44%; width: calc(var(--u) * 28); height: auto; padding: 0; }

.keys .key .keybtn { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14); border-radius: 4px; padding: 0.2rem 0.5rem; min-width: 5.2rem; text-align: right; color: inherit; cursor: pointer; }
.keys .key .keybtn:hover { border-color: var(--accent2); }
.keys .key .keybtn.wait { border-color: var(--accent2); color: var(--accent2); animation: pulse 0.6s alternate infinite; }

.saveio { width: 100%; margin-top: 0.5rem; background: rgba(255,255,255,0.05); color: #dfe3ea; border: 1px solid rgba(255,255,255,0.16); border-radius: 4px; padding: 0.5rem; font: 0.8rem ui-monospace, monospace; resize: vertical; }
.txt { width: 100%; background: rgba(255,255,255,0.05); color: #dfe3ea; border: 1px solid rgba(255,255,255,0.16); border-radius: 4px; padding: 0.45rem 0.6rem; font: 700 1rem ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.txt:focus { outline: 2px solid var(--accent, #e10600); outline-offset: 1px; }
#brain { right: calc(var(--u) * 1.4); top: 51%; width: calc(var(--u) * 22); padding: calc(var(--u) * 0.5) calc(var(--u) * 0.7); font-size: calc(var(--u) * 0.95); line-height: 1.35; }
#brain .bt { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8em; opacity: 0.7; margin-bottom: 0.2em; }
#brain .bh { margin-top: 0.35em; } #brain .bh em { font-style: normal; color: #ffb400; }
#brain .br { display: grid; grid-template-columns: 5.5em 1fr 2.6em; align-items: center; gap: 0.4em; opacity: 0.75; }
#brain .br.on { opacity: 1; font-weight: 700; }
#brain .br i { display: block; height: 0.5em; background: rgba(255,255,255,0.35); border-radius: 2px; } #brain .br.on i { background: #3ddc84; }
#brain .br u { text-decoration: none; text-align: right; opacity: 0.7; }

/* career hub */
.sponsors { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.5rem; }
.sponsor { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.6rem; text-align: left; padding: 0.6rem 0.7rem; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: inherit; cursor: pointer; font: inherit; }
.sponsor b { grid-column: 1; }
.sponsor span { grid-column: 1; font-size: 0.82rem; opacity: 0.72; }
.sponsor i { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-weight: 800; font-size: 1.15rem; color: #ffd24a; }
.sponsor:hover { border-color: rgba(255, 255, 255, 0.35); }
.sponsor.on { border-color: #31d17a; background: rgba(49, 209, 122, 0.12); }
.h2hrow { display: grid; grid-template-columns: 5.5rem 1fr; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.h2hrow small { opacity: 0.7; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; }
.h2h { display: grid; grid-template-columns: 1.6rem 1fr 1.6rem; align-items: center; gap: 0.5rem; text-align: center; }
.h2hbar { height: 0.55rem; background: #555c66; border-radius: 0.3rem; overflow: hidden; }
.h2hbar span { display: block; height: 100%; background: #31d17a; }
.news { padding: 0.45rem 0 0.45rem 0.7rem; border-left: 2px solid var(--line); margin-top: 0.4rem; font-size: 0.9rem; opacity: 0.75; }
.news.top { border-left-color: #ffd24a; opacity: 1; }
.carbar { display: grid; grid-template-columns: auto 5.2rem 1fr auto; align-items: center; gap: 0.5rem; padding: 0.22rem 0.3rem; }
.carbar.me { background: rgba(255, 255, 255, 0.07); }
.carbar .bar { height: 0.5rem; background: rgba(255, 255, 255, 0.08); border-radius: 0.3rem; overflow: hidden; }
.carbar .bar span { display: block; height: 100%; }
.carbar small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repbar { position: relative; height: 0.9rem; background: rgba(255, 255, 255, 0.08); border-radius: 0.45rem; }
.repbar span { display: block; height: 100%; border-radius: 0.45rem; background: linear-gradient(90deg, #2f7dd1, #31d17a 60%, #ffd24a); }
.repbar i { position: absolute; top: -0.25rem; width: 2px; height: 1.4rem; background: #fff; }
.gold { color: #ffd24a; }
.goal { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.goal i { font-style: normal; font-weight: 800; color: #ffd24a; }
.goal.met i { color: #31d17a; }
.goal.miss i { color: #ff6b6b; }

.sstats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.sstat { background: rgba(255,255,255,0.05); border-radius: 0.4rem; padding: 0.45rem 0.6rem; display: flex; flex-direction: column; gap: 0.1rem; }
.sstat.wide { grid-column: 1 / -1; }
.sstat small { color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; }
.sstat b { font-size: 1.15rem; }
.sstat em { font-style: normal; font-weight: 700; font-size: 0.85rem; }
.sstat em.up { color: #31d17a; } .sstat em.down { color: #ff6b5b; }

/* colour-blind HUD (SPEC 9): green / red pairs become blue / orange */
body.cb { --good: #3b9bff; }
body.cb .pedal[style*="31d17a"] { --c: #3b9bff !important; }
body.cb .pedal[style*="ff3b3b"] { --c: #ff7a00 !important; }
body.cb #mfd .ok { color: #3b9bff; } body.cb #mfd .hot { color: #ff7a00; } body.cb #mfd .warn { color: #ffe14a; }
body.cb #timing .delta.pos { color: #ff7a00; }
body.cb #replay .rmark.pass { background: #3b9bff; } body.cb #replay .rmark.contact { background: #ff7a00; }
body.cb .sstat em.up { color: #3b9bff; } body.cb .sstat em.down { color: #ff7a00; }

/* spectator mode: the player-only instruments go; the tower, timing banner and map stay */
body.spectating #dash, body.spectating #tyres, body.spectating #timing, body.spectating #gmeter, body.spectating #keyhint, body.spectating #pit, body.spectating #mfd { display: none !important; }

/* broadcast graphics (SPEC 9) */
#tower .r .age { font-style: normal; font-size: 0.62em; color: var(--dim); margin-left: 0.2em; min-width: 1.4em; display: inline-block; text-align: left; }
#bcast { top: calc(var(--u) * 5.2); left: 50%; transform: translateX(-50%); display: flex; gap: 0.6em; align-items: center; padding: 0.25em 0.8em; font-variant-numeric: tabular-nums; }
#bcast b { color: var(--accent2); font-style: italic; letter-spacing: 0.06em; }
#bcast span { border-left: 4px solid var(--c); padding-left: 0.4em; font-weight: 900; }
#bcast i { font-style: normal; font-weight: 700; min-width: 3em; }

/* podium / parc fermé (SPEC 9) */
#podium { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; padding: 0 16px max(18px, env(safe-area-inset-bottom)); pointer-events: auto; cursor: pointer; background: linear-gradient(transparent, rgba(0,0,0,0.55)); }
#podium.hidden { display: none; }
#podium .ptitle { font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent2); }
#podium .psteps { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
#podium .pstep { min-width: 9.5rem; background: rgba(8,10,14,0.85); border-top: 4px solid var(--c); padding: 0.5rem 0.9rem; display: flex; flex-direction: column; animation: msgin 0.4s ease both; }
#podium .pstep.p1 { padding-block: 1rem; animation-delay: 0.5s; } #podium .pstep.p2 { animation-delay: 0.25s; }
#podium .pstep b { font-size: 1.6rem; font-style: italic; }
#podium .pstep.p1 b { color: #ffd24a; font-size: 2rem; }
#podium .pstep small { color: var(--dim); }
#podium .phint { color: var(--dim); font-size: 0.8rem; }
/* press conference answers (career hub): the effect sits under the answer, not beside it */
.press { display: grid; gap: 0.4rem; margin: 0.4rem 0; }
.press .sponsor { grid-template-columns: 1fr; }
.press .sponsor i { grid-column: 1; grid-row: auto; font-size: 0.78rem; font-weight: 600; color: #9fc3ff; }
