/* =========================================================
   games.guewen.fr — Thème partagé
   Design system unique pour le portail et les compteurs.
   Modes clair / sombre automatiques via prefers-color-scheme.

   Identité : salon de jeu — feutre profond, cartes crème,
   accent or, suite décorative par jeu.
   ========================================================= */

/* =========================================================
   0. Police auto-hébergée (Inter Variable)
   Source : https://rsms.me/inter/ — SIL Open Font License.
   Permet de se passer entièrement de Google Fonts (CSP/RGPD).
   ========================================================= */
@font-face {
	font-family: 'Inter';
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url('/fonts/InterVariable.woff2') format('woff2');
}

/* =========================================================
   1. Tokens — palette & design tokens
   ========================================================= */
:root {
	color-scheme: light;

	/* Couleurs neutres invariantes (référencées par les modes) */
	--ink-900: #0a1612;
	--ink-700: #142822;
	--ink-500: #2a3d36;
	--cream-50: #fbf7ee;
	--cream-100: #f6efe0;
	--cream-200: #e9dcc1;
	--cream-300: #ddcdaa;

	/* Or — accent transverse (légèrement adapté en dark) */
	--gold-soft: #d8b878;
	--gold: #c9a26a;
	--gold-deep: #a8854f;

	/* Sémantique commune */
	--success: #2f7d5b;
	--warning: #b07d2a;
	--danger: #b6233a;

	/* === Mode CLAIR (défaut) === */
	--bg-base: #f0e6cf;
	--bg-glow-1: rgba(216, 184, 120, 0.28);
	--bg-glow-2: rgba(168, 133, 79, 0.14);

	--surface: #ffffff;
	--surface-soft: var(--cream-50);
	--surface-inset: rgba(20, 40, 34, 0.04);
	--surface-emphasis-bg-1: var(--ink-700);
	--surface-emphasis-bg-2: var(--ink-900);
	--surface-emphasis-glow: rgba(216, 184, 120, 0.20);

	--text: var(--ink-900);
	--text-muted: #5d6b62;
	--text-on-emphasis: var(--cream-50);
	--text-on-emphasis-muted: rgba(246, 239, 224, 0.7);

	--border: rgba(20, 40, 34, 0.08);
	--border-strong: rgba(20, 40, 34, 0.16);
	--divider: rgba(20, 40, 34, 0.08);

	--input-bg: #ffffff;
	--input-border: rgba(20, 40, 34, 0.14);
	--input-border-hover: rgba(20, 40, 34, 0.28);
	--input-placeholder: rgba(20, 40, 34, 0.35);
	--select-arrow: "%235d6b62";

	--btn-bg: var(--ink-900);
	--btn-fg: var(--cream-50);
	--btn-border: var(--ink-900);

	--shadow-card:
		0 1px 0 rgba(255, 255, 255, 0.6) inset,
		0 18px 40px -22px rgba(20, 40, 34, 0.18),
		0 6px 18px -10px rgba(20, 40, 34, 0.12);
	--shadow-soft:
		0 8px 20px -12px rgba(20, 40, 34, 0.18),
		0 2px 6px -2px rgba(20, 40, 34, 0.08);
	--shadow-lift:
		0 1px 0 rgba(255, 255, 255, 0.7) inset,
		0 30px 60px -25px rgba(20, 40, 34, 0.22),
		0 12px 28px -15px rgba(20, 40, 34, 0.16);

	--texture-light: 0.06;
	--texture-dark: 0.05;
	--texture-opacity: 0.5;
	--texture-blend: multiply;

	/* Per-page (défauts neutres, surchargés par chaque jeu) */
	--accent: var(--gold-deep);
	--accent-strong: #8a6a3b;
	--accent-soft: rgba(168, 133, 79, 0.1);
	--accent-ring: rgba(168, 133, 79, 0.22);
	--suit: "♠";

	/* Tokens visuels invariants */
	--radius-xl: 22px;
	--radius-lg: 18px;
	--radius-md: 12px;
	--radius-sm: 8px;
	--mono: 'SF Mono', 'JetBrains Mono', 'Menlo', 'Monaco', monospace;
	--ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* === Mode SOMBRE === */
@media (prefers-color-scheme: dark) {
	:root {
		color-scheme: dark;

		--bg-base: #0a1d18;
		--bg-glow-1: rgba(20, 70, 58, 0.55);
		--bg-glow-2: rgba(15, 49, 39, 0.55);

		--surface: #13241e;
		--surface-soft: #172a23;
		--surface-inset: rgba(246, 239, 224, 0.04);
		--surface-emphasis-bg-1: var(--cream-50);
		--surface-emphasis-bg-2: var(--cream-100);
		--surface-emphasis-glow: rgba(168, 133, 79, 0.22);

		--text: var(--cream-50);
		--text-muted: rgba(246, 239, 224, 0.62);
		--text-on-emphasis: var(--ink-900);
		--text-on-emphasis-muted: #5d6b62;

		--border: rgba(246, 239, 224, 0.08);
		--border-strong: rgba(246, 239, 224, 0.18);
		--divider: rgba(246, 239, 224, 0.08);

		--input-bg: #172a23;
		--input-border: rgba(246, 239, 224, 0.12);
		--input-border-hover: rgba(246, 239, 224, 0.24);
		--input-placeholder: rgba(246, 239, 224, 0.35);
		--select-arrow: "%23a3b3ac";

		--btn-bg: var(--cream-50);
		--btn-fg: var(--ink-900);
		--btn-border: var(--cream-50);

		--gold-soft: #e2c891;
		--gold: #d8b878;
		/* --gold-deep reste #a8854f : il est utilisé comme accent
		   typographique sur les bandeaux (encre en clair, crème en
		   sombre) — cette valeur reste lisible sur les deux fonds. */

		--shadow-card:
			0 1px 0 rgba(255, 255, 255, 0.04) inset,
			0 30px 60px -25px rgba(0, 0, 0, 0.55),
			0 12px 28px -18px rgba(0, 0, 0, 0.45);
		--shadow-soft:
			0 8px 20px -12px rgba(0, 0, 0, 0.4),
			0 2px 6px -2px rgba(0, 0, 0, 0.25);
		--shadow-lift:
			0 1px 0 rgba(255, 255, 255, 0.06) inset,
			0 40px 80px -30px rgba(0, 0, 0, 0.6),
			0 18px 40px -20px rgba(0, 0, 0, 0.5);

		--texture-light: 0.025;
		--texture-dark: 0.06;
		--texture-opacity: 0.6;
		--texture-blend: overlay;
	}
}

/* =========================================================
   2. Reset
   ========================================================= */
*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

/* =========================================================
   3. Document
   ========================================================= */
body {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-feature-settings: 'cv11', 'ss01';
	color: var(--text);
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	background-color: var(--bg-base);
	background-image:
		radial-gradient(1200px 700px at 50% -10%, var(--bg-glow-1), transparent 60%),
		radial-gradient(900px 600px at 100% 100%, var(--bg-glow-2), transparent 70%);
	background-attachment: fixed;
	transition:
		background-color 0.3s var(--ease),
		color 0.3s var(--ease);
}

/* Texture discrète, pointillée — feutre / parchemin selon le mode */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	background-image:
		radial-gradient(rgba(255, 255, 255, var(--texture-light)) 1px, transparent 1px),
		radial-gradient(rgba(0, 0, 0, var(--texture-dark)) 1px, transparent 1px);
	background-size: 3px 3px, 5px 5px;
	background-position: 0 0, 1px 2px;
	mix-blend-mode: var(--texture-blend);
	opacity: var(--texture-opacity);
}

