/* Find 'Em — dark theatrical stage. One signal red (the reveal identity),
 * neon green strictly for the blind grid (spec §9), photo-forward board.
 * Shape lock: 14px soft radius, pill buttons. Theme lock: dark only. */

:root {
	--bg: #0c0a12;
	--bg-raise: #16131f;
	--bg-raise-2: #1e1a2a;
	--line: rgb(255 255 255 / 0.09);
	--text: #f3eefb;
	--text-dim: #9d93b3;
	--red: #ff4757;
	--red-deep: #c92a3a;
	--neon: #39ff88;
	--gold: #ffce54;
	--radius: 14px;
	--hud-h: 58px;
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

/* The hidden attribute always wins, even over display:flex stage rules. */
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
		sans-serif;
	height: 100%;
	overscroll-behavior: none;
}

body {
	touch-action: manipulation;
	user-select: none;
	-webkit-user-select: none;
}

#app {
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
}

.view {
	display: none;
	flex: 1;
	flex-direction: column;
	min-height: 100dvh;
}

#app[data-view="landing"] #view-landing,
#app[data-view="rank"] #view-rank,
#app[data-view="lobby"] #view-lobby,
#app[data-view="game"] #view-game {
	display: flex;
}

/* ---------------------------------------------------------------- buttons */

.btn {
	appearance: none;
	border: 1px solid transparent;
	border-radius: 999px;
	padding: 14px 26px;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: 0.02em;
	cursor: pointer;
	color: var(--text);
	background: var(--bg-raise-2);
	transition:
		transform 0.12s ease,
		background 0.2s ease,
		opacity 0.2s ease;
	text-decoration: none;
	text-align: center;
	display: inline-block;
}

.btn:active {
	transform: scale(0.97);
}

.btn-primary {
	background: linear-gradient(160deg, var(--red), var(--red-deep));
	color: #fff;
	box-shadow: 0 6px 24px rgb(255 71 87 / 0.28);
}

.btn-ghost {
	background: transparent;
	border-color: var(--line);
	color: var(--text);
}

.btn-danger {
	background: var(--red-deep);
	color: #fff;
}

.btn-big {
	width: 100%;
	padding: 18px;
	font-size: 18px;
}

.btn-small {
	padding: 8px 16px;
	font-size: 14px;
}

.btn[disabled] {
	opacity: 0.45;
	pointer-events: none;
}

/* ---------------------------------------------------------------- landing */

.landing-wrap {
	margin: auto;
	width: min(420px, 92vw);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	padding: 48px 0 32px;
	text-align: center;
}

