/* Superb Rush UI: supermarket vernacular. Shelf price tag for the score, promo sticker for the
   multiplier, a thermal till slip for the result. Mobile first, thumbs at the bottom. */
:root {
	--navy: #273978;
	--navy-deep: #18244f;
	--red: #ed1c24;
	--red-deep: #a8121a;
	--promo: var(--wacky-gold); /* every yellow in the UI is the Wacky Weekend soft gold */
	--promo-deep: #b0913f;
	--wacky-gold: #e3bf55; /* Wacky Weekend: Superb navy with a soft gold, never red with yellow */
	--paper: #fdfdfb;
	--ink: #1b1940;
	--muted: #63617f;
	--display: 'Bricolage Grotesque', system-ui, sans-serif;
	--till: 'Courier Prime', 'Courier New', monospace;
	--top: max(12px, env(safe-area-inset-top));
	--bottom: max(14px, env(safe-area-inset-bottom));
	color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: #d4efff;
	font-family: var(--display);
	color: var(--ink);
	-webkit-tap-highlight-color: transparent;
	-webkit-text-size-adjust: 100%; /* iOS: no text inflation on rotate */
	-webkit-user-select: none; user-select: none; /* Safari only knows the prefixed one */
	-webkit-touch-callout: none; /* iOS: no long-press menu or magnifier mid-run */
	touch-action: none;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--promo); outline-offset: 2px; }
[hidden] { display: none !important; }

#loading {
	position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; gap: 14px;
	align-items: center; justify-content: center; background: var(--navy); color: #fff; font-weight: 700;
}
#loading img { width: 72px; height: 72px; border-radius: 14px; animation: nod 1s ease-in-out infinite alternate; }
@keyframes nod { to { transform: rotate(-8deg) scale(1.06); } }
#load-progress { position: absolute; right: 14px; bottom: var(--bottom); font-size: 0.75rem; font-weight: 600; opacity: 0.7; font-variant-numeric: tabular-nums; }
body.ready #loading { display: none; }

/* ---------- buttons ---------- */
.cta {
	display: block; width: 100%; min-height: 60px; border-radius: 16px;
	background: var(--red); color: #fff;
	font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em;
	box-shadow: 0 5px 0 var(--red-deep);
	transition: transform 0.08s, box-shadow 0.08s;
}
.cta:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-deep); }
.ghost { min-height: 48px; padding: 0 16px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

/* score: Superb navy shelf price tag with a punched hole */
.tag {
	position: absolute; left: 14px; top: var(--top);
	min-width: 128px; padding: 6px 16px 6px 30px;
	color: #fff; isolation: isolate;
	font-weight: 800; font-size: 2.3rem; line-height: 1.05; font-variant-numeric: tabular-nums;
	font-variation-settings: 'wdth' 75, 'opsz' 96;
}
/* the tag (with its punched hole) and its shadow are two layers behind the score, not a drop-shadow filter:
   phones redraw a filtered element every frame, which cost a Galaxy A07 about 10 fps across the HUD */
.tag::before, .tag::after {
	content: ''; position: absolute; inset: 0; z-index: -1;
	border-radius: 6px 10px 10px 6px; clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
}
.tag::before { background: rgba(24, 36, 79, 0.35); transform: translateY(3px); }
.tag::after { background: radial-gradient(circle at 17px 50%, var(--navy-deep) 4px, transparent 4.5px), var(--navy); }

/* multiplier: white promo sticker with a navy dashed ring, overlapping the tag */
.sticker {
	position: absolute; left: 112px; top: calc(var(--top) + 38px);
	display: grid; place-items: center; width: 64px; height: 64px;
	background: #fff; color: var(--navy); border-radius: 50%;
	border: 3px dashed var(--navy); outline: 3px solid #fff;
	font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums;
	font-variation-settings: 'wdth' 75;
	transform: rotate(-12deg);
	box-shadow: 0 3px 0 rgba(24, 36, 79, 0.35);
}

/* products: a navy Superb hand basket with a black handle. What you just picked up drops in and peeks over the rim;
   the count sits on the basket's front plate. Layers: handle, products, basket. */
.basket { position: absolute; right: 64px; top: calc(var(--top) + 8px); width: 96px; height: 74px; isolation: isolate; }
.basket::before {
	content: ''; position: absolute; left: 16px; right: 16px; top: -10px; height: 56px;
	border: 4px solid #000; border-bottom: 0; border-radius: 32px 32px 0 0 / 30px 30px 0 0;
}
.spill canvas {
	--r: 0deg;
	position: absolute; bottom: 28px; width: 34px; height: 34px; opacity: 0;
	transform: rotate(var(--r)); /* shadow drawn into the canvas (drawThumb) */
}
.spill canvas:nth-child(1) { left: 8px; --r: -16deg; }
.spill canvas:nth-child(2) { left: 52px; --r: 14deg; }
.spill canvas:nth-child(3) { left: 30px; --r: -4deg; bottom: 31px; }
.spill canvas:nth-child(4) { left: 42px; --r: 24deg; }
.spill canvas.in { opacity: 1; }
.spill canvas.drop, .spill canvas.drop2 { animation: drop 0.34s cubic-bezier(0.3, 1.4, 0.6, 1); }
.spill canvas.drop2 { animation-name: drop2; } /* each class + '2' is a twin: replay() in game.js swaps to it to restart a running one */
@keyframes drop { from { opacity: 0; transform: translateY(-34px) rotate(var(--r)) scale(1.3); } 30% { opacity: 1; } }
@keyframes drop2 { from { opacity: 0; transform: translateY(-34px) rotate(var(--r)) scale(1.3); } 30% { opacity: 1; } }

.crate { position: absolute; left: 0; bottom: 0; width: 96px; height: 44px; transform-origin: 50% 100%; }
.crate svg { display: block; width: 100%; height: 100%; overflow: visible; } /* the shadow is a shape in the svg */
.crate.catch, .crate.catch2 { animation: catch 0.26s ease-out; }
.crate.catch2 { animation-name: catch2; }
@keyframes catch { 35% { transform: translateY(3px) scale(1.04, 0.92); } }
@keyframes catch2 { 35% { transform: translateY(3px) scale(1.04, 0.92); } }
#items {
	position: absolute; left: 26px; width: 44px; top: 13px; text-align: center;
	color: var(--navy); font-weight: 800; font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums;
	font-variation-settings: 'wdth' 75, 'opsz' 48;
}