/* =========================================================
   4. Coquille / mise en page
   ========================================================= */
.page {
	position: relative;
	z-index: 1;
	width: min(1080px, 100%);
	margin-inline: auto;
	padding: clamp(24px, 3vw, 48px) clamp(20px, 4vw, 40px) clamp(40px, 5vw, 64px);
	display: flex;
	flex-direction: column;
	gap: clamp(28px, 3.5vw, 44px);
	min-height: 100vh;
}

.app-shell {
	display: flex;
	flex-direction: column;
	gap: clamp(20px, 2.5vw, 28px);
}

#setupPhase,
#gamePhase,
#gameOverPhase {
	display: flex;
	flex-direction: column;
	gap: clamp(20px, 2.5vw, 28px);
}

/* =========================================================
   5. Navigation haute
   ========================================================= */
.top-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.game-id {
	display: inline-flex;
	align-items: center;
	min-height: 34px;
	padding: 6px 12px;
	color: var(--text-muted);
	font: 600 0.75rem var(--mono);
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface-inset);
}

.back-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--text-muted);
	text-decoration: none;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: var(--surface-inset);
	transition:
		color 0.2s var(--ease),
		border-color 0.2s var(--ease),
		background 0.2s var(--ease),
		transform 0.2s var(--ease);
}