.hero-eye {
	position: relative;
	width: 168px;
	height: 96px;
	overflow: hidden;
	border-radius: 50% / 60%;
	background: radial-gradient(circle at 50% 50%, #2a2438 0%, #151020 70%);
	box-shadow:
		inset 0 0 24px rgb(0 0 0 / 0.8),
		0 0 44px rgb(255 71 87 / 0.14);
}

.hero-eye-iris {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 52px;
	height: 52px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: radial-gradient(
		circle at 40% 38%,
		#ff8a94 0%,
		var(--red) 45%,
		#5c0f18 100%
	);
	box-shadow: 0 0 22px rgb(255 71 87 / 0.7);
}

.hero-eye-lid {
	position: absolute;
	left: -6%;
	width: 112%;
	height: 52%;
	background: #0c0a12;
	z-index: 2;
}

.hero-eye-lid-top {
	top: -2%;
	border-bottom: 2px solid rgb(255 255 255 / 0.12);
	border-radius: 0 0 50% 50%;
	animation: blink-top 5.2s ease-in-out infinite;
}

.hero-eye-lid-bottom {
	bottom: -2%;
	border-top: 2px solid rgb(255 255 255 / 0.08);
	border-radius: 50% 50% 0 0;
	animation: blink-bottom 5.2s ease-in-out infinite;
}

@keyframes blink-top {
	0%,
	6%,
	100% {
		transform: translateY(-78%);
	}
	2%,
	4% {
		transform: translateY(0);
	}
}

@keyframes blink-bottom {
	0%,
	6%,
	100% {
		transform: translateY(78%);
	}
	2%,
	4% {
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.hero-eye-lid-top {
		animation: none;
		transform: translateY(-78%);
	}
	.hero-eye-lid-bottom {
		animation: none;
		transform: translateY(78%);
	}
}

.game-title {
	margin: 0;
	font-size: clamp(44px, 11vw, 64px);
	font-weight: 900;
	letter-spacing: -0.03em;
	line-height: 1;
}

.game-sub {
	margin: 0;
	color: var(--text-dim);
	font-size: 16px;
	max-width: 34ch;
}

.landing-form {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: 8px;
}

.landing-form input,
.join-row input {
	width: 100%;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--text);
	font-size: 17px;
	padding: 15px 16px;
	outline: none;
	text-align: center;
}

.landing-form input:focus,
.join-row input:focus {
	border-color: var(--red);
}

.landing-form input::placeholder {
	color: var(--text-dim);
}

.join-row {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 10px;
}

.join-row input {
	text-transform: uppercase;
}

.rank-link {
	color: var(--text-dim);
	font-size: 14px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.form-error {
	color: var(--red);
	font-size: 14px;
	min-height: 18px;
}

/* ------------------------------------------------------------------- rank */

#view-rank {
	padding: 20px 16px 40px;
	max-width: 560px;
	margin: 0 auto;
	width: 100%;
}

.rank-head {
	display: flex;
	align-items: center;
	gap: 14px;
}

.rank-head h2 {
	margin: 0;
	font-size: 24px;
	font-weight: 900;
	letter-spacing: -0.02em;
}

.rank-note {
	color: var(--text-dim);
	font-size: 14px;
	margin: 10px 0 14px;
}

.rank-tabs {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
	margin-bottom: 16px;
}

.rank-tab {
	appearance: none;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	color: var(--text-dim);
	border-radius: 999px;
	padding: 10px 0;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.rank-tab.is-active {
	background: linear-gradient(160deg, var(--red), var(--red-deep));
	border-color: transparent;
	color: #fff;
}

.rank-me {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 12px 16px;
	font-size: 15px;
	margin-bottom: 12px;
}

.rank-me strong {
	color: var(--gold);
}

.rank-board {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.rank-row {
	display: grid;
	grid-template-columns: 44px 1fr auto;
	gap: 10px;
	padding: 12px 16px;
	font-size: 15px;
	align-items: baseline;
}

.rank-row + .rank-row {
	border-top: 1px solid var(--line);
}

.rank-row .pos {
	font-weight: 900;
	color: var(--text-dim);
}

.rank-row.top1 .pos {
	color: var(--gold);
}
.rank-row .score {
	font-variant-numeric: tabular-nums;
	font-weight: 800;
}

.rank-loading,
.rank-empty {
	padding: 28px 16px;
	text-align: center;
	color: var(--text-dim);
	font-size: 14px;
}

/* ------------------------------------------------------------------ lobby */

.lobby-wrap {
	margin: 0 auto;
	width: min(440px, 92vw);
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 64px 0 40px;
}

.lobby-title {
	margin: 0;
	text-align: center;
	font-size: 30px;
	font-weight: 900;
	letter-spacing: -0.02em;
}

.room-code-card {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 18px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

.room-code-label {
	font-size: 12px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--text-dim);
}

.room-code {
	font-size: 34px;
	font-weight: 900;
	letter-spacing: 0.08em;
}

.invite-copied {
	color: var(--neon);
	font-size: 13px;
}

.lobby-panel {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.lobby-panel-title {
	font-size: 13px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--text-dim);
	font-weight: 700;
}

.player-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.player-list li {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 16px;
	font-weight: 600;
}

.player-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--neon);
	flex: none;
}

.player-dot.off {
	background: var(--text-dim);
	opacity: 0.5;
}

.player-host-tag {
	font-size: 11px;
	color: var(--gold);
	border: 1px solid rgb(255 206 84 / 0.4);
	padding: 2px 8px;
	border-radius: 999px;
	margin-left: auto;
}

.rounds-picker {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
}

.rounds-picker button {
	appearance: none;
	background: var(--bg-raise-2);
	border: 1px solid var(--line);
	color: var(--text);
	font-size: 18px;
	font-weight: 800;
	border-radius: var(--radius);
	padding: 12px 0;
	cursor: pointer;
}

.rounds-picker button.is-active {
	background: linear-gradient(160deg, var(--red), var(--red-deep));
	border-color: transparent;
}

.rounds-hint {
	margin: 0;
	font-size: 13px;
	color: var(--text-dim);
	line-height: 1.5;
}

.guest-wait {
	text-align: center;
	color: var(--text-dim);
	font-size: 15px;
}

/* --------------------------------------------------------------- exit btn */

.exit-btn {
	position: fixed;
	top: max(10px, env(safe-area-inset-top));
	left: 12px;
	z-index: 60;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: rgb(12 10 18 / 0.72);
	color: var(--text-dim);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	backdrop-filter: blur(6px);
}

.exit-confirm {
	position: fixed;
	inset: 0;
	background: rgb(0 0 0 / 0.66);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 90;
}

.exit-confirm-card {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 22px;
	width: min(340px, 88vw);
	text-align: center;
}

.exit-confirm-card p {
	margin: 0 0 16px;
	font-size: 16px;
	line-height: 1.5;
}

.exit-confirm-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

/* ------------------------------------------------------------------ slate */

.slate {
	position: fixed;
	inset: 0;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	text-align: center;
	padding: 24px;
	z-index: 30;
}

.slate-kicker {
	font-size: 14px;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--red);
	font-weight: 800;
}

