/* ── Design tokens ─────────────────────────────────────────────── */
:root {
	--pitch: #00c853;
	--pitch-dim: #007a32;
	--pitch-glow: rgba(0, 200, 83, 0.18);
	--navy: #141922;
	--navy-2: #0d1117;
	--navy-3: #161b26;
	--navy-4: #1e2535;
	--card: #1a2030;
	--border: rgba(255, 255, 255, 0.07);
	--text: #e8eaf0;
	--text-dim: #7a8499;
	--text-dimmer: #3d4558;

	--correct: #00c853;
	--correct-bg: rgba(0, 200, 83, 0.5);
	--close: #ffb300;
	--close-bg: rgba(255, 179, 0, 0.5);
	--high: #37414f;
	--high-bg: rgba(55, 65, 79, 0.5);
	--low: #37414f;
	--low-bg: rgba(55, 65, 79, 0.5);
	--wrong: #37414f;
	--wrong-bg: rgba(55, 65, 79, 0.5);

	--radius: 6px;
	--transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
html {
	scroll-behavior: smooth;
}

body {
	background: var(--navy);
	color: var(--text);
	font-family:
		"Barlow Condensed", "Segoe UI Emoji", "Apple Color Emoji",
		"Noto Color Emoji", sans-serif;
	min-height: 100vh;
	overflow-x: hidden;
}

/* ── Layout ────────────────────────────────────────────────────── */
.page {
	position: relative;
	z-index: 1;
	max-width: 860px;
	margin: 0 auto;
	padding: 0 16px 80px;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 28px 0 6px;
	border-bottom: 1px solid var(--border);
	margin-bottom: 0;
}

.logo {
	display: flex;
	flex-direction: column;
	line-height: 1;
}

.logo-title {
	display: flex;
	align-items: center;
	gap: 0.15em;
	font-size: clamp(2.8rem, 6vw, 4.2rem);
	font-weight: 900;
	letter-spacing: -0.02em;
	color: #fff;
	text-transform: uppercase;
	line-height: 1;
}

.logo-title .logo-main span {
	color: var(--pitch);
	text-shadow: 0 0 30px var(--pitch-glow);
}

.logo-title .logo-hyphen {
	color: #ffffff;
	text-shadow: none;
	font-weight: 600;
	font-size: 75%;
}
.logo-title .logo-world {
	color: var(--pitch);
	text-shadow: 0 0 30px var(--pitch-glow);
	font-weight: 600;
	font-size: 75%;
}
.logo-title .logo-cup {
	color: #ffffff;
	text-shadow: none;
	font-weight: 600;
	font-size: 75%;
}

.logo-sub {
	font-size: 0.85rem;
	font-weight: 400;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--text-dim);
	margin-top: 4px;
}

/* ── Mode selector ─────────────────────────────────────────────── */
.mode-selector {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	padding: 6px 0;
	margin-bottom: 0;
	border-bottom: 1px solid var(--border);
}

.mode-selector-btns {
	display: flex;
	gap: 16px;
	justify-content: center;
}

.mode-selector-right {
	display: flex;
	justify-content: flex-end;
}

.mode-btn {
	background: transparent;
	border: 1.5px solid var(--text-dimmer);
	border-radius: 20px;
	color: var(--text-dimmer);
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 4px 10px;
	min-width: 90px;
	text-align: center;
	cursor: pointer;
	transition: all var(--transition);
	white-space: nowrap;
}

.mode-btn:hover {
	border-color: var(--text-dim);
	color: var(--text);
}

.mode-btn.active {
	background: var(--pitch);
	border-color: var(--pitch);
	color: #000;
}

.guesses-pips {
	display: flex;
	gap: 5px;
}

.pips-bar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-bottom: 8px;
}

.pips-label {
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--text-dimmer);
}

.pip {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: 1.5px solid var(--text-dimmer);
	transition:
		background var(--transition),
		border-color var(--transition);
}
.pip.used {
	background: var(--text-dim);
	border-color: var(--text-dim);
}
.pip.won {
	background: var(--pitch);
	border-color: var(--pitch);
}
.pip.lost {
	background: var(--high);
	border-color: var(--high);
}

/* ── Column headers ────────────────────────────────────────────── */
.grid-header {
	display: grid;
	grid-template-columns: 52px repeat(6, 1fr);
	gap: 4px;
	margin-bottom: 4px;
	padding: 0;
}

.col-label {
	font-size: 0.9rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #ffffff;
	text-align: center;
	padding: 4px 0;
	line-height: 1.3;
}
.col-label:first-child {
	text-align: center;
	padding: 0;
}