.back-link:hover {
	color: var(--gold);
	border-color: color-mix(in srgb, var(--gold) 50%, transparent);
	background: color-mix(in srgb, var(--gold) 10%, transparent);
	transform: translateX(-2px);
}

.back-link:focus-visible {
	outline: 2px solid var(--gold-soft);
	outline-offset: 3px;
}

/* =========================================================
   6. Surface "carte"
   ========================================================= */
.card {
	position: relative;
	padding: clamp(24px, 3vw, 36px);
	border-radius: var(--radius-xl);
	background: var(--surface);
	color: var(--text);
	border: 1px solid var(--border);
	box-shadow: var(--shadow-card);
	display: flex;
	flex-direction: column;
	gap: clamp(18px, 2vw, 22px);
	overflow: hidden;
	isolation: isolate;
	transition:
		background 0.3s var(--ease),
		border-color 0.3s var(--ease);
}

/* Liseré or supérieur */
.card::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(
		90deg,
		transparent 8%,
		var(--gold) 35%,
		var(--gold-soft) 50%,
		var(--gold) 65%,
		transparent 92%
	);
}

.card-compact {
	padding: clamp(18px, 2vw, 22px);
	gap: 0;
}

/* En-tête de section dans une carte */
.section-header {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--divider);
}

.section-header h2 {
	font-size: clamp(1.25rem, 2vw, 1.55rem);
	font-weight: 700;
	letter-spacing: -0.015em;
	color: var(--text);
	line-height: 1.2;
}

.section-header h2::before {
	content: var(--suit);
	display: inline-block;
	margin-right: 10px;
	color: var(--accent);
	font-weight: 400;
	transform: translateY(-1px);
}

.section-header p {
	color: var(--text-muted);
	font-size: 0.92rem;
	line-height: 1.55;
}

/* =========================================================
   7. Formulaires
   ========================================================= */
.input-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.helper-text {
	color: var(--text-muted);
	font-size: 0.82rem;
	line-height: 1.45;
}

label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select {
	width: 100%;
	padding: 13px 16px;
	font-family: inherit;
	font-size: 0.98rem;
	color: var(--text);
	background: var(--input-bg);
	border: 1px solid var(--input-border);
	border-radius: var(--radius-md);
	transition:
		border-color 0.2s var(--ease),
		box-shadow 0.2s var(--ease),
		background 0.2s var(--ease),
		color 0.2s var(--ease);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder {
	color: var(--input-placeholder);
}

input:hover,
select:hover {
	border-color: var(--input-border-hover);
}

input:focus,
select:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px var(--accent-ring);
}

select {
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='none' stroke='%235d6b62' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
	background-repeat: no-repeat;
	background-position: right 16px center;
	background-size: 12px 8px;
	padding-right: 40px;
}

@media (prefers-color-scheme: dark) {
	select {
		background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='none' stroke='%23a3b3ac' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
	}
}

/* Checkbox personnalisée */
.checkbox-label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 0.92rem;
	font-weight: 500;
	color: var(--text);
	user-select: none;
}

.checkbox-label input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 5px;
	border: 1.5px solid var(--input-border);
	background: var(--input-bg);
	cursor: pointer;
	display: inline-grid;
	place-content: center;
	transition:
		border-color 0.2s var(--ease),
		background 0.2s var(--ease);
}

.checkbox-label input[type="checkbox"]::before {
	content: "";
	width: 10px;
	height: 10px;
	transform: scale(0);
	transition: transform 0.15s var(--ease);
	background: var(--cream-50);
	clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 20%, 86% 6%, 40% 75%);
}

.checkbox-label input[type="checkbox"]:checked {
	background: var(--accent);
	border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::before {
	transform: scale(1);
}

.checkbox-label input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--gold-soft);
	outline-offset: 3px;
}

/* =========================================================
   8. Boutons
   ========================================================= */
.btn {
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 14px 22px;
	font-family: inherit;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--btn-fg);
	background: var(--btn-bg);
	border: 1px solid var(--btn-border);
	border-radius: 999px;
	cursor: pointer;
	transition:
		transform 0.2s var(--ease),
		background 0.2s var(--ease),
		border-color 0.2s var(--ease),
		color 0.2s var(--ease),
		box-shadow 0.2s var(--ease);
}

