/* Inter, self-hosted (variable latin subset, weights 100-900) */
@font-face { font-family: 'Inter'; src: url(fonts/inter-latin.woff2) format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
/* Barlow Condensed + JetBrains Mono, self-hosted (SIL OFL 1.1, licences in fonts/; latin subsets from Google Fonts) */
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-800.woff2) format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/barlow-condensed-800-italic.woff2) format('woff2'); font-weight: 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url(fonts/jetbrains-mono-latin.woff2) format('woff2'); font-weight: 100 800; font-style: normal; font-display: swap; }
:root {
  --ink: #07090d;
  --panel: rgba(10, 13, 19, 0.78);
  --panel-2: rgba(22, 27, 36, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --txt: #eef1f6;
  --dim: #8b93a3;
  --acc: #ffcc00;      /* signal yellow */
  --acc-2: #ff5a1f;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --purple: #b36bff;
  --r: 10px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  /* HUD geometry: one gutter, one bottom line, fixed column widths */
  --g: 14px;
  --dash-w: 320px;
  --dash-b: 30px;
  --lcol-w: 236px;
  --rcol-w: 252px;
  --map-w: 188px;
  --stat-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--txt); font-family: Inter, system-ui, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui > .hud { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,0.1); color: var(--dim); margin-left: 6px; }
