/* Online Racing Game — Grand Prix edition
   Broadcast-graphics look: skewed panels, timing tower, start lights, kerb stripes.
   Brand colours come from the original game: wall orange and start-line blue.
   --hue is the player's car colour and drives the accent everywhere. */

:root{
	--hue: 20;
	--asphalt: #11151d;
	--panel: rgba(21, 26, 36, 0.9);
	--panel-solid: #171c26;
	--panel-2: #222a38;
	--panel-3: #2c3547;
	--line: rgba(214, 224, 240, 0.09);
	--line-strong: rgba(214, 224, 240, 0.18);
	--chalk: #f3f5f9;
	--mute: #97a3b8;
	--dim: #6b7689;
	--wall: #f48342;
	--wall-deep: #c95f22;
	--start: #2580db;
	--kerb: #e23b3b;
	--purple: #a95cff;
	--green: #3ddc84;
	--car: hsl(var(--hue) 100% 58%);
	--car-soft: hsl(var(--hue) 100% 58% / 0.16);
	--car-ink: hsl(var(--hue) 90% 18%);

	--f-logo: "Monoton", "Barlow Condensed", Impact, sans-serif;
	--f-display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
	--f-body: "Figtree", "Segoe UI", system-ui, sans-serif;

	--s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
	--skew: -11deg;
	--spring: cubic-bezier(.34, 1.56, .64, 1);
	--ease: cubic-bezier(.2, .8, .2, 1);

	--elev-1: 0 1px 0 rgba(255,255,255,.04) inset, 0 6px 18px -8px rgba(3,6,12,.7);
	--elev-2: 0 1px 0 rgba(255,255,255,.05) inset, 0 18px 40px -18px rgba(3,6,12,.85), 0 4px 12px -4px rgba(3,6,12,.5);
	--elev-3: 0 1px 0 rgba(255,255,255,.06) inset, 0 30px 70px -24px rgba(2,4,9,.9), 0 10px 24px -10px hsl(var(--hue) 80% 20% / .45);
	--kerb-stripe: repeating-linear-gradient(135deg, var(--kerb) 0 10px, #f4f6fa 10px 20px);
	color-scheme: dark;
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; margin: 0; }
body{
	background: var(--asphalt);
	color: var(--chalk);
	font-family: var(--f-body);
	font-size: 15px;
	line-height: 1.7;
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
	touch-action: manipulation;
	user-select: none;
	-webkit-user-select: none;
}
input, textarea{ user-select: text; -webkit-user-select: text; }
button{ font: inherit; color: inherit; }
[hidden]{ display: none !important; }

#stage{ position: fixed; inset: 0; }
#stage canvas{ display: block; width: 100%; height: 100%; }
#labels{ position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- Menu shell ---------- */
#ui{ position: fixed; inset: 0; pointer-events: none; }
.screen{
	position: absolute; inset: 0;
	display: flex; flex-direction: column;
	padding: max(var(--s5), env(safe-area-inset-top)) max(var(--s5), env(safe-area-inset-right)) max(var(--s5), env(safe-area-inset-bottom)) max(var(--s5), env(safe-area-inset-left));
	pointer-events: none;
	overflow-y: auto;
	animation: screen-in .45s var(--ease) both;
}
.screen > *{ pointer-events: auto; }
.screen.scrim{
	background:
		radial-gradient(120% 90% at 0% 0%, rgba(8,11,17,.95) 0%, rgba(8,11,17,.72) 38%, rgba(8,11,17,0) 70%),
		linear-gradient(90deg, rgba(8,11,17,.9) 0%, rgba(8,11,17,.55) 45%, rgba(8,11,17,0) 75%);
}
.screen.scrim-full{ background: radial-gradient(140% 100% at 50% 0%, rgba(8,11,17,.78), rgba(8,11,17,.94)); }
.screen::after{
	content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@keyframes screen-in{ from{ opacity: 0; transform: translateY(8px); } to{ opacity: 1; transform: none; } }

.topbar{ display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); }
.logo{ display: flex; flex-direction: column; gap: var(--s2); }
.logo h1{
	margin: 0; font-family: var(--f-logo); font-weight: 400;
	font-size: clamp(30px, 5.2vw, 64px); line-height: .95; letter-spacing: .01em;
	text-shadow: 0 0 24px hsl(var(--hue) 100% 55% / .45), 0 2px 0 rgba(0,0,0,.4);
	text-wrap: balance;
}
.edition{
	align-self: flex-start;
	display: inline-flex; align-items: center; gap: var(--s2);
	font-family: var(--f-display); font-style: italic; font-weight: 800; text-transform: uppercase;
	letter-spacing: .22em; font-size: 13px; line-height: 1;
	padding: 7px 14px 7px 10px; background: var(--chalk); color: #10131a;
	transform: skewX(var(--skew));
}
.edition::before{ content: ""; width: 26px; height: 12px; background: var(--kerb-stripe); }

.icon-btn{
	width: 44px; height: 44px; display: grid; place-items: center;
	background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
	box-shadow: var(--elev-1); cursor: pointer;
	transition: transform .22s var(--spring), background-color .2s;
}
.icon-btn:hover{ transform: translateY(-2px); background: var(--panel-2); }
.icon-btn:active{ transform: scale(.95); }
.icon-btn svg{ width: 20px; height: 20px; }

:focus-visible{ outline: 2px solid var(--car); outline-offset: 3px; }

/* ---------- Title ---------- */
.title-grid{ display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: var(--s6); flex: 1; margin-top: var(--s5); align-items: end; }
.stack{ display: flex; flex-direction: column; gap: var(--s4); }

.panel{
	background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
	box-shadow: var(--elev-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
	padding: var(--s5);
}
.panel.kerbed{ position: relative; }
.panel.kerbed::before{ content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 5px; background: var(--kerb-stripe); border-radius: 4px 4px 0 0; }
.eyebrow{
	font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .16em;
	font-size: 12px; color: var(--mute); line-height: 1.2;
}
.field{ display: flex; flex-direction: column; gap: 6px; }
.field + .field{ margin-top: var(--s4); }
.text-input{
	width: 100%; background: #0d1118; border: 1px solid var(--line-strong); border-radius: 3px;
	padding: 10px 12px; color: var(--chalk); font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: .02em;
	transition: border-color .2s;
}
.text-input:focus{ outline: none; border-color: var(--car); box-shadow: 0 0 0 3px var(--car-soft); }
.text-input::placeholder{ color: var(--dim); }

.hue{
	-webkit-appearance: none; appearance: none; width: 100%; height: 22px; border-radius: 3px; cursor: pointer;
	background: linear-gradient(90deg, hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%));
	border: 1px solid var(--line-strong);
}
.hue::-webkit-slider-thumb{ -webkit-appearance: none; width: 14px; height: 30px; background: var(--chalk); border: 3px solid #0d1118; border-radius: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.hue::-moz-range-thumb{ width: 10px; height: 26px; background: var(--chalk); border: 3px solid #0d1118; border-radius: 2px; }

.bodies{ display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.chip-btn{
	position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px;
	padding: 8px 4px 6px; cursor: pointer; text-align: center;
	font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; line-height: 1.1;
	transition: transform .22s var(--spring), background-color .2s, border-color .2s;
}
.chip-btn small{ display: block; font-family: var(--f-body); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--mute); margin-top: 2px; }
.chip-btn:hover{ transform: translateY(-2px); background: var(--panel-3); }
.chip-btn:active{ transform: scale(.96); }
.chip-btn[aria-pressed="true"], .chip-btn[aria-checked="true"]{ border-color: var(--car); background: linear-gradient(180deg, var(--car-soft), transparent), var(--panel-2); box-shadow: 0 0 0 1px var(--car) inset; }

.race-menu{ display: flex; flex-direction: column; gap: 10px; }
.race-btn{
	position: relative; display: flex; align-items: center; gap: var(--s4); width: 100%;
	padding: 14px 22px 14px 20px; border: 0; cursor: pointer; text-align: left;
	background: var(--panel); box-shadow: var(--elev-2);
	transform: skewX(var(--skew));
	transition: transform .24s var(--spring), background-color .2s;
}
.race-btn > *{ transform: skewX(calc(var(--skew) * -1)); }
a.race-btn{ color: inherit; text-decoration: none; }
.race-btn::before{ content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line-strong); transition: background-color .2s, width .24s var(--spring); }
.race-btn:hover{ transform: skewX(var(--skew)) translateX(8px); background: var(--panel-2); }
.race-btn:hover::before{ background: var(--car); width: 8px; }
.race-btn:active{ transform: skewX(var(--skew)) translateX(8px) scale(.985); }
.race-btn .rb-title{ font-family: var(--f-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 26px; line-height: 1; letter-spacing: .01em; }
.race-btn .rb-sub{ font-size: 13px; color: var(--mute); line-height: 1.35; }
.race-btn .rb-text{ display: flex; flex-direction: column; gap: 4px; flex: 1; }
.race-btn .rb-arrow{ font-family: var(--f-display); font-weight: 800; font-size: 22px; color: var(--dim); transition: color .2s, transform .24s var(--spring); }
.race-btn:hover .rb-arrow{ color: var(--car); transform: skewX(calc(var(--skew) * -1)) translateX(4px); }
.race-btn.primary{ background: linear-gradient(100deg, var(--wall) 0%, var(--wall-deep) 100%); color: #140b05; box-shadow: var(--elev-3); }
.race-btn.primary::before{ background: #140b05; }
.race-btn.primary .rb-sub{ color: rgba(20,11,5,.72); }
.race-btn.primary .rb-arrow{ color: #140b05; }
.race-btn.primary:hover{ background: linear-gradient(100deg, #ff9657 0%, var(--wall) 100%); }
.race-btn.small{ padding: 10px 18px; }
.race-btn.small .rb-title{ font-size: 20px; }

.credit{ font-size: 12px; color: var(--dim); line-height: 1.5; }
.credit a{ color: var(--mute); }

.showcase-tag{
	justify-self: end; align-self: end;
	display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right;
	font-family: var(--f-display); text-transform: uppercase;
}
.showcase-tag .num{ font-size: clamp(60px, 9vw, 120px); font-weight: 900; font-style: italic; line-height: .85; color: transparent; -webkit-text-stroke: 2px var(--car); opacity: .9; }
.showcase-tag .who{ font-size: 22px; font-weight: 800; font-style: italic; letter-spacing: .04em; }
.showcase-tag .what{ font-size: 13px; letter-spacing: .18em; color: var(--mute); }

/* ---------- Setup / online / lobby ---------- */
.screen-head{ display: flex; align-items: center; gap: var(--s4); }
.back-btn{
	display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
	background: var(--panel); border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
	font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 14px;
	transition: transform .22s var(--spring), background-color .2s;
}
.back-btn:hover{ transform: translateX(-3px); background: var(--panel-2); }
.back-btn:active{ transform: scale(.96); }
.screen-title{ margin: 0; font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.01em; }

.setup-grid{ display: grid; grid-template-columns: 1fr minmax(300px, 380px); gap: var(--s5); margin-top: var(--s5); min-height: 0; }
.track-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s3); align-content: start; }
.track-card{
	position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px;
	background: var(--panel); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--elev-1);
	text-align: left; cursor: pointer;
	transition: transform .24s var(--spring), border-color .2s, background-color .2s;
}
.track-card:hover{ transform: translateY(-3px); background: var(--panel-solid); border-color: var(--line-strong); }
.track-card:active{ transform: scale(.98); }
.track-card[aria-checked="true"]{ border-color: var(--car); box-shadow: var(--elev-2), 0 0 0 1px var(--car) inset; }
.track-card[aria-checked="true"]::after{ content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 4px; background: var(--kerb-stripe); }
.track-card svg{ width: 100%; height: 86px; }
.track-card svg path{ fill: none; stroke: var(--chalk); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; opacity: .85; vector-effect: non-scaling-stroke; }
.track-card[aria-checked="true"] svg path{ stroke: var(--car); opacity: 1; }
.track-card svg circle{ fill: var(--start); }
.tc-name{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 20px; line-height: 1.05; letter-spacing: .01em; }
.tc-meta{ display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--mute); line-height: 1.3; }
.tc-flag{
	position: absolute; top: 10px; right: 10px; font-family: var(--f-display); font-weight: 700; font-size: 11px; letter-spacing: .12em;
	padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 2px; color: var(--mute);
}
.tc-record{ font-family: var(--f-display); font-weight: 600; font-size: 14px; color: var(--chalk); font-variant-numeric: tabular-nums; }
.tc-record b{ color: var(--purple); font-weight: 700; }

.options{ display: flex; flex-direction: column; gap: var(--s4); align-self: start; position: sticky; top: 0; }
.opt-row{ display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.opt-row label, .opt-label{ font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 15px; }
.opt-help{ font-size: 12px; color: var(--mute); line-height: 1.4; margin-top: -8px; }
.seg{ display: inline-flex; background: #0d1118; border: 1px solid var(--line-strong); border-radius: 3px; padding: 3px; gap: 3px; }
.seg button{
	border: 0; background: transparent; padding: 6px 12px; border-radius: 2px; cursor: pointer;
	font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; color: var(--mute);
	transition: background-color .2s, color .2s, transform .2s var(--spring);
}
.seg button:hover{ color: var(--chalk); }
.seg button:active{ transform: scale(.95); }
.seg button[aria-checked="true"]{ background: var(--chalk); color: #10131a; }
.seg button:disabled{ opacity: .45; cursor: not-allowed; }
.stepper{ display: inline-flex; align-items: center; background: #0d1118; border: 1px solid var(--line-strong); border-radius: 3px; }
.stepper button{ width: 36px; height: 34px; border: 0; background: transparent; cursor: pointer; font-family: var(--f-display); font-size: 20px; font-weight: 700; color: var(--mute); transition: color .2s, transform .2s var(--spring); }
.stepper button:hover{ color: var(--chalk); }
.stepper button:active{ transform: scale(.9); }
.stepper button:disabled{ opacity: .35; cursor: not-allowed; }
.stepper output{ min-width: 34px; text-align: center; font-family: var(--f-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }

.sel-name{ font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 32px; line-height: 1; }
.sel-blurb{ color: var(--mute); font-size: 14px; line-height: 1.5; margin: 0; }
.board{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.board li{ display: grid; grid-template-columns: 22px 6px 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; background: rgba(255,255,255,.03); font-size: 14px; line-height: 1.4; }
.board li .chip{ width: 6px; height: 16px; }
.board li .t{ font-family: var(--f-display); font-weight: 700; font-size: 16px; }
.board li.first .t{ color: var(--purple); }
.board .empty{ color: var(--dim); font-size: 13px; background: none; display: block; padding: 4px 0; }

.go-btn{
	position: relative; width: 100%; border: 0; cursor: pointer; padding: 16px 20px;
	background: linear-gradient(100deg, var(--wall), var(--wall-deep)); color: #140b05; box-shadow: var(--elev-3);
	font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 28px; letter-spacing: .02em; line-height: 1;
	transform: skewX(var(--skew));
	transition: transform .24s var(--spring), filter .2s;
}
.go-btn > span{ display: inline-block; transform: skewX(calc(var(--skew) * -1)); }
.go-btn:hover{ transform: skewX(var(--skew)) translateY(-2px); filter: brightness(1.08); }
.go-btn:active{ transform: skewX(var(--skew)) scale(.98); }
.go-btn:disabled{ filter: grayscale(.8) brightness(.6); cursor: not-allowed; transform: skewX(var(--skew)); }
.go-btn.ghost{ background: var(--panel-2); color: var(--chalk); box-shadow: var(--elev-1); font-size: 20px; padding: 12px 16px; }

.online-grid{ display: grid; grid-template-columns: repeat(2, minmax(0, 420px)); gap: var(--s5); margin-top: var(--s6); }
.code-input{
	width: 100%; background: #0d1118; border: 1px solid var(--line-strong); border-radius: 3px; padding: 10px 0 10px .5em;
	font-family: var(--f-display); font-weight: 900; font-size: 48px; letter-spacing: .5em; text-transform: uppercase; text-align: center; color: var(--chalk);
}
.code-input:focus{ outline: none; border-color: var(--car); box-shadow: 0 0 0 3px var(--car-soft); }
.msg{ font-size: 14px; line-height: 1.5; margin: 0; }
.msg.err{ color: #ff8a8a; }
.msg.invite{ color: var(--green); font-weight: 600; }
.notice{ border-left: 4px solid var(--wall); }
.notice code{ font-size: 13px; background: #0d1118; padding: 1px 5px; border-radius: 2px; }

.lobby-grid{ display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.3fr); gap: var(--s5); margin-top: var(--s5); }
.room-code{ display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.room-code .code{ font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: clamp(48px, 7vw, 76px); letter-spacing: .12em; line-height: .9; color: var(--chalk); text-shadow: 0 0 30px hsl(var(--hue) 100% 55% / .35); }
.players{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player{
	display: grid; grid-template-columns: 8px 1fr auto auto auto; gap: 12px; align-items: center;
	padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px;
}
.player .chip{ width: 8px; height: 30px; border-radius: 1px; }
.player .pname{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 20px; line-height: 1.05; }
.player .pbody{ display: block; font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--mute); text-transform: none; }
.tag{ font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; padding: 3px 8px; border-radius: 2px; background: rgba(255,255,255,.06); color: var(--mute); }
.tag.ready{ background: rgba(61,220,132,.14); color: var(--green); }
.tag.host{ background: rgba(244,131,66,.16); color: var(--wall); }
.tag.bot{ background: rgba(37,128,219,.18); color: #7fb6f0; }
.x-btn{ width: 30px; height: 30px; border: 1px solid var(--line); background: transparent; border-radius: 3px; cursor: pointer; color: var(--mute); transition: color .2s, background-color .2s, transform .2s var(--spring); }
.x-btn:hover{ color: #fff; background: var(--kerb); }
.x-btn:active{ transform: scale(.9); }
.mini-grid{ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.mini-grid .track-card svg{ height: 54px; }
.mini-grid .tc-name{ font-size: 16px; }

/* ---------- Title extras: weekly challenge, account ---------- */
.title-side{ align-self: stretch; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; gap: var(--s5); min-height: 0; }
.weekly{ width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; }
.weekly .sel-name{ font-size: 28px; }
.weekly .go-btn{ font-size: 20px; padding: 12px 16px; }
.weekly-ends{ color: var(--wall); }
.weekly-last{ margin: 0; }
.acct-row{ display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.acct-text{ font-size: 14px; color: var(--mute); line-height: 1.35; }
.acct-text b{ color: var(--chalk); font-family: var(--f-display); font-size: 16px; letter-spacing: .02em; }
.acct-row .back-btn{ height: 36px; padding: 0 12px; flex: none; }
.acct-card{ display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; font-family: var(--f-display); font-size: 20px; }
.acct-option{ display: flex; flex-direction: column; gap: 10px; padding: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 3px; }
.acct-option .flex > .go-btn{ font-size: 18px; padding: 10px 12px; }
.acct-option .field + .field{ margin-top: 0; }
.hwb-btn{ font-size: 18px !important; background: linear-gradient(100deg, #1b3c73, #26508f) !important; color: #fff !important; }
.tc-round{
	position: absolute; top: 8px; left: 8px; min-width: 26px; height: 26px; display: grid; place-items: center;
	background: var(--car); color: #0e1219; font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 16px;
	transform: skewX(var(--skew));
}

/* ---------- Garage ---------- */
.garage-btn{
	display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: 100%;
	margin-top: var(--s4); padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; text-align: left;
	transition: transform .22s var(--spring), background-color .2s, border-color .2s;
}
.garage-btn:hover{ transform: translateY(-2px); background: var(--panel-3); border-color: var(--car); }
.garage-btn:active{ transform: scale(.98); }
.gb-level{ display: flex; flex-direction: column; align-items: center; min-width: 46px; padding: 2px 8px; background: var(--car); color: #0e1219; transform: skewX(var(--skew)); }
.gb-level > *{ transform: skewX(calc(var(--skew) * -1)); }
.gb-level small{ font-family: var(--f-display); font-weight: 700; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; line-height: 1.2; }
.gb-level b{ font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 26px; line-height: 1; }
/* Past level 30 the badge turns gold. */
.gb-level.past, .lv-num.past{ background: linear-gradient(135deg, #f5d76e, #c9a227 60%, #f5d76e); }
.gb-level.past b, .lv-num.past b{ font-size: 24px; letter-spacing: -.02em; }
.gb-text{ display: flex; flex-direction: column; line-height: 1.25; }
.gb-text b{ font-family: var(--f-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 20px; }
.gb-text small{ font-size: 12px; color: var(--mute); }
.name-note{ margin: 0; color: #ffcf5c; }

.garage-grid{ display: grid; grid-template-columns: minmax(300px, 560px); margin-top: var(--s5); }
.level-card{ display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; position: relative; }
.lv-num{ display: flex; flex-direction: column; align-items: center; padding: 6px 14px; background: var(--car); color: #0e1219; transform: skewX(var(--skew)); }
.lv-num > *{ transform: skewX(calc(var(--skew) * -1)); }
.lv-num small{ font-family: var(--f-display); font-weight: 700; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.lv-num b{ font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 44px; line-height: .95; }
.lv-info{ display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.xp-bar{ display: block; height: 8px; background: #0d1118; overflow: hidden; border: 1px solid var(--line); }
.xp-bar i{ display: block; height: 100%; background: linear-gradient(90deg, var(--car), #fff); transform-origin: left; transform: scaleX(0); transition: transform .6s var(--ease); }
.crown-badge{ position: absolute; top: -12px; right: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; background: #f5c542; color: #1b1406; font-family: var(--f-display); font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; box-shadow: 0 4px 14px rgba(245,197,66,.4); }
.crown-badge svg{ width: 16px; height: 16px; }
.garage-tabs{ align-self: flex-start; flex-wrap: wrap; }
.gitems{ display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: calc(100vh - 360px); overflow-y: auto; padding: 2px; }
.gitem{
	position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left; cursor: pointer;
	background: var(--panel); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--elev-1);
	transition: transform .22s var(--spring), border-color .2s, background-color .2s;
}
.gitem:hover{ transform: translateY(-2px); border-color: var(--line-strong); }
.gitem:active{ transform: scale(.97); }
.gitem.on{ border-color: var(--car); box-shadow: 0 0 0 1px var(--car) inset, var(--elev-2); }
.gitem.locked .gswatch{ filter: grayscale(.75) brightness(.55); }
.gitem.nope{ animation: nope .35s; }
@keyframes nope{ 25%{ transform: translateX(-4px); } 75%{ transform: translateX(4px); } }
.gswatch{ display: block; height: 54px; border-radius: 2px; border: 1px solid rgba(255,255,255,.08); }
.gswatch.gtitle{ display: grid; place-items: center; background: #0d1118; font-family: var(--f-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: 17px; letter-spacing: .04em; color: var(--chalk); }
.gname{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 15px; line-height: 1.1; }
.gtag{ align-self: flex-start; font-family: var(--f-display); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; background: var(--car); color: #0e1219; }
.greq{ font-size: 12px; color: var(--mute); line-height: 1.3; }
.gbar{ display: block; height: 4px; background: #0d1118; }
.gbar i{ display: block; height: 100%; background: var(--wall); transform-origin: left; }
.gprog{ font-family: var(--f-display); font-weight: 700; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.glock{ position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; color: rgba(243,245,249,.85); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.number-panel{ display: flex; flex-direction: column; align-items: center; gap: 12px; }
.num-big{ font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 110px; line-height: .9; color: transparent; -webkit-text-stroke: 3px var(--car); }
.crown-ico{ display: inline-block; width: 1em; height: 1em; margin-right: 4px; vertical-align: -.12em; color: #f5c542; }
.pname .ptitle{ display: block; font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--wall); text-transform: none; letter-spacing: 0; }

/* ---------- Admin ---------- */
.admin-body{ margin-top: var(--s4); overflow-x: auto; }
.admin-table td{ vertical-align: top; }
.admin-table small.dim{ font-size: 11px; color: var(--dim); }
.admin-acts{ display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-act{ height: 32px; padding: 0 10px; font-size: 12px; }
.admin-act.danger:hover{ background: var(--kerb); }
.admin-name{ width: 150px; font-size: 15px; padding: 4px 8px; }
.admin-select{ width: auto; font-size: 16px; margin-bottom: 10px; }
.admin-news{ display: block; width: 100%; max-width: 560px; margin-bottom: 10px; font-size: 16px; resize: vertical; }

/* ---------- Leaderboards ---------- */
.boards-grid{ display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: var(--s5); margin-top: var(--s5); align-items: start; }
#boardTracks.boards-grid{ grid-template-columns: minmax(0, 1fr) minmax(320px, 1.1fr); }
.standings td{ padding: 8px 10px; }
.standings td.num{ font-family: var(--f-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.standings td.lead{ color: var(--chalk); }
.standings td.dim{ color: var(--mute); font-variant-numeric: tabular-nums; }
.standings tr.first td.num.hl{ color: var(--purple); }
.standings .empty td{ color: var(--dim); text-align: center; padding: 24px 10px; }
.you-card{ position: sticky; top: 0; }
.you-stats{ display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; margin: 0; }
.you-stats > div{ background: rgba(255,255,255,.04); padding: 8px 12px; }
.you-stats dt{ font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.you-stats dd{ margin: 0; font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 36px; line-height: 1.05; font-variant-numeric: tabular-nums; }

/* ---------- Results ---------- */
.results-wrap{ display: flex; flex-direction: column; gap: var(--s5); max-width: 880px; width: 100%; margin: var(--s5) auto 0; }
.podium{ display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: var(--s3); }
.step{ display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; }
.step .who{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 20px; line-height: 1.1; }
.step .when{ font-family: var(--f-display); font-weight: 600; font-size: 15px; color: var(--mute); font-variant-numeric: tabular-nums; }
.step .block{
	width: 100%; display: grid; place-items: center; padding-top: 10px;
	background: linear-gradient(180deg, var(--panel-3), var(--panel-solid)); border: 1px solid var(--line); border-top: 5px solid var(--c, var(--chalk));
	font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: 54px; line-height: 1;
	box-shadow: var(--elev-2);
}
.step.p1 .block{ height: 150px; } .step.p2 .block{ height: 110px; } .step.p3 .block{ height: 84px; }
.step .block span{ align-self: start; }
.table-wrap{ overflow-x: auto; }
.results{ width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.results th{ text-align: left; font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--mute); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
.results td{ padding: 10px; border-bottom: 1px solid var(--line); font-size: 15px; }
.results td.pos{ font-family: var(--f-display); font-weight: 900; font-size: 20px; width: 44px; }
.results td.name{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 18px; }
.results td.name i{ display: inline-block; width: 6px; height: 18px; margin-right: 10px; vertical-align: -3px; }
.results td.best.fastest{ color: var(--purple); font-weight: 700; }
.results tr.me td{ background: var(--car-soft); }
.results-actions{ display: flex; flex-wrap: wrap; gap: var(--s3); }
.results-actions > *{ flex: 1 1 200px; }
/* Name effects (NAMEFX in js/cosmetics.js): gradient text, on the tower, over the cars and in lists. */
.nfx-ice, .nfx-flame, .nfx-neon, .nfx-gold, .nfx-rainbow{ -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.nfx-ice{ background-image: linear-gradient(90deg, #bfeaff, #ffffff 50%, #7cc8ff); }
.nfx-flame{ background-image: linear-gradient(90deg, #ff4a1a, #ffb02e 55%, #fff1a0); }
.nfx-neon{ background-image: linear-gradient(90deg, #35e0ff, #ff3bd8); }
.nfx-gold{ background-image: linear-gradient(90deg, #f5d76e, #fff3b8 50%, #d4a017); }
.nfx-rainbow{ background-image: linear-gradient(90deg, #ff5a5a, #ffd23a, #5aff8a, #3ac8ff, #b86bff); }
/* Gold Border (reached by going past level 30): the name in a gold frame. */
.nfx-border{ color: #fff1b8; padding: 0 5px; border: 1px solid #f5c542; border-radius: 3px; box-shadow: 0 0 7px rgba(245,197,66,.45), inset 0 0 6px rgba(245,197,66,.18); }
.gswatch .nfx-ice, .gswatch .nfx-flame, .gswatch .nfx-neon, .gswatch .nfx-gold, .gswatch .nfx-rainbow{ font-size: 20px; }
/* The admin's announcement on the title screen. */
.announce{ display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); padding: 10px 14px; max-width: 780px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--wall); box-shadow: var(--elev-1); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.an-tag{ flex: none; font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--wall); }
#announceText{ flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.announce .link-btn{ flex: none; }
/* Party styles and the wheel of chaos (js/party.js, js/chaos.js). */
.party-hud{ position: absolute; top: 130px; left: 50%; transform: translateX(-50%); max-width: min(92vw, 560px); padding: 7px 18px; text-align: center; background: rgba(12,15,22,.82); border: 1px solid var(--line); border-left: 4px solid var(--wall); font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 17px; line-height: 1.25; box-shadow: var(--elev-2); }
.chaos-tag{ position: absolute; top: 176px; left: 50%; transform: translateX(-50%); padding: 3px 14px; background: rgba(120,40,200,.82); color: #fff; font-family: var(--f-display); font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: .12em; font-size: 14px; }
#hud.blind .tower, #hud.blind .hud-lap, #hud.blind #minimap, #hud.blind .mirror, #hud.blind .hud-speed .speed-read{ visibility: hidden; }
.tower-row.tower-gap{ margin-top: 8px; }     /* (the leaders, then the cars round you: a gap where the places jump) */
.tower-row.is-holder{ background: linear-gradient(90deg, rgba(255,122,18,.55), rgba(18,22,30,.9) 70%); }
.label.holder{ background: var(--wall); color: #170b02; box-shadow: 0 0 14px rgba(255,122,18,.7); }
.label.holder b{ color: #170b02; }
/* Garage: sharing a look, and prize codes. */
.garage-share{ display: flex; flex-wrap: wrap; gap: var(--s2); }
.garage-paste{ display: flex; gap: var(--s2); }
.garage-paste .text-input{ flex: 1; min-width: 0; font-size: 14px; }
.garage-paste .go-btn{ flex: none; font-size: 18px; padding: 10px 16px; }
.msg.ok{ color: var(--green); font-weight: 600; }
/* The winner's celebration, drawn on a canvas over everything but the pop-ups. */
#podiumFx{ position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
/* Voting for the next track on the results screen. */
.vote-box{ display: grid; gap: var(--s2); max-width: 760px; }
.vote-row{ display: flex; flex-wrap: wrap; gap: var(--s2); }
.vote-btn{ flex: 1 1 200px; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--line); color: var(--chalk); font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 18px; letter-spacing: .02em; cursor: pointer; transition: transform .22s var(--spring), border-color .2s; }
.vote-btn:hover{ transform: translateY(-2px); border-color: var(--line-strong); }
.vote-btn:active{ transform: scale(.97); }
.vote-btn > span:first-child{ text-align: left; }
.vote-btn.mine{ border-color: var(--car); box-shadow: 0 0 0 1px var(--car) inset; }
.vote-btn.lead{ background: linear-gradient(90deg, rgba(244,131,66,.28), var(--panel-2) 70%); }
.vote-btn small{ display: block; font-family: var(--f-body); font-weight: 500; font-size: 11px; text-transform: none; letter-spacing: 0; color: var(--mute); }
.vote-btn .vc{ min-width: 30px; height: 30px; display: grid; place-items: center; background: #0d1118; font-variant-numeric: tabular-nums; font-size: 18px; }
/* What you're closest to unlocking in the garage. */
.next-unlock{ display: grid; gap: 6px; padding: 12px 16px; border-left: 4px solid var(--wall); background: var(--panel-2); max-width: 520px; }
.nu-name{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: 22px; line-height: 1.1; }
.nu-need{ font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.next-unlock .gbar{ height: 6px; }
/* Rematch votes: one start light per driver, lit as they ask for one, green once there are enough. */
.rematch{ display: flex; align-items: center; gap: var(--s3); color: var(--mute); font-size: 14px; }
.rm-dots{ display: inline-flex; gap: 6px; }
.rm-dots i{ width: 12px; height: 12px; border-radius: 50%; background: var(--panel-3); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); transform: scale(.85); }
.rm-dots i.on{ background: var(--kerb); box-shadow: 0 0 10px rgba(226,59,59,.6); transform: scale(1.1); animation: rm-pop .4s var(--spring); }
.rematch.go .rm-dots i.on{ background: var(--green); box-shadow: 0 0 10px rgba(61,220,132,.55); }
.rematch.go #rematchText{ color: var(--green); font-weight: 600; }
@keyframes rm-pop{ from{ transform: scale(.5); opacity: .4; } to{ transform: scale(1.1); opacity: 1; } }
@media (prefers-reduced-motion: reduce){ .rm-dots i.on{ animation: none; } }

/* ---------- Halloween (js/season.js): October only, by the calendar ---------- */
.mist, .bats, .weekly-tag{ display: none; }
body.halloween{
	--kerb-stripe: repeating-linear-gradient(135deg, #ff7a12 0 10px, #1b0f26 10px 20px);
}
body.halloween .screen.scrim{
	background:
		radial-gradient(120% 90% at 0% 0%, rgba(16,6,26,.95) 0%, rgba(16,6,26,.72) 38%, rgba(16,6,26,0) 70%),
		linear-gradient(90deg, rgba(16,6,26,.9) 0%, rgba(16,6,26,.55) 45%, rgba(16,6,26,0) 75%);
}
body.halloween .screen.scrim-full{ background: radial-gradient(140% 100% at 50% 0%, rgba(20,8,32,.78), rgba(14,6,22,.94)); }
body.halloween .logo h1{ text-shadow: 0 0 28px rgba(255,122,18,.55), 0 0 64px rgba(150,70,255,.35), 0 2px 0 rgba(0,0,0,.45); }
body.halloween .edition{ background: #ff7a12; color: #170b02; }
body.halloween .panel{ border-color: rgba(176,120,255,.22); }
body.halloween:not([data-view="race"]):not([data-view="replay"]) .mist{ display: block; }
body.halloween[data-view="title"] .bats{ display: block; }
/* Mist drifting along the bottom of the menus: two soft layers, moved with transform only. */
.mist{ position: fixed; left: 0; right: 0; bottom: 0; height: 52vh; overflow: hidden; pointer-events: none; opacity: .85; }
.mist i{ position: absolute; left: -25%; bottom: -10%; width: 150%; height: 100%;
	background: radial-gradient(55% 50% at 30% 85%, rgba(190,160,255,.34), transparent 70%), radial-gradient(45% 42% at 74% 92%, rgba(255,150,70,.2), transparent 70%);
	animation: mist-drift 42s ease-in-out infinite alternate; }
.mist i + i{ bottom: -22%; opacity: .75; animation-duration: 63s; animation-direction: alternate-reverse; }
@keyframes mist-drift{ from{ transform: translate3d(-7%, 0, 0); } to{ transform: translate3d(7%, 0, 0); } }
.bats{ position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.screen > .bats{ pointer-events: none; }
.bat{ position: absolute; top: 0; left: 0; width: 58px; height: 29px; color: #1a0b2a; opacity: .95;
	filter: drop-shadow(0 0 5px rgba(255,138,40,.75));
	animation: bat-fly 19s linear infinite, bat-flap .32s ease-in-out infinite alternate; animation-delay: var(--d, 0s), 0s; }
.bat.b1{ --d: -3s; top: 8vh; }
.bat.b2{ --d: -11s; top: 22vh; width: 44px; height: 22px; animation-duration: 25s, .27s; }
.bat.b3{ --d: -7s; top: 14vh; width: 36px; height: 18px; animation-duration: 31s, .24s; }
.bat.b4{ --d: -16s; top: 30vh; width: 52px; height: 26px; animation-duration: 22s, .3s; }
@keyframes bat-fly{ from{ transform: translate3d(-10vw, 0, 0); } 50%{ transform: translate3d(50vw, -4vh, 0); } to{ transform: translate3d(112vw, 3vh, 0); } }
@keyframes bat-flap{ from{ scale: 1 1; } to{ scale: 1 .55; } }
@media (prefers-reduced-motion: reduce){ .mist i, .bat{ animation: none; } .bat{ display: none; } }
/* The weekly challenge card in the Halloween week: its conditions, and a spooky edge. */
.weekly-tag{ font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 13px; color: #ffb066; }
.weekly[data-theme="halloween"]{ border-color: rgba(255,122,18,.55); box-shadow: var(--elev-2), 0 0 40px -12px rgba(255,122,18,.5); }
.weekly[data-theme="halloween"] .weekly-tag{ display: block; }

/* ---------- HUD ---------- */
/* Settings > Change keys: one row for each thing a key does, with its two keys as buttons. */
.keymap{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.keymap li{ display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 2px 10px; background: rgba(14,18,26,.6); }
.km-name{ font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 15px; color: var(--chalk); }
.km-keys{ display: flex; gap: 6px; }
.km-key{ min-width: 60px; height: 28px; padding: 0 12px; font-family: var(--f-display); font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--chalk); background: #0d1118; border: 1px solid var(--line-strong); border-bottom-width: 3px; border-radius: 3px; cursor: pointer; transition: transform .2s var(--spring), border-color .2s, background-color .2s; }
.km-key:hover{ border-color: var(--car); transform: translateY(-1px); }
.km-key:active{ transform: translateY(1px); border-bottom-width: 2px; }
.km-key:focus-visible{ outline: 2px solid var(--chalk); outline-offset: 2px; }
.km-key.empty{ color: var(--mute); border-style: dashed; border-bottom-width: 1px; }
.km-key.listening{ color: #0e1219; background: var(--chalk); border-color: var(--chalk); animation: km-wait 1s ease-in-out infinite; }
@keyframes km-wait{ 50%{ opacity: .7; } }
@media (prefers-reduced-motion: reduce){ .km-key.listening{ animation: none; } }
/* Settings > Graphics: what Fast and Pretty look like (the same moment of the same race), the one in use lit. */
.quality-prev{ display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.qp{ display: flex; flex-direction: column; gap: 4px; padding: 0 0 10px; text-align: left; color: var(--chalk); background: #0d1118; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; cursor: pointer; transition: transform .22s var(--spring), border-color .2s, box-shadow .2s; }
.qp img{ display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: #161b26; }
.qp-name{ display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 4px 10px 0; font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 16px; }
.qp-auto{ font-style: normal; font-weight: 700; font-size: 11px; letter-spacing: .08em; color: var(--car); }
.qp small{ padding: 0 10px; color: var(--mute); font-size: 12px; line-height: 1.45; }
.qp:hover{ border-color: var(--line-strong); transform: translateY(-2px); }
.qp:active{ transform: scale(.98); }
.qp:focus-visible{ outline: 2px solid var(--chalk); outline-offset: 2px; }
.qp[aria-pressed="true"]{ border-color: var(--car); box-shadow: 0 0 0 1px var(--car) inset, 0 10px 24px -12px var(--car); }
.stepper output.wide{ min-width: 64px; text-align: center; }
#hud{ position: fixed; inset: 0; pointer-events: none; font-family: var(--f-display); }
.tower{
	position: absolute; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left));
	list-style: none; margin: 0; padding: 0; width: 230px; display: flex; flex-direction: column; gap: 2px;
	filter: drop-shadow(0 8px 18px rgba(3,6,12,.45));
}
.tower-row{
	display: grid; grid-template-columns: 26px 4px 1fr auto; align-items: center; gap: 8px; height: 26px; padding-right: 8px;
	background: rgba(14,18,26,.86); font-weight: 700; font-size: 15px; text-transform: uppercase; letter-spacing: .03em;
	transform: skewX(var(--skew)); transition: transform .3s var(--spring);
}
.tower-row > *{ transform: skewX(calc(var(--skew) * -1)); }
.tw-pos{ height: 100%; display: grid; place-items: center; background: var(--chalk); color: #0e1219; font-weight: 900; }
.tw-chip{ width: 4px; height: 16px; }
.tw-name{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-gap{ font-weight: 600; font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.tower-row.is-me{ background: hsl(var(--hue) 70% 22% / .92); }
.tower-row.is-me .tw-pos{ background: var(--car); }
.tower-row.is-out{ opacity: .45; }
.tower-row.is-done .tw-gap{ color: var(--chalk); }

.hud-lap{
	position: absolute; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
	display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right;
}
.lap-big{ display: flex; align-items: baseline; gap: 8px; padding: 6px 16px 4px; background: rgba(14,18,26,.86); transform: skewX(var(--skew)); box-shadow: var(--elev-2); }
.lap-big > *{ transform: skewX(calc(var(--skew) * -1)); }
.lap-big .lbl{ font-weight: 700; font-size: 14px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
.lap-big b{ font-weight: 900; font-style: italic; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.lap-big .of{ font-weight: 700; font-size: 22px; color: var(--mute); }
.times{ display: grid; grid-template-columns: auto auto; gap: 1px 12px; margin: 0; padding: 6px 12px; background: rgba(14,18,26,.72); font-variant-numeric: tabular-nums; }
.times dt{ font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); align-self: center; }
.times dd{ margin: 0; font-weight: 700; font-size: 19px; line-height: 1.25; }
.times dd.best{ color: var(--purple); }
.times dd[data-delta="faster"]{ color: var(--green); }
.times dd[data-delta="slower"]{ color: #ffcf5c; }
.sectors{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; width: 100%; min-width: 186px; }
.sec{ display: grid; gap: 0; padding: 3px 6px 2px; background: rgba(14,18,26,.72); border-bottom: 3px solid rgba(214,224,240,.14); text-align: left; transition: background-color .25s, border-color .25s; }
.sec em{ font-style: normal; font-weight: 700; font-size: 10px; letter-spacing: .14em; color: var(--mute); }
.sec b{ font-weight: 700; font-size: 15px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sec.live{ border-bottom-color: var(--chalk); }
.sec.purple{ background: rgba(169,92,255,.32); border-bottom-color: var(--purple); }
.sec.green{ background: rgba(61,220,132,.24); border-bottom-color: var(--green); }
.sec.yellow{ background: rgba(255,207,92,.2); border-bottom-color: #ffcf5c; }

/* Weather forecast (dynamic weather): what it is now, the next change, and the next six minutes as a strip. Each
   condition has its own colour; the strip starts at "now". js/hud.js setForecast, main.js updateSky. */
.forecast{ --fc: var(--chalk); width: 100%; min-width: 186px; display: grid; gap: 4px; padding: 5px 8px 4px; background: rgba(14,18,26,.72); text-align: left; }
.fc-head{ display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.fc-head b{ color: var(--fc); font-weight: 800; }
.fc-head span{ margin-left: auto; font-weight: 600; font-size: 12px; letter-spacing: .03em; text-transform: none; color: var(--mute); white-space: nowrap; }
.fc-ico{ flex: none; width: 17px; height: 17px; fill: none; stroke: var(--fc); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fc-strip{ display: flex; gap: 1px; height: 9px; border-left: 2px solid var(--chalk); }
.fc-strip i{ display: block; height: 100%; flex: 0 0 auto; background: var(--c); }
.fc-strip i[data-k="clear"]{ --c: #ffcf5c; } .fc-strip i[data-k="cloudy"]{ --c: #7f8da1; } .fc-strip i[data-k="rain"]{ --c: #3f9bff; }
.fc-strip i[data-k="storm"]{ --c: #a95cff; } .fc-strip i[data-k="snow"]{ --c: #f3f5f9; }
.fc-strip i[data-k="fog"]{ --c: #aeb9c2; background-image: repeating-linear-gradient(135deg, rgba(14,18,26,.45) 0 2px, transparent 2px 5px); }
.fc-axis{ display: flex; justify-content: space-between; font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.forecast[data-k="clear"]{ --fc: #ffcf5c; } .forecast[data-k="cloudy"]{ --fc: #a3b0c2; } .forecast[data-k="rain"]{ --fc: #6db3ff; }
.forecast[data-k="storm"]{ --fc: #c08bff; } .forecast[data-k="snow"]{ --fc: #f3f5f9; } .forecast[data-k="fog"]{ --fc: #cfd8df; }

/* Drops on the camera lens in the rain (js/lens.js): a canvas between the 3D picture and the HUD. */
#lens{ position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#lens[hidden]{ display: none; }

#minimap{
	position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
	width: 190px; height: 190px; background: rgba(14,18,26,.6); border: 1px solid var(--line); border-radius: 4px;
	box-shadow: var(--elev-2);
}
.hud-speed{
	position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
	width: 190px; height: 170px; display: grid; place-items: center;
}
.hud-speed svg{ position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hud-speed .track-arc{ fill: none; stroke: rgba(14,18,26,.75); stroke-width: 12; stroke-linecap: butt; }
.hud-speed .fill-arc{ fill: none; stroke: var(--car); stroke-width: 12; stroke-dasharray: 100 100; stroke-dashoffset: 100; filter: drop-shadow(0 0 6px hsl(var(--hue) 100% 55% / .6)); }
.speed-read{ display: flex; flex-direction: column; align-items: center; margin-top: 16px; line-height: 1; }
.speed-read b{ font-weight: 900; font-style: italic; font-size: 56px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.speed-read span{ font-weight: 700; font-size: 12px; letter-spacing: .2em; color: var(--mute); }
.pos-badge{ position: absolute; right: 0; bottom: -2px; display: flex; align-items: baseline; gap: 2px; padding: 4px 12px; background: var(--chalk); color: #0e1219; transform: skewX(var(--skew)); }
.pos-badge > *{ transform: skewX(calc(var(--skew) * -1)); }
.pos-badge b{ font-weight: 900; font-style: italic; font-size: 28px; line-height: 1; }
.pos-badge span{ font-weight: 700; font-size: 16px; }

/* Slipstream: a meter under the speed and speed lines at the screen edges. */
.draft-meter{
	position: absolute; left: 50%; top: 30px; transform: translateX(-50%);
	display: flex; flex-direction: column-reverse; align-items: center; gap: 3px;
	opacity: 0; transition: opacity .25s var(--ease);
}
.draft-meter.on{ opacity: 1; }
.draft-meter span{ font-weight: 700; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #8fd8ff; }
.draft-meter i{ display: block; width: 86px; height: 5px; background: rgba(14,18,26,.8); overflow: hidden; }
.draft-meter em{ display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #5ec8ff, #d9f3ff); transform-origin: left; transform: scaleX(var(--draft, 0)); }
.draft-fx{
	position: absolute; inset: 0; opacity: 0; pointer-events: none;
	background:
		repeating-linear-gradient(90deg, transparent 0 14px, rgba(220,240,255,.14) 14px 15px, transparent 15px 41px),
		repeating-linear-gradient(90deg, transparent 0 27px, rgba(220,240,255,.08) 27px 28px, transparent 28px 63px);
	-webkit-mask-image: radial-gradient(ellipse 58% 52% at 50% 52%, transparent 55%, #000 100%);
	mask-image: radial-gradient(ellipse 58% 52% at 50% 52%, transparent 55%, #000 100%);
	animation: draft-rush .35s linear infinite;
}
@keyframes draft-rush{ from{ transform: translateY(0); } to{ transform: translateY(24px) scaleY(1.02); } }

.lights{
	position: absolute; top: 14%; left: 50%; transform: translateX(-50%);
	display: flex; gap: 10px; padding: 12px 16px; background: #0b0d12; border-radius: 6px;
	box-shadow: 0 16px 40px rgba(0,0,0,.6), 0 0 0 3px #1b1f28 inset;
}
.light{ display: flex; flex-direction: column; gap: 8px; padding: 8px; background: #151922; border-radius: 4px; }
.lights{ --lt: #ff2432; --lt-off: #2a0c0e; }
.lights[data-theme="amber"]{ --lt: #ffb02e; --lt-off: #2b200a; }
.lights[data-theme="ice"]{ --lt: #5ad7ff; --lt-off: #0c2430; }
.lights[data-theme="green"]{ --lt: #3ddc84; --lt-off: #0c2a1a; }
.lights[data-theme="neon"]{ --lt: #ff3bd8; --lt-off: #2a0c27; }
.lights[data-theme="pumpkin"]{ --lt: #ff7a12; --lt-off: #2a1a0a; }
.light i{ width: 34px; height: 34px; border-radius: 50%; background: var(--lt-off); box-shadow: inset 0 3px 6px rgba(0,0,0,.6); transition: background-color .08s, box-shadow .08s; }
.light.on i{ background: var(--lt); box-shadow: 0 0 22px var(--lt), inset 0 -3px 6px rgba(0,0,0,.3); }
.lights.out{ animation: lights-out .7s .25s both var(--ease); }
@keyframes lights-out{ to{ opacity: 0; transform: translateX(-50%) translateY(-20px); } }

.banner{
	position: absolute; top: 30%; left: 50%; transform: translateX(-50%);
	display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; white-space: nowrap;
}
.banner strong{
	display: inline-block; padding: 8px 26px 4px; font-weight: 900; font-style: italic; text-transform: uppercase;
	font-size: clamp(34px, 6vw, 68px); line-height: 1; letter-spacing: .01em; background: rgba(14,18,26,.88); color: var(--chalk);
	transform: skewX(var(--skew)); box-shadow: var(--elev-3);
}
.banner span{ font-weight: 700; font-size: 20px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 14px; background: rgba(14,18,26,.7); font-variant-numeric: tabular-nums; }
.banner[data-kind="final"] strong{ background: var(--chalk); color: #0e1219; border-bottom: 6px solid transparent; border-image: var(--kerb-stripe) 1; }
.banner[data-kind="wrong"] strong{ background: var(--kerb); }
.banner[data-kind="best"] strong{ background: var(--purple); }
.banner[data-kind="go"] strong{ background: var(--green); color: #07140c; }
.banner[data-kind="finish"] strong{ background: repeating-conic-gradient(#111 0 25%, #f4f4f4 0 50%) 0 0 / 22px 22px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 12px #000; }
.banner[data-kind="out"] strong{ background: #3a3f4c; }
.banner.pop{ animation: pop .5s var(--spring) both; }
@keyframes pop{ from{ opacity: 0; transform: translateX(-50%) scale(.7); } to{ opacity: 1; transform: translateX(-50%) scale(1); } }

#spectating, #hudToast{
	position: absolute; left: 50%; transform: translateX(-50%); padding: 6px 16px; background: rgba(14,18,26,.86);
	font-weight: 700; font-size: 16px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
#spectating{ bottom: max(24px, env(safe-area-inset-bottom)); }
#hudToast{ bottom: max(72px, env(safe-area-inset-bottom)); }
.hud-keys{ position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-family: var(--f-body); font-size: 12px; color: rgba(243,245,249,.55); white-space: nowrap; }
/* Top centre: rear-view mirror with the pause button beside it. The mirror image itself is
   drawn by WebGL underneath; this is only the frame around it. */
.hud-top{
	--mirror-w: clamp(240px, 27vw, 400px);
	position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
	display: flex; align-items: flex-start; gap: 12px;
}
.hud-pause{ pointer-events: auto; }
.mirror{ display: none; }
body.mirror-on .mirror{
	display: block; border: 5px solid #161a22; border-top-color: #232833; border-radius: 12px 12px 18px 18px;
	box-shadow: 0 10px 26px rgba(3,6,12,.45), 0 2px 6px rgba(3,6,12,.35);
}
.mirror-glass{
	width: var(--mirror-w); height: calc(var(--mirror-w) / 4); border-radius: 6px 6px 12px 12px;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 8px 14px -8px rgba(255,255,255,.22);
}
/* Keep the pause button centred when there's no mirror; with one, balance it on the left. */
body.mirror-on .hud-top::before{ content: ""; width: 44px; flex: none; }
body.mirror-on .lights{ top: calc(max(16px, env(safe-area-inset-top)) + var(--mirror-top-h, 125px)); }
/* Delta to the ghost (time trial and weekly challenge), in the mirror's spot. */
.delta{ display: none; }
body.delta-on .delta{ display: grid; justify-items: center; gap: 4px; width: clamp(240px, 24vw, 360px); }
body.delta-on .hud-top::before{ content: ""; width: 44px; flex: none; }
.delta-num{
	padding: 2px 16px 0; font-weight: 900; font-style: italic; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums;
	background: rgba(14,18,26,.86); transform: skewX(var(--skew)); box-shadow: var(--elev-2); color: var(--chalk);
}
.delta[data-state="ahead"] .delta-num{ color: var(--green); }
.delta[data-state="behind"] .delta-num{ color: #ff5a5f; }
.delta-bar{
	position: relative; width: 100%; height: 10px; overflow: hidden; background: rgba(14,18,26,.86);
	transform: skewX(var(--skew)); box-shadow: var(--elev-2);
}
.delta-bar::after{ content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--chalk); }
.delta-fill{ position: absolute; top: 0; bottom: 0; width: 50%; transform: scaleX(0); transition: transform .15s linear; }
.delta-fill.ahead{ right: 50%; transform-origin: right center; background: linear-gradient(90deg, #1f9d5b, var(--green)); }
.delta-fill.behind{ left: 50%; transform-origin: left center; background: linear-gradient(90deg, #ff5a5f, #c81e2b); }
.delta-label{ font-weight: 700; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); text-shadow: 0 1px 3px rgba(0,0,0,.6); }
@media (max-width: 640px){ body.delta-on .delta{ width: 150px; } .delta-num{ font-size: 24px; } body.delta-on .hud-top::before{ display: none; } }
@media (max-width: 900px){ .hud-top{ --mirror-w: 170px; } body.mirror-on .hud-top::before{ display: none; } }
@media (max-width: 640px){ body.mirror-on .mirror{ display: none; } body.mirror-on .hud-top::before{ display: none; } body.mirror-on .lights{ top: 22%; } }

.label{
	position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; padding: 2px 8px 1px 4px;
	background: rgba(14,18,26,.78); border-left: 3px solid var(--c); white-space: nowrap;
	font-family: var(--f-display); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; line-height: 1.2;
	transform-origin: 50% 100%; will-change: transform;
}
.label b{ font-weight: 900; color: var(--mute); }

.touch-zone{ position: fixed; top: 0; bottom: 0; width: 50%; pointer-events: auto; background: transparent; border: 0; }
.touch-zone.left{ left: 0; } .touch-zone.right{ right: 0; }
.touch-zone.active{ background: linear-gradient(90deg, rgba(255,255,255,.06), transparent); }
.touch-zone.right.active{ background: linear-gradient(270deg, rgba(255,255,255,.06), transparent); }

/* ---------- TV coverage ---------- */
#tv{ position: fixed; inset: 0; pointer-events: none; font-family: var(--f-display); z-index: 5; }
.tv-tag{
	position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%) skewX(var(--skew));
	display: flex; align-items: center; gap: 8px; padding: 5px 14px; background: var(--kerb); color: #fff; box-shadow: var(--elev-2);
}
.tv-tag > *{ transform: skewX(calc(var(--skew) * -1)); }
.tv-tag b{ font-weight: 900; font-style: italic; font-size: 18px; letter-spacing: .12em; text-transform: uppercase; }
.tv-tag #tvSub{ font-weight: 600; font-size: 13px; letter-spacing: .06em; opacity: .9; }
.tv-tag #tvSub:empty{ display: none; }
.tv-dot{ width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: tv-blink 1.2s infinite; }
#tv.replay .tv-tag{ background: #2a3344; }
#tv.replay .tv-dot{ background: var(--wall); }
@keyframes tv-blink{ 50%{ opacity: .25; } }
.tv-third{
	position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: 96px; display: flex; align-items: stretch; flex-wrap: wrap; max-width: calc(100% - 48px);
	filter: drop-shadow(0 10px 22px rgba(3,6,12,.55)); animation: third-in .45s var(--spring) both;
}
@keyframes third-in{ from{ opacity: 0; transform: translateX(-24px); } to{ opacity: 1; transform: none; } }
#tv:not(.replay) .tv-third{ bottom: 232px; }
body.tv-on .hud-keys{ display: none; }
.tv-pos{ display: grid; place-items: center; min-width: 54px; padding: 0 10px; background: var(--chalk); color: #0e1219; font-weight: 900; font-style: italic; font-size: 30px; transform: skewX(var(--skew)); }
.tv-pos:empty{ display: none; }
.tv-name{ padding: 6px 22px 4px 16px; background: rgba(14,18,26,.92); border-left: 6px solid var(--c, var(--car)); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 32px; line-height: 1.1; transform: skewX(var(--skew)); }
.tv-event{ flex-basis: 100%; margin-top: 4px; padding: 5px 16px; background: var(--wall); color: #140b05; font-weight: 800; font-size: 18px; letter-spacing: .03em; text-transform: uppercase; transform: skewX(var(--skew)); justify-self: start; width: max-content; max-width: 100%; }
.tv-bar{ position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; pointer-events: auto; max-width: calc(100% - 32px); }
.tv-btn{ height: 38px; padding: 0 12px; }
.tv-replay{ display: flex; align-items: center; gap: 6px; }
.tv-scrub{ width: 240px; }
@media (max-width: 640px){ .tv-name{ font-size: 22px; } .tv-pos{ font-size: 22px; min-width: 40px; } .tv-scrub{ width: 140px; } .tv-third{ bottom: 150px; } #tv:not(.replay) .tv-third{ bottom: 150px; } }

/* ---------- Modals ---------- */
.modal{ position: fixed; inset: 0; display: grid; place-items: center; padding: var(--s4); background: rgba(6,8,12,.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 10; animation: screen-in .25s var(--ease) both; }
.modal .panel{ width: min(520px, 100%); max-height: calc(100% - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); }
.modal h2{ margin: 0; font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 34px; line-height: 1; }
.modal h3{ margin: 0; font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 18px; }
.modal p, .modal li{ font-size: 14px; color: #c8d0dd; margin: 0; }
.modal ul{ margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
kbd{ font-family: var(--f-display); font-weight: 700; font-size: 13px; padding: 1px 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; background: #0d1118; color: var(--chalk); }
.range{ width: 160px; accent-color: var(--car); }
/* The ten-level bot slider: a hard-edged track that fills with your car's colour, and a skewed handle like the timing tower's. */
.level-pick{ display: flex; align-items: center; gap: var(--s2); }
.opt-label.nowrap{ white-space: nowrap; }
.level-pick output{ min-width: 84px; text-align: right; font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 14px; white-space: nowrap; color: var(--chalk); font-variant-numeric: tabular-nums; }
.level-pick .range{ -webkit-appearance: none; appearance: none; width: 116px; height: 26px; background: transparent; cursor: pointer; --fill: 55%; }
.level-pick .range::-webkit-slider-runnable-track{ height: 8px; background: linear-gradient(90deg, var(--car) var(--fill), #2a3243 var(--fill)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.level-pick .range::-moz-range-track{ height: 8px; background: linear-gradient(90deg, var(--car) var(--fill), #2a3243 var(--fill)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.level-pick .range::-webkit-slider-thumb{ -webkit-appearance: none; width: 12px; height: 22px; margin-top: -7px; background: var(--chalk); border: 0; transform: skewX(-12deg); box-shadow: 0 2px 8px rgba(3,6,12,.55), 0 0 0 2px rgba(14,18,26,.9); transition: transform .2s var(--spring); }
.level-pick .range::-moz-range-thumb{ width: 12px; height: 22px; background: var(--chalk); border: 0; border-radius: 0; transform: skewX(-12deg); box-shadow: 0 2px 8px rgba(3,6,12,.55), 0 0 0 2px rgba(14,18,26,.9); }
.level-pick .range:hover::-webkit-slider-thumb{ transform: skewX(-12deg) scaleY(1.12); }
.level-pick .range:active::-webkit-slider-thumb{ transform: skewX(-12deg) scaleY(.94); }
.level-pick .range:focus-visible{ outline: 2px solid var(--chalk); outline-offset: 3px; }

@media (max-width: 900px){
	.title-grid{ grid-template-columns: 1fr; align-items: start; }
	.showcase-tag{ display: none; }
	.title-side{ align-items: stretch; }
	.weekly{ width: 100%; }
	.setup-grid, .lobby-grid, .boards-grid, #boardTracks.boards-grid{ grid-template-columns: 1fr; }
	.you-card{ position: static; }
	.options{ position: static; }
	.online-grid{ grid-template-columns: 1fr; }
}
@media (max-width: 640px){
	.screen{ padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
	.track-grid{ grid-template-columns: repeat(2, 1fr); }
	.tower{ width: 168px; }
	.tower-row{ font-size: 13px; height: 22px; }
	.tower-row:nth-child(n+6){ display: none; }
	.times, .sectors{ display: none; }
	.lap-big b{ font-size: 32px; }
	#minimap{ width: 120px; height: 120px; }
	.hud-speed{ width: 140px; height: 124px; }
	.speed-read b{ font-size: 40px; }
	.lights{ top: 22%; gap: 6px; padding: 8px 10px; }
	.light i{ width: 22px; height: 22px; }
	.hud-keys{ display: none; }
	.podium .block{ font-size: 36px; }
	.race-btn .rb-title{ font-size: 22px; }
}
@media (prefers-reduced-motion: reduce){
	*, *::before, *::after{ animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Hwb account extras */
.acct-card.linked { align-items: flex-start; }
.acct-card.linked div { display: grid; gap: 2px; min-width: 0; }
.acct-card.linked b { overflow-wrap: anywhere; }
.acct-card.linked small { color: var(--mute); font-family: var(--f-body, inherit); font-size: 13px; line-height: 1.5; }
.link-btn{ align-self: flex-start; background: none; border: 0; padding: 0; color: var(--mute); font-size: 13px; text-decoration: underline; cursor: pointer; }
.link-btn:hover{ color: var(--chalk); }
.verify-box{ display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-left: 4px solid #ffcf5c; background: rgba(255,207,92,.08); }
.verify-box .go-btn{ width: auto; font-size: 17px; padding: 10px 14px; }

/* Racing other people's ghosts */
.ghost-cell{ text-align: right; white-space: nowrap; }
.ghost-btn{
	font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
	padding: 4px 10px; color: var(--chalk); background: rgba(169,92,255,.18); border: 1px solid rgba(169,92,255,.55); border-radius: 3px; cursor: pointer;
	transition: transform .2s var(--spring), background-color .2s;
}
.ghost-btn:hover{ background: rgba(169,92,255,.34); transform: translateY(-1px); }
.ghost-btn:active{ transform: translateY(1px) scale(.97); }
.ghost-btn:focus-visible{ outline: 2px solid var(--purple); outline-offset: 2px; }
.label.ghost-label{ opacity: .85; }
.label.ghost-label b{ color: var(--purple); }
.sr-only{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.menu-toast{
	position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
	padding: 10px 18px; max-width: min(560px, calc(100vw - 32px)); background: rgba(14,18,26,.94); border-left: 4px solid var(--purple);
	font-weight: 600; font-size: 15px; box-shadow: var(--elev-3); animation: pop .35s var(--spring) both;
}

#voiceSettings{ display: contents; }
#voiceSettings[hidden]{ display: none; }
/* What the race engineer and the commentators are saying (js/audio.js onCaption, main.js). Radio is green, commentary blue. */
.voice-cap{
	--vc: var(--green);
	position: fixed; left: 50%; bottom: max(64px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45;
	display: flex; align-items: center; gap: 12px; max-width: min(680px, calc(100vw - 32px)); padding: 9px 18px 10px 14px;
	background: rgba(14,18,26,.92); border-left: 3px solid var(--vc); box-shadow: var(--elev-3); pointer-events: none;
	animation: vc-in .22s var(--ease) both;
}
.voice-cap[hidden]{ display: none; }
.voice-cap[data-kind="cast"]{ --vc: var(--start); }
.vc-bars{ flex: none; display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.vc-bars i{ width: 3px; height: 100%; background: var(--vc); transform-origin: bottom; animation: vc-bar .8s ease-in-out infinite; }
.vc-bars i:nth-child(2){ animation-delay: -.25s; } .vc-bars i:nth-child(3){ animation-delay: -.5s; } .vc-bars i:nth-child(4){ animation-delay: -.12s; }
.vc-who{ flex: none; font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--vc); white-space: nowrap; }
.vc-text{ font-weight: 600; font-size: 15px; line-height: 1.35; }
@keyframes vc-bar{ 0%, 100%{ transform: scaleY(.25); } 50%{ transform: scaleY(1); } }
@keyframes vc-in{ from{ opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce){ .vc-bars i{ animation: none; transform: scaleY(.6); } .voice-cap{ animation: none; } }
@media (max-width: 640px){ .voice-cap{ bottom: max(110px, env(safe-area-inset-bottom)); } .vc-who{ display: none; } }

/* Picking a track in a menu: a chip while its preview is being built (see previewTrack in js/main.js). The kerb
   stripes run by transform only, so they keep moving while the page is busy building. */
.track-loading{
	position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 55;
	display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 14px; max-width: calc(100vw - 32px);
	background: rgba(14,18,26,.94); box-shadow: var(--elev-3); pointer-events: none;
	font-weight: 600; font-size: 15px; white-space: nowrap; animation: tl-in .18s var(--ease) both;
}
.track-loading[hidden]{ display: none; }
.track-loading span{ overflow: hidden; text-overflow: ellipsis; }
.tl-kerb{ position: relative; flex: none; width: 38px; height: 10px; overflow: hidden; }
.tl-kerb::before{ content: ""; position: absolute; top: 0; bottom: 0; left: -29px; width: calc(100% + 58px); background: var(--kerb-stripe); animation: tl-run .7s linear infinite; }
@keyframes tl-run{ to{ transform: translateX(28.28px); } }
@keyframes tl-in{ from{ opacity: 0; } }
@media (prefers-reduced-motion: reduce){ .tl-kerb::before{ animation: none; } .track-loading{ animation: none; } }

/* Options with many choices: label above, buttons sharing the full width below. */
.opt-row.stacked{ flex-direction: column; align-items: stretch; gap: 8px; }
.seg.seg-fill{ display: flex; width: 100%; }
.seg.seg-fill button{ flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; }
/* The Layout switch: up to five layouts, wrapping onto a second line on narrow screens. */
.seg.seg-wrap{ flex-wrap: wrap; }
.seg.seg-wrap button{ flex: 1 0 auto; white-space: nowrap; padding-left: 10px; padding-right: 10px; }

/* New version available */
.update-bar{
	position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 70;
	display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; max-width: calc(100vw - 32px);
	background: rgba(14,18,26,.95); border-left: 4px solid var(--green); box-shadow: var(--elev-3);
	font-weight: 600; font-size: 15px; animation: pop .35s var(--spring) both;
}
.update-bar span{ white-space: nowrap; }
.update-bar .go-btn{ flex: none; width: auto; min-width: 0; padding: 6px 16px; min-height: 0; font-size: 15px; }
.tag.old{ background: #ffcf5c; color: #1b1405; }

/* ---------- Room chat ---------- */
.chat-box{ display: flex; flex-direction: column; gap: 8px; padding-top: var(--s3); border-top: 1px solid var(--line); }
.chat-box.is-off .chat-log, .chat-box.is-off .chat-quick, .chat-box.is-off .chat-form{ display: none; }
.chat-note{ letter-spacing: .1em; text-align: right; }
.chat-log{
	list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px;
	height: 190px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
	background: #0d1118; border: 1px solid var(--line); border-radius: 3px;
}
.cm{
	position: relative; display: grid; grid-template-columns: 4px 1fr auto; gap: 8px; align-items: start;
	padding: 5px 8px 5px 6px; border-radius: 2px; font-size: 14px; line-height: 1.45;
	animation: cm-in .32s var(--spring) both;
}
.cm:hover, .cm:focus-within{ background: rgba(255,255,255,.04); }
.cm.mine{ background: hsl(var(--hue) 45% 50% / .1); }
.cm-chip{ width: 4px; height: 15px; margin-top: 3px; border-radius: 1px; }
.cm-body{ min-width: 0; overflow-wrap: anywhere; }
.cm-name{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; font-size: 15px; margin-right: 6px; color: var(--chalk); }
.cm-text{ color: #d3dae6; }
.cm-acts{ display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.cm:hover .cm-acts, .cm:focus-within .cm-acts{ opacity: 1; }
.cm-act{
	width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 2px;
	background: transparent; color: var(--mute); cursor: pointer; transition: color .15s, background-color .15s, transform .2s var(--spring);
}
.cm-act svg{ width: 15px; height: 15px; }
.cm-act:hover{ color: var(--chalk); background: rgba(255,255,255,.08); }
.cm-act:active{ transform: scale(.88); }
.cm-act:focus-visible, .chat-chip:focus-visible, .chat-send:focus-visible, .chat-toggle:focus-visible, .mute-btn:focus-visible{ outline: 2px solid var(--car); outline-offset: 2px; }
.cm-empty{ color: var(--dim); font-size: 13px; padding: 6px; }
@keyframes cm-in{ from{ opacity: 0; transform: translateY(6px); } to{ opacity: 1; transform: none; } }
.chat-quick{ display: flex; flex-wrap: wrap; gap: 4px; }
.chat-chip{
	border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--chalk); border-radius: 999px; padding: 4px 10px; cursor: pointer;
	font-family: var(--f-body); font-weight: 600; font-size: 12px; line-height: 1.3;
	transition: transform .2s var(--spring), background-color .15s, border-color .15s;
}
.chat-chip:hover{ transform: translateY(-1px); background: var(--panel-3); border-color: var(--car); }
.chat-chip:active{ transform: scale(.94); }
.chat-chip:disabled, .chat-send:disabled{ opacity: .4; cursor: not-allowed; transform: none; }
.chat-form{ display: flex; gap: 6px; }
.chat-form[hidden]{ display: none; }
.chat-input{ font-family: var(--f-body); font-size: 15px; font-weight: 500; letter-spacing: 0; padding: 8px 10px; }
.chat-send{
	flex: none; border: 0; cursor: pointer; padding: 0 16px; border-radius: 3px;
	background: linear-gradient(100deg, var(--wall), var(--wall-deep)); color: #140b05;
	font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 17px; letter-spacing: .03em;
	box-shadow: 0 6px 16px -8px rgba(244,131,66,.55); transition: transform .2s var(--spring), filter .15s;
}
.chat-send:hover{ transform: translateY(-1px); filter: brightness(1.08); }
.chat-send:active{ transform: scale(.95); }
.chat-err{ margin: 0; font-size: 13px; line-height: 1.4; color: #ffcf5c; }
.mute-btn{
	border: 1px solid var(--line); background: transparent; color: var(--mute); border-radius: 3px; padding: 5px 8px; cursor: pointer;
	font-family: var(--f-display); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px;
	transition: color .15s, background-color .15s, transform .2s var(--spring);
}
.mute-btn:hover{ color: var(--chalk); background: rgba(255,255,255,.06); }
.mute-btn:active{ transform: scale(.94); }
.mute-btn.on{ color: #ffcf5c; border-color: rgba(255,207,92,.4); }

/* In a race: a few recent lines above the minimap that fade away; Enter opens the box. */
.chat-float{
	position: fixed; z-index: 25; left: max(16px, env(safe-area-inset-left)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 206px);
	width: 320px; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.chat-float[hidden]{ display: none; }
.chat-panel{ display: flex; flex-direction: column; gap: 6px; }
.chat-toggle{ display: none; }
.chat-float[data-mode="race"] .chat-log{ height: auto; max-height: 190px; background: none; border: 0; padding: 0; overflow: hidden; gap: 3px; }
.chat-float[data-mode="race"] .cm{ background: rgba(14,18,26,.8); box-shadow: 0 6px 16px -10px rgba(3,6,12,.8); }
.chat-float[data-mode="race"] .cm.mine{ background: hsl(var(--hue) 60% 18% / .88); }
.chat-float[data-mode="race"] .cm.fade{ animation: cm-in .32s var(--spring) both, cm-out 9s linear both; }
@keyframes cm-out{ 0%, 80%{ opacity: 1; } 100%{ opacity: 0; } }
.chat-float .chat-form, .chat-float .chat-err, .chat-float .chat-quick, .chat-float .chat-toggle, .chat-float .cm-acts{ pointer-events: auto; }
.chat-float .chat-err{ background: rgba(14,18,26,.9); padding: 4px 8px; }
.chat-hint{ margin: 0; font-size: 12px; color: rgba(243,245,249,.5); }
.chat-hint[hidden]{ display: none; }

/* On the results screen: a dock in the corner that opens and closes. */
.chat-float[data-mode="results"]{ bottom: max(16px, env(safe-area-inset-bottom)); width: 300px; pointer-events: auto; }
.chat-float[data-mode="results"] .chat-toggle{
	display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer;
	background: rgba(14,18,26,.94); color: var(--chalk); border: 1px solid var(--line-strong); border-left: 4px solid var(--car); border-radius: 3px;
	font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 15px;
	box-shadow: var(--elev-2); transition: transform .2s var(--spring), background-color .15s;
}
.chat-float[data-mode="results"] .chat-toggle:hover{ transform: translateY(-2px); background: var(--panel-2); }
.chat-float[data-mode="results"] .chat-toggle:active{ transform: scale(.96); }
.chat-toggle svg{ width: 16px; height: 16px; color: var(--car); }
.chat-float[data-mode="results"] .chat-panel{
	order: -1; padding: 10px; background: rgba(17,21,30,.95); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--elev-3);
	transform-origin: bottom left; transition: transform .28s var(--spring), opacity .18s;
}
.chat-float[data-mode="results"]:not(.open) .chat-panel{ opacity: 0; transform: translateY(10px) scale(.96); pointer-events: none; visibility: hidden; }
.chat-float[data-mode="results"] .chat-log{ height: 220px; }
@media (max-width: 640px){
	.chat-float{ width: calc(100vw - 32px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 136px); }
	.chat-float[data-mode="results"]{ width: calc(100vw - 32px); }
	.chat-log{ height: 160px; }
}

/* ---- FPS counter (Settings > FPS counter; js/gfx.js) ---- */
.fps-box{
	position: fixed; left: 16px; bottom: 222px; z-index: 40; pointer-events: none;
	padding: 6px 10px 7px; min-width: 190px; border-radius: 8px;
	font: 600 11px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; color: rgba(243,245,249,.78);
	background: rgba(10,13,20,.72); border: 1px solid rgba(255,255,255,.09);
	box-shadow: 0 6px 18px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.05) inset;
}
.fps-box .fps-big{ font-size: 18px; letter-spacing: .02em; color: #7be38a; margin-right: 8px; }
.fps-box.slow .fps-big{ color: #ffb454; }
.fps-box .fps-ms{ font-size: 11px; color: rgba(243,245,249,.6); }
.fps-box .fps-row{ white-space: nowrap; }
.fps-box .fps-gpu{ color: rgba(243,245,249,.45); max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px){ .fps-box{ bottom: auto; top: 54px; left: 8px; } }

/* ---------- Big screen: a projector or TV (Online > Big screen, or ?tv=CODE; see main.js joinAsBigScreen) ---------- */
.bigtv{
	display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: clamp(20px, 3vw, 56px) clamp(32px, 5vw, 96px);
	height: 100%; padding: clamp(24px, 4vw, 72px); align-content: start;
}
.bigtv-head{ grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s5); }
.bigtv-code{
	font-family: var(--f-display); font-weight: 900; font-style: italic; font-size: clamp(80px, 14vw, 240px); line-height: .86; letter-spacing: .1em; color: var(--chalk);
	text-shadow: 0 0 60px hsl(var(--hue) 100% 55% / .4); padding-bottom: .08em; background: var(--kerb-stripe) bottom / 100% 8px no-repeat;
}
.bigtv-next{ display: flex; flex-direction: column; gap: var(--s3); align-self: center; }
.bigtv-track{ font-family: var(--f-display); font-weight: 900; font-style: italic; text-transform: uppercase; font-size: clamp(44px, 6.4vw, 110px); line-height: .95; letter-spacing: -.02em; }
.bigtv-sub{ font-size: clamp(18px, 2vw, 34px); font-weight: 600; color: var(--mute); letter-spacing: .01em; }
.bigtv-status{ display: flex; align-items: center; gap: 16px; margin: var(--s4) 0 0; font-size: clamp(16px, 1.6vw, 26px); font-weight: 600; color: var(--chalk); }
.bigtv-status .tl-kerb{ width: 62px; height: 14px; }
.bigtv-sound{ margin: 0; font-size: clamp(14px, 1.3vw, 22px); color: #ffcf5c; font-weight: 600; }
.bigtv-roster{ list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; align-content: start; align-self: center; }
.bigtv-roster li{
	display: grid; grid-template-columns: 10px 1fr auto; gap: 14px; align-items: center; padding: 10px 16px 10px 12px;
	background: rgba(23, 28, 38, .86); border: 1px solid var(--line); box-shadow: var(--elev-2); animation: bt-in .4s var(--ease) both;
}
.bigtv-roster .chip{ width: 10px; height: 38px; border-radius: 1px; }
.bigtv-roster .bt-name{ font-family: var(--f-display); font-weight: 800; text-transform: uppercase; font-size: clamp(18px, 2vw, 36px); line-height: 1.05; overflow-wrap: anywhere; }
.bigtv-roster .bt-car{ display: block; font-family: var(--f-body); font-weight: 500; font-size: clamp(12px, 1vw, 17px); color: var(--mute); text-transform: none; }
.bigtv-roster .tag{ font-size: clamp(12px, 1vw, 17px); }
@keyframes bt-in{ from{ opacity: 0; transform: translateY(10px); } }
@media (max-width: 900px){ .bigtv{ grid-template-columns: 1fr; } .bigtv-roster{ grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce){ .bigtv-roster li{ animation: none; } }

/* On the big screen the race is a broadcast: no driving instruments, a bigger timing tower, subtitles and lap counter. */
body.bigtv .hud-speed, body.bigtv .hud-keys, body.bigtv .hud-pause, body.bigtv #mirror, body.bigtv .delta, body.bigtv .sectors, body.bigtv .times dt:nth-of-type(n+2), body.bigtv .times dd:nth-of-type(n+2){ display: none !important; }
body.bigtv .tower{ width: 330px; gap: 3px; transform: scale(1.5); transform-origin: top left; }
body.bigtv .hud-lap{ transform: scale(1.5); transform-origin: top right; }
body.bigtv #minimap{ width: 260px; height: 260px; left: auto; right: max(24px, env(safe-area-inset-right)); }
body.bigtv .chat-float, body.bigtv .fps-box{ display: none !important; }
body.bigtv #tv:not(.replay) .tv-bar{ display: none; }
body.bigtv #tv:not(.replay) .tv-third{ bottom: 150px; transform: scale(1.3); transform-origin: bottom left; }
body.bigtv .tv-tag{ transform: translateX(-50%) skewX(var(--skew)) scale(1.4); transform-origin: top center; }
body.bigtv .voice-cap{ bottom: max(40px, env(safe-area-inset-bottom)); max-width: min(1100px, calc(100vw - 64px)); padding: 14px 28px 16px 20px; }
body.bigtv .vc-text{ font-size: clamp(20px, 2vw, 32px); }
body.bigtv .vc-who{ font-size: clamp(13px, 1.1vw, 18px); }
body.bigtv .vc-bars{ height: 26px; } body.bigtv .vc-bars i{ width: 4px; }
body.bigtv .results, body.bigtv .results td, body.bigtv .results th{ font-size: clamp(16px, 1.6vw, 28px); }
