:root {
  --bg: #0d1117;
  --panel: rgba(16, 20, 28, .9);
  --line: #2a3240;
  --text: #e8edf3;
  --muted: #8d99a8;
  --accent: #ff6a2b;
  --accent2: #ffb02e;
  --good: #3ddc84;
  --bad: #ff5a5a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#speedfx { position: fixed; left: 50%; top: 50%; width: 110vmax; height: 110vmax; margin: -55vmax 0 0 -55vmax; pointer-events: none; opacity: 0; will-change: transform, opacity; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 .35em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: #1a2030; font: 12px/1.6 ui-monospace, monospace; text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }
#timebox { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#timer { font: 700 44px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .5px; }
#sub { margin-top: 6px; font-size: 14px; color: #dfe6ee; display: flex; gap: 14px; justify-content: center; }
#split { margin-top: 8px; font: 700 22px/1 ui-monospace, monospace; opacity: 0; transition: opacity .25s; }
#split.show { opacity: 1; }
#split.good, .delta.good { color: var(--good); }
#split.bad, .delta.bad { color: var(--bad); }
#countdown { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font: 800 120px/1 system-ui, sans-serif; text-shadow: 0 6px 30px rgba(0,0,0,.6); }
#countdown.go { color: var(--good); }
#wrongway { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font: 800 42px/1 system-ui, sans-serif; color: var(--bad); text-transform: uppercase; letter-spacing: 3px; text-shadow: 0 3px 16px rgba(0,0,0,.7); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
#minimap { position: absolute; left: 14px; bottom: 14px; width: 180px; height: 180px; border-radius: 12px; background: rgba(10,14,20,.5); }
#ghostlabel { position: absolute; left: 14px; bottom: 200px; font-size: 13px; color: #dfe6ee; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#speedo { position: absolute; right: 22px; bottom: 16px; text-align: right; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
#speed { font: 800 56px/1 ui-monospace, monospace; }
#speedo small { display: block; color: #dfe6ee; font-size: 13px; letter-spacing: 1px; }
.iconbtn { pointer-events: auto; position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(16,20,28,.6); font-size: 13px; }

/* ---------- touch controls ---------- */
#touch { position: fixed; left: 0; right: 0; bottom: 0; height: 0; pointer-events: none; }
.tgroup { position: absolute; bottom: 18px; display: flex; gap: 14px; pointer-events: auto; }
.tgroup.left { left: 18px; }
.tgroup.right { right: 18px; }
.tgroup button { width: 78px; height: 78px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(16,20,28,.45); font-size: 26px; touch-action: none; }
.tgroup button.on { background: rgba(255,106,43,.55); }
.tgroup .gas { width: 92px; height: 92px; }
body.touch #minimap { bottom: auto; top: 64px; width: 120px; height: 120px; }
body.touch #ghostlabel { bottom: auto; top: 190px; }
body.touch #speedo { bottom: 130px; }
body.touch #timer { font-size: 32px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, rgba(6,8,12,.35), rgba(6,8,12,.75)); overflow: auto; }
.overlay.see-through { background: rgba(6,8,12,.35); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; box-shadow: 0 24px 70px rgba(0,0,0,.5); backdrop-filter: blur(6px); width: min(940px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.small-panel { width: min(420px, 100%); text-align: center; }
h1 { margin: 0; font-size: 34px; letter-spacing: .5px; }
h1::after { content: ""; display: block; width: 60px; height: 4px; margin-top: 6px; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
h2 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.small-panel h2 { margin-top: 0; font-size: 20px; color: var(--text); text-transform: none; letter-spacing: 0; }
.lead { margin: 10px 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.menu-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.account { text-align: right; font-size: 14px; color: var(--muted); }
.account b { color: var(--text); }
.account button, .linkbtn { background: none; border: 0; padding: 0; color: var(--accent2); text-decoration: underline; text-underline-offset: 2px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; gap: 0; } h1 { font-size: 28px; } .account { text-align: left; } }

.tracks { display: grid; gap: 10px; }
.track { text-align: left; border: 1px solid var(--line); background: #141a24; border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.track:hover { border-color: #3b4658; }
.track.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.track .nm { font-weight: 700; font-size: 16px; }
.track .len { color: var(--muted); font-size: 13px; text-align: right; }
.track .bl { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.track .tm { grid-column: 1 / -1; font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.track .tm span { color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #141a24; padding: 8px 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
#ghostnote { margin: 6px 0 0; min-height: 1.4em; }

.big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 22px; border-radius: 12px; border: 1px solid var(--line); background: #1a2130; font-weight: 700; font-size: 16px; }
.big:hover { border-color: #3b4658; }
.big small { font-weight: 400; color: rgba(255,255,255,.6); font-size: 12px; }
.big.primary { background: linear-gradient(135deg, var(--accent), #ff4a3d); border-color: transparent; color: #fff; }
.big.primary:hover { filter: brightness(1.08); }
#play { margin-top: 18px; width: 100%; font-size: 18px; padding: 14px; }
.keys { margin: 14px 0 0; color: var(--muted); font-size: 12.5px; line-height: 2; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.board table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.board th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.board td { padding: 6px; border-bottom: 1px solid rgba(42,50,64,.5); }
.board tr.click { cursor: pointer; }
.board tr.click:hover td { background: rgba(255,255,255,.04); }
.board tr.me td { background: rgba(255,106,43,.12); }
.board tr.ghost td:nth-child(2)::after { content: " 👻"; }
.board .rk { width: 2.2em; color: var(--muted); }
.board .t { text-align: right; font-family: ui-monospace, monospace; }
.board .gap { text-align: right; color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.board .sep td { text-align: center; color: var(--muted); padding: 2px; border: 0; }
.board .empty { color: var(--muted); padding: 18px 0; }

.bigtime { font: 800 52px/1.1 ui-monospace, monospace; margin: 6px 0; font-variant-numeric: tabular-nums; }
.delta { font: 700 18px/1.3 ui-monospace, monospace; min-height: 1.3em; }
.status { margin-top: 10px; min-height: 1.4em; color: var(--muted); }
.status b { color: var(--accent2); }
.splits { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font: 12.5px/1.2 ui-monospace, monospace; }
.splits span { padding: 4px 7px; border-radius: 6px; background: #141a24; }
.splits .good { color: var(--good); }
.splits .bad { color: var(--bad); }

/* ---------- laps, toasts, multiplayer (v2) ---------- */
#racetime { color: #ffd59a; }
#laptoast { margin-top: 10px; font: 600 16px/1.3 system-ui, sans-serif; padding: 6px 14px; border-radius: 10px; background: rgba(10,14,20,.6); display: inline-block; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
#laptoast.show { opacity: 1; transform: none; }
#laptoast.pb { background: rgba(61,220,132,.22); }
#laptoast.bad { background: rgba(255,90,90,.25); }
#laptoast.feed { font-size: 13px; font-weight: 500; }
#laptoast .good { color: var(--good); }
#laptoast .bad { color: var(--bad); }
#laplist { position: absolute; right: 14px; top: 66px; font: 13px/1.6 ui-monospace, monospace; text-align: right; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#laplist span { color: #c3cbd6; margin-right: 8px; }
#laplist .best { color: var(--good); }
#position { position: absolute; left: 16px; top: 12px; font: 800 40px/1 system-ui, sans-serif; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
#standings { position: absolute; left: 14px; top: 60px; font-size: 13px; line-height: 1.75; text-shadow: 0 1px 4px rgba(0,0,0,.85); }
#standings .pn { display: inline-block; width: 1.4em; color: #c3cbd6; }
#standings i, .players i, .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
#standings .me { font-weight: 700; }
#mpstatus { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font: 700 26px/1.2 system-ui, sans-serif; text-shadow: 0 3px 16px rgba(0,0,0,.7); }
body.mp #laplist { top: 66px; }
body.touch #position { top: auto; bottom: 230px; font-size: 28px; }
body.touch #standings { display: none; }

.pickrow { display: flex; gap: 22px; flex-wrap: wrap; }
.link { color: var(--accent2); }
.tracks { max-height: 330px; overflow-y: auto; padding-right: 2px; }
.mp { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #141a24; }
.mprow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mprow .or { color: var(--muted); font-size: 13px; }
#mp-code { width: 92px; padding: 11px 10px; border-radius: 10px; border: 1px solid var(--line); background: #0f141c; color: var(--text); font: 700 16px ui-monospace, monospace; letter-spacing: 2px; text-transform: uppercase; text-align: center; }
.mp .big { padding: 10px 16px; font-size: 15px; }
#mp-msg { margin: 8px 0 0; min-height: 1.2em; }
#mp-msg.bad { color: var(--bad); }
.field { display: block; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.field input, .field select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: #0f141c; color: var(--text); font: inherit; }
.field select:disabled { opacity: .7; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0 8px; }
.lobby-panel { width: min(820px, 100%); }
.code { font-family: ui-monospace, monospace; letter-spacing: 4px; color: var(--accent2); }
.players { list-style: none; padding: 0; margin: 0; }
.players li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; background: #141a24; }
.players .ok { color: var(--good); }
.players .host { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(255,176,46,.18); color: var(--accent2); margin-left: 4px; }
.small-panel.wide { width: min(560px, 100%); }
#p-laps { margin: 0 0 14px; }
.bootfail { position: fixed; inset: auto 16px 40%; text-align: center; font-size: 16px; }
body.testmode .hide-test { display: none !important; }

/* ---------- tilt steering ---------- */
.touch-only { display: none; }
body.touch .touch-only { display: block; }
#sensrow { display: none; }
body.tilt #sensrow { display: inline-flex; }
#steernote.bad { color: var(--bad); }
.tiltbrake, #tiltmeter, #recenter { display: none; }
body.tilt .steerbtn, body.tilt .btnbrake { display: none; }
body.tilt .tiltbrake { display: block; }
body.tilt .tgroup button { width: 92px; height: 92px; }
body.tilt #tiltmeter { display: block; position: absolute; left: 50%; bottom: 30px; width: 170px; height: 8px; margin-left: -85px; border-radius: 4px; background: rgba(10,14,20,.55); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
#tiltmeter::before { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: rgba(255,255,255,.35); }
#tiltmeter i { position: absolute; top: -4px; width: 16px; height: 16px; margin-left: -8px; left: 50%; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
body.tilt #recenter { display: block; position: absolute; left: 50%; bottom: 50px; transform: translateX(-50%); pointer-events: auto; padding: 6px 12px; border-radius: 9px; border: 1px solid rgba(255,255,255,.25); background: rgba(16,20,28,.5); font-size: 13px; touch-action: manipulation; }

/* ---------- boost, damage, cars (v4) ---------- */
#meters { position: absolute; right: 22px; bottom: 100px; width: 150px; display: grid; gap: 6px; }
.meter { position: relative; height: 14px; border-radius: 7px; background: rgba(10,14,20,.6); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); overflow: hidden; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 7px; transition: width .1s; }
.meter span { position: absolute; left: 8px; top: 0; font: 700 9.5px/14px system-ui, sans-serif; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.85); text-shadow: 0 1px 2px #000; }
.meter.boost i { background: linear-gradient(90deg, #ff6a2b, #ffd23f); }
.meter.boost.full { box-shadow: inset 0 0 0 1px #ffd23f, 0 0 10px rgba(255,210,63,.6); }
.meter.boost.on i { background: linear-gradient(90deg, #39c6ff, #b8f0ff); }
.meter.dmg i { background: #3ddc84; }
.meter.dmg.warn i { background: #ffb02e; }
.meter.dmg.bad i { background: #ff5a5a; }
.meter.tyre i { background: #8f99a6; }
.meter.tyre.t-soft i { background: linear-gradient(90deg, #a52a22, #e8322f); }
.meter.tyre.t-medium i { background: linear-gradient(90deg, #a07a12, #d9ab22); }
.meter.tyre.t-hard i { background: linear-gradient(90deg, #6d7580, #a9b2bd); }
.meter.tyre.warn i { filter: saturate(.7) brightness(.85); }
.meter.tyre.bad i { background: #ff5a5a; animation: blink 1s steps(2) infinite; }
.meter.tyre.warn i { background: #ffb02e; }
.meter.tyre.bad i { background: #ff5a5a; }
#pitinfo { position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%); padding: 8px 16px; border-radius: 10px; background: rgba(10,14,20,.72); color: #fff; font: 700 15px/1.3 system-ui, sans-serif; text-align: center; box-shadow: inset 0 0 0 2px #ffd23f; pointer-events: none; }
#pittyres { display: flex; gap: 6px; justify-content: center; margin-top: 8px; pointer-events: auto; }
#pittyres button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font: 600 13px system-ui, sans-serif; cursor: pointer; }
#pittyres button.on { background: rgba(255,210,63,.25); border-color: #ffd23f; }
#pittyres kbd { font: 600 10px system-ui; opacity: .7; }
.tyredot { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid #f2c230; background: #15181d; color: #fff; font: 800 8px/1 system-ui, sans-serif; font-style: normal; vertical-align: -3px; flex: none; box-sizing: content-box; }
.tyredot.t-soft { border-color: #e8322f; }
.tyredot.t-medium { border-color: #f2c230; }
.tyredot.t-hard { border-color: #e9ecef; }
#tyrename .tyredot { position: relative; left: auto; top: auto; bottom: auto; width: 9px; height: 9px; border-width: 2px; border-radius: 50%; font-size: 6px; margin-right: 4px; vertical-align: -1px; transition: none; letter-spacing: 0; }
.tyrebox { margin-top: 10px; }
.tyrebox h2 { margin-bottom: 6px; }
.tyrepick button { display: inline-flex; align-items: center; gap: 6px; }

#jumpinfo { position: absolute; left: 50%; bottom: 19%; transform: translateX(-50%); padding: 7px 16px; border-radius: 10px; background: rgba(10,14,20,.72); color: #fff; font: 800 16px/1.25 system-ui, sans-serif; text-align: center; letter-spacing: .02em; box-shadow: inset 0 0 0 2px #3ddc84; pointer-events: none; zoom: var(--hud, 1); }
#jumpinfo.slow { box-shadow: inset 0 0 0 2px #ff4d4d; }
#jumpinfo.slow b { color: #ff7a7a; }
#jumpinfo small { display: block; font-weight: 600; font-size: 12px; color: #cbd5e1; letter-spacing: 0; }
#pitinfo small { display: block; font-weight: 500; font-size: 12px; color: #cbd5e1; }
#pitinfo .bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: linear-gradient(90deg, #3ddc84 var(--p, 0%), rgba(255,255,255,.15) var(--p, 0%)); }
#wreck { position: absolute; top: 38%; left: 0; right: 0; text-align: center; font: 600 22px/1.3 system-ui, sans-serif; text-shadow: 0 3px 14px rgba(0,0,0,.8); }
#wreck b { display: block; font-size: 40px; color: var(--bad); text-transform: uppercase; letter-spacing: 2px; }
body.touch #meters { bottom: 235px; width: 120px; }
.tgroup button.small { width: 64px; height: 64px; font: 700 11px system-ui, sans-serif; letter-spacing: .5px; align-self: flex-end; }
.tgroup .boostbtn { background: rgba(255,106,43,.35); }
.carpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.carcard { text-align: left; border: 1px solid var(--line); background: #141a24; border-radius: 10px; padding: 8px 10px; display: grid; gap: 7px; }
.carcard.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.carcard .nm { font-weight: 700; margin-bottom: 2px; }
.carcard .bar { position: relative; display: block; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); margin-left: 44px; }
.carcard .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent2); }
.carcard .bar em { position: absolute; right: calc(100% + 6px); top: -5px; font: normal 10.5px/14px system-ui, sans-serif; color: var(--muted); }
.garage { display: grid; grid-template-columns: 1fr 1.2fr; gap: 10px; margin-top: 10px; align-items: start; }
#carpreview { width: 100%; height: 150px; border-radius: 10px; background: radial-gradient(ellipse at 50% 60%, #263142, #0f141c 75%); }
.garage .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.garage .field { margin-bottom: 6px; }
.garage input[type=color] { height: 32px; padding: 2px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; margin: 0 0 8px; }
.swatches button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); padding: 0; }
.players .carname { float: right; color: var(--muted); font-size: 12.5px; }
@media (max-width: 760px) { .garage { grid-template-columns: 1fr; } }

/* ---------- open world (v6) ---------- */
#mapbtn, #roamprompt, #gatearrow { display: none; }
body.roam #mapbtn { display: block; top: 62px; }
body.roam #roamprompt:not([hidden]) { display: block; }
body.roam #gatearrow:not([hidden]) { display: block; }
#roamprompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 8px 16px; border-radius: 10px; background: rgba(10,14,20,.7); font-size: 15px; text-align: center; white-space: nowrap; }
#roamprompt b { color: var(--accent2); }
#gatearrow { position: absolute; left: 50%; top: 118px; transform: translateX(-50%); width: 0; height: 0; transform-origin: 50% 50%; }
#gatearrow i { position: absolute; left: -16px; top: -18px; border-left: 16px solid transparent; border-right: 16px solid transparent; border-bottom: 34px solid #ffc531; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
#gatedist { position: absolute; left: -40px; top: 20px; width: 80px; text-align: center; font: 700 13px ui-monospace, monospace; text-shadow: 0 1px 3px #000; }
#bigmap { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.6); pointer-events: auto; }
body.roam #laplist, body.roam #ghostlabel, body.roam #position, body.roam #standings, body.roam #racetime { display: none; }
body.roam #p-restart { display: none; }
body.worldsel .pickrow, body.worldsel #ghostnote { display: none; }
.track.world { background: linear-gradient(135deg, #16324a, #1d3b2a); }

/* ---------- party mode (v7) ---------- */
@property --pa { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.partytoggle { display: flex; gap: 12px; align-items: center; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #141a24; cursor: pointer; }
.partytoggle input { position: absolute; opacity: 0; pointer-events: none; }
.partytoggle .sw { flex: none; position: relative; width: 44px; height: 24px; border-radius: 12px; background: #2a3240; transition: background .25s; }
.partytoggle .sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.partytoggle input:checked + .sw { background: linear-gradient(90deg, #ff3d8b, #ffb02e); }
.partytoggle input:checked + .sw::after { transform: translateX(20px); }
.partytoggle input:focus-visible + .sw { outline: 2px solid var(--accent2); outline-offset: 2px; }
.partytoggle input:disabled ~ * { cursor: default; }
.partytoggle b { display: block; }
.partytoggle small { display: block; color: var(--muted); font-size: 12.5px; }
.dice { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 8px; margin: 0 0 12px; }
.dice div { text-align: center; padding: 8px 4px 10px; border-radius: 12px; border: 1px solid rgba(255,176,46,.35); background: linear-gradient(160deg, #241a33, #1a2130); }
.dice em { display: block; font: normal 11px/1.2 system-ui, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.dice b { display: inline-block; margin-top: 2px; font: 900 34px/1 system-ui, sans-serif; background: linear-gradient(90deg, #ff3d8b, #ffb02e, #3ddc84, #39c6ff, #ff3d8b); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: party-shimmer 3s linear infinite, dice-wobble 2.2s ease-in-out infinite; }
.dice div:nth-child(2) b { animation-delay: 0s, .25s; }
.dice div:nth-child(3) b { animation-delay: 0s, .5s; }
@keyframes party-shimmer { to { background-position: 300% 0; } }
@keyframes dice-wobble { 0%, 60%, 100% { transform: none; } 70% { transform: rotate(-14deg) scale(1.15); } 80% { transform: rotate(10deg) scale(1.1); } 90% { transform: rotate(-4deg); } }
.lobby-panel.partying { border: 2px solid transparent; background: linear-gradient(var(--panel), var(--panel)) padding-box, conic-gradient(from var(--pa), #ff3d8b, #ffb02e, #3ddc84, #39c6ff, #9b5de5, #ff3d8b) border-box; animation: party-border 4s linear infinite; }
@keyframes party-border { to { --pa: 360deg; } }
.big.party-btn, .lobby-panel.partying #lb-start { background: linear-gradient(90deg, #ff3d8b, #ff6a2b, #ffb02e, #ff3d8b); background-size: 300% 100%; animation: party-shimmer 4s linear infinite; }
.rs-party { margin: -4px 0 10px; font-weight: 600; color: var(--accent2); }

/* the reveal: three slot-machine reels over the track */
.party { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, rgba(40,16,60,.55), rgba(6,8,12,.88) 70%); animation: party-in .45s ease-out; }
.party.leaving { animation: party-out .55s ease-in forwards; pointer-events: none; }
@keyframes party-in { from { opacity: 0; } }
@keyframes party-out { to { opacity: 0; transform: scale(1.12); } }
.party-rays { position: absolute; left: 50%; top: 45%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax; background: repeating-conic-gradient(rgba(255,176,46,.10) 0 9deg, transparent 9deg 18deg); animation: rays-spin 14s linear infinite; pointer-events: none; }
.party.done .party-rays { animation-duration: 5s; background: repeating-conic-gradient(rgba(255,61,139,.14) 0 9deg, transparent 9deg 18deg); }
@keyframes rays-spin { to { transform: rotate(360deg); } }
.party-glow { position: absolute; left: 50%; top: 45%; width: 70vmin; height: 70vmin; margin: -35vmin 0 0 -35vmin; border-radius: 50%; background: radial-gradient(circle, rgba(255,106,43,.35), transparent 65%); animation: glow-pulse 1.1s ease-in-out infinite alternate; pointer-events: none; }
@keyframes glow-pulse { to { transform: scale(1.25); opacity: .6; } }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.party-stage { position: relative; z-index: 1; width: min(860px, 100%); text-align: center; }
.party-title { margin: 0 0 22px; font: 900 clamp(34px, 8vw, 72px)/1 system-ui, sans-serif; letter-spacing: 2px; text-transform: uppercase; }
.party-title::after { display: none; }
.party-title span { display: inline-block; background: linear-gradient(180deg, #fff3b0, #ffb02e 55%, #ff3d8b); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 rgba(120,20,60,.8)) drop-shadow(0 10px 24px rgba(0,0,0,.6)); animation: letter-drop .6s cubic-bezier(.2, 1.6, .4, 1) backwards, letter-wave 1.6s ease-in-out .8s infinite; }
@keyframes letter-drop { from { transform: translateY(-120px) rotate(-20deg) scale(.4); opacity: 0; } }
@keyframes letter-wave { 0%, 100% { transform: none; } 50% { transform: translateY(-8px); } }
.party-title.ready span { animation: letter-drop .45s cubic-bezier(.2, 1.6, .4, 1) backwards, ready-pulse .5s ease-in-out .5s infinite alternate; }
@keyframes ready-pulse { to { transform: scale(1.12); } }
.reels { display: flex; gap: 14px; justify-content: center; }
.reel { flex: 1; min-width: 0; animation: reel-in .5s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.reel.wide { flex: 1.7; }
.reel:nth-child(2) { animation-delay: .1s; }
.reel:nth-child(3) { animation-delay: .2s; }
@keyframes reel-in { from { transform: translateY(40px) scale(.85); opacity: 0; } }
.reel em { display: block; margin-bottom: 6px; font: 700 12px/1 system-ui, sans-serif; font-style: normal; letter-spacing: 3px; text-transform: uppercase; color: #ffd59a; text-shadow: 0 1px 4px #000; }
.reel .win { position: relative; height: 216px; overflow: hidden; border-radius: 16px; border: 3px solid #ffb02e; background: linear-gradient(180deg, #0b0e14, #1b2232 50%, #0b0e14); box-shadow: 0 0 0 4px rgba(0,0,0,.4), 0 14px 40px rgba(0,0,0,.55), inset 0 0 30px rgba(0,0,0,.8); transition: border-color .3s, box-shadow .3s; }
.reel .win::before, .reel .win::after { content: ""; position: absolute; left: 0; right: 0; height: 72px; z-index: 1; pointer-events: none; }
.reel .win::before { top: 0; background: linear-gradient(180deg, rgba(8,10,16,.95), rgba(8,10,16,.35)); }
.reel .win::after { bottom: 0; background: linear-gradient(0deg, rgba(8,10,16,.95), rgba(8,10,16,.35)); }
.reel .strip { will-change: transform; }
.reel .strip div { height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 10px; font: 800 24px/1.1 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reel .strip div span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.reel .strip small { font: 600 11px/1.2 system-ui, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
#reel-laps .strip div { font: 900 44px/1 ui-monospace, monospace; }
.reel.landed .win { border-color: #3ddc84; box-shadow: 0 0 0 4px rgba(61,220,132,.25), 0 0 40px rgba(61,220,132,.55), inset 0 0 30px rgba(0,0,0,.8); animation: reel-land .5s cubic-bezier(.2, 1.8, .4, 1); }
.reel.landed .strip div.hit { color: #fff; text-shadow: 0 0 18px rgba(255,210,63,.9); animation: hit-pop .6s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes reel-land { 0% { transform: scale(1); } 30% { transform: scale(1.08) translateY(4px); } 100% { transform: none; } }
@keyframes hit-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.18); } 100% { transform: none; } }
.party-sub { min-height: 1.4em; margin: 22px 0 0; font: 700 clamp(18px, 3.4vw, 26px)/1.3 system-ui, sans-serif; text-shadow: 0 2px 10px #000; }
.party-sub b { color: var(--accent2); }
.party-sub.pop { animation: hit-pop .5s cubic-bezier(.2, 1.8, .4, 1); }
.party-drivers { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.party-drivers span { padding: 5px 12px; border-radius: 20px; background: rgba(16,20,28,.75); border: 2px solid; font-size: 14px; font-weight: 600; animation: chip-in .5s cubic-bezier(.2, 1.6, .4, 1) backwards, chip-bob 1.4s ease-in-out infinite alternate; }
@keyframes chip-in { from { transform: scale(0); } }
@keyframes chip-bob { to { transform: translateY(-5px); } }
@media (max-width: 600px) {
  .reels { flex-direction: column; gap: 8px; }
  .reel .win { height: 120px; }
  .reel .win::before, .reel .win::after { height: 24px; }
  .reel em { margin-bottom: 3px; }
  .party-title { margin-bottom: 12px; }
  .party-sub { margin-top: 14px; }
}
@media (max-height: 520px) {
  .reel .win { height: 120px; }
  .reel .win::before, .reel .win::after { height: 24px; }
  .party-title { margin-bottom: 10px; font-size: 36px; }
  .party-sub { margin-top: 10px; }
  .party-drivers { display: none; }
  .dice b { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .party-rays, .party-glow, .dice b, .party-title span, .party-drivers span, .lobby-panel.partying { animation: none; }
}

/* ---------- party modifiers (v8) ---------- */
.partytoggle.sub { margin-top: -4px; padding: 8px 12px; }
.dice { grid-template-columns: 1fr 1.6fr 1fr; }
.dice.mods { grid-template-columns: 1fr 1.5fr .8fr 1.1fr; }
.dice div:nth-child(4) b { animation-delay: 0s, .75s; }
#modbadge { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 20px; font: 700 14px/1.3 system-ui, sans-serif; color: #fff; background: linear-gradient(90deg, rgba(255,61,139,.75), rgba(255,106,43,.75)); box-shadow: 0 2px 10px rgba(0,0,0,.4); text-shadow: 0 1px 2px rgba(0,0,0,.5); }
/* the modifier card: pops in, shuffles, flips over */
.modcard { width: min(440px, 100%); height: 86px; margin: 18px auto 0; perspective: 900px; animation: mc-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes mc-pop { from { transform: scale(0) rotate(-12deg); opacity: 0; } }
.mc-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); }
.modcard.flip .mc-in { transform: rotateY(180deg); }
.mc-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 0 18px; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 3px solid #ffb02e; box-shadow: 0 14px 40px rgba(0,0,0,.55), inset 0 0 24px rgba(0,0,0,.6); }
.mc-back { background: repeating-linear-gradient(45deg, #2a1640 0 14px, #331a4d 14px 28px); }
.mc-back b { font: 900 46px/1 system-ui, sans-serif; filter: drop-shadow(0 3px 6px rgba(0,0,0,.6)); }
.mc-back span { font: 700 12px/1 system-ui, sans-serif; letter-spacing: 3px; text-transform: uppercase; color: #ffd59a; }
.modcard.shuffling .mc-back b { animation: mc-jiggle .12s linear infinite; }
@keyframes mc-jiggle { 50% { transform: scale(1.15) rotate(6deg); } }
.mc-front { transform: rotateY(180deg); justify-content: flex-start; text-align: left; background: linear-gradient(120deg, #3a1230, #2b1a10); border-color: #ff3d8b; }
.modcard.flip .mc-front { box-shadow: 0 0 0 4px rgba(255,61,139,.25), 0 0 46px rgba(255,61,139,.55), inset 0 0 24px rgba(0,0,0,.6); }
.mc-front b { font: 900 48px/1 system-ui, sans-serif; }
.mc-front em { display: block; font: 900 26px/1.1 system-ui, sans-serif; font-style: normal; background: linear-gradient(90deg, #fff3b0, #ffb02e, #ff3d8b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mc-front small { display: block; margin-top: 3px; font: 600 14px/1.3 system-ui, sans-serif; color: #e8d9e6; }
@media (max-width: 600px) { .modcard { height: 72px; margin-top: 10px; } .mc-front b, .mc-back b { font-size: 36px; } .mc-front em { font-size: 20px; } .mc-front small { font-size: 12.5px; } }
@media (max-height: 520px) { .modcard { height: 64px; margin-top: 8px; } .mc-front b, .mc-back b { font-size: 32px; } .mc-front em { font-size: 19px; } }
@media (prefers-reduced-motion: reduce) { .modcard.shuffling .mc-back b { animation: none; } }

/* ---------- replays, spectating, mirror (v9) ---------- */
#viewbar { position: fixed; left: 0; right: 0; bottom: 0; top: 0; pointer-events: none; z-index: 5; font-variant-numeric: tabular-nums; }
#viewbar button, #viewbar input { pointer-events: auto; }
.vb-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 6px 12px; border-radius: 12px; background: rgba(10,14,20,.6); white-space: nowrap; max-width: calc(100% - 24px); }
.vb-badge { font: 800 12px/1 system-ui, sans-serif; letter-spacing: 2px; padding: 5px 8px; border-radius: 6px; background: #ff3d5a; color: #fff; }
.vb-badge.live { background: #2fb85a; animation: blink 1.6s steps(2) infinite; }
.vb-driver { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.vb-driver b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.vb-driver button, .vb-btn { border: 1px solid rgba(255,255,255,.2); background: rgba(26,33,48,.85); border-radius: 9px; padding: 6px 10px; font-weight: 700; }
.vb-driver button { padding: 3px 9px; }
.vb-info { color: #dfe6ee; font-size: 14px; }
.vb-bar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 8px 10px; border-radius: 14px; background: rgba(10,14,20,.72); width: min(980px, calc(100% - 24px)); }
.vb-bar .seg button { padding: 6px 10px; font-size: 13px; pointer-events: auto; }
#vb-scrubwrap { position: relative; flex: 1 1 220px; min-width: 160px; height: 26px; display: flex; align-items: center; }
#vb-scrub { width: 100%; accent-color: #ff3d5a; margin: 0; }
#vb-marks { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
#vb-marks i { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: rgba(255,210,63,.75); border-radius: 1px; }
.vb-time { font: 600 13px ui-monospace, monospace; color: #dfe6ee; min-width: 120px; text-align: center; }
#vb-share { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px; border-radius: 12px; background: rgba(10,14,20,.85); width: min(520px, calc(100% - 24px)); }
#vb-link { flex: 1; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: #0f141c; color: var(--text); font: 13px ui-monospace, monospace; pointer-events: auto; }
.vb-note { position: absolute; left: 50%; bottom: 82px; transform: translateX(-50%); margin: 0; font-size: 13px; color: #ffd59a; text-shadow: 0 1px 4px #000; text-align: center; width: calc(100% - 24px); }
#viewbar.live .rp-only { display: none; }
body.viewing #hud > *:not(#standings) { display: none; }
body.viewing #touch { display: none !important; }
@media (max-width: 640px) {
  .vb-bar { gap: 6px; padding: 6px; bottom: 8px; }
  .vb-bar .seg button { padding: 5px 7px; font-size: 12px; }
  .vb-time { min-width: 0; font-size: 12px; }
  .vb-top { top: 8px; gap: 8px; padding: 5px 8px; }
  .vb-info { display: none; }
  #vb-share { bottom: 132px; }
  .vb-note { bottom: 118px; }
}
/* look behind (touch) */
.tgroup .lookbtn { background: rgba(57,198,255,.3); font-size: 22px; }
/* the mirror sits at the top: the timer moves down out of its way */
body.mirror #timebox { top: calc(14px + var(--mirror-h, 0px)); }
/* leaderboard: watch a lap */
.board .watch { width: 1%; text-align: right; }
.board .watch button { border: 1px solid var(--line); background: #1a2130; border-radius: 7px; padding: 2px 8px; font-size: 12px; }
.board .watch button:hover { border-color: var(--accent); }
.players .watching { float: right; color: #39c6ff; font-size: 12.5px; }
#rs-body small.pen { color: #ff6b6b; margin-left: 6px; font-weight: 700; }
#rs-body small.stops { display: block; color: #94a3b8; font-size: 11px; }

/* ---------- start menu (2026-10-28 redesign) ----------
   the selected track's picture behind everything; a header with the logo and the account; a menu
   on the left (Race, Leaderboard, Garage, Multiplayer, Settings); the Race view: tracks with their
   pictures | the chosen track big, Start and the race options | the cars as cards. The other views
   use the space of the middle (and the tracks or the cars where they're needed). Phones: the menu
   becomes tabs and the parts stack. */
.menubg { position: fixed; inset: -20px; background: #0b0e14 center / cover no-repeat; filter: blur(5px) saturate(1.1); }
.menubg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, rgba(8,10,16,.35), rgba(8,10,16,.88) 70%), linear-gradient(180deg, rgba(8,10,16,.25), rgba(8,10,16,.8)); }
#menu { padding: 0; place-items: stretch; background: none; overflow: hidden; }
.menu-panel.dash {
  position: relative; width: 100%; height: 100vh; max-height: none; overflow: hidden; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; padding: 0 22px 18px 0;
  display: grid; grid-template-columns: 196px minmax(250px, 320px) minmax(0, 1fr) minmax(300px, 400px); grid-template-rows: auto minmax(0, 1fr); gap: 14px 18px;
  grid-template-areas: "head head head head" "nav tracks main side";
}
.dash[data-view="board"], .dash[data-view="mp"] { grid-template-areas: "head head head head" "nav tracks main main"; }
.dash[data-view="board"] .col-side, .dash[data-view="mp"] .col-side { display: none; }
.dash[data-view="garage"] { grid-template-areas: "head head head head" "nav main main side"; }
.dash[data-view="garage"] .col-tracks { display: none; }
.dash h2 { margin: 0 0 10px; }
.card2 { background: rgba(14,18,26,.9); border: 1px solid rgba(255,255,255,.07); border-radius: 16px; padding: 16px 18px; }

/* the header: logo, tagline, buttons and the account */
.dash .menu-head { grid-area: head; align-items: center; padding: 16px 0 0 22px; gap: 24px; flex-wrap: nowrap; }
.dash .brand { display: flex; align-items: center; gap: 36px; min-width: 0; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo .mark { width: 52px; height: 44px; flex-shrink: 0; transform: skewX(-14deg); border-radius: 6px;
  background: conic-gradient(from 0deg at 50% 50%, #ff3d2e 0 25%, #ff8a2a 0 50%, #ff3d2e 0 75%, #ff8a2a 0) 0 0 / 22px 22px; box-shadow: 0 6px 22px rgba(255,80,40,.35); }
.dash .brand h1 { font: italic 800 38px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.5px; }
.dash .brand h1 em { color: var(--accent); font-style: italic; }
.dash .brand h1::after { display: none; }
.tagline { margin: 4px 0 0; font-style: italic; color: #c6cfdb; font-size: 14px; }
.dash .brand .lead { margin: 0; max-width: 420px; font-size: 15px; font-style: italic; color: #d2d9e3; position: relative; padding-bottom: 10px; }
.dash .brand .lead::after { content: ""; position: absolute; left: 0; bottom: 0; width: 40px; height: 3px; border-radius: 2px; background: var(--accent); }
.dash .headbtns { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dash .headbtns .iconbtn { width: 48px; height: 48px; border-radius: 12px; background: rgba(14,18,26,.9); border: 1px solid rgba(255,255,255,.08); font-size: 19px; }
.dash .account { display: flex; align-items: center; gap: 10px; text-align: left; min-height: 48px; padding: 6px 14px 6px 8px; border-radius: 12px; background: rgba(14,18,26,.9); border: 1px solid rgba(255,255,255,.08); font-size: 13px; position: relative; }
.account .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #252d3b; color: #c6cfdb; font-weight: 700; flex-shrink: 0; }
.account .who b { display: block; font-size: 14px; }
.account .who small { color: var(--muted); }
.account details summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.account details summary::-webkit-details-marker { display: none; }
.account details summary::after { content: "⌄"; color: var(--muted); margin-left: 6px; font-size: 16px; }
.account details .drop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; min-width: 180px; padding: 6px; border-radius: 12px; background: #141a24; border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.5); display: grid; }
.account .drop a, .account .drop button { text-align: left; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; font-size: 14px; }
.account .drop a:hover, .account .drop button:hover { background: #1f2735; }
.account .loginbtn { padding: 8px 14px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; }

/* the menu on the left */
.mnav { grid-area: nav; display: flex; flex-direction: column; gap: 6px; padding: 8px 0 0; min-height: 0; }
.mnav > button { display: flex; align-items: center; gap: 14px; padding: 13px 18px 13px 22px; border: 0; background: none; color: #c6cfdb; font-size: 15px; font-weight: 600; text-align: left; border-radius: 0 14px 14px 0; position: relative; }
.mnav > button svg { width: 24px; height: 24px; flex-shrink: 0; }
.mnav > button:hover { background: rgba(255,255,255,.05); color: var(--text); }
.mnav > button.on { color: var(--accent); background: linear-gradient(90deg, rgba(255,106,43,.22), rgba(255,106,43,.06)); }
.mnav > button.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--accent); }
.navfoot { margin-top: auto; padding: 12px 10px 4px 22px; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.navacct { display: flex; align-items: center; gap: 10px; }
.navacct .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #252d3b; color: #c6cfdb; font-weight: 700; flex-shrink: 0; }
.navacct small { display: block; color: var(--muted); }
.navacct b { color: var(--text); font-weight: 600; }
.navacct a { color: var(--text); text-decoration: none; }
.navfps { color: var(--good); font-size: 12px; font-weight: 700; padding-left: 44px; }

.dcol { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2a3240 transparent; }
.col-tracks { grid-area: tracks; display: flex; flex-direction: column; gap: 10px; overflow: hidden; background: rgba(14,18,26,.9); border: 1px solid rgba(255,255,255,.07); border-radius: 16px; padding: 16px 14px 12px; }
.col-main { grid-area: main; display: flex; flex-direction: column; gap: 14px; padding-right: 2px; }
.col-side { grid-area: side; display: flex; flex-direction: column; gap: 14px; }
.col-main > *, .col-side > * { flex-shrink: 0; }

/* tracks: a picture of each, the name and length */
.colhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.colhead h2 { margin: 0; font-size: 19px; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 700; }
.colhead .count { color: var(--muted); font-weight: 600; font-size: 14px; margin-left: 6px; }
.findbox { display: block; position: relative; }
.findbox::after { content: ""; position: absolute; right: 12px; top: 50%; width: 12px; height: 12px; margin-top: -8px; border: 2px solid var(--muted); border-radius: 50%; pointer-events: none; }
#trackfind { width: 100%; padding: 10px 34px 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1); background: rgba(8,11,16,.7); color: var(--text); font: inherit; font-size: 14px; }
.dash .tracks { flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 8px; align-content: start; padding: 2px 4px 2px 2px; max-height: none; }
.dash .track { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; grid-template-rows: auto auto auto; gap: 1px 12px; align-items: center; padding: 7px 10px 7px 7px; border-radius: 12px; border: 1px solid rgba(255,255,255,.07); background: rgba(22,28,38,.75); }
.dash .track:hover { border-color: #3b4658; background: rgba(30,37,50,.85); }
.dash .track.sel { border: 2px solid var(--accent); padding: 6px 9px 6px 6px; background: linear-gradient(90deg, rgba(255,106,43,.18), rgba(22,28,38,.75)); }
.dash .track .th { grid-row: 1 / span 3; width: 92px; height: 56px; border-radius: 8px; background: #1b222e center / cover no-repeat; position: relative; overflow: hidden; }
.dash .track .th canvas { width: 100%; height: 100%; display: block; }
.dash .track .th .flag { position: absolute; left: 4px; bottom: 4px; width: 18px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.dash .track .nm { grid-column: 2; font-weight: 700; font-size: 14.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.dash .track .len { grid-column: 2; grid-row: 2; text-align: left; font-size: 12.5px; color: var(--muted); }
.dash .track .tm { grid-column: 2; grid-row: 3; font-size: 11.5px; margin: 0; color: #aeb8c6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash .track .tm span { color: var(--muted); }
.dash .track .bl { display: none; }
.dash .track .chev { grid-column: 3; grid-row: 1 / span 3; color: var(--muted); font-size: 22px; }
.dash .track.sel .chev { color: var(--accent); }
.dash .track[hidden] { display: none; }
.buildlink { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,106,43,.45); background: rgba(255,106,43,.08); color: var(--accent2); font-weight: 600; font-size: 14px; text-decoration: none; }
.buildlink span { font-size: 22px; line-height: 1; color: var(--accent); }
.buildlink i { margin-left: auto; font-style: normal; font-size: 20px; color: var(--muted); }

/* the chosen track: its picture, flag, name and tags, the outline, then your best / car / rank */
.hero { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); background: #10151d; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.hero .himg { position: relative; height: clamp(200px, 46cqw, 440px); background: #1b222e center / cover no-repeat; }
.hero .himg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,13,19,0) 35%, rgba(10,13,19,.88)); }
.hero .htext { position: absolute; left: 24px; right: 220px; bottom: 18px; z-index: 1; }
.hero .hcountry { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #e8edf3; margin-bottom: 4px; }
.hero .hcountry .flag { width: 27px; height: 18px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.hero .hname { margin: 0; font-size: 44px; font-weight: 800; line-height: 1.05; letter-spacing: -.6px; text-shadow: 0 2px 18px rgba(0,0,0,.5); }
.hero .htags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hero .htags span { font-size: 13px; padding: 5px 12px; border-radius: 999px; background: rgba(10,13,19,.6); border: 1px solid rgba(255,255,255,.18); color: #e8edf3; }
.hero .htags .pit { background: rgba(242,194,48,.18); color: #f2c230; border-color: rgba(242,194,48,.4); }
.hero canvas#heromap { position: absolute; right: 18px; bottom: 16px; z-index: 1; width: 200px; height: 160px; }
.hero .hstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 8px; }
.hero .hstats > div { padding: 2px 18px; border-left: 1px solid rgba(255,255,255,.09); min-width: 0; }
.hero .hstats > div:first-child { border-left: 0; }
.hero .hstats small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 4px; }
.hero .hstats b.time { font: 700 30px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.5px; }
.hero .hstats .sub { color: var(--muted); font-size: 12.5px; }
.hero .hstats .carcell { display: flex; align-items: center; gap: 10px; }
.hero .hstats .carcell img { width: 74px; height: 42px; object-fit: contain; }
.hero .hstats .carcell b { font-size: 16px; }
.hero .hstats button.rank { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; border: 0; background: none; text-align: left; font-size: 24px; font-weight: 800; }
.hero .hstats button.rank i { margin-left: auto; font-style: normal; color: var(--muted); font-size: 22px; }
.hero .hstats button.rank:hover i { color: var(--text); }
.drivebar { display: flex; }
.drivebar #play { flex: 1; padding: 20px 22px; font-size: 21px; font-weight: 800; letter-spacing: .3px; border-radius: 16px; border: 0; color: #fff; background: linear-gradient(90deg, #ff6a2b, #ff3d5a); box-shadow: 0 14px 36px rgba(255,70,60,.35); }
.drivebar #play:hover { filter: brightness(1.08); }

/* race options as cards */
.optcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; }
.optcard { background: rgba(14,18,26,.9); border: 1px solid rgba(255,255,255,.07); border-radius: 16px; padding: 14px 12px 14px; }
.optcard h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 700; margin-bottom: 12px; }
.oi { font-size: 16px; filter: grayscale(.2); }
.optcard .seg { display: flex; gap: 8px; border: 0; background: none; }
#lappick { display: grid; grid-template-columns: repeat(3, 1fr) 1.5fr; }
.optcard .seg button { flex: 1; min-width: 0; padding: 10px 4px; font-size: 13.5px; white-space: nowrap; letter-spacing: -.1px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); font-weight: 700; display: grid; place-items: center; line-height: 1.1; }
.optcard .seg button small { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.optcard .seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.optcard .seg button.on small { color: #fff; }
.mirrortoggle { display: flex; align-items: center; gap: 12px; }
.mirrortoggle .sw { width: 58px; height: 32px; border-radius: 999px; border: 0; padding: 3px; background: #2a3240; position: relative; flex-shrink: 0; }
.mirrortoggle .sw i { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #e8edf3; transition: left .15s; }
.mirrortoggle .sw.on { background: var(--accent); }
.mirrortoggle .sw.on i { left: 29px; }
.setup { display: flex; flex-direction: column; gap: 14px; }
.setup #ghostnote { margin: -4px 4px 0; }
.dash details.keys { margin: 0 4px; }
.dash details.keys summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.dash details.keys p { margin: 8px 0 0; }

/* the cars as cards with a picture of each in your paint */
.carbox { container-type: inline-size; }
.carbox h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 700; }
.carcards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.carcards button { position: relative; display: block; text-align: left; padding: 10px 12px; height: 86px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08); background: linear-gradient(160deg, rgba(34,42,56,.9), rgba(18,23,32,.9)); overflow: hidden; }
.carcards button:hover { border-color: #3b4658; }
.carcards button b { position: relative; z-index: 1; font-size: 13.5px; font-weight: 700; display: block; max-width: 70%; line-height: 1.2; }
.carcards button img { position: absolute; right: 4px; bottom: 2px; width: 62%; height: 58%; object-fit: contain; object-position: right bottom; }
.carcards button.sel { border: 2px solid var(--accent); padding: 9px 11px; background: linear-gradient(160deg, rgba(255,106,43,.22), rgba(18,23,32,.9)); }
.carcards button.customchip { border-color: rgba(242,194,48,.45); }
.carcards button.customchip.sel { border-color: #f2c230; background: linear-gradient(160deg, rgba(242,194,48,.2), rgba(18,23,32,.9)); }
.carcards button.customchip b::before { content: "★ "; color: #f2c230; }
.carstats { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; align-items: center; margin-top: 14px; font-size: 12.5px; }
.carstats em { font-style: normal; color: var(--muted); }
.carstats .b { height: 7px; border-radius: 4px; background: rgba(255,255,255,.08); position: relative; overflow: hidden; }
.carstats .b i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.carstats .v { color: #c6cfdb; font-variant-numeric: tabular-nums; text-align: right; }
.garagebtn { display: flex; align-items: center; width: 100%; margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); font-weight: 600; }
.garagebtn i { margin-left: auto; font-style: normal; font-size: 20px; color: var(--muted); }

/* narrow columns: one car per row; smaller track pictures */
@container (max-width: 300px) {
  .carcards { grid-template-columns: 1fr; gap: 6px; }
  .carcards button { height: 52px; display: flex; align-items: center; }
  .carcards button b { max-width: 55%; }
  .carcards button img { width: 45%; height: 90%; bottom: 3%; }
}
.col-tracks { container-type: inline-size; }
@container (max-width: 250px) {
  .dash .track { grid-template-columns: 62px minmax(0, 1fr) auto; gap: 1px 9px; }
  .dash .track .th { width: 62px; height: 42px; }
  .dash .track .nm { font-size: 13.5px; }
}

/* the other views */
.boardpane, .mppane { flex: 1; }
.boardpane h2#boardtitle { font-size: 18px; color: var(--text); text-transform: none; letter-spacing: 0; }
.garagepane { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-content: start; }
.garagepane h2 { font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
.garagepane .garagecar { grid-row: span 2; }
.garagepane #carpreview { width: 100%; height: 240px; display: block; border-radius: 12px; background: radial-gradient(ellipse at 50% 60%, #263142, #0f141c 75%); }
.garagepane .garage { display: block; margin: 0; }
.garagepane .garage .grid2 { grid-template-columns: 1fr 1fr; }
.garagepane #customed, .garagepane #customhint { grid-column: 1 / -1; }
.garagepane .tyrebox h2 { margin: 0 0 10px; }
.mppane .mp { padding: 0; background: none; border: 0; }

/* the hero and the race options fit themselves to the space they get */
.hero, .optcard { container-type: inline-size; }
@container (max-width: 660px) {
  .hero .hname { font-size: 32px; }
  .hero .htext { right: 18px; }
  .hero canvas#heromap { top: 12px; right: 12px; bottom: auto; width: 130px; height: 104px; }
  .hero .hstats b.time { font-size: 22px; }
  .hero .hstats > div { padding: 2px 12px; }
}
@container (max-width: 480px) {
  .hero .hname { font-size: 26px; }
  .hero .htags span { font-size: 12px; padding: 4px 10px; }
  .hero .hstats { grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .hero .hstats > div:last-child { grid-column: 1 / -1; border-left: 0; border-top: 1px solid rgba(255,255,255,.09); padding-top: 10px; }
  .hero .hstats .carcell img { display: none; }
}
@container (max-width: 250px) {
  #lappick button small { display: none; }
  .optcard .seg button { font-size: 13px; padding: 9px 4px; }
}
/* medium screens: the menu as icons, narrower columns */
@media (max-width: 1500px) {
  .menu-panel.dash { grid-template-columns: 64px minmax(230px, 290px) minmax(0, 1fr) minmax(270px, 360px); gap: 12px 14px; padding-right: 16px; }
  .mnav > button { padding: 13px 0; justify-content: center; border-radius: 0 12px 12px 0; }
  .mnav > button span, .navfoot { display: none; }
  .dash .brand .lead { display: none; }
}
@media (max-width: 1250px) {
  .menu-panel.dash { grid-template-columns: 64px minmax(200px, 240px) minmax(0, 1fr) minmax(230px, 270px); }
}
@media (max-height: 820px) and (min-width: 901px) {
  .dash .menu-head { padding-top: 10px; }
  .logo .mark { width: 40px; height: 34px; }
  .dash .brand h1 { font-size: 30px; }
  .hero .himg { height: clamp(180px, 38cqw, 360px); }
  .hero .hname { font-size: 32px; }
  .drivebar #play { padding: 14px 20px; font-size: 18px; }
}

/* phones and narrow windows: the menu as tabs, the parts one under the other, Start at hand */
@media (max-width: 900px) {
  #menu { overflow-x: hidden; overflow-y: auto; }
  .menu-panel.dash { display: flex; flex-direction: column; height: auto; min-height: 100%; padding: 0 12px 0; overflow: visible; gap: 12px; }
  .dash .menu-head { padding: 12px 0 0; gap: 10px; flex-wrap: wrap; }
  .logo .mark { width: 34px; height: 30px; }
  .dash .brand h1 { font-size: 26px; }
  .tagline, .dash .brand .lead { display: none; }
  .dash .headbtns .iconbtn { width: 40px; height: 40px; }
  .dash .account { min-height: 40px; }
  .account .who small { display: none; }
  .mnav { position: sticky; top: 0; z-index: 3; flex-direction: row; margin: 0 -12px; padding: 8px 8px; gap: 4px; background: rgba(10,13,19,.96); border-bottom: 1px solid var(--line); overflow-x: auto; }
  .mnav > button { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; border-radius: 10px; font-size: 11px; white-space: nowrap; justify-content: center; min-width: 0; }
  .mnav > button span { display: inline !important; }
  .mnav > button svg { width: 20px; height: 20px; }
  .mnav > button.on::before, .navfoot, .mnav .navset { display: none; }
  .dcol { overflow: visible; min-height: auto; }
  .menu-panel.dash > * { flex-shrink: 0; }
  #menu { display: block; }
  .col-tracks { order: 4; }
  .col-tracks .tracks { max-height: 60vh; }
  .col-main { order: 2; }
  .col-side { order: 3; }
  .hero .himg { height: max(170px, 56cqw); }
  .hero .htext { left: 14px; right: 14px; bottom: 12px; }
  .hero .hname { font-size: 26px; }
  .hero canvas#heromap { width: 96px; height: 78px; top: 10px; right: 10px; bottom: auto; }
  .hero .hstats { padding: 10px 2px; }
  .hero .hstats > div { padding: 2px 10px; }
  .hero .hstats b.time { font-size: 18px; }
  .hero .hstats .carcell img { display: none; }
  .hero .hstats button.rank { font-size: 18px; }
  .optcards { grid-template-columns: 1fr; }
  .drivebar { position: sticky; bottom: 0; z-index: 3; margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(10,13,19,0), rgba(10,13,19,.96) 30%); order: 99; }
  .setup .drivebar { order: 0; }
  .garagepane { grid-template-columns: 1fr; }
  .garagepane .garagecar { grid-row: auto; }
  .dash[data-view="board"] .col-tracks, .dash[data-view="mp"] .col-tracks { display: none; }
  .dash[data-view="garage"] .col-side { order: 1; }
}
/* ---- tyres next to names (overrides the round colour dots) ---- */
#standings .tyredot, .players .tyredot { width: 10px; height: 10px; border-width: 2px; font-size: 6.5px; margin: 0 0 0 5px; border-radius: 50%; vertical-align: -1px; }
#standings .tyredot.t-soft, .players .tyredot.t-soft { border-color: #e8322f; }
#standings .tyredot.t-medium, .players .tyredot.t-medium { border-color: #f2c230; }
#standings .tyredot.t-hard, .players .tyredot.t-hard { border-color: #e9ecef; }
.board .tyredot { width: 11px; height: 11px; border-width: 2px; font-size: 7px; vertical-align: -2px; margin-left: 3px; }
#standings .dnf { opacity: .55; }
#standings .stdnf, #standings .stpit, #standings .stpen { font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; margin-left: 5px; }
#standings .stdnf { background: #1b1d22; color: #fff; box-shadow: inset 0 0 0 1px #fff4; }
#standings .stpit { background: #f2c230; color: #111; }
#standings .stpen { background: #ff5a5a; color: #fff; }
#standings .sthp { display: inline-block; width: 34px; height: 5px; margin-left: 6px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; vertical-align: 1px; }
#standings .sthp i { display: block; width: 100%; height: 100%; margin: 0; border-radius: 0; background: #3ddc84; }
.lbtyres { margin-top: 14px; }
#results .lbtyres { margin: 12px 0 4px; }
.cdtyres { position: absolute; top: calc(34% + 150px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: rgba(10, 14, 20, .72); border-radius: 12px; padding: 8px 12px; pointer-events: auto; z-index: 5; max-width: calc(100vw - 24px); }
.cdtyres > span { font-weight: 700; font-size: 14px; }
.cdtyres small { color: var(--muted); font-size: 12px; }
.lbtyres h2 { margin-bottom: 6px; }

/* ---- race control ---- */
#rcbar { position: absolute; top: 116px; left: 50%; transform: translateX(-50%); min-width: 260px; padding: 8px 18px; border-radius: 10px; text-align: center; color: #111; background: #ffd23f; box-shadow: 0 6px 24px rgba(0,0,0,.4); pointer-events: none; }
#rcbar b { display: block; font: 900 18px/1.1 system-ui, sans-serif; letter-spacing: 2px; }
#rcbar small { display: block; font: 600 12.5px/1.3 system-ui, sans-serif; margin-top: 2px; }
#rcbar.vsc { background: repeating-linear-gradient(135deg, #ffd23f 0 14px, #1b1d22 14px 28px); color: #fff; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
#rcbar.sc { background: #ffd23f; }
#rcbar.yellow { background: #ffd23f; animation: blink 1s steps(2) infinite; }
#rcbar.red { background: #e8322f; color: #fff; }
#rcbar.blue { background: #2f7fe0; color: #fff; }
#rcbar.warn { background: #ff9a1a; color: #111; }
#rcbar.black { background: #111; color: #fff; box-shadow: inset 0 0 0 2px #fff, 0 6px 24px rgba(0,0,0,.4); }
#rcfeed { position: absolute; right: 14px; top: 64px; width: 300px; display: grid; gap: 6px; pointer-events: none; }
#rcfeed .rcm { padding: 6px 10px; border-radius: 8px; background: rgba(10,14,20,.78); font: 500 12.5px/1.35 system-ui, sans-serif; box-shadow: inset 3px 0 0 #ffd23f; }
#rcfeed .rcm b { display: block; font-size: 9.5px; letter-spacing: 1.5px; color: #ffd23f; }
#rcfeed .rcm.order { box-shadow: inset 3px 0 0 #ff6a2b; }
#rcfeed .rcm.you { box-shadow: inset 3px 0 0 #39c6ff; background: rgba(20,40,60,.85); }
#lights { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; padding: 12px 16px; border-radius: 12px; background: #111c; }
#lights i { width: 34px; height: 34px; border-radius: 50%; background: #3a1010; box-shadow: inset 0 0 0 3px #000; }
#lights i.on { background: radial-gradient(circle at 40% 35%, #ff9a8a, #e8322f 55%, #8a1010); box-shadow: 0 0 18px #ff3b2f; }
.rcbox { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.rcbox summary { cursor: pointer; font-weight: 700; }
.rcbox .check, .rcbox .field { margin-top: 6px; }
.mmrc { margin: 12px 0; }
.mmrc h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: #c3cbd6; }
.mmrc .row { display: flex; flex-wrap: wrap; gap: 6px; }
.mmrc button { flex: 1 1 45%; padding: 9px 8px; border-radius: 10px; border: 1px solid var(--line); background: #141a24; color: #e8edf3; font-weight: 600; cursor: pointer; }
.mmrc button:hover:not(:disabled) { background: #1d2532; }
.mmrc button:disabled { opacity: .35; }

/* ---- results: DNFs and the tournament ---- */
#rs-body tr.dnf { opacity: .7; }
#rs-body .why { display: block; font-size: 11px; color: #c3cbd6; font-weight: 500; }
.tourtable { margin-top: 12px; }
.tourtable .champ { margin: 0 0 8px; font-size: 18px; text-align: center; color: #ffd23f; }

/* ---- arcade combat ---- */
#combat { position: absolute; right: 22px; bottom: 196px; width: 150px; display: grid; gap: 8px; }
.meter.hp { height: 18px; border-radius: 9px; }
.meter.hp i { background: linear-gradient(90deg, #2fb85a, #3ddc84); border-radius: 9px; }
.meter.hp.warn i { background: #ffb02e; }
.meter.hp.bad i { background: #ff5a5a; }
.meter.hp span { line-height: 18px; font-size: 11px; }
#weap { display: flex; gap: 6px; justify-content: flex-end; }
#weap button { position: relative; width: 46px; height: 46px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(10,14,20,.65); color: #fff; padding: 0; cursor: pointer; overflow: hidden; touch-action: none; }
#weap button b { display: block; font-size: 20px; line-height: 34px; }
#weap button small { position: absolute; left: 0; right: 0; bottom: 2px; font: 700 9px system-ui; opacity: .7; }
#weap #w-gun::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--cd, 1) * 100%); background: #ffd23f; }
#weap #w-shield.cool { opacity: .55; }
#weap #w-shield.up { box-shadow: 0 0 0 2px #5fd0ff, 0 0 14px #5fd0ff; }
#weap #w-shield i { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 800 16px system-ui; font-style: normal; color: #fff; text-shadow: 0 0 6px #000; }
#weap #w-item.has { box-shadow: 0 0 0 2px #39c6ff, 0 0 14px rgba(57,198,255,.6); }
#weap.off button { filter: grayscale(1); opacity: .45; }
body.touch #combat { bottom: 232px; }
@media (max-width: 600px) {
  #rcfeed { width: 220px; top: 56px; }
  #rcbar { top: 96px; min-width: 200px; }
  #rcbar b { font-size: 15px; }
}
.tourtable th:nth-child(2), .tourtable td:nth-child(2) { text-align: left; }
.rcbox.off { opacity: .45; }
.partytoggle.norules { margin-top: 10px; }
#mm-end { background: rgba(255,90,90,.14); border-color: rgba(255,90,90,.5); color: #ffc2c2; }
#mm-end:hover { background: rgba(255,90,90,.24); }

/* ---- sound settings ---- */
#soundpanel { z-index: 60; }
.soundpanel { width: min(420px, 100%); }
.soundpanel h2 { margin-top: 0; }
label.vol { display: grid; grid-template-columns: 100px 1fr 48px; gap: 10px; align-items: center; margin: 10px 0; font-weight: 600; }
label.vol input { width: 100%; accent-color: var(--accent); }
label.vol output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.headbtns { display: flex; gap: 10px; align-items: flex-start; }
.iconbtn.soundbtn { position: static; flex: none; font-size: 18px; width: 40px; height: 40px; }

/* ---- menu motion: panels come in, buttons respond, picks pop ---- */
@keyframes panel-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.overlay:not([hidden]) > .panel { animation: panel-in .32s cubic-bezier(.2, .8, .3, 1); }
.big, .seg button, .carchips button, .track, .iconbtn { transition: transform .12s ease, border-color .15s, box-shadow .15s, filter .15s, background-color .15s; }
.big:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.big:active:not(:disabled), .seg button:active, .carchips button:active, .iconbtn:active { transform: translateY(1px) scale(.97); }
.track:hover { transform: translateX(3px); }
.track.sel { animation: pick-pop .3s ease; }
@keyframes pick-pop { 40% { transform: scale(1.025); } }
.carchips button.sel, .seg button.on { animation: pick-pop .25s ease; }
#play { position: relative; overflow: hidden; }
#play::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.28), transparent); animation: shine 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 55% { left: -60%; } 85%, 100% { left: 130%; } }
#countdown.pop { animation: count-pop .55s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes count-pop { from { transform: scale(1.9); opacity: 0; } 60% { opacity: 1; } }
#laptoast.show { animation: toast-in .3s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes toast-in { from { transform: translateY(-10px) scale(.96); opacity: 0; } }
#rcfeed .rcm { animation: feed-in .3s ease-out; }
@keyframes feed-in { from { transform: translateX(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .overlay:not([hidden]) > .panel, .track.sel, .carchips button.sel, .seg button.on, #countdown.pop, #laptoast.show, #rcfeed .rcm { animation: none; }
  #play::after { display: none; }
  .big:hover:not(:disabled), .track:hover { transform: none; }
}
.soundpanel a { color: var(--accent2); }

/* ---- settings (the ⚙ panel, laid out like Box Arena's) ---- */
#settings { z-index: 60; background: rgba(6, 8, 12, 0.82); backdrop-filter: blur(3px); }
#settings .settings-card { width: min(760px, 100%); max-height: calc(100vh - 32px); padding: 0; display: flex; flex-direction: column; overflow: hidden; user-select: none; }
.set-head { padding: 20px 26px 0; border-bottom: 1px solid var(--line); }
.set-head h2 { margin: 0 0 12px; }
.set-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.set-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 9px 14px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.set-tabs button:hover { color: var(--text); }
.set-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.set-body { overflow-y: auto; padding: 6px 26px 12px; flex: 1; }
.set-body .set-h { margin: 18px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.set-body .note { margin: 14px 0 8px; font-size: 12.5px; color: var(--muted); }
.set-body a { color: var(--accent2); }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: center; padding: 13px 0; border-bottom: 1px solid #1e2632; }
.srow.tog { grid-template-columns: minmax(0, 1fr) auto; }
.srow label { cursor: pointer; }
.srow label b { display: block; font-size: 14.5px; font-weight: 600; }
.srow label small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.sctl { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sctl input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.sctl .setting-val { min-width: 62px; text-align: right; font: 700 13px ui-monospace, monospace; }
.sctl select { width: 100%; padding: 8px 10px; font-size: 14px; border-radius: 8px; border: 1px solid var(--line); background: #0c0f14; color: var(--text); }
input.switch { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: #2a3240; position: relative; cursor: pointer; margin: 0; transition: background .15s; flex: 0 0 auto; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #cbd5e1; transition: transform .15s, background .15s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); background: #fff; }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bind-list { display: grid; gap: 2px; margin-top: 6px; }
.bind-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 120px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid #1e2632; font-size: 13.5px; }
.bind-head { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; border: 0; }
.bind-key { padding: 6px 8px; font-size: 13px; font-weight: 600; background: #0f131a; border: 1px solid #3a4454; border-radius: 6px; text-align: center; }
.bind-key:hover { border-color: var(--accent); }
.bind-key.waiting { border-color: var(--accent); color: var(--accent); animation: blink 1s steps(2) infinite; }
.set-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 26px; border-top: 1px solid var(--line); background: rgba(12, 15, 20, .6); }
.set-foot .note { margin: 0; font-size: 12px; color: var(--muted); }
.iconbtn.setbtn { position: static; flex: none; font-size: 18px; width: 40px; height: 40px; }
@media (max-width: 640px) {
  .set-head, .set-body, .set-foot { padding-left: 16px; padding-right: 16px; }
  .srow { grid-template-columns: 1fr; gap: 8px; }
  .srow.tog { grid-template-columns: minmax(0, 1fr) auto; }
  .set-foot .note { display: none; }
  .set-tabs button { padding: 9px 9px; font-size: 13.5px; }
  .bind-row { grid-template-columns: minmax(0, 1fr) 88px 88px; font-size: 12.5px; }
}

/* ---- HUD size, minimap off, the FPS counter ---- */
#timebox, #speedo, #meters, #minimap, #standings, #position, #laplist, #combat, #rcbar, #pitinfo { zoom: var(--hud, 1); }
body.nominimap #minimap { display: none !important; }
#fpscount { position: fixed; top: 62px; right: 16px; z-index: 55; padding: 3px 8px; border-radius: 6px; background: rgba(10, 14, 20, .6); font: 700 12px ui-monospace, monospace; color: #9ff0c4; pointer-events: none; }
.set-head h2 { font-size: 24px; text-transform: none; letter-spacing: 0; color: var(--text); }

/* the custom car editor */
.carchips button.customchip { border-color: rgba(242,194,48,.55); color: #f6d365; }
.carchips button.customchip.sel { background: linear-gradient(135deg, #f6d365, #f2a93b); color: #1a1205; border-color: transparent; }
.customed { margin: 10px 0 12px; padding: 12px; border: 1px solid rgba(242,194,48,.35); border-radius: 12px; background: rgba(242,194,48,.06); }
.customed .ce-top { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.customed .ce-top input, .customed .ce-top select { width: 100%; }
.customed .ce-left { margin: 10px 0 6px; font-size: 13.5px; }
.customed .ce-left b { color: #f6d365; font-size: 16px; } .customed .ce-left b.zero { color: #7fe0a0; }
.ce-rows { display: grid; gap: 4px; }
.ce-row { display: grid; grid-template-columns: 74px 26px 1fr 26px 74px; gap: 6px; align-items: center; font-size: 12.5px; }
.ce-row em { font-style: normal; color: var(--muted); }
.ce-row button { height: 24px; padding: 0; border-radius: 6px; border: 1px solid var(--line); background: #141a24; color: var(--text); font-weight: 800; cursor: pointer; }
.ce-row button:disabled { opacity: .35; cursor: default; }
.ce-row .pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.ce-row .pips i { height: 12px; border-radius: 3px; background: rgba(255,255,255,.08); cursor: pointer; }
.ce-row .pips i.on { background: linear-gradient(180deg, #ffb35c, #ff6a2b); }
.ce-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.ce-save { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.ce-save .good { color: #7fe0a0; } .ce-save .bad { color: #ff8c7a; }
.board td small.carname { display: block; color: var(--muted); font-size: 11px; }
@media (max-width: 420px) { .ce-row { grid-template-columns: 62px 24px 1fr 24px 62px; } .customed .ce-top { grid-template-columns: 1fr; } }
#ce-save { padding: 8px 16px; border-radius: 10px; border: 0; background: linear-gradient(135deg, #ffb35c, #ff6a2b); color: #1a0d05; font-weight: 800; font-size: 14px; cursor: pointer; }
#ce-save:disabled { opacity: .45; cursor: default; }

/* the infinite stat */
.ce-row .v { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.infbtn { width: 22px; height: 20px; padding: 0; border-radius: 6px; border: 1px solid rgba(160,120,255,.5); background: transparent; color: #c6a8ff; font-weight: 800; font-size: 13px; line-height: 1; cursor: pointer; }
.infbtn:hover, .infbtn.on { background: linear-gradient(135deg, #8a5cff, #d36bff); color: #fff; border-color: transparent; }
.ce-row.infrow { grid-template-columns: 74px 0 1fr 0 26px; }
.ce-row .infpower { padding: 3px 8px; border-radius: 6px; background: linear-gradient(90deg, rgba(138,92,255,.35), rgba(211,107,255,.2)); color: #ead9ff; font-weight: 700; }
.customed .ce-left b.neg { color: #ff8c7a; }
.inftag { color: #c6a8ff; }
@media (max-width: 420px) { .ce-row.infrow { grid-template-columns: 62px 0 1fr 0 24px; } }
.ce-row { grid-template-columns: 74px 26px 1fr 26px 104px; }
.ce-row .v { white-space: nowrap; }
@media (max-width: 420px) { .ce-row { grid-template-columns: 62px 24px 1fr 24px 96px; } }

/* ---- the lobby chat (chat.js): in the lobby and results panels, floating over the race ---- */
#chat { font-size: 13px; }
#chat-log { max-height: 190px; min-height: 64px; overflow-y: auto; padding: 8px 10px; background: rgba(8,11,16,.55); border: 1px solid var(--line); border-radius: 10px; }
#chat .cl { line-height: 1.45; overflow-wrap: anywhere; }
#chat .cl b { font-weight: 700; margin-right: 3px; }
#chat .cl .role { font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 1px 5px; margin-right: 4px; border-radius: 4px; background: var(--accent); color: #14100c; vertical-align: 1px; }
#chat .cl.sys { color: var(--muted); font-style: italic; }
#chat .cl.announce { color: var(--accent2); font-style: normal; font-weight: 700; }
#chat .cl.mine { font-style: normal; color: #9fd3ff; }
#chat .cl.err { color: #ff8a80; }
#chat-note { margin: 5px 0 0; color: var(--muted); }
#chat-form { display: flex; gap: 6px; margin-top: 6px; }
#chat-in { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0f141c; color: inherit; font: inherit; }
#chat-in:focus { outline: none; border-color: var(--accent); }
#chat-in:disabled { opacity: .6; }
#chat-form button { flex: none; width: 38px; border-radius: 8px; border: 1px solid var(--line); background: #1a2030; color: inherit; cursor: pointer; }
.chatslot { margin-top: 14px; }
#results .chatslot { margin: 12px 0 4px; }
#chat.floating { position: fixed; left: 14px; bottom: calc(14px + 194px * var(--hud, 1)); width: min(380px, calc(100vw - 28px)); z-index: 30; pointer-events: none; }
#chat.floating #chat-log { min-height: 0; max-height: 150px; background: transparent; border-color: transparent; padding: 4px 6px; text-shadow: 0 1px 4px rgba(0,0,0,.95); }
#chat.floating:not(.open) #chat-form, #chat.floating:not(.open) #chat-note { display: none; }
#chat.floating.empty:not(.open) { display: none; }
#chat.floating.open { pointer-events: auto; }
#chat.floating.open #chat-log { max-height: 230px; background: rgba(8,11,16,.75); border-color: var(--line); padding: 8px 10px; }
body.nominimap #chat.floating { bottom: 14px; }
body.touch #chat.floating { top: 64px; bottom: auto; left: 50%; transform: translateX(-50%); }
#chatbtn { display: none; right: 62px; font-size: 16px; }
body.mp #chatbtn { display: block; }
body.viewing #chatbtn { display: none; }

/* ---- the manual gearbox: the gear and a rev bar by the speedometer ---- */
#gearbox { position: absolute; right: 168px; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; zoom: var(--hud, 1); text-shadow: 0 2px 10px rgba(0,0,0,.6); }
#gb-gear { font: 800 44px/1 system-ui, sans-serif; min-width: 1ch; text-align: center; }
#gearbox .gb-bar { width: 64px; height: 7px; border-radius: 4px; background: rgba(10,14,20,.55); overflow: hidden; }
#gb-rev { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4ad66d, #f2c230 75%, #ff4b3a); }
#gearbox.shift #gb-gear { color: #f2c230; }
#gearbox.limit #gb-gear { color: #ff4b3a; }
body.touch #gearbox { bottom: 134px; right: 150px; }

/* ---- Settings → Wheel ---- */
.wh-devs { display: grid; gap: 8px; margin: 10px 0; }
.wh-devs button { text-align: left; font-size: 13px; }
.wz-prompt { font-size: 16px; margin: 10px 0; }
.wz-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.note.bad { color: #ff8a80; }
.wh-live { display: grid; gap: 6px; margin: 10px 0 14px; }
.wh-bar { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; font-size: 13px; }
.wh-bar i { position: relative; height: 10px; border-radius: 5px; background: #1a2030; overflow: hidden; }
.wh-bar i b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.wh-bar em { font: 800 18px system-ui, sans-serif; font-style: normal; }

/* the leaderboard's Automatic / Manual switch */
.boardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.boardhead h2 { margin: 0; }
.seg.boardgb button { padding: 4px 10px; font-size: 12px; }

/* a driver on the manual gearbox (lobby list, race standings) */
.mtag { display: inline-block; margin-left: 5px; padding: 0 4px; border-radius: 4px; font-size: 10px; font-weight: 800; line-height: 1.5; background: #f2c230; color: #14100c; vertical-align: 1px; }

/* ---- menus with a controller (padnav.js) ---- */
.padfocus { outline: 3px solid var(--accent2) !important; outline-offset: 2px; box-shadow: 0 0 0 6px rgba(255,176,46,.25) !important; }
tr.padfocus { outline-offset: -3px; }
#padhint { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 60; display: flex; gap: 14px; padding: 6px 14px; border-radius: 999px; background: rgba(10,14,20,.82); border: 1px solid var(--line); font-size: 12px; color: #dfe6ee; pointer-events: none; }
#padhint b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-right: 3px; border-radius: 10px; background: #2a3240; color: #fff; font-size: 11px; }
body.viewing #padhint { bottom: 70px; }

/* ---- the bottom bar HUD (Settings → Game → HUD layout), like a racing sim's: a rev strip over one row
   of position, lap, lap time (with the last checkpoint's gap to your ghost), last and best lap, the
   gear, the speed and the meters ---- */
#hudbar { display: none; }
body.hudbar #hudbar { display: block; position: absolute; left: 0; right: 0; bottom: 0; zoom: var(--hud, 1); background: linear-gradient(180deg, rgba(8,11,16,.55), rgba(8,11,16,.88)); border-top: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(3px); }
body.hudbar #timer, body.hudbar #sub, body.hudbar #speedo, body.hudbar #gearbox, body.hudbar #position, body.hudbar #laplist { display: none !important; }
body.hudbar #minimap { bottom: 96px; }
body.hudbar #ghostlabel { bottom: 282px; }
body.hudbar #timebox { top: 10px; }
.hb-rev { height: 6px; background: rgba(255,255,255,.08); }
#hb-rev { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3ddc84 0%, #3ddc84 60%, #f2c230 80%, #ff4b3a 95%); background-size: 100vw 100%; transition: width .05s linear; }
#hudbar.limit #hb-rev { animation: hb-flash .12s steps(2) infinite; }
@keyframes hb-flash { 50% { filter: brightness(1.8); } }
.hb-row { display: flex; align-items: stretch; justify-content: center; gap: 0; padding: 6px 12px 8px; }
.hb-cell { display: flex; flex-direction: column; justify-content: center; padding: 0 18px; border-left: 1px solid rgba(255,255,255,.1); min-width: 0; }
.hb-cell:first-child { border-left: 0; }
.hb-cell em { font: 700 10px/1.2 system-ui, sans-serif; font-style: normal; letter-spacing: 1.5px; text-transform: uppercase; color: #9aa6b4; white-space: nowrap; }
.hb-cell b { font: 700 22px/1.15 ui-monospace, "SF Mono", Menlo, monospace; color: #fff; white-space: nowrap; }
.hb-time b { font-size: 28px; min-width: 7.4ch; }
#hb-delta { margin-left: 6px; letter-spacing: 0; font: 700 12px ui-monospace, monospace; }
#hb-delta.good { color: var(--good); } #hb-delta.bad { color: var(--bad); }
.hb-gear { align-items: center; padding: 0 22px; background: rgba(255,255,255,.04); }
.hb-gear b { font: 800 48px/1 system-ui, sans-serif; }
#hudbar.shift .hb-gear b { color: #f2c230; } #hudbar.limit .hb-gear b { color: #ff4b3a; }
.hb-speed { align-items: flex-end; }
.hb-speed b { font-size: 34px; min-width: 3ch; text-align: right; }
.hb-meters #meters { position: static; width: 170px; gap: 4px; zoom: 1; }
.hb-meters .meter { height: 15px; }
.hb-cp b { font-size: 18px; }
body.touch.hudbar #hudbar { top: 0; bottom: auto; }
body.touch.hudbar .hb-row { padding: 4px 8px; }
body.touch.hudbar .hb-cell { padding: 0 8px; }
body.touch.hudbar #minimap { bottom: auto; }
@media (max-width: 900px) { .hb-cell { padding: 0 10px; } .hb-cp, #hb-poscell:empty { display: none; } .hb-meters #meters { width: 120px; } }
#hb-poscell[hidden] + .hb-cell { border-left: 0; }

/* ?shot (tools/race-shots): only the 3D view, for a picture of the track */
body.shotmode > *:not(#view) { display: none !important; }

/* the autopilot (admins) */
.apbox { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(120, 80, 255, .12); border: 1px solid rgba(150, 120, 255, .35); }
.apbox label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.apbox input[type=range] { width: 140px; }
.apbox small { flex-basis: 100%; opacity: .7; }
.apbadge { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: rgba(110, 70, 255, .85); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .04em; pointer-events: none; z-index: 4; }