#pause {
	pointer-events: auto; position: absolute; right: 12px; top: var(--top);
	display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
	background: var(--navy); color: #fff; box-shadow: 0 3px 0 var(--navy-deep);
}
#pause svg { width: 22px; fill: currentColor; }

.bump, .bump2 { animation: bump 0.32s cubic-bezier(0.3, 1.8, 0.5, 1); }
.sticker.bump, .sticker.bump2 { animation: stickerBump 0.4s cubic-bezier(0.3, 1.8, 0.5, 1); }
.bump2 { animation-name: bump2; }
.sticker.bump2 { animation-name: stickerBump2; }
@keyframes bump { 40% { transform: scale(1.3); } }
@keyframes bump2 { 40% { transform: scale(1.3); } }
@keyframes stickerBump { 40% { transform: rotate(-4deg) scale(1.25); } }
@keyframes stickerBump2 { 40% { transform: rotate(-4deg) scale(1.25); } }

#floaters i {
	position: absolute; right: 150px; top: calc(var(--top) + 42px); opacity: 0; /* beside the basket, clear of the count */
	font-style: normal; font-weight: 800; font-size: 1.1rem; color: var(--promo);
	-webkit-text-stroke: 1.5px var(--navy); paint-order: stroke fill; text-shadow: 0 2px 0 var(--navy);
}
#floaters i.go, #floaters i.go2 { animation: rise 0.7s ease-out; }
#floaters i.go2 { animation-name: rise2; }
@keyframes rise { 0% { opacity: 1; transform: translate(0, 0) scale(0.8); } 100% { opacity: 0; transform: translate(-12px, -36px) scale(1.15); } }
@keyframes rise2 { 0% { opacity: 1; transform: translate(0, 0) scale(0.8); } 100% { opacity: 0; transform: translate(-12px, -36px) scale(1.15); } }