/* ── Guess rows ────────────────────────────────────────────────── */
#guess-rows {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 24px;
}

.guess-row {
	display: grid;
	grid-template-columns: 52px repeat(6, 1fr);
	gap: 4px;
	opacity: 0;
	transform: translateY(-8px);
	animation: rowIn 0.35s ease forwards;
}

/* Answer row (shown on loss) has no name/photo cell, so drop that column
   track entirely — otherwise the 6 stat cells sit shifted right instead of
   filling the row evenly. */
.guess-row.answer-row {
	grid-template-columns: repeat(6, 1fr);
}

@keyframes rowIn {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ── Player name cell ──────────────────────────────────────────── */
.cell-name {
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: 0;
	padding: 2px;
	overflow: visible;
	min-height: 52px;
}

.cell-name img {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: var(--navy-4);
	border: 2px solid rgba(255, 255, 255, 0.15);
	display: block;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cell-name .player-label {
	display: none;
}

/* ── Stat cells — two-face 3D flip ─────────────────────────────── */

/* Outer container: sets up 3D perspective and height */
.cell {
	perspective: 600px;
	min-height: 52px;
	position: relative;
}

/* Inner card that actually flips */
.cell-inner {
	width: 100%;
	height: 100%;
	min-height: 52px;
	position: relative;
	transform-style: preserve-3d;
	transition: transform 0.75s ease;
	border-radius: var(--radius);
}

/* Flipped state — applied by JS with a delay per cell */
.cell-inner.flipped {
	transform: rotateY(180deg);
}

/* Shared face styles */
.cell-front,
.cell-back {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius);
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	-moz-backface-visibility: hidden;
	padding: 6px 4px;
	/* Firefox Android fallback — hide back face via opacity */
	transition: opacity 0.01s;
}

/* Firefox-only fix for backface-visibility bug on Android */
@-moz-document url-prefix() {
	.cell-back {
		opacity: 0;
	}
	.cell-inner.flipped .cell-front {
		opacity: 0;
	}
	.cell-inner.flipped .cell-back {
		opacity: 1;
	}
}

/* Front face — neutral dark, shows value before reveal */
.cell-front {
	background: var(--navy-3);
	border: 1px solid var(--border);
}

.cell-front .cell-value {
	color: #ffffff;
	font-size: 1.1rem;
}

/* Front face per-field sizes — match back face */
.cell[data-field="position"] .cell-front .cell-value,
.cell[data-field="wc_games"] .cell-front .cell-value,
.cell[data-field="wc_goals"] .cell-front .cell-value,
.cell[data-field="first_wc_year"] .cell-front .cell-value,
.cell[data-field="wc_best_stage"] .cell-front .cell-value {
	font-size: 1.65rem;
}

/* Back face — starts rotated 180deg, shows coloured result */
.cell-back {
	transform: rotateY(180deg);
	border: 1px solid transparent;
}

/* Result colour variants on the back face */
.cell.correct .cell-back {
	background: var(--correct-bg);
	border-color: var(--correct);
}
.cell.correct .cell-back .cell-value {
	color: #ffffff;
}

/* close — used by nationality (same continent) and position (same family) */
.cell.close .cell-back {
	background: var(--close-bg);
	border-color: var(--close);
}
.cell.close .cell-back .cell-value {
	color: #ffffff;
}

.cell.close_high .cell-back {
	background: var(--close-bg);
	border-color: var(--close);
}
.cell.close_high .cell-back .cell-value {
	color: #ffffff;
}
.cell.close_low .cell-back {
	background: var(--close-bg);
	border-color: var(--close);
}
.cell.close_low .cell-back .cell-value {
	color: #ffffff;
}

.cell.high .cell-back {
	background: var(--high-bg);
	border-color: var(--high);
}
.cell.high .cell-back .cell-value {
	color: #ffffff;
}

.cell.low .cell-back {
	background: var(--low-bg);
	border-color: var(--low);
}
.cell.low .cell-back .cell-value {
	color: #ffffff;
}

.cell.incorrect .cell-back {
	background: var(--wrong-bg);
	border-color: var(--wrong);
}
.cell.incorrect .cell-back .cell-value {
	color: #ffffff;
}

.cell.unknown .cell-back {
	background: var(--wrong-bg);
	border-color: var(--wrong);
}
.cell.unknown .cell-back .cell-value {
	color: rgba(255, 255, 255, 0.5);
}

.cell-flag {
	font-size: 1.6rem;
	line-height: 1;
	font-family:
		"Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

/* Flag-only nationality back face — make it bigger */
.cell .cell-back .cell-flag:only-child,
.cell .cell-back .cell-flag:first-child:last-child {
	font-size: 1.6rem;
}

/* Numeric tile: value always perfectly centred,
       triangle pinned to top or bottom edge via absolute positioning */
.cell-back-col {
	position: relative;
	width: 100%;
	height: 100%;
	min-height: 52px;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* CSS triangle — absolutely pinned to edge */
.cell-tri {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 0;
}

.tri-up {
	top: 6px;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-bottom: 7px solid rgba(255, 255, 255, 0.85);
}

.tri-down {
	bottom: 6px;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 7px solid rgba(255, 255, 255, 0.85);
}

/* Base cell value — centred, size overridden per field */
.cell-value {
	font-size: 1.1rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	text-align: center;
	line-height: 1;
	color: #ffffff;
}

/* Per-field font size overrides */
.cell[data-field="position"] .cell-value,
.cell[data-field="wc_games"] .cell-value,
.cell[data-field="wc_goals"] .cell-value,
.cell[data-field="first_wc_year"] .cell-value,
.cell[data-field="wc_best_stage"] .cell-value {
	font-size: 1.65rem;
}

/* keep cell-hint class but hide it — no longer used for arrows */
.cell-hint {
	display: none;
}

/* ── Input area ────────────────────────────────────────────────── */
.input-section {
	position: relative;
	margin-bottom: 20px;
}

.input-row {
	display: flex;
	gap: 8px;
}

.search-wrap {
	position: relative;
	flex: 1;
}

#search-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-dimmer);
	font-size: 1rem;
	pointer-events: none;
}

#player-input {
	width: 100%;
	background: var(--navy-3);
	border: 1.5px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	font-family: "Barlow Condensed", sans-serif;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 12px 14px 12px 40px;
	outline: none;
	transition:
		border-color var(--transition),
		box-shadow var(--transition);
}

#player-input::placeholder {
	color: var(--text-dimmer);
	text-transform: uppercase;
}
#player-input:focus {
	border-color: var(--pitch-dim);
	box-shadow: 0 0 0 3px var(--pitch-glow);
}