.btn:hover {
	background: var(--accent);
	color: var(--cream-50);
	border-color: var(--accent);
	box-shadow: 0 14px 28px -14px var(--accent);
	transform: translateY(-1px);
}

.btn:active {
	transform: translateY(0);
}

.btn:focus-visible {
	outline: 2px solid var(--gold-soft);
	outline-offset: 3px;
}

.btn-danger {
	background: transparent;
	color: var(--danger);
	border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-danger:hover {
	background: var(--danger);
	color: var(--cream-50);
	border-color: var(--danger);
	box-shadow: 0 14px 28px -14px var(--danger);
}

/* Petit bouton "revenir en arrière" dans l'historique */
.btn-revert {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	font-family: inherit;
	font-size: 1rem;
	color: var(--text-muted);
	background: transparent;
	border: 1px solid var(--border);
	border-radius: 999px;
	cursor: pointer;
	line-height: 1;
	transition:
		color 0.2s var(--ease),
		border-color 0.2s var(--ease),
		background 0.2s var(--ease),
		transform 0.2s var(--ease);
}

.btn-revert:hover {
	color: var(--accent);
	border-color: var(--accent);
	background: var(--accent-soft);
	transform: translateY(-1px);
}

.btn-revert:focus-visible {
	outline: 2px solid var(--gold-soft);
	outline-offset: 2px;
}

/* =========================================================
   9. Bandeau "manche/donne en cours"
   Surface d'emphase : ink en clair, crème en sombre.
   ========================================================= */
.round-info {
	position: relative;
	padding: clamp(20px, 2.5vw, 28px) clamp(24px, 3vw, 36px);
	border-radius: var(--radius-xl);
	background:
		radial-gradient(120% 140% at 0% 0%, var(--surface-emphasis-glow), transparent 55%),
		linear-gradient(135deg, var(--surface-emphasis-bg-1) 0%, var(--surface-emphasis-bg-2) 100%);
	color: var(--text-on-emphasis);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.05) inset,
		var(--shadow-soft);
	display: flex;
	flex-direction: column;
	gap: 6px;
	overflow: hidden;
	isolation: isolate;
}

.round-info::after {
	content: var(--suit);
	position: absolute;
	top: 50%;
	right: -16px;
	transform: translateY(-50%) rotate(-10deg);
	font-size: 8rem;
	color: var(--accent);
	opacity: 0.22;
	pointer-events: none;
	z-index: -1;
}

.round-number {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.32em;
	text-transform: uppercase;
	color: var(--gold-deep);
}

.round-number span {
	color: var(--text-on-emphasis);
	font-size: 1.05rem;
	letter-spacing: 0.08em;
	margin-left: 4px;
}

.round-info p {
	font-size: 0.95rem;
	color: var(--text-on-emphasis-muted);
	line-height: 1.5;
	max-width: 60ch;
}

/* =========================================================
   10. Classement / cartes joueurs
   ========================================================= */
.players-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: clamp(14px, 1.6vw, 18px);
}

.player-card {
	position: relative;
	padding: 18px 20px;
	border-radius: var(--radius-lg);
	background: var(--surface);
	border: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	gap: 8px;
	transition:
		transform 0.25s var(--ease),
		border-color 0.25s var(--ease),
		box-shadow 0.25s var(--ease);
}

.player-card:hover {
	transform: translateY(-2px);
	border-color: var(--border-strong);
	box-shadow: var(--shadow-soft);
}

.player-name {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.player-score {
	font-family: var(--mono);
	font-size: 1.85rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text);
	font-variant-numeric: tabular-nums;
}

.player-score.leader {
	color: var(--success);
}

.player-score.danger {
	color: var(--danger);
}

.player-card.winner {
	border-color: var(--success);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
}

.player-card.winner::before {
	content: "♚";
	position: absolute;
	top: 14px;
	right: 16px;
	font-size: 1.15rem;
	color: var(--success);
}

.player-card.attacking {
	border-color: var(--gold);
}

.player-card.attacking::before {
	content: "♠";
	position: absolute;
	top: 14px;
	right: 16px;
	font-size: 1.05rem;
	color: var(--gold-deep);
}