/* shopping list: a slip of paper under the basket, opens when it changes, tap to peek */
.list {
	pointer-events: auto; position: absolute; right: 12px; top: calc(var(--top) + 88px); width: 168px;
	padding: 8px 10px; background: var(--paper); color: var(--ink); border-radius: 4px;
	font-family: var(--till); font-size: 0.82rem; line-height: 1.3;
	box-shadow: 0 3px 0 rgba(24, 36, 79, 0.35); transform: rotate(1.5deg); transform-origin: top right;
	transition: width 0.25s ease-out;
}
.list header { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; white-space: nowrap; }
.list ul { list-style: none; margin: 0; padding: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.list.open { width: 220px; }
.list.open ul { max-height: 120px; margin-top: 6px; border-top: 1px dashed #b9b8c8; padding-top: 4px; }
.list li { display: flex; justify-content: space-between; gap: 8px; }
.list li.done span { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.list li.done b { color: var(--red); }

/* power-ups: icon with a draining ring */
.powers { position: absolute; left: 14px; top: calc(var(--top) + 112px); display: flex; flex-direction: column; gap: 8px; }
.power {
	--left: 1;
	display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%;
	background: conic-gradient(var(--promo) calc(var(--left) * 360deg), rgba(255, 255, 255, 0.35) 0);
	color: var(--navy);
}
.power svg { width: 40px; height: 40px; padding: 7px; border-radius: 50%; background: #fff; }
#pw-rocket { color: var(--red); }
#pw-fuel { color: #179a52; }
.power.ending { animation: blink 0.25s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

#hint {
	position: absolute; left: 50%; bottom: calc(var(--bottom) + 18px); margin: 0;
	padding: 12px 20px; border-radius: 999px; white-space: nowrap;
	background: #fff; color: var(--navy); font-weight: 800; font-size: 1.15rem;
	box-shadow: 0 4px 0 var(--navy);
	transform: translateX(-50%);
	animation: hintIn 0.25s ease-out, hintNudge 0.9s ease-in-out 0.25s infinite;
}
#hint[data-kind='barrier']::after { content: ' ↑'; }
#hint[data-kind='banner']::after { content: ' ↓'; }
#hint[data-kind='truck']::after { content: ' ←→'; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes hintNudge { 50% { transform: translate(-50%, -5px); } }

#toast {
	position: fixed; left: 50%; top: 30%; z-index: 3; pointer-events: none; opacity: 0; white-space: nowrap;
	font-weight: 800; font-size: clamp(2rem, 11vw, 3.6rem); letter-spacing: -0.02em; color: #fff;
	-webkit-text-stroke: 2px var(--navy); paint-order: stroke fill;
	text-shadow: 0 5px 0 var(--navy);
	transform: translate(-50%, -50%);
}
#toast.pop { animation: pop 1.3s ease-out; }
#toast.warn, #toast.rocket { color: var(--promo); }
#toast.discount { color: #fff; -webkit-text-stroke-color: var(--red); text-shadow: 0 5px 0 var(--red); }
#toast.fuel { color: #6ff0a4; }
#toast.count { font-size: clamp(4rem, 24vw, 7rem); top: 42%; }
#toast.milestone, #toast.combo { font-size: clamp(1.4rem, 7vw, 2.4rem); top: 22%; }
@keyframes pop {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
	14% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
	26% { transform: translate(-50%, -50%) scale(1) rotate(0); }
	78% { opacity: 1; }
	100% { opacity: 0; transform: translate(-50%, -75%); }
}

/* grabbed special: a white, Superb-blue-edged shelf price rail along the bottom, the product standing on it */
.ticker {
	position: absolute; left: 12px; right: 12px; bottom: var(--bottom);
	display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 8px; height: 60px;
	background: #fff; color: var(--navy); border: 3px solid var(--navy); border-radius: 8px; box-shadow: 0 4px 0 var(--navy-deep);
	transform: translateY(calc(100% + var(--bottom) + 40px)); transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.ticker.in { transform: none; }
.ticker canvas { position: static; width: 74px; height: 74px; align-self: end; margin: 0 0 5px 2px; }
.ticker p { margin: 0; min-width: 0; align-self: center; }
.ticker small { display: block; color: var(--red); font-size: 0.75rem; font-weight: 700; line-height: 1.1; }
.ticker p > span { display: block; overflow: hidden; mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent); }
#ticker-name { display: inline-block; white-space: nowrap; font-size: 1.15rem; font-weight: 700; line-height: 1.35; }
/* the notched ticket of the score, in Superb red */
.ticker .ticker-price {
	align-self: stretch; display: grid; align-content: center; justify-items: end; padding: 0 12px 0 20px;
	background: var(--red); color: #fff; border-radius: 0 4px 4px 0;
	clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
	font-variant-numeric: tabular-nums;
}
.ticker-price s { font-size: 0.78rem; opacity: 0.8; }
#ticker-price { font-size: 1.7rem; font-weight: 800; line-height: 1; font-variation-settings: 'wdth' 75, 'opsz' 96; }
/* Wacky Weekend: navy and soft gold, like its tags on the road */
.ticker.weekend { background: var(--navy); color: #fff; box-shadow: 0 4px 0 var(--navy-deep); }
.ticker.weekend small { color: var(--wacky-gold); }
.ticker.weekend .ticker-price { background: var(--wacky-gold); color: var(--navy); }
.ticker.weekend .ticker-price s { color: var(--navy-deep); opacity: 0.65; }
.ticker.in ~ #hint { bottom: calc(var(--bottom) + 92px); }

/* live road: other drivers near you as a small navy chip (green dot while any drive right now), and overtakes
   as a quiet pill where the hints sit, never the big toast */
.nearby {
	align-self: flex-start; display: flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
	background: var(--navy); color: #fff; font-size: 0.8rem; font-weight: 700; line-height: 1.2; white-space: nowrap;
	box-shadow: 0 2px 0 var(--navy-deep);
}
.nearby.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; }
#pass {
	position: absolute; left: 50%; bottom: calc(var(--bottom) + 22px); margin: 0;
	padding: 6px 14px; border-radius: 999px; white-space: nowrap;
	background: var(--navy); color: #fff; font-weight: 700; font-size: 0.95rem; box-shadow: 0 3px 0 var(--navy-deep);
	opacity: 0; transform: translate(-50%, 8px); transition: opacity 0.25s, transform 0.25s;
}
#pass.on { opacity: 1; transform: translateX(-50%); }
.ticker.in ~ #pass { bottom: calc(var(--bottom) + 92px); }
#hint:not([hidden]) ~ #pass { bottom: calc(var(--bottom) + 82px); } /* sits above a hint rather than skipping */
.ticker.in ~ #hint:not([hidden]) ~ #pass { bottom: calc(var(--bottom) + 156px); }

/* Wacky Weekend sash: sweeps across the sky once per run, letters jostling like a hand-cut shop poster */
.wacky {
	--zig: 12px;
	position: absolute; left: -10%; right: -10%; top: calc(var(--top) + 150px);
	display: grid; justify-items: center; padding: 14px 0 16px;
	background: var(--navy); color: var(--wacky-gold);
	mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / var(--zig) 51% repeat-x,
		conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--zig) 51% repeat-x;
	transform: rotate(-4deg) translateX(-120%);
}
.wacky.go { animation: sash 2.8s both; }
@keyframes sash {
	0% { transform: rotate(-4deg) translateX(-120%); animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1.1); }
	15%, 82% { transform: rotate(-4deg) translateX(0); animation-timing-function: cubic-bezier(0.6, 0, 0.9, 0.4); }
	100% { transform: rotate(-4deg) translateX(120%); }
}
.wacky b { font-size: clamp(2rem, 11vw, 3.2rem); font-weight: 800; line-height: 1; text-shadow: 0 4px 0 var(--navy-deep); }
.wacky i { --t: -7deg; display: inline-block; font-style: normal; transform: rotate(var(--t)); }
.wacky i:nth-child(even) { --t: 6deg; translate: 0 3px; }
.wacky i:nth-child(3n) { --t: -2deg; translate: 0 -2px; }
.wacky.go i { animation: jostle 0.32s steps(1) infinite; }
.wacky.go i:nth-child(even) { animation-delay: -0.16s; }
@keyframes jostle { 50% { transform: rotate(calc(var(--t) * -1)); } }
body:has(.wacky.go) #toast { top: 46%; } /* toasts drop below the sash while it is up */
.wacky span { margin-top: 4px; color: #fff; font-family: var(--till); font-weight: 700; font-size: 0.95rem; }

/* power-up edge glows: cyan for the magnet, gold for double points (they stack) */
#aura { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#aura::before, #aura::after { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s; }
#aura::before { box-shadow: inset 0 0 70px 10px rgba(41, 182, 255, 0.6); }
#aura::after { box-shadow: inset 0 0 70px 6px rgba(255, 196, 0, 0.6); background: radial-gradient(ellipse at 50% 0%, rgba(255, 210, 31, 0.18), transparent 55%); }
body.fx-magnet #aura::before { opacity: 1; animation: auraPulse 0.9s ease-in-out infinite; }
body.fx-double #aura::after { opacity: 1; animation: auraPulse 0.7s ease-in-out infinite; }
body.fx-magnet-ending #aura::before, body.fx-double-ending #aura::after { animation: blink 0.25s steps(2) infinite; }
@keyframes auraPulse { 50% { opacity: 0.45; } }
body.rush #aura { box-shadow: inset 0 0 60px 6px rgba(237, 28, 36, 0.55); animation: auraPulse 0.5s ease-in-out infinite; }
#toast.rush { color: var(--promo); -webkit-text-stroke-color: var(--red); text-shadow: 0 5px 0 var(--red); }
#toast.listdone { color: #fff; -webkit-text-stroke-color: var(--red); text-shadow: 0 5px 0 var(--red); }

/* HUD tells too: the basket glows while the magnet pulls, the price tag wears a x2 badge */
/* the magnet glow is a gradient behind the basket, not a drop-shadow filter (see .tag) */
.basket::after { content: ''; position: absolute; inset: -14px -10px -6px; z-index: -1; border-radius: 50%; background: radial-gradient(closest-side, rgba(41, 182, 255, 0.75), transparent); opacity: 0; transition: opacity 0.2s; }
body.fx-magnet .basket::after { opacity: 1; }
body.fx-magnet .basket { animation: wobble 0.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.x2 {
	position: absolute; left: 124px; top: calc(var(--top) - 8px); z-index: 1; display: none; padding: 2px 7px; border-radius: 8px;
	background: var(--red); color: #fff; font-size: 1rem; line-height: 1.2; transform: rotate(10deg);
	box-shadow: 0 2px 0 var(--red-deep);
}
body.fx-double .x2 { display: block; animation: x2 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) infinite alternate; }
body.fx-double-ending .x2 { animation: blink 0.25s steps(2) infinite; }
@keyframes x2 { to { transform: rotate(-6deg) scale(1.2); } }
#floaters i.doubled { color: #fff; -webkit-text-stroke: 1px var(--red); font-size: 1.35rem; }

/* navy vignette while driving, closing in with speed (game.js sets --speed 0..1): framing the road for no 3D cost */
#vignette {
	position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 0.4s;
	background: radial-gradient(ellipse 80% 70% at 50% 52%, transparent 50%, rgba(8, 18, 61, 0.5));
}
body[data-mode='play'] #vignette, body[data-mode='paused'] #vignette { opacity: calc(0.45 + 0.55 * var(--speed, 0)); }