#guess-btn {
	background: var(--pitch);
	color: #000;
	border: none;
	border-radius: var(--radius);
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.95rem;
	font-weight: 900;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 12px 24px;
	cursor: pointer;
	transition:
		background var(--transition),
		transform var(--transition),
		box-shadow var(--transition);
	white-space: nowrap;
}

#guess-btn:hover:not(:disabled) {
	background: #00e65b;
	box-shadow: 0 0 20px var(--pitch-glow);
	transform: translateY(-1px);
}

#guess-btn:active:not(:disabled) {
	transform: translateY(0);
}
#guess-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

/* ── Autocomplete dropdown ─────────────────────────────────────── */
#autocomplete {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	max-height: 220px;
	overflow-y: auto;
	z-index: 100;
	display: none;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

#autocomplete.open {
	display: block;
}

.ac-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 14px;
	cursor: pointer;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--text);
	border-bottom: 1px solid var(--border);
	transition: background var(--transition);
}
.ac-item:last-child {
	border-bottom: none;
}
.ac-item:hover,
.ac-item.active {
	background: var(--navy-4);
}

.ac-item img {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--navy-4);
	flex-shrink: 0;
}

/* ── Legend ────────────────────────────────────────────────────── */
.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 20px;
	padding: 14px 16px;
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	margin-bottom: 28px;
}

.legend-item {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--text-dim);
}

.legend-dot {
	width: 10px;
	height: 10px;
	border-radius: 2px;
	flex-shrink: 0;
}

/* ── Toast / messages ──────────────────────────────────────────── */
#message-bar {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translateX(-50%) translateY(-80px);
	z-index: 999;
	transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
	pointer-events: none;
}

#message-bar.show {
	transform: translateX(-50%) translateY(0);
}

.toast {
	background: var(--navy-4);
	border: 1px solid var(--border);
	border-radius: 30px;
	padding: 10px 22px;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--text);
	white-space: nowrap;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* ── End game banner ───────────────────────────────────────────── */
/* ── End game modal ────────────────────────────────────────────── */
#end-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 300;
	align-items: flex-start;
	justify-content: center;
	padding: 16px 12px 24px;
	overflow-y: auto;
}

#end-modal.show {
	display: flex;
}

#end-modal .modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.75);
}

.end-modal-close {
	position: absolute;
	top: -14px;
	right: -14px;
	background: var(--navy-4);
	border: 1px solid var(--border);
	border-radius: 50%;
	color: var(--text-dim);
	font-size: 0.85rem;
	cursor: pointer;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	transition: all var(--transition);
}