/* =========================================================
   11. Saisie de score (lignes)
   ========================================================= */
.score-input-grid {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.score-input-row {
	display: grid;
	grid-template-columns: minmax(140px, 220px) 1fr;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	border-radius: var(--radius-md);
	background: var(--surface-inset);
	border: 1px solid var(--border);
}

.score-input-row label {
	margin: 0;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	color: var(--text);
}

.score-input-row input {
	font-family: var(--mono);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	text-align: right;
}

.score-input-row .non-capot-control {
	grid-column: 2;
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 0.76rem;
	font-weight: 500;
	color: var(--text-muted);
	cursor: pointer;
}

.score-input-row .non-capot-control input {
	width: auto;
	margin: 0;
	accent-color: var(--accent);
}

/* =========================================================
   12. Aperçu / boîte d'information
   ========================================================= */
.round-preview {
	padding: 14px 18px;
	border-radius: var(--radius-md);
	background: color-mix(in srgb, var(--gold) 12%, transparent);
	border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
	color: var(--text);
	font-size: 0.92rem;
	line-height: 1.5;
	animation: fade-up 0.25s var(--ease);
}

@keyframes fade-up {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* =========================================================
   13. Fin de partie
   ========================================================= */
.game-over {
	position: relative;
	text-align: center;
	padding: clamp(36px, 4vw, 56px) clamp(24px, 3vw, 40px);
	border-radius: var(--radius-xl);
	background:
		radial-gradient(80% 100% at 50% 0%, var(--surface-emphasis-glow), transparent 55%),
		linear-gradient(160deg, var(--surface-emphasis-bg-1) 0%, var(--surface-emphasis-bg-2) 100%);
	color: var(--text-on-emphasis);
	box-shadow: var(--shadow-card);
	overflow: hidden;
	isolation: isolate;
}

.game-over::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(
		90deg,
		transparent 8%,
		var(--gold) 35%,
		var(--gold-soft) 50%,
		var(--gold) 65%,
		transparent 92%
	);
}

.game-over::after {
	content: "♛";
	position: absolute;
	top: -28px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 9rem;
	color: var(--text-on-emphasis);
	opacity: 0.12;
	z-index: -1;
}

.game-over h2 {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.36em;
	text-transform: uppercase;
	color: var(--gold-deep);
	margin-bottom: 6px;
}

.game-over p {
	font-size: 0.9rem;
	color: var(--text-on-emphasis-muted);
	margin-bottom: 14px;
}

.game-over .winner-name {
	font-size: clamp(1.8rem, 3.2vw, 2.4rem);
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--text-on-emphasis);
	line-height: 1.15;
}

/* =========================================================
   14. Pied de page
   ========================================================= */
footer {
	margin-top: auto;
	padding-top: clamp(20px, 3vw, 28px);
	text-align: center;
	color: var(--text-muted);
	font-size: 0.85rem;
	letter-spacing: 0.01em;
	border-top: 1px solid var(--divider);
}

footer a {
	color: var(--gold-deep);
	font-weight: 600;
	text-decoration: none;
	transition: color 0.2s var(--ease);
}

footer a:hover {
	color: var(--gold);
}

/* =========================================================
   15. Utilitaires
   ========================================================= */
.hidden {
	display: none !important;
}

/* =========================================================
   16. Responsive partagé
   ========================================================= */