/* wind streaks above ~30 m/s: short white dashes radiating from the road's vanishing point, clear of the car and centre road. Two full-screen
   images (game.js draws them: conic wedges cut into dashes, cleared in the middle) just scale outward from that point: transform/opacity only */
#vignette::before, #vignette::after {
	content: ''; position: fixed; inset: 0; display: none; will-change: transform, opacity; transform-origin: 50% 30%;
	background: var(--streak-a) 0 0 / 100% 100%;
	animation: wind calc(0.8s - 0.4s * var(--speed, 0)) linear infinite;
}
#vignette::after {
	background-image: var(--streak-b);
	animation-delay: calc(-0.4s + 0.2s * var(--speed, 0));
}
body[data-mode='play'] #vignette.windy::before, body[data-mode='play'] #vignette.windy::after { display: block; } /* .windy: game.js, once --wind is above 0 */
@keyframes wind { 0% { transform: scale(1); opacity: 0; } 20% { opacity: var(--wind, 0); } 70% { opacity: var(--wind, 0); } 100% { transform: scale(1.7); opacity: 0; } }
#vignette { --wind: clamp(0, (var(--speed, 0) - 0.5) * 4, 0.9); }
@media (prefers-reduced-motion: reduce) { #vignette::before, #vignette::after { display: none !important; } }

/* rain on the lens (game.js sets --rain 0..1 and unhides): drops and streaks sliding down the glass, kept faint so obstacles stay readable */
body.lite #lens, body.lite #vignette::before, body.lite #vignette::after { display: none !important; }
#lens { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; opacity: calc(0.3 + 0.6 * var(--rain, 0)); }
#lens::before, #lens::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 200vh; will-change: transform; }
#lens::before {
	background:
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.55) 0 1px, rgba(210, 225, 255, 0.2) 2px, transparent 4px) 0 0 / 97px calc(100vh / 5),
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.5) 0 1.5px, rgba(210, 225, 255, 0.18) 3px, transparent 5px) 31px 17px / 141px calc(100vh / 4),
		radial-gradient(ellipse 5px 7px at 50% 50%, rgba(255, 255, 255, 0.35) 0 2px, rgba(210, 225, 255, 0.15) 4px, transparent 7px) 73px 40px / 183px calc(100vh / 3),
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.4) 0 0.5px, transparent 2px) 12px 9px / 59px calc(100vh / 8);
	animation: lens 24s linear infinite;
}
#lens::after {
	background:
		linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)) 18% 0 / 2px calc(100vh / 6) repeat-y,
		linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.35)) 47% 0 / 2px calc(100vh / 4) repeat-y,
		linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4)) 71% 0 / 2px calc(100vh / 5) repeat-y,
		linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.35)) 92% 0 / 1px calc(100vh / 3) repeat-y;
	animation: lens 6s linear infinite;
}
@keyframes lens { from { transform: translateY(-100vh); } }