.slate-title {
	font-size: clamp(34px, 9vw, 56px);
	font-weight: 900;
	letter-spacing: -0.02em;
	line-height: 1.05;
	max-width: 14ch;
}

.slate-sub {
	color: var(--text-dim);
	font-size: 16px;
	max-width: 36ch;
}

/* -------------------------------------------------------------- eye stage */

.eye-stage {
	position: fixed;
	inset: 0;
	background: #050308;
	z-index: 40;
	overflow: hidden;
}

.eye-beam {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 3px;
	transform: translateY(-50%) scaleY(1);
	background: linear-gradient(
		90deg,
		transparent 0%,
		rgb(255 235 220 / 0.85) 18%,
		#fff 50%,
		rgb(255 235 220 / 0.85) 82%,
		transparent 100%
	);
	box-shadow:
		0 0 18px 4px rgb(255 220 190 / 0.55),
		0 0 60px 14px rgb(255 120 130 / 0.25);
	transition:
		height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
		opacity 0.4s ease;
}

.eye-lid {
	position: absolute;
	left: 0;
	right: 0;
	height: 50%;
	background: #050308;
	z-index: 2;
	transition: transform 0.75s cubic-bezier(0.7, 0, 0.2, 1);
}

.eye-lid-top {
	top: 0;
	border-bottom: 3px solid rgb(255 230 210 / 0.35);
	border-radius: 0 0 48% 48% / 0 0 14% 14%;
}

.eye-lid-bottom {
	bottom: 0;
	border-top: 3px solid rgb(255 230 210 / 0.22);
	border-radius: 48% 48% 0 0 / 14% 14% 0 0;
}

.eye-stage.open .eye-lid-top {
	transform: translateY(-104%);
}

.eye-stage.open .eye-lid-bottom {
	transform: translateY(104%);
}

.eye-stage.open .eye-beam {
	opacity: 0;
}

.eye-count {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	z-index: 3;
	font-size: clamp(72px, 22vw, 132px);
	font-weight: 900;
	color: #fff;
	text-shadow:
		0 0 30px rgb(255 200 180 / 0.8),
		0 0 90px rgb(255 71 87 / 0.5);
	transition:
		opacity 0.2s ease,
		transform 0.2s ease;
}

.eye-count.open-word {
	font-size: clamp(56px, 17vw, 110px);
	letter-spacing: 0.04em;
}

.eye-prompt {
	position: absolute;
	left: 50%;
	bottom: max(26px, env(safe-area-inset-bottom));
	transform: translateX(-50%);
	z-index: 3;
	color: var(--text-dim);
	font-size: 16px;
	font-weight: 600;
	width: 92vw;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.eye-lid {
		transition: none;
	}
	.eye-beam {
		transition: none;
	}
}

/* ------------------------------------------------------------------ board */

.board-wrap {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	z-index: 20;
}

.hud {
	height: var(--hud-h);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: max(6px, env(safe-area-inset-top)) 14px 0 60px;
}