.end-modal-close:hover {
	color: #ffffff;
	background: var(--navy);
}

.end-modal-box {
	position: relative;
	z-index: 1;
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: 14px;
	width: 100%;
	max-width: 380px;
	text-align: center;
	overflow: visible;
	margin: auto;
	margin-top: 20px;
}

/* Coloured top band */
.end-modal-band {
	padding: 16px 24px 12px;
	background: var(--navy-4);
	border-radius: 14px 14px 0 0;
}

.end-headline {
	font-size: clamp(1.8rem, 5vw, 2.6rem);
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: -0.01em;
	line-height: 1;
	margin-bottom: 0;
	text-align: center;
}

.end-headline.won {
	color: #ffffff;
	text-shadow: none;
}
.end-headline.lost {
	color: var(--close);
}

.end-guess-count {
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--text-dim);
}

/* Player card */
.end-player-card {
	padding: 12px 24px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	border-bottom: 1px solid var(--border);
}

.end-player-img {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
	border: 3px solid var(--border);
	background: var(--navy-4);
}

.end-player-name {
	font-size: clamp(1.4rem, 4vw, 2rem);
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #ffffff;
	line-height: 1;
}

/* Action buttons */
.end-actions {
	display: flex;
	gap: 10px;
	padding: 12px 16px;
	justify-content: center;
}

.end-btn {
	flex: 1;
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.9rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 12px 16px;
	border-radius: var(--radius);
	cursor: pointer;
	transition: all var(--transition);
	border: none;
}

.end-band-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
}

.end-btn-new {
	background: var(--pitch);
	color: #000;
}

.end-btn-new:hover {
	background: #00e65b;
	box-shadow: 0 0 20px var(--pitch-glow);
}

/* ── Loading state ─────────────────────────────────────────────── */
#loading-overlay {
	position: fixed;
	inset: 0;
	background: var(--navy);
	z-index: 200;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 20px;
	transition: opacity 0.4s ease;
}

#loading-overlay.hidden {
	opacity: 0;
	pointer-events: none;
}

.loader-logo {
	font-size: 4rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: -0.02em;
	color: #fff;
}
.loader-logo span {
	color: var(--pitch);
}

.spinner {
	width: 32px;
	height: 32px;
	border: 3px solid var(--navy-4);
	border-top-color: var(--pitch);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ── Error state ───────────────────────────────────────────────── */
#error-screen {
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 60vh;
	gap: 16px;
	text-align: center;
}

#error-screen.show {
	display: flex;
}

.error-title {
	font-size: 2rem;
	font-weight: 900;
	text-transform: uppercase;
	color: var(--close);
}

.error-msg {
	color: var(--text-dim);
	font-size: 0.9rem;
	max-width: 400px;
	line-height: 1.6;
}

/* ── Empty rows ────────────────────────────────────────────────── */
.empty-row {
	display: grid;
	grid-template-columns: 52px repeat(6, 1fr);
	gap: 4px;
	opacity: 0.3;
}

.empty-cell {
	height: 52px;
	border-radius: var(--radius);
	border: 1px dashed rgba(255, 255, 255, 0.35);
}

/* First cell in empty row — circular photo placeholder */
.empty-cell.empty-photo {
	border: none;
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
}

.empty-photo-circle {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 1px dashed rgba(255, 255, 255, 0.35);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.grid-header,
	.guess-row,
	.empty-row {
		grid-template-columns: 52px repeat(6, 1fr);
	}

	.col-label {
		font-size: 0.78rem;
	}
	.cell {
		min-height: 46px;
	}
	.cell-inner {
		min-height: 46px;
	}
	.cell-front,
	.cell-back {
		min-height: 46px;
	}
	.cell-flag {
		font-size: 1.6rem;
		line-height: 1;
		font-family:
			"Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
	}

	/* Flag-only nationality back face — make it bigger */
	.cell .cell-back .cell-flag:only-child,
	.cell .cell-back .cell-flag:first-child:last-child {
		font-size: 1.6rem;
	}

	.cell-value {
		font-size: 1.4rem;
	}
	.cell[data-field="position"] .cell-value,
	.cell[data-field="wc_games"] .cell-value,
	.cell[data-field="wc_goals"] .cell-value,
	.cell[data-field="first_wc_year"] .cell-value {
		font-size: 1.4rem;
	}
	.cell[data-field="wc_best_stage"] .cell-value {
		font-size: 1.2rem;
	}
	/* front face too */
	.cell[data-field="position"] .cell-front .cell-value,
	.cell[data-field="wc_games"] .cell-front .cell-value,
	.cell[data-field="wc_goals"] .cell-front .cell-value,
	.cell[data-field="first_wc_year"] .cell-front .cell-value {
		font-size: 1.4rem;
	}
	.cell[data-field="wc_best_stage"] .cell-front .cell-value {
		font-size: 1.2rem;
	}

	#guess-btn {
		padding: 12px 14px;
		font-size: 0.85rem;
	}
}