/* rocket speed lines + pickup flash */
#speedlines {
	position: fixed; inset: -20%; z-index: 1; pointer-events: none; opacity: 0;
	background: repeating-conic-gradient(from 0deg at 50% 42%, rgba(200, 238, 255, 0.8) 0 0.7deg, transparent 0.7deg 4.5deg);
	-webkit-mask: radial-gradient(circle at 50% 42%, transparent 16%, #000 58%);
	mask: radial-gradient(circle at 50% 42%, transparent 16%, #000 58%);
	transition: opacity 0.4s;
}
/* deep-blue vignette framing the tunnel */
#speedlines::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 42%, transparent 30%, rgba(8, 18, 61, 0.75) 78%); }
body.boosting #speedlines { opacity: 0.85; animation: rush 0.1s linear infinite; }
@keyframes rush { 50% { transform: scale(1.06) rotate(2deg); } }
body::after { content: ''; position: fixed; inset: 0; z-index: 4; pointer-events: none; background: #fff; opacity: 0; } /* game.js flash() */

/* ---------- menu sheet ---------- */
.sheet {
	position: fixed; left: 50%; bottom: 0; z-index: 3; transform: translateX(-50%);
	width: min(100%, 460px); max-height: 66vh; overflow-y: auto; touch-action: pan-y;
	padding: 20px 16px var(--bottom);
	background: var(--navy); color: #fff;
	border-radius: 26px 26px 0 0;
	box-shadow: 0 -10px 40px rgba(24, 36, 79, 0.35);
	animation: sheetIn 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes sheetIn { from { transform: translate(-50%, 40%); } }

.brand { margin-bottom: 16px; }
.brand .wordmark { display: block; width: 168px; height: auto; margin-bottom: 8px; }
h1 { margin: 0; font-size: 2.5rem; font-weight: 800; line-height: 0.95; letter-spacing: -0.035em; font-variation-settings: 'opsz' 96; }
.brand p { margin: 4px 0 0; font-size: 0.98rem; font-weight: 500; opacity: 0.85; line-height: 1.3; }

/* local weather: a small forecast strip under the title */
.weather {
	display: flex; align-items: center; gap: 10px; min-height: 48px; margin: -4px 0 14px; padding: 6px 6px 6px 12px;
	border-radius: 12px; background: rgba(255, 255, 255, 0.1);
}
.weather p { flex: 1; margin: 0; font-size: 0.92rem; font-weight: 600; line-height: 1.25; }
.weather button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 10px; background: var(--promo); color: var(--navy); font-weight: 800; box-shadow: 0 3px 0 var(--promo-deep); }
.weather[data-state='loading'] p { opacity: 0.7; }
.weather[data-state='live'] { background: rgba(255, 210, 31, 0.16); }

/* car choice: painted loading bays on asphalt */
.bays { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.bays button {
	position: relative; min-height: 84px; border-radius: 6px;
	background: #2c3038; color: rgba(255, 210, 31, 0.45);
	border-left: 4px solid rgba(255, 255, 255, 0.5); border-right: 4px solid rgba(255, 255, 255, 0.5);
	transition: transform 0.15s, color 0.15s, box-shadow 0.15s;
}
.bays b { font-size: 3.6rem; font-weight: 800; line-height: 1; font-variation-settings: 'wdth' 75, 'opsz' 96; }
.bays button::after {
	content: ''; position: absolute; left: 10%; right: 10%; bottom: 10px; height: 4px;
	background: currentColor; opacity: 0.8;
}
.bays button[aria-pressed='true'] { color: var(--promo); border-color: #fff; box-shadow: 0 0 0 3px var(--promo); transform: translateY(-2px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#play { min-height: 68px; font-size: 1.7rem; }

.moves { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0 6px; padding: 0; list-style: none; font-size: 0.9rem; font-weight: 600; }
.moves li { display: flex; align-items: center; gap: 6px; opacity: 0.9; }
kbd { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.15); font-family: var(--display); font-weight: 800; }

/* leaderboard button: a gold promo disc with a podium, top right of the menu and pause card */
.brand { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.board-btn {
	flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
	background: var(--promo); color: var(--navy); box-shadow: 0 4px 0 var(--promo-deep);
	transition: transform 0.08s, box-shadow 0.08s;
}
.board-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--promo-deep); }
.board-btn svg { width: 28px; height: 28px; }
.card .board-btn { position: absolute; right: 14px; top: 14px; width: 46px; height: 46px; }
.card .board-btn svg { width: 24px; height: 24px; }
.my-best { display: flex; justify-content: space-between; margin: 12px 0 2px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.18); font-weight: 700; }
.my-best b { color: var(--promo); font-variant-numeric: tabular-nums; }

/* Leaderboard, printed on the till slip. 1st is reverse-printed (solid ink, paper text) under a gold
   promo starburst; 2nd and 3rd print bold beside a round stamp; the rest are plain lines with dot leaders. */
.board { list-style: none; counter-reset: r; margin: 0; padding: 0; font-family: var(--till); font-variant-numeric: tabular-nums; }
.board li {
	counter-increment: r; display: grid; grid-template-columns: 2.1em minmax(0, auto) 1fr auto; align-items: baseline;
	column-gap: 6px; min-height: 28px; font-size: 0.95rem;
}
.board li::before { content: counter(r, decimal-leading-zero); color: var(--muted); }
.board li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li i { align-self: end; margin-bottom: 0.4em; border-bottom: 2px dotted #b9b8c8; }
.board li b { font-weight: 700; }
.board li.me span::after { content: ' (you)'; font-weight: 700; }
.board li.me { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.board li:nth-child(-n + 3)::before {
	content: counter(r); display: grid; place-items: center; align-self: center;
	width: 1.75em; height: 1.75em; border-radius: 50%; color: #fff; font-family: var(--display); font-weight: 800;
}
.board li:nth-child(2), .board li:nth-child(3) { align-items: center; min-height: 40px; font-size: 1.08rem; font-weight: 700; }
.board li:nth-child(2) i, .board li:nth-child(3) i { align-self: center; margin: 0.5em 0 0; }
.board li:nth-child(2)::before { background: var(--red); }
.board li:nth-child(3)::before { background: var(--navy); }
.board li:nth-child(3) { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 2px dashed #b9b8c8; }
.board li:nth-child(1) {
	position: relative; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; row-gap: 0;
	margin: 14px 0 10px; padding: 12px 14px 12px 64px;
	background: var(--ink); color: var(--paper); border-radius: 3px;
}
.board li:nth-child(1)::before {
	position: absolute; left: -8px; top: 50%; width: 62px; height: 62px; margin-top: -31px; border-radius: 0;
	background: var(--promo); color: var(--red); font-size: 1.8rem; line-height: 1; font-variation-settings: 'wdth' 75, 'opsz' 96;
	clip-path: polygon(50% 0, 61% 14%, 79% 7%, 81% 25%, 98% 31%, 88% 47%, 98% 63%, 81% 70%, 79% 89%, 61% 82%, 50% 100%, 39% 82%, 21% 89%, 19% 70%, 2% 63%, 12% 47%, 2% 31%, 19% 25%, 21% 7%, 39% 14%);
	transform: rotate(-12deg); filter: drop-shadow(0 2px 0 var(--red-deep));
}
.board li:nth-child(1) span { grid-column: 1; font-size: 1.4rem; font-weight: 700; line-height: 1.15; }
.board li:nth-child(1) i { display: none; }
.board li:nth-child(1) b { grid-column: 2; grid-row: 1 / 3; align-self: center; font-family: var(--display); font-size: 2rem; font-weight: 800; color: var(--promo); font-variation-settings: 'wdth' 75; }
.board li:nth-child(1)::after { content: 'Top driver'; grid-column: 1; font-size: 0.8rem; opacity: 0.7; }
.board li.empty { display: block; padding: 10px 0; text-align: center; color: var(--muted); background: none; }
.board li.empty::before, .board li.empty::after { content: none; }

/* ---------- pause card ---------- */
.card {
	position: fixed; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%);
	width: min(calc(100% - 32px), 340px); padding: 24px 18px 12px; text-align: center;
	background: var(--navy); color: #fff; border-radius: 24px; box-shadow: 0 10px 40px rgba(24, 36, 79, 0.45);
}
.card { padding-top: 28px; }
.card h2 { margin: 0 0 18px; font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.card .ghost { margin-top: 8px; }
/* on/off switch row: label left, pill right */
.toggle {
	display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; margin-top: 10px;
	padding: 0 4px 0 6px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}
.toggle::after {
	content: ''; width: 46px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, 0.25) radial-gradient(circle at 14px 50%, #fff 10px, transparent 11px);
	transition: background-color 0.15s, background-position 0.15s;
}
.toggle[aria-checked='true']::after { background-color: var(--promo); background-position: 18px 0; }
.toggle + .toggle { margin-top: 0; }
#install { display: block; width: 100%; color: #fff; }

/* ---------- game over: till slip ---------- */
#over {
	position: fixed; left: 50%; bottom: 0; z-index: 3; transform: translateX(-50%);
	width: min(100%, 440px); max-height: 74vh; display: flex; flex-direction: column;
}
.receipt {
	flex: 1 1 auto; min-height: 0; overflow-y: auto; touch-action: pan-y; user-select: text;
	margin: 0 14px; padding: 26px 20px 16px;
	background: var(--paper); color: var(--ink);
	font-family: var(--till); font-size: 1rem; line-height: 1.45;
	/* torn top edge: a row of 8px teeth, solid paper below */
	-webkit-mask: conic-gradient(from 135deg at top, #000 90deg, #0000 0) 0 0 / 14px 8px repeat-x, linear-gradient(#000 0 0) 0 8px / 100% 100% no-repeat;
	mask: conic-gradient(from 135deg at top, #000 90deg, #0000 0) 0 0 / 14px 8px repeat-x, linear-gradient(#000 0 0) 0 8px / 100% 100% no-repeat;
	box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
	animation: print 0.6s cubic-bezier(0.2, 1, 0.3, 1);
	position: relative;
}
@keyframes print { from { transform: translateY(60%); } }
.slip-head { text-align: center; padding-bottom: 10px; border-bottom: 2px dashed #b9b8c8; }
.slip-head img { display: block; margin: 0 auto 6px; width: 180px; height: auto; filter: grayscale(1) contrast(1.6); }
.slip-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.lines { display: grid; grid-template-columns: 1fr auto; margin: 12px 0; row-gap: 4px; }
.lines dt { margin: 0; }
.lines dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.lines dd.hit, .total b.hit { animation: bump 0.3s cubic-bezier(0.3, 1.8, 0.5, 1); }
.tip { margin: 0; padding: 10px 0 36px; /* clears the leaderboard button over the slip edge */ text-align: center; font-weight: 800; color: var(--navy); }
.total {
	position: relative; display: flex; justify-content: space-between; align-items: baseline;
	padding: 8px 0; border-top: 3px double var(--ink); border-bottom: 3px double var(--ink);
	font-weight: 700; font-size: 1.15rem;
}
.total b { font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.stamp {
	position: absolute; left: 30%; top: 2px; opacity: 0;
	padding: 4px 12px; border: 4px solid var(--red); border-radius: 8px;
	color: var(--red); font-family: var(--display); font-weight: 800; font-size: 1.5rem;
	transform: rotate(-14deg) scale(2.4); pointer-events: none; mix-blend-mode: multiply;
}
#over.best .stamp { animation: stamp 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) forwards; }
@keyframes stamp { to { opacity: 0.88; transform: rotate(-14deg) scale(1); } }
#over.thud .slip-wrap { animation: thud 0.3s ease-out; }
@keyframes thud { 20% { transform: translate(3px, 4px); } 45% { transform: translate(-3px, -1px); } 70% { transform: translate(2px, 1px); } }
#confetti { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.specials { margin: 14px 0 0; }
.specials p { margin: 0 0 6px; text-align: center; }
.specials ul { list-style: none; margin: 0; padding: 0; }
.specials li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 4px 0; border-bottom: 2px dotted #b9b8c8; }
.specials a { color: inherit; text-decoration: underline; text-decoration-style: dotted; }
.specials s { color: var(--muted); }
.specials b { color: var(--red); font-variant-numeric: tabular-nums; }
.specials span { text-align: right; white-space: nowrap; }
.specials small { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.barcode { display: flex; gap: 2px; height: 44px; margin: 16px 6px 2px; }
.barcode i { background: var(--ink); min-width: 1px; }
.barcode i:nth-child(3n) { background: transparent; }
.barcode-num { margin: 0; text-align: center; letter-spacing: 0.4em; font-size: 0.85rem; }
.receipt h3 { margin: 18px 0 6px; padding-top: 10px; border-top: 2px dashed #b9b8c8; font-size: 1rem; text-align: center; letter-spacing: 0.08em; }

/* leaderboard button riding on the slip: drops the paper down to the leaderboard */
.slip-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.fab {
	position: absolute; left: 0; right: 0; bottom: -18px; z-index: 1; width: fit-content; margin: 0 auto; /* centred without transform, which the animations own */
	display: flex; align-items: center; gap: 2px; height: 50px; padding: 0 10px 0 14px; border-radius: 25px;
	background: var(--navy); color: var(--promo); border: 3px solid var(--paper); box-shadow: 0 4px 0 var(--navy-deep), 0 6px 18px rgba(24, 36, 79, 0.3);
	animation: fabIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.fab svg { width: 26px; height: 26px; }
.fab .chev { width: 20px; height: 20px; color: #fff; animation: nudge 1.1s ease-in-out infinite; }
.fab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy-deep); }
@keyframes fabIn { from { opacity: 0; transform: translateY(16px) scale(0.8); } }
@keyframes nudge { 50% { transform: translateY(3px); } }

/* thermal printer: lines stay blank paper until the count reaches them (layout reserved, so the
   feed never jumps), then darken in as the head heats */
#over .lines > *, #over .total, #over .specials, #over .barcode, #over .barcode-num, #over .receipt h3, #over .board { visibility: hidden; opacity: 0.3; }
#over .receipt .printed { visibility: visible; opacity: 1; transition: opacity 0.18s steps(3); }

.actions {
	flex: none; padding: 14px 16px var(--bottom);
	background: var(--navy); color: #fff;
	opacity: 0; transform: translateY(30px); pointer-events: none;
	transition: opacity 0.3s, transform 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
#over.done .actions { opacity: 1; transform: none; pointer-events: auto; }
#submit label, #submit legend { display: block; margin-bottom: 6px; padding: 0; font-weight: 700; font-size: 0.95rem; }
#submit input {
	width: 100%; min-width: 0; height: 50px; padding: 0 14px; border-radius: 14px; border: 2px solid transparent;
	font: inherit; font-size: 17px; font-weight: 600; color: var(--ink); background: #fff; -webkit-user-select: text; user-select: text;
}
#submit input[aria-invalid='true'] { border-color: var(--promo); }
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 12px; padding: 0; border: 0; }
.contact legend { grid-column: 1 / -1; }
#submit .save { width: 100%; height: 50px; border-radius: 14px; background: var(--promo); color: var(--navy); font-weight: 800; font-size: 1.1rem; box-shadow: 0 3px 0 var(--promo-deep); }
#submit .save:disabled { opacity: 0.6; }
#over.done #submit:not([hidden]) { animation: ask 0.6s ease-out 0.2s; }
@keyframes ask { 30% { transform: translateX(-6px); } 60% { transform: translateX(6px); } }
#submit-msg { min-height: 1.3em; margin: 6px 0 8px; font-weight: 600; font-size: 0.92rem; }
.row { display: flex; align-items: center; gap: 8px; }
.row .cta { flex: 1; }

/* ---------- location ask ---------- */
.modal {
	position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px;
	background: rgba(24, 36, 79, 0.62);
	animation: fade 0.25s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
	width: min(100%, 360px); padding: 18px 20px 12px; text-align: center;
	background: #fff; color: var(--ink); border-radius: 24px;
	box-shadow: 0 6px 0 var(--navy-deep), 0 20px 50px rgba(0, 0, 0, 0.3);
	animation: rise-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes rise-in { from { transform: translateY(40px) scale(0.92); } }
.modal-card .sky { display: block; width: 150px; margin: 0 auto 6px; }
.modal-card h2 { margin: 0 0 8px; color: var(--navy); font-size: 1.7rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.modal-card p { margin: 0 0 16px; font-size: 1rem; line-height: 1.4; color: var(--muted); }
.modal-card .ghost { width: 100%; margin-top: 6px; color: var(--navy); }
.modal-card .fine { margin: 4px 0 0; font-size: 0.8rem; }

/* ---------- leaderboard slip (menu, pause) ---------- */
.board-sheet { display: flex; flex-direction: column; gap: 12px; width: min(100%, 400px); max-height: calc(100vh - 32px); }
.board-sheet .receipt { flex: 1 1 auto; margin: 0; }
.board-sheet h2 { margin: 4px 0 2px; font-family: var(--till); font-size: 1.1rem; letter-spacing: 0.08em; }
.slip-foot { display: flex; justify-content: space-between; margin: 10px 0 0; padding-top: 10px; border-top: 2px dashed #b9b8c8; }
#board-close { flex: none; min-height: 52px; font-size: 1.2rem; }

/* ---------- sound toggle ---------- */
#mute {
	position: fixed; left: 12px; top: var(--top); z-index: 6;
	display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
	background: rgba(255, 255, 255, 0.92); color: var(--navy); box-shadow: 0 3px 0 var(--navy);
}
#mute svg { width: 24px; }
#mute .cross { display: none; }
#mute[aria-pressed='true'] .cross { display: inline; }
#mute[aria-pressed='true'] .wave { display: none; }
body[data-mode='play'] #mute, body[data-mode='crash'] #mute, body[data-mode='paused'] #mute { display: none; } /* paused: the card has a Sound switch */

/* ---------- larger screens: panels move to the right, the 3D scene keeps the left ---------- */
@media (min-width: 900px) and (min-height: 600px) {
	.sheet { left: auto; right: 28px; bottom: 28px; transform: none; border-radius: 26px; max-height: calc(100vh - 56px); animation: none; }
	#over { left: auto; right: 28px; bottom: 0; transform: none; max-height: calc(100vh - 28px); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
	body.boosting #speedlines { opacity: 0.4; }
	#ticker-name { white-space: normal; font-size: 0.95rem; line-height: 1.15; }
}