.hud-prompt {
	flex: 1;
	font-size: clamp(15px, 4.2vw, 19px);
	font-weight: 800;
	letter-spacing: -0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hud-timer {
	font-size: 24px;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	color: var(--text);
	min-width: 64px;
	text-align: right;
}

.hud-timer.low {
	color: var(--red);
}

.hud-bar {
	height: 4px;
	background: var(--bg-raise-2);
}

.hud-bar-fill {
	height: 100%;
	width: 100%;
	background: linear-gradient(90deg, var(--red), #ff8a94);
	transform-origin: left;
}

.board {
	position: relative;
	flex: 1;
	margin: 8px auto;
	max-width: 100vw;
	overflow: hidden;
	border-radius: var(--radius);
	background: #000;
	align-self: center;
	aspect-ratio: 768 / 1365;
	max-height: calc(100dvh - var(--hud-h) - 26px);
	touch-action: none;
}

@media (pointer: fine) {
	.board.searching {
		cursor:
			url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ccircle cx='11' cy='11' r='7.5' fill='none' stroke='white' stroke-width='2.4'/%3E%3Cline x1='16.5' y1='16.5' x2='25' y2='25' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3Ccircle cx='11' cy='11' r='1.6' fill='%23ff4757'/%3E%3C/svg%3E")
			11 11,
			crosshair;
	}
}

.board-photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}

.board-svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 6;
}

/* Wood obstruction (spec §6): vertical board, one horizontal window ~1/3. */

.wood-layer {
	position: absolute;
	inset: 0;
	z-index: 4;
}

.wood-panel {
	position: absolute;
	left: 0;
	right: 0;
	background-image: url("/assets/wood.webp");
	background-size: 100% auto;
	box-shadow: inset 0 0 34px rgb(0 0 0 / 0.55);
}

.wood-panel-top {
	top: -2px;
	background-position: top center;
	border-bottom: 4px solid #2a1a0e;
}

.wood-panel-bottom {
	bottom: -2px;
	background-position: bottom center;
	border-top: 4px solid #2a1a0e;
}

.wood-window {
	position: absolute;
	left: 0;
	right: 0;
	z-index: 5;
}

/* Smaller red grip with up/down arrows so it clearly reads as drag-me. */
.wood-handle {
	position: absolute;
	left: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 30px;
	height: 58px;
	padding: 5px 0;
	border-radius: 10px;
	border: 2px solid #ffd9d9;
	background: linear-gradient(160deg, var(--red), var(--red-deep));
	box-shadow:
		0 3px 14px rgb(0 0 0 / 0.55),
		0 0 14px rgb(255 71 87 / 0.5);
	cursor: grab;
	touch-action: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-between;
	color: #fff;
}

.wh-arrow {
	font-size: 12px;
	line-height: 1;
	color: #fff;
	opacity: 0.95;
}

.wh-grip {
	width: 12px;
	height: 14px;
	border-left: 2px solid rgb(255 255 255 / 0.85);
	border-right: 2px solid rgb(255 255 255 / 0.85);
}

/* "Drag Here" hint that rides beside the handle. */
.wood-hint {
	position: absolute;
	left: 44px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 6;
	background: rgb(12 10 18 / 0.82);
	border: 1px solid rgb(255 71 87 / 0.5);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	padding: 5px 10px;
	border-radius: 999px;
	white-space: nowrap;
	pointer-events: none;
	backdrop-filter: blur(4px);
}

@media (prefers-reduced-motion: no-preference) {
	.wood-hint {
		animation: woodHintPulse 2s ease-in-out infinite;
	}
}

@keyframes woodHintPulse {
	0%,
	100% {
		opacity: 0.72;
	}
	50% {
		opacity: 1;
	}
}

/* Flashlight layer is a canvas painted in JS. */
.light-layer {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 4;
}

/* tap feedback */
.tap-fx {
	position: absolute;
	z-index: 8;
	width: 64px;
	height: 64px;
	margin: -32px 0 0 -32px;
	border-radius: 50%;
	pointer-events: none;
	border: 3px solid var(--red);
	opacity: 0;
}

.tap-fx.miss {
	animation: tap-miss 0.5s ease-out;
}

.tap-fx.hit {
	border-color: var(--neon);
	animation: tap-hit 0.6s ease-out;
}

@keyframes tap-miss {
	0% {
		opacity: 1;
		transform: scale(0.4);
	}
	100% {
		opacity: 0;
		transform: scale(1.4);
	}
}

@keyframes tap-hit {
	0% {
		opacity: 1;
		transform: scale(0.3);
	}
	100% {
		opacity: 0;
		transform: scale(1.8);
	}
}