/* ── Info button ───────────────────────────────────────────────── */
.info-btn {
	background: transparent;
	border: 1.5px solid var(--pitch);
	border-radius: 50%;
	color: var(--pitch);
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.9rem;
	font-weight: 700;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all var(--transition);
	flex-shrink: 0;
}

.info-btn:hover {
	border-color: #00e65b;
	color: #00e65b;
}

/* ── Info modal overlay ────────────────────────────────────────── */
#info-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 300;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

#info-modal.show {
	display: flex;
}

.modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.7);
}

.modal-box {
	position: relative;
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: 10px;
	width: 100%;
	max-width: 420px;
	max-height: 85vh;
	overflow-y: auto;
	padding: 24px 22px 28px;
	z-index: 1;
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.modal-title {
	font-size: 1.2rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--pitch);
}

.modal-close {
	background: transparent;
	border: none;
	color: var(--text-dimmer);
	font-size: 1.4rem;
	cursor: pointer;
	line-height: 1;
	padding: 0 4px;
	transition: color var(--transition);
}

.modal-close:hover {
	color: var(--text);
}

.modal-section-title {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--pitch-dim);
	margin: 16px 0 8px;
	padding-bottom: 4px;
	border-bottom: 1px solid var(--border);
}

.modal-section-title:first-of-type {
	margin-top: 0;
}

.modal-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.82rem;
}

.modal-table td {
	padding: 5px 4px;
	vertical-align: top;
	color: var(--text);
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.modal-table td:first-child {
	font-family: "DM Mono", monospace;
	font-weight: 500;
	color: var(--pitch);
	white-space: nowrap;
	padding-right: 14px;
	width: 60px;
}

.modal-table tr:last-child td {
	border-bottom: none;
}

.modal-note {
	font-size: 0.78rem;
	color: var(--text-dim);
	line-height: 1.5;
	margin-top: 6px;
}

/* ── Stats panel ───────────────────────────────────────────────── */
.stats-panel {
	padding: 10px 14px 4px;
	border-top: 1px solid var(--border);
}

.stats-panel-title {
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: #8899aa;
	text-align: center;
	margin-bottom: 14px;
}

.stats-row {
	display: flex;
	justify-content: space-around;
	gap: 8px;
	margin-bottom: 18px;
}

.stat-box {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	flex: 1;
}

.stat-value {
	font-size: 1.3rem;
	font-weight: 900;
	color: #ffffff;
	line-height: 1;
}

.stat-label {
	font-size: 0.6rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #8899aa;
	text-align: center;
	line-height: 1.3;
}

/* Bar chart */
.chart-title {
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: #8899aa;
	margin-bottom: 10px;
}

.chart-bars {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin-bottom: 20px;
}

.chart-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.chart-label {
	font-size: 0.75rem;
	font-weight: 700;
	color: #8899aa;
	width: 14px;
	text-align: right;
	flex-shrink: 0;
}

.chart-bar-wrap {
	flex: 1;
	height: 20px;
	background: var(--navy-4);
	border-radius: 3px;
	overflow: hidden;
}

.chart-bar {
	height: 100%;
	background: var(--pitch);
	border-radius: 3px;
	min-width: 2px;
	transition: width 0.6s ease;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding-right: 6px;
}

.chart-bar.highlight {
	background: var(--close);
}

.chart-bar-count {
	font-size: 0.68rem;
	font-weight: 700;
	color: #000;
	white-space: nowrap;
}

.chart-bar-count.outside {
	color: #8899aa;
	padding-left: 6px;
	padding-right: 0;
	justify-content: flex-start;
}

/* ── Long-press / hover tooltip ────────────────────────────────── */
.tt-wrap {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.tt-bubble {
	visibility: hidden;
	opacity: 0;
	position: absolute;
	bottom: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	background: var(--navy);
	color: #ffffff;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	white-space: nowrap;
	padding: 5px 10px;
	border-radius: 5px;
	border: 1px solid var(--border);
	pointer-events: none;
	z-index: 200;
	transition: opacity 0.15s ease;
}

.tt-bubble::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: var(--border);
}

.tt-wrap.tt-show .tt-bubble,
.tt-wrap:hover .tt-bubble {
	visibility: visible;
	opacity: 1;
}

/* ── Sports switcher tile ──────────────────────────────────────── */
.sports-tile {
	background: var(--wrong-bg);
	border: 1px solid var(--wrong);
	border-radius: var(--radius);
	cursor: pointer;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1px;
	width: 52px;
	height: 52px;
	flex-shrink: 0;
	place-items: center;
	transition:
		border-color var(--transition),
		background var(--transition);
}

.sports-tile:hover {
	border-color: var(--text-dim);
	background: var(--navy-4);
}

.sports-tile span {
	font-size: 0.8rem;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	width: 100%;
	height: 100%;
}

/* Coming soon modal */
#sports-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 300;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

#sports-modal.show {
	display: flex;
}