@media (max-width: 640px) {
	.score-input-row {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	.score-input-row input {
		text-align: left;
	}

	.players-grid {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/* =========================================================
   17. Finition commune — portail et compteurs
   ========================================================= */
:root {
	--bg-base: #f0f3f0;
	--bg-glow-1: rgba(114, 151, 128, 0.09);
	--bg-glow-2: rgba(201, 162, 106, 0.07);
	--surface: #ffffff;
	--surface-soft: #f6f8f6;
	--surface-inset: rgba(21, 43, 34, 0.045);
	--text: #12251d;
	--text-muted: #637169;
	--border: rgba(24, 49, 38, 0.09);
	--border-strong: rgba(24, 49, 38, 0.17);
	--divider: rgba(24, 49, 38, 0.09);
	--input-bg: #ffffff;
	--input-border: rgba(24, 49, 38, 0.17);
	--input-border-hover: rgba(24, 49, 38, 0.3);
	--radius-xl: 16px;
	--radius-lg: 12px;
	--radius-md: 10px;
	--radius-sm: 8px;
	--shadow-card: 0 1px 2px rgba(20, 40, 30, .035), 0 10px 28px -18px rgba(20, 40, 30, .22);
	--shadow-soft: 0 1px 2px rgba(20, 40, 30, .04), 0 5px 16px -10px rgba(20, 40, 30, .18);
	--shadow-lift: 0 10px 28px -14px rgba(20, 40, 30, .2);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg-base: #0e1914;
		--bg-glow-1: rgba(38, 83, 61, .24);
		--bg-glow-2: rgba(119, 90, 48, .10);
		--surface: #17231d;
		--surface-soft: #1b2922;
		--surface-inset: rgba(240, 247, 242, .045);
		--text: #eef4ef;
		--text-muted: #a3b1a8;
		--border: rgba(232, 242, 235, .09);
		--border-strong: rgba(232, 242, 235, .17);
		--divider: rgba(232, 242, 235, .09);
		--input-bg: #15221b;
		--input-border: rgba(232, 242, 235, .17);
		--input-border-hover: rgba(232, 242, 235, .3);
		--shadow-card: 0 1px 2px rgba(0, 0, 0, .16), 0 12px 30px -18px rgba(0, 0, 0, .5);
		--shadow-soft: 0 1px 2px rgba(0, 0, 0, .18), 0 6px 16px -10px rgba(0, 0, 0, .45);
		--shadow-lift: 0 12px 30px -16px rgba(0, 0, 0, .55);
	}
}

body {
	background-image:
		radial-gradient(1000px 640px at 50% -18%, var(--bg-glow-1), transparent 66%),
		radial-gradient(800px 560px at 100% 100%, var(--bg-glow-2), transparent 72%);
}
body::before { display: none; }
.page {
	width: min(1120px, 100%);
	gap: clamp(22px, 3vw, 34px);
	padding-top: clamp(20px, 3vw, 38px);
	padding-bottom: clamp(30px, 4vw, 48px);
}
.app-shell { gap: 18px; }
#setupPhase,
#gamePhase,
#gameOverPhase { gap: 16px; }

.top-nav {
	min-height: 46px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--divider);
}
.back-link {
	min-height: 38px;
	padding: 8px 12px;
	border-radius: 9px;
	font-size: .82rem;
	letter-spacing: 0;
	background: var(--surface);
}
.back-link:hover { transform: none; }
.game-id {
	max-width: min(58vw, 420px);
	min-height: 32px;
	padding: 6px 10px;
	border-radius: 8px;
	font-size: .7rem;
	overflow-wrap: anywhere;
}

.card {
	padding: clamp(19px, 2.5vw, 27px);
	gap: 17px;
	border-radius: 14px;
	box-shadow: var(--shadow-card);
}
.card::before {
	left: 24px;
	right: auto;
	width: 30px;
	height: 3px;
	border-radius: 0 0 3px 3px;
	background: var(--accent);
}
.card-compact { padding: 16px; gap: 0; }
.section-header { gap: 5px; padding-bottom: 12px; }
.section-header h2 {
	font-size: clamp(1.08rem, 2vw, 1.25rem);
	font-weight: 680;
	letter-spacing: -.02em;
}
.section-header h2::before { content: none; }
.section-header p { font-size: .84rem; line-height: 1.5; }

label {
	font-size: .78rem;
	font-weight: 650;
	letter-spacing: .01em;
	text-transform: none;
}
input[type="text"],
input[type="number"],
select {
	min-height: 44px;
	padding: 10px 13px;
	border-radius: 9px;
	font-size: .92rem;
}
select { padding-right: 38px; }
.input-group { gap: 7px; }
.helper-text { font-size: .78rem; }
input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--accent) 44%, transparent);
	outline-offset: 2px;
}