.penalty-pop {
	position: absolute;
	z-index: 9;
	color: var(--red);
	font-weight: 900;
	font-size: 22px;
	pointer-events: none;
	animation: pop-rise 0.8s ease-out forwards;
	text-shadow: 0 2px 8px rgb(0 0 0 / 0.8);
}

@keyframes pop-rise {
	0% {
		opacity: 1;
		transform: translateY(0);
	}
	100% {
		opacity: 0;
		transform: translateY(-42px);
	}
}

.clue-banner {
	position: absolute;
	left: 50%;
	bottom: 14px;
	transform: translateX(-50%);
	z-index: 10;
	background: rgb(12 10 18 / 0.88);
	border: 1px solid rgb(255 71 87 / 0.5);
	color: #fff;
	font-size: 16px;
	font-weight: 700;
	padding: 10px 18px;
	border-radius: 999px;
	white-space: nowrap;
	animation: clue-in 0.3s ease-out;
	backdrop-filter: blur(6px);
}

@keyframes clue-in {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0);
	}
}

/* Find flash — a big unmistakable "Find the X" that fires at the start of every
 * search prompt so the player ALWAYS knows the target, even when the board is
 * obscured (flashlight/wood) and the small HUD prompt is easy to miss. */
.find-flash {
	position: absolute;
	left: 50%;
	top: 22%;
	transform: translateX(-50%);
	z-index: 12;
	max-width: 88%;
	text-align: center;
	font-size: clamp(22px, 6.4vw, 34px);
	font-weight: 900;
	letter-spacing: -0.01em;
	line-height: 1.15;
	color: #fff;
	text-shadow:
		0 2px 4px rgb(0 0 0 / 0.9),
		0 0 22px rgb(255 71 87 / 0.7),
		0 0 46px rgb(0 0 0 / 0.8);
	pointer-events: none;
}

.find-flash .ff-kick {
	display: block;
	font-size: 0.42em;
	letter-spacing: 0.24em;
	font-weight: 800;
	color: var(--red);
	margin-bottom: 4px;
	text-shadow: 0 2px 4px rgb(0 0 0 / 0.9);
}