/* ── Welcome / how-to-play modal ───────────────────────────────── */
#welcome-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 400;
	align-items: flex-start;
	justify-content: center;
	padding: 16px 12px 24px;
	overflow-y: auto;
}

#welcome-modal.show {
	display: flex;
}

#welcome-modal .modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
}

.welcome-box {
	position: relative;
	z-index: 1;
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: 14px;
	width: 100%;
	max-width: 420px;
	margin: auto;
	margin-top: 16px;
	overflow: hidden;
}

.welcome-header {
	background: var(--navy-4);
	padding: 16px 20px 12px;
	border-bottom: 1px solid var(--border);
	text-align: center;
}

.welcome-title {
	font-size: 1.3rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #ffffff;
}

.welcome-subtitle {
	font-size: 0.75rem;
	color: #8899aa;
	margin-top: 4px;
	letter-spacing: 0.04em;
}

.welcome-body {
	padding: 14px 16px 16px;
}

.welcome-instruction {
	font-size: 0.78rem;
	color: #aabbcc;
	text-align: center;
	margin-bottom: 12px;
	line-height: 1.4;
}

/* Mini grid for the example */
.welcome-grid {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 14px;
}

.welcome-row {
	display: grid;
	grid-template-columns: 38px repeat(6, 1fr);
	gap: 3px;
}

.welcome-photo {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--navy-4);
	border: 1.5px solid rgba(255, 255, 255, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.6rem;
	color: #8899aa;
	overflow: hidden;
	flex-shrink: 0;
}

.welcome-photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.wc {
	height: 38px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	color: #ffffff;
	font-family: "Barlow Condensed", sans-serif;
	letter-spacing: 0.02em;
	position: relative;
}

.wc.correct {
	background: var(--correct-bg);
	border: 1px solid var(--correct);
}
.wc.close {
	background: var(--close-bg);
	border: 1px solid var(--close);
}
.wc.wrong {
	background: var(--wrong-bg);
	border: 1px solid var(--wrong);
}

.wc .wc-tri {
	position: absolute;
	width: 0;
	height: 0;
	left: 50%;
	transform: translateX(-50%);
}
.wc .wc-tri.up {
	top: 3px;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-bottom: 6px solid rgba(255, 255, 255, 0.8);
}
.wc .wc-tri.down {
	bottom: 3px;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 6px solid rgba(255, 255, 255, 0.8);
}

.welcome-footer {
	text-align: center;
	padding: 10px 16px 16px;
	border-top: 1px solid var(--border);
	font-size: 0.75rem;
	color: #8899aa;
	line-height: 1.5;
}

.welcome-footer strong {
	color: #ffffff;
}

.welcome-start-btn {
	margin-top: 12px;
	background: var(--pitch);
	border: none;
	border-radius: 8px;
	color: #000;
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.9rem;
	font-weight: 800;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 10px 28px;
	cursor: pointer;
	transition: background var(--transition);
	display: block;
	margin-left: auto;
	margin-right: auto;
}

.welcome-start-btn:hover {
	background: #00e65b;
}

/* Column labels for example grid */
.welcome-col-labels {
	display: grid;
	grid-template-columns: 38px repeat(6, 1fr);
	gap: 3px;
	margin-bottom: 4px;
}

/* Welcome grid cell tooltips */
.wc {
	position: relative;
}

.wc-tip {
	display: none;
	position: fixed;
	background: var(--navy);
	border: 1px solid var(--border);
	border-radius: 5px;
	color: #ffffff;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: normal;
	max-width: 240px;
	width: max-content;
	text-align: center;
	padding: 6px 10px;
	z-index: 600;
	pointer-events: none;
	text-transform: none;
	line-height: 1.4;
}

