/* ---------- race HUD, laid out like the reference screenshot ----------
   Flat panels only. No backdrop-filter anywhere in here: blurring a WebGL canvas
   every frame is what made the old HUD lag on phones. */
:root { --u: min(1vh, 1.6vw); }
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; font-family: var(--font); }
#hud button { pointer-events: auto; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at 50% 55%, transparent 58%, rgba(10,16,30,0.34) 100%); }
.lite #vignette { display: none; }
#glare { position: fixed; left: 0; top: 0; width: 70vmin; height: 70vmin; margin: -35vmin 0 0 -35vmin; pointer-events: none; z-index: 3; opacity: 0; will-change: transform, opacity;
  background: radial-gradient(circle, rgba(255,246,220,0.95) 0, rgba(255,230,170,0.4) 16%, rgba(255,212,140,0.14) 40%, transparent 68%); }

/* timing tower */
#tower { position: absolute; left: calc(var(--safe-l) + 1.6 * var(--u)); top: calc(var(--safe-t) + 2.2 * var(--u)); width: max(calc(20 * var(--u)), 138px); background: rgba(6,6,8,0.9); }
#flagbar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: calc(0.5 * var(--u)) calc(0.9 * var(--u)); font-weight: 900; font-style: italic; font-size: max(calc(1.5 * var(--u)), 9px); line-height: 1.15; text-align: center; letter-spacing: 0.02em; color: #f6c400; background: #050506; border-bottom: 1px solid #222; }
#flagbar i { flex: none; width: calc(1.9 * var(--u)); height: calc(1.9 * var(--u)); min-width: 11px; min-height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe27a, #f6a800 70%); box-shadow: 0 0 6px rgba(246,168,0,0.6); }
#flagbar.none { display: none; }
#flagbar.green { color: #31e26a; } #flagbar.green i { background: radial-gradient(circle at 35% 30%, #8dffb0, #17b64a 70%); box-shadow: 0 0 6px rgba(49,226,106,0.6); }
#flagbar.white { color: #fff; } #flagbar.white i { background: radial-gradient(circle at 35% 30%, #fff, #bbb 70%); box-shadow: none; }
#towerHead { padding: calc(0.6 * var(--u)) calc(1 * var(--u)) calc(0.5 * var(--u)); font-size: max(calc(2.4 * var(--u)), 13px); font-weight: 900; font-style: italic; color: #fff; border-bottom: 3px solid #d4142c; letter-spacing: 0.01em; }
#towerHead span { font-size: 0.7em; opacity: 0.9; }
#rows { position: relative; height: calc(var(--n, 20) * var(--rh, 24px)); }
.row { position: absolute; left: 0; right: 0; top: 0; height: var(--rh, 24px); transform: translateY(calc(var(--slot, 0) * var(--rh, 24px))); display: grid; grid-template-columns: calc(var(--rh) * 0.82) 1.7em 1fr calc(var(--rh) * 0.8); align-items: center; gap: calc(var(--rh) * 0.2); padding: 0 calc(var(--rh) * 0.25) 0 calc(var(--rh) * 0.15); font-size: calc(var(--rh) * 0.7); font-weight: 800; font-style: italic; letter-spacing: 0.01em; color: #fff; font-variant-numeric: tabular-nums; transition: transform 0.4s cubic-bezier(.2,.8,.2,1), opacity 0.3s; }
.row .ty { width: calc(var(--rh) * 0.78); height: calc(var(--rh) * 0.78); border-radius: 50%; border: calc(var(--rh) * 0.12) solid #e3122a; display: grid; place-items: center; font-size: 0.62em; line-height: 1; font-style: normal; }
.row .ty.m { border-color: #f4c20d; } .row .ty.h { border-color: #f2f2f2; }
.row .p { text-align: left; }
.row .fl { width: calc(var(--rh) * 0.8); height: calc(var(--rh) * 0.54); background-size: 100% 100%; border-radius: 2px; }
.row.me { background: linear-gradient(90deg, rgba(255,255,255,0.2), rgba(255,255,255,0.08)); box-shadow: inset 3px 0 0 var(--accent); }
.row.off { opacity: 0; }
.row .gp { position: absolute; right: calc(var(--rh) * 1.2); font-size: 0.7em; color: #aaa; font-weight: 600; display: none; }

#dots { position: absolute; left: 50%; top: calc(var(--safe-t) + 0.6 * var(--u)); transform: translateX(-50%); display: flex; gap: 6px; padding: 10px 18px; background: none; border: 0; }
#dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.85); }
#lights { position: absolute; top: calc(var(--safe-t) + 5 * var(--u)); left: 50%; transform: translateX(-50%); display: none; gap: calc(1.4 * var(--u)); padding: calc(1 * var(--u)) calc(1.8 * var(--u)); border-radius: 999px; background: rgba(6,6,8,0.8); }
#lights.on { display: flex; }
#lights i { width: calc(2.4 * var(--u)); height: calc(2.4 * var(--u)); min-width: 14px; min-height: 14px; border-radius: 50%; background: #1d1d20; box-shadow: inset 0 2px 4px rgba(0,0,0,0.6); }
#lights i.lit { background: #ff2a1a; box-shadow: 0 0 14px #ff2a1a, 0 0 30px rgba(255,42,26,0.6); }
#fps { position: absolute; left: 50%; top: calc(var(--safe-t) + 8 * var(--u)); transform: translateX(-50%); font: 700 11px/1 ui-monospace, Menlo, Consolas, monospace; color: #9dff9d; background: rgba(0,0,0,0.55); padding: 3px 7px; border-radius: 4px; display: none; }
#fps.on { display: block; }

/* right column */
#rcol { position: absolute; right: calc(var(--safe-r) + 1.6 * var(--u)); top: calc(var(--safe-t) + 1.4 * var(--u)); width: max(calc(31 * var(--u)), 218px); display: grid; gap: calc(1.2 * var(--u)); transition: transform 0.3s, opacity 0.3s; }
.hide-side #rcol { transform: translateX(110%); opacity: 0; }
.hide-side #tower { transform: translateX(-110%); transition: transform 0.3s; }
#tower { transition: transform 0.3s; }
#icons { display: flex; justify-content: flex-end; gap: calc(2.4 * var(--u)); }
#icons button { background: none; border: 0; padding: 4px; width: max(calc(5.2 * var(--u)), 34px); height: max(calc(5.2 * var(--u)), 34px); }
#icons svg { width: 100%; height: 100%; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55)); }
#icons button:active svg { stroke: var(--accent); }

#timing { background: rgba(14,14,16,0.82); font-size: max(calc(1.6 * var(--u)), 10px); letter-spacing: 0.01em; }
.secs { display: grid; grid-template-columns: repeat(3, 1fr); background: #2a2b2f; gap: 2px; }
.secs div { background: #26272b; text-align: center; padding-top: 1px; }
.secs b { display: block; font-size: 0.82em; color: #e8e8e8; font-weight: 700; line-height: 1.5; }
.secs u { display: block; height: calc(1.5 * var(--u)); min-height: 7px; background: #000; text-decoration: none; position: relative; overflow: hidden; }
.secs u i { position: absolute; inset: 0 auto 0 0; width: 0%; background: #ddd; }
.secs u.s1 i { background: #f4c20d; width: 100% !important; } .secs u.s2 i { background: #20d85e; width: 100% !important; } .secs u.s3 i { background: #c23cff; width: 100% !important; }
.trow { display: flex; justify-content: space-between; align-items: baseline; padding: calc(0.28 * var(--u)) calc(1.1 * var(--u)); font-weight: 800; font-style: italic; }
.trow span { color: #fff; font-size: 0.86em; } .trow b { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.12em; color: #fff; }
.trow.best span { color: #2fe26a; } .trow.fast span { color: #e040ff; } .trow.delta span { color: #f4d90d; }
.trow.delta b.neg { color: #2fe26a; } .trow.delta b.pos { color: #ff5a4a; }

#dash { background: rgba(10,12,18,0.5); border-radius: calc(1.4 * var(--u)); padding: calc(0.8 * var(--u)) calc(1 * var(--u)) calc(0.7 * var(--u)); border: 1px solid rgba(255,255,255,0.08); }
.dtop { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: calc(1 * var(--u)); }
.dtop span { font-style: italic; font-weight: 800; line-height: 0.9; } .dtop span b { font-size: max(calc(2.2 * var(--u)), 13px); display: block; font-variant-numeric: tabular-nums; }
.dtop span small { font-size: max(calc(1.2 * var(--u)), 8px); opacity: 0.8; }
.kph { color: #e9f1ff; } .mph { color: #43e48a; text-align: right; }
#rev { display: grid; grid-template-columns: repeat(15, 1fr); gap: 2px; align-self: start; padding-top: 2px; }
#rev i { aspect-ratio: 1; border-radius: 50%; background: #3a3b3f; }
#rev i.l1 { background: #c9f021; box-shadow: 0 0 5px #c9f021; } #rev i.l2 { background: #ff3a2a; box-shadow: 0 0 5px #ff3a2a; } #rev i.l3 { background: #4ea9ff; box-shadow: 0 0 6px #4ea9ff; }
.dmid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: calc(0.8 * var(--u)); align-items: center; margin-top: calc(0.5 * var(--u)); }
#gear { font-size: max(calc(7 * var(--u)), 32px); font-weight: 900; line-height: 1; color: #fff; text-align: center; min-width: 1.1ch; text-shadow: 0 0 14px rgba(255,255,255,0.25); }
.mod { min-width: 0; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.12); border-radius: calc(1 * var(--u)); padding: calc(0.7 * var(--u)); display: grid; gap: calc(0.6 * var(--u)); justify-items: center; }
#carIcon { width: 100%; max-width: max(calc(9 * var(--u)), 44px); } #carIcon .body, #carIcon .wing { fill: #21e05a; } #carIcon .tyre { fill: #0e8f36; }
#modCar.warn #carIcon .body, #modCar.warn #carIcon .wing { fill: #f4b50d; } #modCar.bad #carIcon .body, #modCar.bad #carIcon .wing { fill: #ff3a2a; }
.ibar { width: 100%; height: calc(0.7 * var(--u)); min-height: 4px; background: rgba(255,255,255,0.18); border-radius: 3px; overflow: hidden; position: relative; }
#inBar { display: block; height: 100%; width: 0; background: #fff; } .ibar u { position: absolute; right: 0; top: 0; bottom: 0; width: 18%; background: #e3122a; }
.tt { display: flex; align-items: center; gap: calc(0.4 * var(--u)); font-style: italic; font-weight: 800; font-size: max(calc(1.9 * var(--u)), 11px); color: #d7e6ff; }
.tyreIcon { width: calc(3 * var(--u)); min-width: 16px; fill: none; stroke: #20d0f0; stroke-width: 5; } .therm { height: calc(3 * var(--u)); min-height: 16px; fill: #20d0f0; }
.tt.hot .tyreIcon { stroke: #ff5a3a; } .tt.hot .therm { fill: #ff5a3a; } .tt.ok .tyreIcon { stroke: #35e07a; } .tt.ok .therm { fill: #35e07a; }
#tyreBar { display: block; height: 100%; width: 100%; background: #20d0f0; }
#ersBtn { display: block; margin: calc(0.6 * var(--u)) auto 0; padding: 3px 14px; background: rgba(20,60,150,0.5); border: 1px solid rgba(110,150,255,0.5); border-radius: 999px; box-shadow: 0 0 14px rgba(70,110,255,0.55); }
#ersBtn svg { display: block; width: calc(5.2 * var(--u)); min-width: 34px; } #ersBtn .shell { fill: none; stroke: #e6ecff; stroke-width: 1.6; } #ersBtn .fill { fill: #21e05a; } #ersBtn .bolt { fill: #fff; opacity: 0; }
#ersBtn.use .fill { fill: #ff8a1f; } #ersBtn.use .bolt { opacity: 1; fill: #fff; }
#mapWrap { width: calc(15 * var(--u)); height: calc(15 * var(--u)); justify-self: end; background: rgba(8,8,10,0.55); border-radius: calc(1.4 * var(--u)); padding: 3px; }
#map { width: 100%; height: 100%; display: block; }
#side { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: calc(4.2 * var(--u)); height: calc(8 * var(--u)); min-width: 22px; min-height: 40px; border: 0; border-radius: 999px 0 0 999px; background: rgba(40,44,52,0.85); color: #fff; font-size: calc(4 * var(--u)); line-height: 1; padding: 0 0 4px; }
.hide-side #side { transform: translateY(-50%) rotate(180deg); }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(32px, 5.5vw, 72px); font-weight: 900; font-style: italic; letter-spacing: 0.04em; text-transform: uppercase; text-shadow: 0 8px 40px rgba(0,0,0,0.7); opacity: 0; transform: scale(0.9); transition: opacity 0.35s, transform 0.35s; }
#banner.show { opacity: 1; transform: scale(1); }
#banner small { display: block; font-size: 0.26em; letter-spacing: 0.2em; color: #fff; font-style: normal; font-weight: 700; margin-top: 4px; opacity: 0.8; }
#toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 12.5 * var(--u)); transform: translate(-50%, -8px); padding: 8px 18px; border-radius: 999px; font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; background: rgba(10,10,12,0.8); border: 1px solid rgba(255,255,255,0.2); opacity: 0; transition: opacity 0.3s, transform 0.3s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#wrong { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); padding: 10px 26px; border-radius: 12px; background: rgba(200,16,46,0.85); font-weight: 900; font-style: italic; letter-spacing: 0.18em; display: none; }
#wrong.show { display: block; animation: blink 0.6s infinite alternate; }
@keyframes blink { to { opacity: 0.45; } }

/* ---------- touch controls (pedals like the reference, round buttons, steering pads) ---------- */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; --pw: max(calc(15 * var(--u)), 100px); --ph: max(calc(9.5 * var(--u)), 66px); --gw: max(calc(10 * var(--u)), 72px); --gh: max(calc(14 * var(--u)), 100px); --rb: max(calc(7.2 * var(--u)), 46px); }
body:not(.touch) #touch { display: none !important; }
#touch button { pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
.pedal { position: absolute; bottom: calc(var(--safe-b) + 2.2 * var(--u)); border: 1px solid rgba(255,255,255,0.28); border-radius: calc(1.6 * var(--u)); background-color: rgba(120,126,136,0.34); transition: filter 0.08s, transform 0.08s; }
.pedal.brake { width: var(--pw); height: var(--ph); background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.34) 0 3px, rgba(255,255,255,0.06) 3px 11px); }
.pedal.gas { right: calc(var(--safe-r) + 2 * var(--u)); width: var(--gw); height: var(--gh); background-image: repeating-linear-gradient(180deg, rgba(255,255,255,0.34) 0 3px, rgba(255,255,255,0.06) 3px 11px); }
.pedal.down { filter: brightness(1.5); transform: scale(0.95); }
.padsteer { position: absolute; left: calc(var(--safe-l) + 2 * var(--u)); bottom: calc(var(--safe-b) + 2.2 * var(--u)); display: flex; gap: calc(1.4 * var(--u)); }
.pad { width: max(calc(11 * var(--u)), 78px); height: max(calc(10 * var(--u)), 70px); border-radius: calc(1.8 * var(--u)); border: 1px solid rgba(255,255,255,0.3); background: rgba(120,126,136,0.34); display: grid; place-items: center; }
.pad svg { width: 46%; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pad.down { filter: brightness(1.5); transform: scale(0.95); }
.rounds { position: absolute; bottom: calc(var(--safe-b) + 2.2 * var(--u)); display: flex; gap: calc(1.4 * var(--u)); }
.rbtn { width: var(--rb); height: var(--rb); border-radius: 50%; border: 2px solid rgba(255,255,255,0.6); background: rgba(255,255,255,0.12); color: #fff; font-weight: 900; font-size: max(calc(1.7 * var(--u)), 11px); letter-spacing: 0.06em; display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }
.rbtn svg { width: 46%; fill: #fff; } .rbtn.push { border-color: #b46bff; box-shadow: 0 0 16px rgba(160,90,255,0.65); background: rgba(150,90,255,0.2); }
.rbtn.down { filter: brightness(1.6); transform: scale(0.93); } .rbtn.latched { box-shadow: 0 0 18px #2fe06a; border-color: #2fe06a; }

/* gyro mode: pedals in the corners exactly like the reference, no steering pads */
body.mode-gyro .padsteer { display: none; }
body.mode-gyro .pedal.brake { left: calc(var(--safe-l) + 2 * var(--u)); }
body.mode-gyro .rounds { left: calc(var(--safe-l) + 2 * var(--u) + var(--pw) + 3 * var(--u)); }
/* button mode: steering pads left, brake + gas right */
body.mode-buttons .pedal.brake { right: calc(var(--safe-r) + 2 * var(--u) + var(--gw) + 1.6 * var(--u)); left: auto; }
body.mode-buttons .rounds { left: calc(var(--safe-l) + 2 * var(--u) + 2 * max(calc(11 * var(--u)), 78px) + 4 * var(--u)); }

@media (max-height: 560px) {
  #gear { font-size: max(calc(6 * var(--u)), 26px); }
  .mod { padding: 3px; gap: 3px; }
  .tt { font-size: 10px; }
  #mapWrap { display: none; }
  #lights { top: calc(var(--safe-t) + 6 * var(--u)); }
  .pedal.gas { height: max(calc(12 * var(--u)), 88px); }
}
@media (orientation: portrait) {
  :root { --u: 1.6vw; }
  #tower { width: 150px; } #rcol { width: 215px; }
}

/* ---------- starting grid intro ---------- */
#intro { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#intro .band { position: absolute; left: 0; right: 0; top: 20%; bottom: 20%; background: rgba(70,82,96,0.3); }
#intro h1 { margin: 0; text-align: center; padding-top: calc(4 * var(--u)); font-size: calc(6 * var(--u)); font-weight: 900; font-style: italic; letter-spacing: 0.01em; text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,0.5); }
#gcard { position: absolute; right: 0; bottom: 20%; display: flex; height: calc(16.5 * var(--u)); min-height: 78px; width: min(64vw, 100%); }
#gcard.pop { animation: slidein 0.28s ease-out; } .pop { animation: slidein 0.28s ease-out; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#gcard .gpos { width: calc(16.5 * var(--u)); min-width: 78px; background: #000; display: grid; place-items: center; align-content: center; gap: 2px; }
#gcard .gpos b { font-size: calc(8 * var(--u)); font-weight: 900; font-style: italic; line-height: 0.9; }
#gcard .chev { width: calc(4.4 * var(--u)); height: calc(3.4 * var(--u)); background: var(--c, #d4142c); clip-path: polygon(0 0, 28% 0, 50% 55%, 72% 0, 100% 0, 58% 100%, 42% 100%); }
#gcard .gtxt { flex: 1; background: rgba(0,0,0,0.76); padding: calc(1 * var(--u)) calc(3 * var(--u)); display: grid; align-content: center; text-align: right; min-width: 0; }
#gcard em { font-size: calc(4 * var(--u)); font-weight: 900; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#gcard .gtxt span { font-size: calc(2.7 * var(--u)); font-weight: 800; letter-spacing: 0.02em; }
#gcard .gtxt b { font-size: calc(5 * var(--u)); font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; }
#btnSkip { position: absolute; left: calc(var(--safe-l) + 2 * var(--u)); bottom: calc(var(--safe-b) + 2 * var(--u)); pointer-events: auto; }

/* ---------- podium UI ---------- */
#podiumUi { position: fixed; inset: 0; z-index: 12; pointer-events: none; display: grid; justify-items: center; align-content: space-between; padding: calc(5 * var(--u)) 0 calc(4 * var(--u)); text-align: center; }
#pTitle { font-size: calc(8 * var(--u)); font-weight: 900; font-style: italic; text-shadow: 0 4px 0 rgba(0,0,0,0.55), 0 0 30px rgba(0,0,0,0.5); animation: slidedown 0.6s ease-out; }
#pSub { font-size: calc(2.8 * var(--u)); font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; text-shadow: 0 2px 10px rgba(0,0,0,0.7); position: absolute; top: calc(15 * var(--u)); left: 0; right: 0; }
#podiumUi .cta { width: auto; pointer-events: auto; padding-left: 40px; padding-right: 40px; }
@keyframes slidedown { from { transform: translateY(-30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* v5: tyre compound badge, gap readouts */
.tt .cmp { display: grid; place-items: center; width: max(calc(2.6 * var(--u)), 16px); height: max(calc(2.6 * var(--u)), 16px); border: 2px solid #ffd23a; border-radius: 50%; font-size: max(calc(1.3 * var(--u)), 9px); font-style: normal; font-weight: 900; line-height: 1; }
.tt .cmp.worn { animation: worn 0.9s ease-in-out infinite alternate; }
@keyframes worn { to { opacity: 0.35; } }
#gaps { position: absolute; left: 50%; top: calc(var(--safe-t) + 4.4 * var(--u)); transform: translateX(-50%); display: flex; gap: calc(1.4 * var(--u)); font: 800 italic max(calc(1.7 * var(--u)), 11px)/1 var(--font); color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.8); pointer-events: none; }
#gaps span:empty { display: none; }
#gaps span { background: rgba(6,6,8,0.72); padding: calc(0.45 * var(--u)) calc(1 * var(--u)); border-radius: 999px; }
#gaps .drs { color: #35e07a; box-shadow: 0 0 0 1px #35e07a inset; }
#lights.on ~ #gaps, #lights.on + #gaps { display: none; }

/* v5.1 slider steering + gyro gauge */
#wheelPad { display: none; position: absolute; left: calc(var(--safe-l) + 2 * var(--u)); bottom: calc(var(--safe-b) + 2.2 * var(--u)); width: max(calc(26 * var(--u)), 190px); height: max(calc(10 * var(--u)), 70px); border-radius: calc(5 * var(--u)); border: 1px solid rgba(255,255,255,0.3); background: rgba(120,126,136,0.34); pointer-events: auto; touch-action: none; }
#wheelPad .wtrack { position: absolute; left: 8%; right: 8%; top: 50%; height: 3px; margin-top: -1.5px; background: rgba(255,255,255,0.35); border-radius: 3px; }
#wheelPad i { position: absolute; left: 50%; top: 50%; width: max(calc(7 * var(--u)), 48px); height: max(calc(7 * var(--u)), 48px); margin: calc(max(calc(7 * var(--u)), 48px) / -2) 0 0 calc(max(calc(7 * var(--u)), 48px) / -2); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #b9c2d6 60%, #7d879b); box-shadow: 0 4px 14px rgba(0,0,0,0.5); pointer-events: none; }
#wheelPad span { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: max(calc(1.1 * var(--u)), 8px); letter-spacing: 0.3em; opacity: 0.5; pointer-events: none; }
body.mode-wheel #wheelPad { display: block; } body.mode-wheel .padsteer { display: none; }
body.mode-wheel .pedal.brake { right: calc(var(--safe-r) + 2 * var(--u) + var(--gw) + 1.6 * var(--u)); left: auto; }
body.mode-wheel .rounds { left: calc(var(--safe-l) + 2 * var(--u) + max(calc(26 * var(--u)), 190px) + 3 * var(--u)); }
#gyroGauge { position: relative; height: 10px; margin: 10px 2px 2px; border-radius: 6px; background: rgba(255,255,255,0.14); }
#gyroGauge::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: rgba(255,255,255,0.5); }
#gyroKnob { position: absolute; left: 50%; top: -3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* weather widget, pit button, radio */
#wx { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 1.6 * var(--u)); transform: translateX(-50%); font: 800 max(calc(1.35 * var(--u)), 9px)/1 var(--font); letter-spacing: .08em; color: #fff; text-shadow: 0 1px 4px #000; padding: calc(.55 * var(--u)) calc(1.2 * var(--u)); border-radius: 999px; background: rgba(6,6,8,.6); pointer-events: none; white-space: nowrap; }
#wx:empty { display: none; } #wx.wet { color: #8fd0ff; } #wx.pit { color: #ffd23a; }
#radio { position: absolute; left: 50%; top: calc(var(--safe-t) + 8.2 * var(--u)); transform: translate(-50%, -8px); opacity: 0; transition: opacity .25s, transform .25s; display: flex; gap: calc(1 * var(--u)); align-items: center; max-width: 70vw; padding: calc(.7 * var(--u)) calc(1.4 * var(--u)); border-radius: calc(1.2 * var(--u)); background: rgba(8,10,16,.82); border-left: 3px solid #35a7ff; color: #fff; font: 600 max(calc(1.5 * var(--u)), 10px)/1.25 var(--font); pointer-events: none; }
#radio.show { opacity: 1; transform: translate(-50%, 0); } #radio b { color: #35a7ff; font-size: .7em; letter-spacing: .25em; }
#btnPit.armed { border-color: #ffd23a; color: #ffd23a; box-shadow: 0 0 16px rgba(255,210,58,.7); background: rgba(255,210,58,.16); }
.tower .dnf, .row.dnf { opacity: .45; }

#dmgBar { display: block; height: 100%; width: 100%; background: #39d98a; transition: width .3s, background .3s; } .dmgbar { margin-top: calc(0.3 * var(--u)); }

#vig { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%), repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,.05) 0 .6deg, transparent .6deg 7deg); -webkit-mask-image: radial-gradient(ellipse at center, transparent 35%, #000 85%); mask-image: radial-gradient(ellipse at center, transparent 35%, #000 85%); }
#rows .row .p { min-width: 2.6em; white-space: nowrap; } #rows .row.dnf .p { color: #ff6a5a; }
#fbBtn { position: absolute; top: calc(2.2 * var(--u)); left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: auto; font: 800 calc(1.7 * var(--u)) system-ui; color: #fff; background: rgba(20,24,40,.7); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: .35em .9em; backdrop-filter: blur(6px); } #fbBtn.off { opacity: .35; }

/* =====================================================================================================
   PHONE HUD (body.phone, landscape). Goal: the road stays visible.
   - leaderboard shows only the 5 cars around you (not all 22)
   - minimap is always on, top right
   - one slim speed / gear / tyre pill replaces the big dashboard
   - big, thumb-friendly controls in the corners, nothing in the middle of the screen
   ===================================================================================================== */
body.phone { --t: 8px; --pedW: clamp(74px, 12vw, 100px); --pedH: clamp(96px, 30vh, 124px); --brkW: clamp(86px, 14vw, 118px); --brkH: clamp(56px, 16vh, 70px); --padW: clamp(66px, 10.5vw, 92px); --padH: clamp(60px, 16vh, 76px); --rb: clamp(42px, 12vh, 52px); --rs: clamp(34px, 9.5vh, 40px); }
body.phone #vig, body.phone #glare, body.phone #vignette { display: none; }
body.phone #side, body.phone #fps.on { display: none; }
body.phone #hud button, body.phone #touch button { touch-action: none; }

/* leaderboard */
body.phone #tower { left: calc(var(--safe-l) + var(--t)); top: calc(var(--safe-t) + var(--t)); width: clamp(104px, 15vw, 128px); background: rgba(6,6,8,0.62); border-radius: 8px; overflow: hidden; }
body.phone #flagbar { font-size: 8px; padding: 2px 5px; }
body.phone #towerHead { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; padding: 3px 7px 3px; border-bottom-width: 2px; }
body.phone #towerHead i { font-style: italic; color: #ffd23a; margin-right: auto; }
#towerHead i { display: none; } body.phone #towerHead i { display: inline; }
body.phone #rows { height: calc(var(--n, 5) * var(--rh, 19px)); }

/* top right: icons, minimap, lap time */
body.phone #rcol { display: contents; }
body.phone #icons { position: absolute; right: calc(var(--safe-r) + var(--t)); top: calc(var(--safe-t) + 4px); gap: 6px; }
body.phone #icons button { width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: rgba(8,10,14,0.5); }
body.phone #mapWrap { display: block !important; position: absolute; right: calc(var(--safe-r) + var(--t)); top: calc(var(--safe-t) + 44px); width: clamp(72px, 19vh, 96px); height: clamp(72px, 19vh, 96px); border-radius: 12px; background: rgba(8,10,14,0.5); padding: 2px; }
body.phone #timing { position: absolute; right: calc(var(--safe-r) + var(--t)); top: calc(var(--safe-t) + 44px + clamp(72px, 19vh, 96px) + 4px); width: clamp(72px, 19vh, 96px); background: rgba(8,10,14,0.55); border-radius: 8px; overflow: hidden; font-size: 10px; }
body.phone #timing .secs, body.phone #timing .trow.fast, body.phone #timing .trow.best { display: none; }
body.phone .trow { padding: 2px 6px; align-items: center; } body.phone .trow span { display: none; }
body.phone .trow::before { content: "LAP"; font-size: 8px; font-weight: 800; color: #fff; letter-spacing: .06em; opacity: .75; }
body.phone .trow.delta::before { content: "\0394"; color: #f4d90d; opacity: 1; font-size: 11px; }
body.phone .trow b { font-size: 11px; }

/* speed / gear / tyre pill, bottom centre */
body.phone #dash { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 6px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 3px 12px 3px 10px; border-radius: 999px; background: rgba(8,10,14,0.55); border: 1px solid rgba(255,255,255,0.1); width: auto; }
body.phone .dtop { display: block; } body.phone #rev, body.phone .mph, body.phone #modCar { display: none; }
body.phone .dtop span.kph { display: flex; align-items: baseline; gap: 3px; } body.phone .dtop span b { font-size: 20px; display: inline; } body.phone .dtop span small { font-size: 8px; }
body.phone .dmid { display: flex; align-items: center; gap: 10px; margin: 0; }
body.phone #gear { font-size: 22px; min-width: 14px; }
body.phone #modTyre { padding: 2px 6px; display: flex; flex-direction: row; align-items: center; gap: 6px; background: rgba(0,0,0,0.25); }
body.phone .tt { font-size: 10px; } body.phone .tt .tyreIcon, body.phone .tt .therm { display: none; }
body.phone .tyrebar { width: 34px; }
body.phone #ersBtn { margin: 0; padding: 2px 6px; box-shadow: none; } body.phone #ersBtn svg { width: 28px; min-width: 28px; }

/* messages */
body.phone #lights { top: calc(var(--safe-t) + 30px); } body.phone #gaps { top: calc(var(--safe-t) + 30px); font-size: 11px; }
body.phone #dots { top: calc(var(--safe-t) + 0px); padding: 8px 18px; }
body.phone #wx { bottom: auto; top: calc(var(--safe-t) + 56px); font-size: 9px; }
body.phone #toast { top: calc(var(--safe-t) + 52px); font-size: 11px; padding: 6px 14px; }
body.phone #radio { top: calc(var(--safe-t) + 76px); max-width: 52vw; font-size: 11px; padding: 5px 10px; }
body.phone #banner { top: 24%; font-size: clamp(28px, 11vh, 48px); }
body.phone #fbBtn { left: calc(var(--safe-l) + var(--t)); transform: none; top: calc(var(--safe-t) + var(--t) + 150px); font-size: 11px; padding: 4px 10px; }
body.phone #wrong { top: 36%; }

/* controls */
body.phone #touch { --pw: var(--brkW); --ph: var(--brkH); --gw: var(--pedW); --gh: var(--pedH); }
body.phone .pedal { bottom: calc(var(--safe-b) + var(--t)); border-radius: 14px; background-color: rgba(120,126,136,0.3); border-color: rgba(255,255,255,0.3); }
body.phone .pedal.gas { right: calc(var(--safe-r) + var(--t)); width: var(--pedW); height: var(--pedH); }
body.phone .pedal.brake { width: var(--brkW); height: var(--brkH); }
body.phone .padsteer { left: calc(var(--safe-l) + var(--t)); bottom: calc(var(--safe-b) + var(--t)); gap: 8px; }
body.phone .pad { width: var(--padW); height: var(--padH); border-radius: 14px; }
body.phone.mode-buttons .pedal.brake, body.phone.mode-wheel .pedal.brake { right: calc(var(--safe-r) + var(--t) * 2 + var(--pedW)); left: auto; }
body.phone.mode-gyro .pedal.brake { left: calc(var(--safe-l) + var(--t)); right: auto; }
body.phone #wheelPad { left: calc(var(--safe-l) + var(--t)); bottom: calc(var(--safe-b) + var(--t)); width: clamp(180px, 30vw, 250px); height: var(--padH); border-radius: 30px; }
/* round buttons: BOOST + DRS above the gas pedal (right thumb), R + PIT above the left thumb */
body.phone .rounds { display: contents; }
body.phone .rbtn { position: absolute; width: var(--rb); height: var(--rb); bottom: calc(var(--safe-b) + var(--t) * 2 + var(--pedH)); background: rgba(20,22,28,0.45); }
body.phone .rbtn.push { right: calc(var(--safe-r) + var(--t)); }
body.phone .rbtn[data-act="drs"] { right: calc(var(--safe-r) + var(--t) * 2 + var(--rb)); }
body.phone .rbtn[data-act="reset"], body.phone .rbtn[data-act="pit"] { width: var(--rs); height: var(--rs); font-size: 10px; bottom: calc(var(--safe-b) + var(--t) * 2 + var(--padH)); }
body.phone .rbtn[data-act="reset"] { left: calc(var(--safe-l) + var(--t)); }
body.phone .rbtn[data-act="pit"] { left: calc(var(--safe-l) + var(--t) * 2 + var(--rs)); }
body.phone.mode-gyro .rbtn[data-act="reset"], body.phone.mode-gyro .rbtn[data-act="pit"] { bottom: calc(var(--safe-b) + var(--t) * 2 + var(--brkH)); }
body.phone.mode-wheel .rbtn[data-act="reset"], body.phone.mode-wheel .rbtn[data-act="pit"] { bottom: calc(var(--safe-b) + var(--t) * 2 + var(--padH)); }

/* intro + podium on a phone */
body.phone #intro .band { top: 14%; bottom: 14%; }
body.phone #gcard { height: 64px; min-height: 64px; bottom: 16%; width: min(58vw, 100%); }
body.phone #gcard .gpos { width: 64px; min-width: 64px; } body.phone #gcard .gpos b { font-size: 28px; }
body.phone #gcard em { font-size: 17px; } body.phone #gcard .gtxt span { font-size: 11px; } body.phone #gcard .gtxt b { font-size: 20px; }
body.phone #intro h1 { font-size: 22px; padding-top: 10px; }
body.phone #pTitle { font-size: clamp(26px, 10vh, 44px); } body.phone #pSub { top: clamp(40px, 14vh, 64px); font-size: 12px; }
body.phone #podiumUi .cta { padding: 10px 28px; font-size: 14px; }
#intro.opening #gcard { opacity: 0; transform: translateY(20px); } #intro.opening h1 { letter-spacing: .5em; }