/* a drawn keycap, for "press E" alerts */
kbd.cap { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin: 0 3px; padding: 0 5px; font: 800 12px var(--mono); color: #111; background: linear-gradient(#fff, #d9dde4); border-radius: 5px; box-shadow: 0 2px 0 #7d8594, 0 3px 6px rgba(0,0,0,0.4); vertical-align: 1px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
.hud { position: absolute; inset: 0; font-size: 13px; }
.hud .pitpanel { pointer-events: auto; }

/* left column: aids chip, pit banner, timing tower */
.lcol { position: absolute; left: var(--g); top: var(--g); display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: var(--lcol-w); }

.aidchip { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px 8px; color: #e8ecf2; cursor: pointer; font: inherit; backdrop-filter: blur(8px); pointer-events: auto; }
.aidchip:hover { border-color: var(--acc); }
.aidchip small { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: var(--acc); }
.aidchip small span { font-size: 11px; letter-spacing: 0; font-weight: 600; color: #9aa3b2; }
.aidchip b { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-weight: 600; }
.aidchip i { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,0.09); }
.aidchip i.none { color: #9aa3b2; }
.aidchip kbd { font-size: 11px; margin-left: 0; margin-right: 3px; }

.tower { background: var(--panel); border-radius: var(--r); padding: 6px 0; backdrop-filter: blur(8px); border: 1px solid var(--line); }
.tower .row { display: flex; align-items: center; height: 20px; padding: 0 8px; gap: 6px; font-weight: 600; font-size: 12px; }
.tower .row.me { background: linear-gradient(90deg, rgba(255,204,0,0.26), rgba(255,204,0,0.05)); }
.tower .row.out { opacity: 0.4; }
.tower .row.cut { opacity: 0.5; }
.tower .pos { width: 18px; text-align: right; color: var(--dim); font-family: var(--mono); font-size: 11.5px; }
.tower .row.me .pos { color: var(--acc); }
.tower .bar { width: 3px; height: 13px; border-radius: 2px; }
.tower .nm { width: 38px; letter-spacing: 0.04em; }
.tower .fl { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 6px var(--purple); }
.tower .gap { flex: 1; text-align: right; font-family: var(--mono); font-size: 11px; color: #cfd5df; }
.tower .gap em { font-style: normal; color: var(--warn); font-family: Inter; font-weight: 800; font-size: 11px; }
.tower .pen { font-family: var(--mono); font-size: 11px; color: #fff; background: var(--bad); border-radius: 3px; padding: 0 3px; }
.tower .ty, .tyl { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--c); display: inline-grid; place-items: center; font-size: 11px; font-weight: 900; color: #fff; background: #111; flex: none; }
.tower .thead { font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: var(--acc); padding: 2px 10px 6px; }
/* the folded part of the field: top three, then the cars round you */
.tower .fold { height: 8px; margin: 1px 10px; background: radial-gradient(circle, rgba(255,255,255,0.45) 1.2px, transparent 1.6px) center / 8px 8px repeat-x; }

/* pit lane banner (in the left column) */
.pitbar { display: flex; align-items: stretch; gap: 6px; }
.pitbar > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; backdrop-filter: blur(8px); }
.pitbar small { display: block; font-size: 11px; letter-spacing: 0.14em; font-weight: 800; color: #9aa3b2; }
.pitbar kbd { background: var(--acc); color: #111; border: 0; font-weight: 800; }
.pb-lim { background: #f4f4f2 !important; color: #111; border: 4px solid #d11d2a !important; border-radius: 999px !important; text-align: center; min-width: 66px; flex: none; }
.pb-lim small { color: #555; font-size: 11px; }
.pb-lim b { display: block; font-size: 22px; line-height: 1; font-weight: 900; }
.pb-lim span { font-size: 11px; font-weight: 700; }
.pb-spd { text-align: center; min-width: 58px; flex: none; }
.pb-spd b { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pb-spd span { font-size: 11px; color: #9aa3b2; }
.pb-spd.over { border-color: var(--bad); }
.pb-spd.over b { color: #ff6b6b; }
.pb-do { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.pb-do span { font-size: 12px; font-weight: 600; margin-top: 3px; line-height: 1.3; }
.pb-do .go { color: var(--acc); }
.pitbar.warn .pb-do { border-color: var(--bad); }
.pitbar .pb-do .over { color: #ff8b8b; }
.pitbar .pb-do .over kbd { background: var(--bad); color: #fff; }

/* top middle: lap / position */
.hud-top { position: absolute; top: var(--g); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.hud-top > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 5px 14px; text-align: center; min-width: 88px; backdrop-filter: blur(8px); }
.hud-top .wide { min-width: 128px; }
.hud-top small { display: block; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); font-weight: 700; }
.hud-top b { font-size: 22px; font-weight: 900; }
.hud-top b i { font-style: normal; font-size: 13px; color: var(--dim); font-weight: 600; }
.hud-top b.mono { font-size: 19px; }
.hud-top b.bad { color: var(--bad); }

/* right column: weather, radar (or the pit / grid tyre panel) */
.rcol { position: absolute; right: var(--g); top: var(--g); width: var(--rcol-w); display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.rcol.pp .radar { display: none; }
.wx-now { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 12px; backdrop-filter: blur(8px); }
.wx-now .ic { width: 26px; height: 26px; display: grid; place-items: center; flex: none; }
.wx-now .ic svg { width: 26px; height: 26px; }
.wx-now b { display: block; font-size: 13px; }
.wx-now small { color: var(--dim); font-size: 11px; }
.wx-now small.wx-out { display: block; font-size: 11.5px; font-weight: 800; color: var(--acc); margin-top: 2px; }
.wx-now small.wx-out.rain { color: #7cc0ff; }
.radar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; backdrop-filter: blur(8px); }
.radar small { display: block; font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: #9aa3b2; margin: 0 2px 6px; }
.radar canvas { display: block; width: 236px; height: 190px; border-radius: 8px; }
.rd-legend { display: flex; gap: 10px; font-size: 11px; color: #c3cad6; margin: 7px 2px 2px; }
.rd-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.rd-out { display: block; font-size: 13px; margin: 5px 2px 1px; }

/* pit stop / starting tyres: a side panel in the right column */
.pitpanel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; backdrop-filter: blur(10px); }
.pitpanel h4 { margin: 0 0 10px; font-size: 15px; }
.pitpanel .tyres { display: flex; flex-direction: column; gap: 5px; }
.pitpanel .tyres button { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05); border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; text-align: left; font-weight: 700; }
.pitpanel .tyres button:hover { background: rgba(255,255,255,0.1); }
.pitpanel .tyres button.rec { border-color: var(--acc); }
.pitpanel .tyres button kbd { margin-left: auto; }
.pitpanel .rep { display: flex; gap: 8px; align-items: center; margin: 10px 0 6px; font-weight: 600; }
.pitpanel small { color: var(--dim); display: block; }
.pp-foot { margin-top: 10px; text-align: right; }
.pp-foot button { background: none; border: 0; color: var(--dim); }
.gridwx { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.gridwx svg { width: 32px; height: 32px; flex: none; }
.gridwx b { display: block; font-size: 13px; }
.gridwx small { color: var(--acc); font-weight: 700; }
.eng { display: flex; gap: 8px; align-items: flex-start; background: rgba(96,165,250,0.12); border-left: 3px solid #60a5fa; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px; }
.eng .mi, .eng .mi svg { width: 16px; height: 16px; flex: none; }

/* bottom middle: speed dash */
/* v0.9.17: the dash is the car's steering wheel (hud.js buildDash), fixed; the lights are the revs */
.dash { position: absolute; bottom: calc(var(--dash-b) - 12px); left: 50%; transform: translateX(-50%); width: var(--dash-w); text-align: center; pointer-events: none; }
.wheel { position: relative; width: 320px; height: 140px; margin: 0 auto; filter: drop-shadow(0 8px 16px rgba(0,0,0,0.45)); }
.wheel-body { position: absolute; inset: 0; width: 100%; height: 100%; }
.wheel-body .grip { fill: #14171d; stroke: #2a303b; stroke-width: 1.5; }
.wheel-body .grip-line { stroke: rgba(255,255,255,0.06); stroke-width: 3; stroke-linecap: round; }
.wheel-body .body { fill: rgba(16, 19, 25, 0.96); stroke: rgba(255,255,255,0.16); stroke-width: 1.5; }
.wheel-body .screen { fill: #05070a; stroke: rgba(255,255,255,0.12); stroke-width: 1.2; }
.wheel-body .knob { fill: #20252f; stroke: #3b4250; stroke-width: 1.5; }
.wheel-body .btn { fill: #262c37; stroke: #3b4250; stroke-width: 1; }
.revs { position: absolute; left: 0; right: 0; top: 14px; display: flex; gap: 3px; justify-content: center; }
.revs i { width: 11px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.09); }
/* v0.9.17b (Uday: "real or less vibrant"): a calm warm-white ramp like a real wheel's LEDs at night, a soft amber tip,
   barely any glow. Still one hue, so it never reads as the racing line's green / yellow / red. */
.revs i.on { background: #e9e2d0; box-shadow: 0 0 3px rgba(233, 226, 208, 0.35); }
.revs i.on.top { background: #e6a44a; box-shadow: 0 0 3px rgba(230, 164, 74, 0.4); }
.wheel.shift .revs i.on.top { animation: shiftflash 0.24s steps(2) infinite; }
@keyframes shiftflash { 50% { background: #fff4dc; box-shadow: 0 0 6px rgba(255, 244, 220, 0.7); } }
.dash-main { position: absolute; left: 88px; top: 30px; width: 144px; height: 62px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.gear { font-size: 30px; font-weight: 900; width: 26px; color: var(--acc); font-family: var(--mono); line-height: 1; }
.speed b { font-size: 34px; font-weight: 900; font-family: var(--mono); letter-spacing: -0.02em; min-width: 66px; display: inline-block; text-align: right; line-height: 1; }
.speed span { font-size: 11px; color: var(--dim); margin-left: 4px; font-weight: 700; }
.dash-row { position: absolute; left: 0; right: 0; top: 98px; display: flex; justify-content: center; gap: 8px; font-size: 11px; font-weight: 800; color: var(--dim); }
.dash-row .gone, .dash-row .delta:empty { display: none; }
.dash-row .drs { padding: 1px 8px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.15); color: rgba(255,255,255,0.25); }
.dash-row .drs.armed { color: var(--txt); border-color: rgba(255,255,255,0.45); }
.dash-row .drs.ready { color: #111; background: var(--good); border-color: var(--good); }
.dash-row .drs.open { color: #111; background: var(--acc); border-color: var(--acc); }
.dash-row .lim { color: #111; background: var(--acc); border-radius: 5px; padding: 1px 8px; }
/* v0.9.16: the pit limiter on the dash */
.lb-none { margin: 6px 0 2px; color: var(--dim); font-size: 13px; }
.dash.limon .wheel-body .body { stroke: #60a5fa; stroke-width: 3; }
.dash.limoff .wheel-body .body { stroke: #ef4444; stroke-width: 3; }
.limbar { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin: -4px auto 0; width: max-content; padding: 5px 14px; border-radius: 9px; color: #fff; }
.limbar.hidden { display: none; }
.limbar b { font: 800 italic 20px/1 var(--f-display); letter-spacing: 0.06em; }
.limbar span { font-size: 13px; font-weight: 700; opacity: 0.95; }
.dash.limon .limbar { background: #1d4ed8; }
.dash.limoff .limbar { background: #b91c1c; animation: limblink 0.9s steps(2) infinite; }
@keyframes limblink { 50% { background: #7f1d1d; } }

/* bottom left: the car, one compact card */
.status { position: absolute; left: var(--g); bottom: 18px; width: var(--stat-w); display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; backdrop-filter: blur(8px); }
.status:empty { display: none; }
/* v0.9.18: a stop is called: the card is outlined and the part it is for pulses (src/ui/hud.js pitWhy) */
.status.called { border-color: #f59e0b; box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.45); }
.status .hot { animation: hotpulse 0.9s ease-in-out infinite; }
.status .st-r.hot b { color: #fbbf24; }
.st-r.dmg { display: block; }
.st-r.dmg b { font-size: 12.5px; letter-spacing: 0.02em; }
@keyframes hotpulse { 50% { opacity: 0.35; } }
.diag { width: 44px; height: 88px; flex: none; }
.st-rows { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-r { display: grid; grid-template-columns: 40px auto 1fr; align-items: baseline; gap: 6px; padding: 1px 0; }
.st-r small { font-size: 11px; color: var(--dim); letter-spacing: 0.1em; font-weight: 800; white-space: nowrap; }
.st-r small:last-child { letter-spacing: 0; font-weight: 600; font-size: 11px; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.st-r b { font-size: 14px; font-weight: 800; white-space: nowrap; }
.st-r b.mono { font-size: 12.5px; }
.st-r b.cold { color: #7cc0ff; }
.st-r .tyl { align-self: center; width: 20px; height: 20px; font-size: 11px; border-width: 3px; }
.st-r.warn b { color: #ff7a7a; }
.st-r.warn small:first-child { color: #ff7a7a; }

/* bottom right: map */
.minimap { position: absolute; right: var(--g); bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px; backdrop-filter: blur(8px); }
.minimap canvas { width: 180px; height: 180px; display: block; }

/* message strip: right of the dash, newest on top, never over the road */
.strip { position: absolute; bottom: var(--dash-b); left: calc(50% + var(--dash-w) / 2 + 12px); width: min(400px, calc(50% - var(--dash-w) / 2 - 12px - var(--map-w) - var(--g) - 12px)); height: 118px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; pointer-events: none; }
.msg { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-left: 3px solid var(--acc); border-radius: 6px; padding: 5px 10px; font-size: 12px; font-weight: 600; line-height: 1.3; transition: opacity .6s, transform .6s; animation: msgin .25s ease-out; }
.msg b { font-weight: 800; }
.msg.bad { border-color: var(--bad); }
.msg.warn { border-color: var(--warn); }
.msg.good { border-color: var(--good); }
.msg.best { border-color: var(--purple); }
.msg.best b { color: #d4adff; }
.msg.radio { border-color: #60a5fa; }
.msg.dim { border-color: rgba(255,255,255,0.2); color: #b8bfcc; }
.msg.out { opacity: 0; transform: translateX(12px); }
.msg .mi { width: 15px; height: 15px; display: inline-grid; flex: none; }
.msg .mi svg { width: 15px; height: 15px; }
.strip .msg:nth-child(2) { opacity: 0.85; }
.strip .msg:nth-child(3) { opacity: 0.65; }
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* alerts: left of the dash. DRS ready, low fuel, low grip, box, penalty */
.alerts { position: absolute; bottom: var(--dash-b); right: calc(50% + var(--dash-w) / 2 + 12px); width: min(280px, calc(50% - var(--dash-w) / 2 - 12px - var(--stat-w) - var(--g) - 12px)); height: 118px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; pointer-events: none; }
.alert { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px 7px 9px; animation: pop .28s cubic-bezier(.2,1.4,.4,1); transition: opacity .3s, transform .3s; }
.alert.out { opacity: 0; transform: translateX(-10px); }
.alert .ai { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,0.08); }
.alert .ai svg { width: 20px; height: 20px; }
.alert b { display: block; font-size: 13px; font-weight: 900; letter-spacing: 0.08em; }
.alert span { display: block; font-size: 11.5px; color: #c9d0db; font-weight: 600; margin-top: 1px; line-height: 1.35; }
.alert.drs { border-color: var(--good); }
.alert.drs .ai { background: var(--good); color: #111; }
.alert.drs b { color: #6ee79a; }
.alert.drs.open { border-color: var(--acc); }
.alert.drs.open .ai { background: var(--acc); }
.alert.drs.open b { color: var(--acc); }
.alert.warn { border-color: var(--warn); }
.alert.warn .ai { background: var(--warn); color: #111; }
.alert.warn b { color: #ffc15a; }
.alert.bad { border-color: var(--bad); }
.alert.bad .ai { background: var(--bad); color: #fff; }
.alert.bad b { color: #ff8080; }
.alert.box { border-color: var(--acc); }
.alert.box .ai { background: var(--acc); color: #111; animation: pulse 1s infinite alternate; }
.alert.box b { color: var(--acc); }
@keyframes pop { from { opacity: 0; transform: scale(0.9) translateY(6px); } to { opacity: 1; transform: none; } }
/* v0.9.17: a penalty has its own slot in the left column (hud.js penaltyFrame): what for, how long, when it is served */
.penbar { flex: none; position: relative; display: flex; align-items: center; gap: 10px; background: rgba(60, 8, 10, 0.94); border: 1px solid var(--bad); border-radius: 12px; padding: 7px 12px 9px 9px; overflow: hidden; box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25), 0 6px 18px rgba(0, 0, 0, 0.35); }
.penbar.hidden { display: none; }
.hud.focus .lcol > .penbar { opacity: 1; filter: none; }
.penbar .ai { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--bad); color: #fff; }
.penbar .ai svg { width: 20px; height: 20px; }
.penbar small { display: block; font-size: 11px; letter-spacing: 0.14em; font-weight: 800; color: #ffb4b4; }
.alerts:has(.chance:not(.hidden)) .alert { display: none; }
.penbar b { display: block; font-size: 15px; font-weight: 800; line-height: 1.25; }
.penbar span { display: block; font-size: 11.5px; color: #f3caca; line-height: 1.3; }
.penbar span b { display: inline; font-size: inherit; font-variant-numeric: tabular-nums; color: #fff; }
.penbar em { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--bad); }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.65; } }

/* the few centre texts: small and high, never over the car */
.bigmsg { position: absolute; left: 50%; top: 104px; transform: translate(-50%, -6px); text-align: center; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.bigmsg.on { opacity: 1; transform: translate(-50%, 0); }
.bigmsg b { display: block; font-size: 34px; font-weight: 900; font-family: var(--mono); letter-spacing: 0.02em; text-shadow: 0 3px 20px rgba(0,0,0,0.7); }
.bigmsg b.good { color: var(--good); }
.bigmsg b.bad { color: var(--bad); }
.bigmsg b.warn { color: var(--warn); }
/* qualifying: "Good lap. Happy with it?" with the End my qualifying button */
.qdone { position: absolute; left: 50%; top: 170px; transform: translateX(-50%); width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-radius: 12px; background: var(--panel-2, rgba(15,23,42,0.9)); border: 1px solid var(--good, #22c55e); box-shadow: 0 8px 30px rgba(0,0,0,0.45); pointer-events: auto; animation: pop .28s cubic-bezier(.2,1.4,.4,1); transition: opacity .35s; z-index: 5; }
.qdone.out { opacity: 0; }
.qdone b { font-size: 16px; color: var(--good, #22c55e); }
.qdone span { font-size: 13px; line-height: 1.35; color: #dfe4ec; }
.qdone button { align-self: flex-start; margin-top: 4px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line, rgba(255,255,255,0.2)); background: rgba(255,255,255,0.1); color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.qdone button:hover { background: rgba(255,255,255,0.18); }
/* key caps inside sentences and on the qualifying buttons: big enough that G never reads as 6 */
.hint kbd, .qdone kbd, .garagepanel .gp-skip kbd { font: 700 12.5px/1.3 var(--mono); padding: 1px 6px; color: #fff; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.28); }
.bigmsg span { display: block; font-size: 13px; font-weight: 700; color: #dfe4ec; text-shadow: 0 2px 10px rgba(0,0,0,0.85); max-width: 380px; margin: 2px auto 0; }

.lights { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: none; gap: 10px; background: #0b0b0d; padding: 10px 14px; border-radius: 12px; border: 1px solid #222; }
.lights.on { display: flex; }
.lights .lamp { width: 30px; height: 30px; border-radius: 50%; background: #2a0a0a; box-shadow: inset 0 0 8px #000; }
.lights .lamp.lit { background: radial-gradient(circle at 40% 35%, #ff8a8a, #ff1a1a 45%, #a00000); box-shadow: 0 0 22px #ff2a2a; }

/* short flag bar under the lap boxes */
.flagbar { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); padding: 5px 16px; border-radius: 7px; font-weight: 900; letter-spacing: 0.14em; font-size: 12px; white-space: nowrap; }
.flagbar.yellow { background: #ffcc00; color: #111; animation: pulse .8s infinite alternate; }
.flagbar.green { background: #16a34a; color: #fff; }

/* the key strip: under the dash, at the very bottom */
.keyhint { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #c7cdd8; background: rgba(0,0,0,0.5); padding: 3px 12px; border-radius: 20px; transition: opacity 1s; white-space: nowrap; }
.keyhint kbd { margin-left: 0; font-size: 11px; padding: 0 4px; }
.keyhint.fade { opacity: 0; }

/* ---------------- overlays / screens ---------------- */
.overlay { position: absolute; inset: 0; background: rgba(4,6,10,0.6); display: grid; place-items: center; backdrop-filter: blur(6px); }
.panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 24px; min-width: 300px; }
.panel h2 { margin: 0 0 16px; }
.btn, .primary { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 10px; padding: 11px 18px; font-weight: 800; }
.primary { background: var(--acc); color: #111; border-color: var(--acc); }
.primary:hover { filter: brightness(1.06); }
.btn:hover { background: rgba(255,255,255,0.14); }

/* pause: driving aids */
.pause .aids { margin-top: 14px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.pause .aids-head { grid-column: 1 / -1; margin-bottom: 4px; }
.pause .aids-head b { display: block; font-size: 15px; color: var(--acc); }
.pause .aids-head span { font-size: 12.5px; color: #9aa3b2; }
.pause .aid { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.pause .aid.off { opacity: 0.5; cursor: default; }
.pause .aid input { accent-color: var(--acc); width: 16px; height: 16px; }

/* short screens: tighter tower rows and a smaller radar */
@media (max-height: 760px) {
  .radar canvas { height: 150px; }
  .minimap canvas { width: 150px; height: 150px; }
  :root { --map-w: 158px; }
}
@media (max-width: 1100px) {
  .radar { display: none; }
}
@media (max-width: 1250px) {
  .alerts { right: auto; left: var(--g); width: var(--stat-w); bottom: 150px; height: auto; }
  .alerts .alert { background: #151b27; }
  .hud .alerts .chance { background: #082816; }
}
@media (max-width: 1180px) {
  .strip { left: auto; right: var(--g); width: min(300px, 34vw); bottom: 176px; height: auto; }
}
@media (max-width: 900px) {
  .strip { left: auto; right: var(--g); width: min(360px, calc(100vw - 2 * var(--g))); bottom: 150px; height: auto; }
  .alerts { right: auto; left: var(--g); width: min(300px, calc(100vw - 2 * var(--g))); bottom: 150px; height: auto; }
  .lcol { width: 200px; }
}

/* pit bar and garage hints stay on one line */
.pitbar { width: max-content; max-width: min(560px, 46vw); }
.pb-do { flex: none; min-width: 0; }
.pb-do small, .pb-do span, .gp-go { white-space: nowrap; }

/* second chance (round 7): a rewarded-ad offer in the alert slot */
.hud .chance { pointer-events: auto; flex: none; display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: #fff; cursor: pointer; background: rgba(8, 40, 22, 0.94); border: 1px solid #22c55e; border-radius: 12px; padding: 7px 10px 7px 9px; animation: pop .28s cubic-bezier(.2,1.4,.4,1); }
.hud .chance.hidden { display: none; }
.hud .chance:disabled { cursor: default; opacity: 0.85; }
.hud .chance svg { flex: none; color: #4ade80; }
.hud .chance span { min-width: 0; }
.hud .chance b { display: block; font-size: 13px; font-weight: 900; letter-spacing: 0.08em; color: #9ff0bd; white-space: nowrap; }
.hud .chance i { display: block; font-style: normal; font-size: 11.5px; font-weight: 600; color: #d6f7e2; white-space: nowrap; }
.hud .chance kbd { margin-left: auto; background: #22c55e; color: #052e16; font-weight: 800; }
/* round 9: the player's row wears their title's name card */
.tower .row.me.nc-gold { box-shadow: inset 3px 0 0 #f5c518, 0 0 14px rgba(245, 197, 24, 0.35); }
.tower .row.me.nc-silver { box-shadow: inset 3px 0 0 #d6dde6; }
.tower .row.me.nc-bronze { box-shadow: inset 3px 0 0 #d98c4a; }
.tower .row.me.nc-orange { box-shadow: inset 3px 0 0 #ff9a3c; } .tower .row.me.nc-teal { box-shadow: inset 3px 0 0 #39d0c0; }
.tower .row.me.nc-blue { box-shadow: inset 3px 0 0 #6fb2ff; } .tower .row.me.nc-violet { box-shadow: inset 3px 0 0 #c08bff; } .tower .row.me.nc-green { box-shadow: inset 3px 0 0 #63d98a; }

/* round 11: strikes, give-back countdown and puncture, one short line each, above the tower */
.warnbox { display: flex; flex-direction: column; gap: 2px; background: rgba(30, 24, 8, 0.92); border: 1px solid #c9a227; border-radius: var(--r); padding: 4px 10px; white-space: nowrap; }
.warnbox.hidden, .warnbox .wl.hidden { display: none; }
.warnbox .wl { font-size: 11px; letter-spacing: 0.1em; font-weight: 800; color: #ffd866; font-variant-numeric: tabular-nums; }
.warnbox .wl.give, .warnbox .wl.punc { color: #ff9a9a; }
/* round 11: on the grid, the pointer to the driving help (yellow key, read at a glance) */
.bigmsg span kbd { font-size: 12px; padding: 1px 7px; color: #111; background: var(--acc); }

/* round 12: ghost laps (src/meta/ghosts.js). Watching one lap: only the timing tower, the settings and this card. */
.hud.gh-watching .dash, .hud.gh-watching .status, .hud.gh-watching .minimap, .hud.gh-watching .hud-top, .hud.gh-watching .alerts,
.hud.gh-watching .strip, .hud.gh-watching .keyhint, .hud.gh-watching .warnbox, .hud.gh-watching .pitbar,
.hud.gh-watching .rcol > :not(.rtop) { display: none !important; }
.gh-watch { position: absolute; left: var(--g, 16px); bottom: 18px; width: min(300px, calc(100vw - 32px)); display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--panel, rgba(15,23,42,0.9)); border: 1px solid rgba(143, 211, 255, 0.55); box-shadow: 0 8px 30px rgba(0,0,0,0.4); backdrop-filter: blur(8px); pointer-events: auto; z-index: 5; }
.gh-watch small { font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: #8fd3ff; }
.gh-watch b { font-size: 18px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-watch .gh-lt { font-size: 13px; color: #dfe4ec; }
.gh-watch .gh-live { display: flex; justify-content: space-between; gap: 10px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.gh-watch .gh-back { justify-self: start; margin-top: 6px; padding: 7px 12px; }
.gh-watch kbd { font-size: 11px; opacity: 0.75; }

/* v0.9.17: the braking hint pinned to the road (src/ui/brakeHint.js): what the red is, what to press, how long */
.brakehint { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 13px 7px; border-radius: 11px; background: rgba(127, 18, 18, 0.94); border: 1px solid #ff8a80; color: #fff; text-align: center; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity .2s; }
.brakehint.on { opacity: 1; }
.brakehint::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #ff8a80; }
.brakehint b { font: 800 italic 19px/1.1 var(--f-display); letter-spacing: 0.05em; text-transform: uppercase; }
.brakehint b kbd { font-style: normal; font-size: 15px; margin: 0 2px; }
.brakehint span { font-size: 11.5px; font-weight: 700; color: #ffd6d2; }
.brakehint.on b { animation: bhpulse 0.9s ease-in-out infinite; }
@keyframes bhpulse { 50% { transform: scale(1.08); } }
/* v0.9.17: the camp rival in the race order */
.tower .row.rival { box-shadow: inset 0 0 0 1px #f97316; border-radius: 4px; }
.tower .row.rival .nm::after { content: 'RIVAL'; margin-left: 6px; padding: 0 4px; border-radius: 3px; background: #f97316; color: #111; font-size: 11px; font-weight: 900; letter-spacing: 0.06em; vertical-align: 1px; }

/* v0.9.27 (CrazyGames QA round 10: the 3-2-1 after a pause was hidden under Ray's card): while the HUD counts, the cards
   at the top centre step aside and the count sits on top of everything */
.hud.counting .mentor, .hud.counting .qdone, .hud.counting .tour { opacity: 0 !important; pointer-events: none !important; }
.hud.counting .bigmsg { z-index: 60; }
.hud.counting .bigmsg b { font-size: 48px; }
/* v0.9.27 the grid tyre pick: its explanation and small print never under 11 px */
.pitpanel .gt-why { margin: 0 0 8px; font-size: 12.5px; line-height: 1.4; color: #dfe4ec; }
.pitpanel .gt-how { margin-top: 8px; font-size: 11.5px; line-height: 1.35; }
.pitpanel .gridwx small, .pitpanel h4 small { font-size: 11.5px; }
.pitpanel small, .rw-lines li small { font-size: 11.5px; }
/* v0.9.28: W on the grid before a tyre is picked: the panel pulses once */
.hud .pitpanel.grid.nudge { animation: tyreNudge .4s ease-in-out 3; }
@keyframes tyreNudge { 50% { box-shadow: 0 0 0 3px var(--acc); } }