@media (hover: hover) {
	.wc:hover .wc-tip {
		display: block;
	}
}

.wcl {
	font-size: 0.48rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #8899aa;
	text-align: center;
	line-height: 1.2;
}

.lang-selector {
	display: flex;
	gap: 4px;
	align-items: center;
	flex-shrink: 0;
}

.lang-btn {
	background: transparent;
	border: 1px solid var(--border);
	border-radius: 4px;
	color: var(--text-dim);
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	padding: 3px 6px;
	cursor: pointer;
	transition: all var(--transition);
}

.lang-btn:hover,
.lang-btn.active {
	border-color: var(--pitch);
	color: var(--pitch);
}

/* ── Cookie consent banner ── */
#cookie-banner {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #1e2634;
	border-top: 1px solid var(--border);
	padding: 16px 20px;
	z-index: 9999;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	font-size: 0.78rem;
	color: #aabbcc;
	line-height: 1.5;
}
#cookie-banner.hidden {
	display: none;
}
.cookie-text {
	flex: 1;
	min-width: 200px;
}
.cookie-text a {
	color: var(--pitch);
}
.cookie-btns {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}
.cookie-btn {
	font-family: "Barlow Condensed", sans-serif;
	font-weight: 700;
	font-size: 0.78rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 7px 16px;
	border-radius: 6px;
	border: none;
	cursor: pointer;
	transition: all 0.15s;
}
.cookie-btn-accept {
	background: var(--pitch);
	color: #000;
}
.cookie-btn-accept:hover {
	background: #00e676;
}
.cookie-btn-decline {
	background: transparent;
	color: var(--dim);
	border: 1px solid var(--border);
}
.cookie-btn-decline:hover {
	border-color: var(--text);
	color: var(--text);
}

/* ── Footer ── */
.site-footer {
	text-align: center;
	padding: 20px;
	font-size: 0.7rem;
	color: #484f58;
	letter-spacing: 0.06em;
}
.site-footer a {
	color: #484f58;
	text-decoration: none;
}
.site-footer a:hover {
	color: var(--dim);
}

/* ── Ad modal ── */
#ad-modal {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	z-index: 8000;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
#ad-modal.hidden {
	display: none;
}
.ad-modal-box {
	background: var(--navy-3);
	border: 1px solid var(--border);
	border-radius: 14px;
	width: 100%;
	max-width: 380px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.ad-fact-section {
	padding: 24px 20px 20px;
	flex: 1;
}
.ad-fact-label {
	font-family: "Barlow Condensed", sans-serif;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: #ffffff;
	margin-bottom: 10px;
	text-align: center;
}
.ad-fact-text {
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--text);
}

.ad-continue-section {
	padding: 12px 20px;
	border-top: 1px solid var(--border);
}
#ad-continue-btn {
	width: 100%;
	padding: 12px;
	border: none;
	border-radius: 8px;
	font-family: "Barlow Condensed", sans-serif;
	font-weight: 700;
	font-size: 0.9rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	cursor: not-allowed;
	background: var(--navy-4);
	color: var(--dim);
	transition: all 0.3s;
}
#ad-continue-btn.ready {
	background: var(--pitch);
	color: #000;
	cursor: pointer;
}
#ad-continue-btn.ready:hover {
	background: #00e676;
}

/* ══════════════════════════════════════════════════════════════════
   Sub-page styles (privacy.html, credits.html)
   ══════════════════════════════════════════════════════════════════ */

/* Extra root tokens used by sub-pages (aliased to match game tokens) */
:root {
	--bg: #0d1117; /* = --navy-2 */
	--panel: #161b26; /* = --navy-3 */
	--dim: #7a8499; /* = --text-dim */
}

body.sub-page {
	background: var(--bg);
	color: var(--text);
	font-family: "Barlow", sans-serif;
	font-size: 15px;
	line-height: 1.7;
	min-height: 100vh;
}

body.sub-page header {
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	padding: 14px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 10;
}

body.sub-page .logo {
	font-family: "Barlow Condensed", sans-serif;
	font-weight: 900;
	font-size: 1.4rem;
	letter-spacing: 0.12em;
	color: var(--pitch);
	text-decoration: none;
}

body.sub-page .logo span {
	color: var(--dim);
	font-weight: 400;
	font-size: 0.85rem;
	margin-left: 8px;
}

.back-link {
	font-size: 0.78rem;
	color: var(--dim);
	text-decoration: none;
	letter-spacing: 0.08em;
	transition: color 0.15s;
}
.back-link:hover {
	color: var(--pitch);
}

