/* Sized for a car's center screen (~1920x1200 landscape); light by day, dark by night. */
:root {
	--bg: #ececee;
	--card: #fff;
	--dock: #dfdfe2;
	--shadow: 0 1px 2px #0000000f, 0 2px 8px #0000000a;
	--text: #171a20;
	--muted: #44464b;
	--accent: #1a3d9e;
	--correct: #0a5530;
	--danger: #8f1a1d;
	/* Text on accent, correct, and danger fills. Every text color meets WCAG AAA (7:1) on its surface. */
	--on-accent: #fff;
	--on-correct: #fff;
	--on-danger: #fff;
	--radius: 16px;
	--chamfer: 0px;
	--mono: ui-monospace, "SF Mono", Menlo, monospace;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0d0d0e;
		--card: #1f2023;
		--dock: #18181a;
		--shadow: none;
		--text: #f2f2f3;
		--muted: #a8abb0;
		--accent: #8ca9f5;
		--correct: #5bbd8d;
		--danger: #ef9194;
		--on-accent: #0d0d0e;
		--on-correct: #0d0d0e;
		--on-danger: #0d0d0e;
	}
}

* { box-sizing: border-box; }

body {
	display: grid;
	grid-template-columns: auto 1fr;
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 500 16px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* Behave like an app: no zooming (also set in the viewport meta), no pull-to-refresh bounce,
   no text selection on long-press, no tap flash. The type is already sized for each screen. */
html, body {
	touch-action: pan-x pan-y;
	overscroll-behavior: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
}

/* Instructions for voice assistants that read the HTML without running JavaScript. Visually hidden and
   taking no space, so the page never shows scrollbars before the board renders. */
#board:not(.board) {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}


.muted { color: var(--muted); }

.card {
	background: var(--card);
	box-shadow: var(--shadow);
	border-radius: var(--radius);
}

.icon {
	width: 1em;
	height: 1em;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Sidebar */
#dock {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2vh;
	width: clamp(5rem, 7vw, 8.5rem);
	padding: 3vh 0;
	background: var(--dock);
}
.dock-clock {
	font-size: clamp(1.1rem, 2.6vh, 1.8rem);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.dock-apps {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 2vh;
}
.dock-item {
	display: grid;
	place-items: center;
	width: clamp(3.5rem, 8vh, 6rem);
	aspect-ratio: 1;
	padding: 0;
	border: 0;
	border-radius: 22%;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: clamp(1.75rem, 4.2vh, 3rem);
	cursor: pointer;
	transition: background 0.2s, color 0.2s, transform 0.1s;
}
.dock-item:hover { color: var(--text); }
.dock-item.is-active { background: var(--accent); color: var(--on-accent); }

/* ⋮ menu (popover) */
.dock-more .icon path { fill: currentColor; stroke: none; }
.dock-menu {
	position: fixed;
	inset: auto;
	margin: 0;
	min-width: 14rem;
	padding: 1vh 0;
	border: 0;
	color: var(--text);
	font-size: clamp(1rem, 2.2vh, 1.4rem);
}
.dock-menu-label { margin: 0.6em 1.2em 0.3em; font-size: 0.75em; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.dock-menu-item { display: flex; align-items: center; gap: 0.6em; width: 100%; padding: 0.7em 1.2em; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.dock-menu-item:hover, .dock-menu-item:focus-visible { background: color-mix(in srgb, var(--accent) 12%, transparent); outline: none; }
.dock-menu-item[aria-checked="true"]::after { content: "✓"; margin-inline-start: auto; color: var(--accent); }
.dock-menu-item.is-danger { color: var(--danger); }
.dock-menu hr { margin: 0.6vh 0; border: 0; border-top: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); }

/* Touch feedback */
.dock-item:active, a.card:active { transform: scale(0.96); }
a.card { transition: transform 0.1s; }

/* Main board */
.board {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 100dvh;
	padding: 3vh 3vw;
	gap: 3vh;
}

.bar {
	display: flex;
	justify-content: space-between;
	font-size: clamp(1rem, 2.4vh, 1.6rem);
	color: var(--muted);
}
.bar-title { color: var(--text); font-weight: 600; }

.stage {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 4.5vh;
}
.state-idle .stage,
.next,
.state-score .question,
.state-end .question,
.state-hall .question,
.clue { text-align: center; }
.state-idle .muted,
.next .muted { margin: 0; font-size: clamp(1.1rem, 3vh, 2rem); }

.question {
	margin: 0;
	font-size: clamp(1.75rem, 6vh, 4.5rem);
	font-weight: 500;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.eyebrow {
	margin: 0;
	color: var(--accent);
	font-size: clamp(1.1rem, 3vh, 2rem);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* Answer choices */
.choices {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.6vh 1.2vw;
}
.choices.count-1, .choices.count-3 { grid-template-columns: 1fr; }

.choice {
	display: flex;
	align-items: center;
	gap: 1.4vw;
	padding: 3vh 2vw;
	font-size: clamp(1.4rem, 4vh, 3rem);
	text-align: start;
	transition: color 0.3s, background 0.3s;
}
.choice .muted { min-width: 1.2em; font-size: 0.75em; font-weight: 600; }
.choice.is-correct { background: var(--correct); color: var(--on-correct); }
.choice.is-correct .muted { color: inherit; }
/* Wrong answers recede by color, not opacity, so they stay readable. */
.choice.is-dim { color: var(--muted); box-shadow: none; background: transparent; outline: 1px solid color-mix(in srgb, var(--muted) 40%, transparent); outline-offset: -1px; }
.clue .choice { justify-content: center; }

.verdict {
	font-size: clamp(1.5rem, 4.5vh, 3.25rem);
	font-weight: 600;
	color: var(--accent);
	text-align: center;
}
.wagers { margin: 0; font-size: clamp(1rem, 2.6vh, 1.75rem); }

/* Score strip under questions */
.strip {
	display: flex;
	justify-content: center;
	gap: 1vw;
}
/* Whose turn it is */
.chip.is-up { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.next .question { font-size: clamp(2.5rem, 11vh, 8rem); font-weight: 600; }

.chip {
	display: flex;
	gap: 0.6em;
	padding: 1vh 1.4vw;
	background: var(--card);
	box-shadow: var(--shadow);
	border-radius: 999px;
	font-size: clamp(1rem, 2.6vh, 1.75rem);
}

/* Scoreboard; 4-6 players go two columns, ranked down then across. */
.scores {
	list-style: none;
	margin: 0 auto;
	padding: 0;
	width: min(100%, 56rem);
	display: grid;
	gap: 1.4vh;
}
.scores:is(.count-4, .count-5, .count-6) {
	width: min(100%, 84rem);
	grid-template-rows: repeat(3, auto);
	grid-auto-flow: column;
	column-gap: 1.4vw;
}
.score-row {
	display: flex;
	justify-content: space-between;
	gap: 1em;
	padding: 2.4vh 2.2vw;
	font-size: clamp(1.4rem, 4.2vh, 3.25rem);
}
.score-value { font-variant-numeric: tabular-nums; }
.score-row.is-leader { box-shadow: var(--shadow), inset 0 0 0 3px var(--accent); }
.is-leader .score-value { color: var(--accent); font-weight: 600; }
.state-hall .score-row { font-size: clamp(1.2rem, 3.4vh, 2.5rem); }

/* Home launcher: every game visible at once on any screen. Tiles share a row when there's room, and on
   short screens the descriptions drop out before anything would scroll. */
.home-head { display: grid; gap: 1vh; }
.home-hint { margin: 0; font-size: clamp(1rem, 2.4vh, 1.6rem); }
.state-home .stage { gap: 3.5vh; }
.launcher {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
	gap: 1.6vh 1.2vw;
}
.tile {
	display: flex;
	flex-direction: column;
	gap: 1vh;
	padding: clamp(1rem, 3vh, 2.2rem) clamp(1rem, 1.6vw, 2rem);
	font-size: clamp(0.95rem, 2.2vh, 1.5rem);
}
.tile .icon { font-size: 2.4em; color: var(--accent); }
.tile strong { font-size: 1.45em; font-weight: 600; }
.tile-say { margin-top: auto; color: var(--accent); }
@media (max-height: 760px) {
	.tile .muted { display: none; }
	.tile .icon { font-size: 1.8em; }
}

/* Category board */
.grid {
	display: grid;
	grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
	gap: 1.2vh 0.8vw;
}
.grid-cat {
	overflow-wrap: anywhere;
	display: grid;
	place-items: end center;
	min-height: 7vh;
	padding-bottom: 0.6vh;
	color: var(--muted);
	font-size: clamp(0.9rem, 2.4vh, 1.6rem);
	font-weight: 600;
	text-align: center;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.grid-cell {
	display: grid;
	place-items: center;
	height: 11vh;
	color: var(--accent);
	font-size: clamp(1.3rem, 4.4vh, 3.25rem);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}
.grid-cell.is-used { background: transparent; box-shadow: inset 0 0 0 2px var(--card); }
.grid-cell.is-current { background: var(--accent); color: var(--on-accent); }

/* Effects */
@property --left {
	syntax: "<percentage>";
	inherits: false;
	initial-value: 100%;
}

.fx-timer {
	position: absolute;
	top: 1.6vh;
	left: 50%;
	translate: -50% 0;
	display: grid;
	place-items: center;
	width: 9vh;
	aspect-ratio: 1;
	border-radius: 50%;
	background:
		radial-gradient(closest-side, var(--bg) 84%, transparent 85%),
		conic-gradient(var(--accent) var(--left), var(--card) 0);
	font-size: 3.4vh;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	animation: drain var(--duration) linear forwards;
}
.fx-timer.is-done { color: var(--danger); }
@keyframes drain { to { --left: 0%; } }

.fx-confetti {
	position: fixed;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
}
.fx-confetti i {
	position: absolute;
	top: -4vh;
	left: var(--x);
	width: 1vh;
	height: 1.6vh;
	border-radius: 2px;
	background: var(--color);
	animation: fall var(--time) cubic-bezier(0.3, 0.6, 0.6, 1) var(--delay) both;
}
@keyframes fall { to { transform: translate3d(var(--drift), 112vh, 0) rotate(var(--spin)); } }

/*
 * Cyber theme: the angular in-car software look. Near-black flat panels, chamfered corners,
 * hairline edges, wide uppercase labels in a technical face, white as the accent.
 * theme=cyber or the ⋮ menu.
 */
:root[data-theme="cyber"] {
	--bg: #0a0b0c;
	--card: #17181b;
	--dock: #0f1012;
	--edge: #ffffff24;
	--shadow: none;
	--text: #eef0f2;
	--muted: #a5a8af;
	--accent: #f2f4f6;
	--correct: #4ade80;
	--danger: #ff847d;
	--on-accent: #0a0b0c;
	--on-correct: #04140a;
	--on-danger: #0a0b0c;
	--radius: 0px;
	--chamfer: 14px;
	color-scheme: dark;
}

[data-theme="cyber"] body { background: var(--bg); }

/* Chamfered panels: flat fills, a shade lighter than the background, so the cut corners read clearly. */
[data-theme="cyber"] .card,
[data-theme="cyber"] .chip,
[data-theme="cyber"] .dock-item {
	border-radius: 0;
	clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
}
[data-theme="cyber"] .card,
[data-theme="cyber"] .chip { background: var(--card); box-shadow: none; }
[data-theme="cyber"] .chip { --chamfer: 8px; }
[data-theme="cyber"] .dock-item { --chamfer: 10px; }
[data-theme="cyber"] #dock { border-inline-end: 1px solid var(--edge); }
[data-theme="cyber"] .dock-menu { clip-path: none; border: 1px solid var(--edge); }

[data-theme="cyber"] .bar,
[data-theme="cyber"] .grid-cat,
[data-theme="cyber"] .eyebrow,
[data-theme="cyber"] .dock-clock,
[data-theme="cyber"] .choice .muted {
	font-family: var(--mono);
	text-transform: uppercase;
	letter-spacing: 0.14em;
}
[data-theme="cyber"] .question { font-weight: 600; letter-spacing: -0.02em; }
[data-theme="cyber"] .grid-cell,
[data-theme="cyber"] .score-value,
[data-theme="cyber"] .chip,
[data-theme="cyber"] .fx-timer { font-family: var(--mono); }

/* States repeat their fill here, since the panel background above is more specific. */
[data-theme="cyber"] .dock-item.is-active,
[data-theme="cyber"] .grid-cell.is-current { background: var(--accent); }
[data-theme="cyber"] .choice.is-correct { background: var(--correct); }
[data-theme="cyber"] .choice.is-dim { background: var(--card); outline: 0; }
[data-theme="cyber"] .grid-cell.is-used { background: var(--dock); }
/* Highlights: an accent edge drawn as a background layer, so it follows the chamfer. */
[data-theme="cyber"] .score-row.is-leader,
[data-theme="cyber"] .chip.is-up,
[data-theme="cyber"] .chess-player.is-turn,
[data-theme="cyber"] .adv-character.is-up {
	background: linear-gradient(var(--card), var(--card)) padding-box, var(--accent) border-box;
	border: 2px solid transparent;
	box-shadow: none;
}
[data-theme="cyber"] .fx-timer { background: radial-gradient(closest-side, var(--bg) 84%, transparent 85%), conic-gradient(var(--accent) var(--left), #2a2d31 0); }

/* Confirmation dialog */
.confirm {
	width: min(92vw, 34rem);
	padding: 4vh 2.6vw 3vh;
	border: 0;
	border-radius: var(--radius);
	background: var(--card);
	color: var(--text);
	box-shadow: 0 24px 64px #00000040;
	font-size: clamp(1rem, 2.4vh, 1.5rem);
}
.confirm::backdrop { background: #0000008c; }
.confirm h2 { margin: 0 0 1.5vh; font-size: 1.4em; font-weight: 600; }
.confirm p { margin: 0 0 3.5vh; line-height: 1.45; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 1vw; }
.button {
	min-width: 7em;
	padding: 1.4vh 1.6vw;
	border: 0;
	border-radius: 999px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.button.is-danger { background: var(--danger); color: var(--on-danger); }
[data-theme="cyber"] .confirm,
[data-theme="cyber"] .button {
	border-radius: 0;
	clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
}
[data-theme="cyber"] .button { --chamfer: 8px; }

/* Final-screen credit: small and quiet */
.credit {
	align-self: center;
	color: var(--muted);
	font-size: clamp(0.75rem, 1.6vh, 1rem);
}
.credit:hover { color: var(--text); }

/* Portrait screens (older Model S and X): tighter type and spacing so every screen fits without scrolling. */
@media (orientation: portrait) {
	.board { padding: 2.5vh 4vw; }
	.question { font-size: clamp(1.6rem, 4.6vh, 3.6rem); }
	.choices { grid-template-columns: 1fr; }
	.grid-cell { height: 9vh; font-size: clamp(1rem, 3.4vw, 2.4rem); }
	.grid-cat { font-size: clamp(0.8rem, 2vw, 1.3rem); }
}

/* auto= progress: a thin bar along the bottom that fills until the board moves on */
.fx-auto {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	height: 4px;
	background: var(--accent);
	transform-origin: left;
	animation: fx-auto var(--duration) linear forwards;
}
[dir="rtl"] .fx-auto { transform-origin: right; }
@keyframes fx-auto { from { transform: scaleX(0); } }

/* Recap QR on the final screen */
.recap { position: absolute; inset-inline-end: 3vw; bottom: 3vh; display: grid; justify-items: center; gap: 0.6vh; margin: 0; font-size: clamp(0.75rem, 1.6vh, 1rem); }
.recap-qr { width: clamp(6rem, 16vh, 11rem); aspect-ratio: 1; border-radius: 10px; background: #fff; image-rendering: pixelated; }