.btn {
	min-height: 44px;
	padding: 11px 16px;
	border-radius: 9px;
	font-size: .84rem;
	font-weight: 650;
	letter-spacing: .01em;
	text-transform: none;
}
.btn:hover { box-shadow: var(--shadow-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-danger { background: var(--surface); }
.btn-danger:hover { box-shadow: var(--shadow-soft); }
.btn-revert { width: 32px; height: 32px; border-radius: 8px; }

.round-info {
	min-height: 102px;
	padding: 19px 22px;
	border-radius: 14px;
	box-shadow: var(--shadow-soft);
}
.round-info::after {
	right: 12px;
	font-size: 5rem;
	opacity: .10;
}
.round-number {
	font-size: .7rem;
	letter-spacing: .12em;
	color: var(--text-on-emphasis-muted);
}
.round-number span {
	margin-left: 5px;
	font-size: 1.05rem;
	font-variant-numeric: tabular-nums;
}
.round-info p { font-size: .88rem; }

.players-grid { gap: 10px; }
.player-card {
	min-width: 0;
	padding: 15px 16px;
	gap: 8px;
	border-radius: 11px;
	box-shadow: none;
}
.player-card:hover { transform: none; box-shadow: var(--shadow-soft); }
.player-name {
	font-size: .76rem;
	font-weight: 620;
	letter-spacing: .025em;
	text-transform: none;
	overflow-wrap: anywhere;
}
.player-score {
	font-size: clamp(1.45rem, 3vw, 1.8rem);
	font-variant-numeric: tabular-nums;
}
.player-card.winner { box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 14%, transparent); }
.player-card.winner::before { content: "Gagnant"; top: 11px; right: 11px; padding: 3px 6px; color: var(--success); background: color-mix(in srgb, var(--success) 11%, transparent); border-radius: 999px; font-size: .62rem; font-weight: 650; }
.player-card.attacking::before { content: "À l’attaque"; top: 11px; right: 11px; color: var(--gold-deep); font-size: .62rem; font-weight: 650; }

.score-input-grid { gap: 8px; }
.score-input-row {
	grid-template-columns: minmax(130px, 220px) minmax(0, 1fr);
	gap: 11px;
	padding: 10px 12px;
	border-radius: 9px;
}
.score-input-row label { font-size: .86rem; }
.score-input-row input { min-width: 0; }
.score-input-row .non-capot-control { font-size: .75rem; }
.round-preview { padding: 12px 14px; border-radius: 9px; font-size: .86rem; }

.game-over {
	padding: clamp(28px, 4vw, 40px) 22px;
	border-radius: 14px;
	box-shadow: var(--shadow-card);
}
.game-over::before { left: 24px; right: auto; width: 30px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.game-over::after { display: none; }
.game-over h2 { margin-bottom: 8px; font-size: .74rem; letter-spacing: .12em; color: var(--text-on-emphasis-muted); }
.game-over p { margin-bottom: 8px; font-size: .84rem; }
.game-over .winner-name { font-size: clamp(1.65rem, 4vw, 2.2rem); }
footer { padding-top: 18px; font-size: .78rem; }
footer a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--gold-deep) 40%, transparent); text-underline-offset: 3px; }

.history-container,
.round-history { padding: 2px; }
.history-table {
	border-radius: 9px;
	font-size: .82rem;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .025);
}
.history-table thead th {
	padding: 10px 12px;
	font-size: .66rem;
	letter-spacing: .06em;
}
.history-table tbody td { padding: 10px 12px; font-size: .8rem; }
.history-total-row { background: var(--surface-inset); }
.history-total-row td { font-weight: 650; }
.empty-history,
.empty-round-history { padding: 20px; font-size: .84rem; }

@media (max-width: 640px) {
	.page { padding-inline: 16px; }
	.card { padding: 18px; }
	.card-compact { padding: 14px; }
	.round-info { padding: 17px 18px; }
	.round-info::after { right: -4px; font-size: 4rem; }
	.players-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
	.score-input-row { grid-template-columns: 1fr; gap: 7px; }
	.score-input-row input { text-align: left; }
	.game-id { max-width: 54vw; font-size: .64rem; }
}

/* L’identifiant n’occupe aucune place avant la création/reprise. */
.game-id:empty { display: none; }

.game-intro { display: flex; flex-direction: column; gap: 6px; max-width: 700px; }
.game-eyebrow {
	color: var(--accent);
	font-size: .68rem;
	font-weight: 720;
	letter-spacing: .11em;
	text-transform: uppercase;
}
.game-intro h1 {
	color: var(--text);
	font-size: clamp(1.8rem, 4vw, 2.55rem);
	font-weight: 730;
	letter-spacing: -.045em;
	line-height: 1.1;
}
.game-intro > p:last-child { color: var(--text-muted); font-size: .9rem; line-height: 1.55; }
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
@media (max-width: 640px) {
	.game-intro { gap: 5px; }
	.game-intro h1 { font-size: 1.9rem; }
}