/* ── Privacy page ── */
body.sub-page main {
	max-width: 720px;
	margin: 0 auto;
	padding: 40px 24px 80px;
}

body.sub-page h1 {
	font-family: "Barlow Condensed", sans-serif;
	font-size: 2rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	margin-bottom: 6px;
}

.updated {
	color: var(--dim);
	font-size: 0.82rem;
	margin-bottom: 32px;
}

body.sub-page h2 {
	font-family: "Barlow Condensed", sans-serif;
	font-size: 1.2rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--pitch);
	margin-top: 36px;
	margin-bottom: 10px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--border);
}

body.sub-page p {
	margin-bottom: 14px;
	color: #c9d1d9;
}

body.sub-page ul {
	margin: 0 0 14px 20px;
	color: #c9d1d9;
}

body.sub-page li {
	margin-bottom: 6px;
}

body.sub-page a {
	color: var(--pitch);
}

.contact-box {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 16px 20px;
	margin-top: 12px;
	color: var(--dim);
	font-size: 0.88rem;
}
.contact-box a {
	color: var(--pitch);
}

/* ── Credits page ── */
body.sub-page main.credits-main {
	max-width: 860px;
	padding: 32px 20px 60px;
}

body.sub-page h1.credits-title {
	font-size: 1.8rem;
	margin-bottom: 8px;
}

.intro {
	color: var(--dim);
	font-size: 0.85rem;
	line-height: 1.6;
	max-width: 600px;
	margin-bottom: 28px;
}
.intro a {
	color: var(--pitch);
}

.credits-search-wrap {
	position: relative;
	margin-bottom: 24px;
}
#credits-search {
	width: 100%;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	font-family: "Barlow", sans-serif;
	font-size: 0.9rem;
	padding: 10px 14px 10px 36px;
	outline: none;
	transition: border-color 0.15s;
}
#credits-search:focus {
	border-color: var(--pitch);
}
.credits-search-icon {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--dim);
	font-size: 0.9rem;
	pointer-events: none;
}

.stats-bar {
	display: flex;
	gap: 20px;
	margin-bottom: 20px;
	font-size: 0.75rem;
	color: var(--dim);
	letter-spacing: 0.06em;
}
.stats-bar span {
	color: var(--text);
	font-weight: 600;
}

.credits-table {
	width: 100%;
	border-collapse: collapse;
}
.credits-table th {
	text-align: left;
	font-family: "Barlow Condensed", sans-serif;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--dim);
	padding: 8px 12px;
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 57px;
	background: var(--bg);
}
.credits-table td {
	padding: 10px 12px;
	border-bottom: 1px solid rgba(48, 54, 61, 0.5);
	vertical-align: middle;
	font-size: 0.78rem;
}
.credits-table tr:hover td {
	background: rgba(255, 255, 255, 0.02);
}

.player-cell {
	display: flex;
	align-items: center;
	gap: 10px;
}
.player-photo {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	border: 1.5px solid var(--border);
	background: var(--panel);
	flex-shrink: 0;
}
.player-no-photo {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 1.5px solid var(--border);
	background: var(--panel);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--dim);
	font-size: 0.7rem;
}
.player-name {
	font-weight: 600;
}
.player-nat {
	color: var(--dim);
	font-size: 0.78rem;
}

.license-badge {
	display: inline-block;
	font-size: 0.65rem;
	font-weight: 600;
	letter-spacing: 0.05em;
	padding: 2px 7px;
	border-radius: 10px;
	border: 1px solid var(--border);
	color: var(--dim);
	white-space: nowrap;
}
.license-badge.cc0 {
	border-color: var(--pitch);
	color: var(--pitch);
}
.license-badge.ccby {
	border-color: #79c0ff;
	color: #79c0ff;
}
.license-badge.ccbysa {
	border-color: #79c0ff;
	color: #79c0ff;
}

.attr-text {
	color: var(--dim);
	font-size: 0.78rem;
	line-height: 1.4;
}

.link-cell a {
	color: var(--pitch);
	text-decoration: none;
	font-size: 0.78rem;
	white-space: nowrap;
}
.link-cell a:hover {
	text-decoration: underline;
}

.no-photo-row td {
	opacity: 0.45;
}

.credits-empty {
	text-align: center;
	padding: 60px 0;
	color: var(--dim);
	font-size: 0.9rem;
}

#credits-loading {
	text-align: center;
	padding: 60px 0;
	color: var(--dim);
}
#credits-loading .spinner {
	display: inline-block;
	width: 24px;
	height: 24px;
	border-width: 2px;
	margin-bottom: 12px;
}