.find-flash.show {
	animation: find-flash-in 1.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes find-flash-in {
	0% {
		opacity: 0;
		transform: translateX(-50%) scale(0.82);
	}
	14% {
		opacity: 1;
		transform: translateX(-50%) scale(1);
	}
	72% {
		opacity: 1;
		transform: translateX(-50%) scale(1);
	}
	100% {
		opacity: 0;
		transform: translateX(-50%) scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.find-flash.show {
		animation: none;
		opacity: 1;
	}
}

/* Waiting veil (eyes closed after finding) */
.waiting-veil {
	position: absolute;
	inset: 0;
	z-index: 14;
	background: rgb(5 3 8 / 0.94);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 20px;
}

.waiting-slit {
	width: 132px;
	height: 3px;
	border-radius: 2px;
	background: linear-gradient(90deg, transparent, #fff, transparent);
	box-shadow: 0 0 16px 3px rgb(255 220 190 / 0.5);
	animation: slit-breathe 2.2s ease-in-out infinite;
}

@keyframes slit-breathe {
	0%,
	100% {
		opacity: 0.5;
	}
	50% {
		opacity: 1;
	}
}

.waiting-title {
	font-size: 24px;
	font-weight: 900;
}

.standings {
	list-style: none;
	margin: 0;
	padding: 0;
	width: min(400px, 90vw);
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 46dvh;
	overflow-y: auto;
}

.standings li {
	display: grid;
	grid-template-columns: 1fr auto auto;
	gap: 10px;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 9px 13px;
	font-size: 14px;
	align-items: baseline;
}

.standings .st-name {
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.standings .st-detail {
	color: var(--text-dim);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.standings .st-total {
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.standings li.searching-row {
	opacity: 0.55;
}

/* Bottom-right 3-2-1 before the reveal (spec §4). */
.pre-reveal-count {
	position: absolute;
	right: 18px;
	bottom: max(18px, env(safe-area-inset-bottom));
	z-index: 16;
	font-size: 84px;
	font-weight: 900;
	color: #fff;
	text-shadow: 0 0 26px rgb(255 71 87 / 0.8);
	font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- reveal */

.reveal-stage {
	position: fixed;
	inset: 0;
	z-index: 34;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 18px;
}

.reveal-caption {
	font-size: 20px;
	font-weight: 800;
}

.reveal-photo-wrap {
	position: relative;
	height: min(64dvh, 70vw * 1.777);
	aspect-ratio: 768 / 1365;
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: 0 12px 60px rgb(0 0 0 / 0.6);
}

.reveal-photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ------------------------------------------------------------- blind find */

.blind-stage {
	position: fixed;
	inset: 0;
	z-index: 32;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: calc(max(10px, env(safe-area-inset-top)) + 52px) 16px 20px;
	gap: 14px;
}

.blind-head {
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: center;
}

.blind-kicker {
	font-size: 13px;
	letter-spacing: 0.24em;
	color: var(--neon);
	font-weight: 800;
}

.blind-prompt {
	font-size: clamp(18px, 5vw, 24px);
	font-weight: 900;
	max-width: 26ch;
}

.blind-timer {
	font-size: 30px;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	color: var(--neon);
}

.blind-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	gap: 8px;
	width: min(76vw, 46dvh, 420px);
	aspect-ratio: 768 / 1365;
	max-height: 56dvh;
}

.blind-cell {
	appearance: none;
	border: 2px solid rgb(57 255 136 / 0.35);
	background: rgb(57 255 136 / 0.05);
	border-radius: 10px;
	cursor: pointer;
	color: rgb(57 255 136 / 0.5);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	transition:
		background 0.15s ease,
		border-color 0.15s ease;
}

.blind-cell.armed {
	background: rgb(57 255 136 / 0.2);
	border-color: var(--neon);
	color: var(--neon);
}

.blind-cell.locked {
	background: var(--neon);
	color: #052312;
	border-color: var(--neon);
	box-shadow: 0 0 24px rgb(57 255 136 / 0.5);
}

.blind-hint {
	color: var(--text-dim);
	font-size: 13px;
	margin: 0;
}

/* ---------------------------------------------------------------- results */

.results-stage {
	position: fixed;
	inset: 0;
	z-index: 36;
	background: var(--bg);
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	padding: calc(max(10px, env(safe-area-inset-top)) + 54px) 16px 40px;
}

.results-title {
	margin: 0;
	font-size: 26px;
	font-weight: 900;
	letter-spacing: -0.02em;
}

.results-blind {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.results-blind-photo {
	position: relative;
	height: min(38dvh, 320px);
	aspect-ratio: 768 / 1365;
	border-radius: 12px;
	overflow: hidden;
}

.results-photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Neon green zone grid over the round photo (spec §9). */
.results-grid {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
	z-index: 5;
}

.results-grid .cell {
	border: 1.5px solid rgb(57 255 136 / 0.55);
	position: relative;
}

.results-grid .cell.actual {
	background: rgb(57 255 136 / 0.16);
	box-shadow: inset 0 0 18px rgb(57 255 136 / 0.4);
}

.results-grid .cell .pick-chips {
	position: absolute;
	inset: 2px;
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
	align-content: flex-end;
}

.results-grid .chip {
	background: rgb(12 10 18 / 0.85);
	color: var(--neon);
	border: 1px solid rgb(57 255 136 / 0.6);
	font-size: 9px;
	font-weight: 800;
	padding: 1px 5px;
	border-radius: 999px;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.results-blind-note {
	font-size: 14px;
	color: var(--text-dim);
	text-align: center;
	max-width: 40ch;
}

.results-table-wrap {
	width: min(560px, 94vw);
	overflow-x: auto;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}

.results-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.results-table th,
.results-table td {
	padding: 9px 10px;
	text-align: right;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.results-table th {
	color: var(--text-dim);
	font-weight: 700;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-bottom: 1px solid var(--line);
}

.results-table th:first-child,
.results-table td:first-child {
	text-align: left;
	font-weight: 700;
	max-width: 120px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.results-table tr + tr td {
	border-top: 1px solid var(--line);
}

.results-table .total-col {
	font-weight: 900;
	color: var(--gold);
}

.results-table .clean-yes {
	color: var(--neon);
	font-weight: 800;
}

/* ------------------------------------------------------------------ bonus */

.bonus-stage {
	position: fixed;
	inset: 0;
	z-index: 32;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	padding: calc(max(10px, env(safe-area-inset-top)) + 50px) 18px 24px;
	gap: 12px;
	align-items: center;
}

.bonus-head {
	width: min(480px, 100%);
	display: flex;
	justify-content: space-between;
	align-items: baseline;
}

.bonus-progress {
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 0.1em;
	color: var(--text-dim);
}

.bonus-timer {
	font-size: 28px;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
}

.bonus-timer.low {
	color: var(--red);
}

.bonus-stage .hud-bar {
	width: min(480px, 100%);
	border-radius: 2px;
	overflow: hidden;
}

.bonus-question {
	width: min(480px, 100%);
	font-size: clamp(19px, 5.4vw, 26px);
	font-weight: 900;
	line-height: 1.25;
	min-height: 3.6em;
	display: flex;
	align-items: center;
}

.bonus-choices {
	width: min(480px, 100%);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.bonus-choice {
	appearance: none;
	display: grid;
	grid-template-columns: 44px 1fr;
	align-items: center;
	gap: 12px;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 10px 14px;
	color: var(--text);
	font-size: 16px;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		background 0.15s ease;
}

.bonus-choice .letter {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid var(--text-dim);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 900;
	font-size: 17px;
}

.bonus-choice.armed {
	border-color: var(--gold);
}

.bonus-choice.armed .letter {
	border-color: var(--gold);
	color: var(--gold);
}

.bonus-choice.locked {
	border-color: var(--red);
	background: rgb(255 71 87 / 0.12);
}

.bonus-choice.locked .letter {
	background: var(--red);
	border-color: var(--red);
	color: #fff;
}

.bonus-hint {
	color: var(--text-dim);
	font-size: 13px;
	margin: 4px 0 0;
}

.bonus-done {
	position: absolute;
	inset: 0;
	background: rgb(5 3 8 / 0.94);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	z-index: 5;
	font-size: 16px;
	color: var(--text-dim);
}

/* ------------------------------------------------------------------ final */

.podium {
	list-style: none;
	margin: 0;
	padding: 0;
	width: min(480px, 94vw);
	display: flex;
	flex-direction: column;
	gap: 8px;
	counter-reset: place;
}

.podium li {
	display: grid;
	grid-template-columns: 48px 1fr auto;
	gap: 12px;
	align-items: center;
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 13px 16px;
	font-size: 17px;
	font-weight: 700;
}

.podium .place {
	font-size: 22px;
	font-weight: 900;
	color: var(--text-dim);
}

.podium li.p1 {
	border-color: rgb(255 206 84 / 0.5);
	background: linear-gradient(160deg, rgb(255 206 84 / 0.12), var(--bg-raise));
}

.podium li.p1 .place {
	color: var(--gold);
}

.podium .final-score {
	font-variant-numeric: tabular-nums;
	font-weight: 900;
}

.awards {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	width: min(480px, 94vw);
}

.award {
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.award .award-label {
	font-size: 11px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--text-dim);
	font-weight: 700;
}

.award .award-name {
	font-size: 16px;
	font-weight: 800;
}

.award .award-detail {
	font-size: 12px;
	color: var(--text-dim);
}

.personal-best {
	width: min(480px, 94vw);
	background: linear-gradient(160deg, rgb(255 206 84 / 0.16), var(--bg-raise));
	border: 1px solid rgb(255 206 84 / 0.45);
	border-radius: var(--radius);
	padding: 14px 16px;
	font-size: 15px;
	line-height: 1.5;
}

.personal-best strong {
	color: var(--gold);
}

.personal-best.new-best {
	animation: best-flash 1s ease-in-out 2;
}

@keyframes best-flash {
	0%,
	100% {
		box-shadow: none;
	}
	50% {
		box-shadow: 0 0 34px rgb(255 206 84 / 0.5);
	}
}

.final-board {
	width: min(480px, 94vw);
	background: var(--bg-raise);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.final-board .fb-title {
	padding: 11px 16px;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--text-dim);
	font-weight: 800;
	border-bottom: 1px solid var(--line);
}

.final-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
}

/* ------------------------------------------------------------------ toast */

.toast {
	position: fixed;
	left: 50%;
	bottom: max(20px, env(safe-area-inset-bottom));
	transform: translateX(-50%);
	background: var(--bg-raise-2);
	border: 1px solid var(--line);
	color: var(--text);
	padding: 11px 20px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	z-index: 99;
	max-width: 90vw;
	text-align: center;
}

/* Desktop: letterbox the portrait board gracefully. */
@media (min-width: 900px) {
	.board {
		border: 1px solid var(--line);
	}
}
