/* cémantix (clone) — palette des thèmes « colorés » de l'original : clair et sombre selon le système. */
:root {
	color-scheme: light;
	--back-bg: #987578;
	--back-shadow: #684548;
	--body-edge: #BDE8F6;
	--body-bg: #9DC8D6;
	--body-shadow: #6D98A6;
	--antibody-edge: #7DA8B6;
	--antibody-bg: #4D7886;
	--header: #333;
	--antiheader: #DDD;
	--text: #333;
	--summary-edge: #FFE750;
	--summary-bg: #FFD700;
	--summary-shadow: #E7B700;
	--summary-link: darkgreen;
	--error: #9A0000;
	--success-bg: lightgreen;
	--success-shadow: #60BE60;
	--success-text: #000;
	--link: darkgreen;
	--focus: #000;
	--inactive-text: #FFF; /* onglet inactif : fond sombre en clair, clair en sombre */
	/* °C : bleu si hors des 1000, sinon rouge → orange selon ‰ */
	--cold: rgb(16, 64, 255);
	--hot-base: 84;
}

@media (prefers-color-scheme: dark) {
	:root {
		color-scheme: dark;
		--back-bg: #A88588;
		--back-shadow: #785558;
		--body-edge: #7DA8B6;
		--body-bg: #4D7886;
		--body-shadow: #1D4856;
		--antibody-edge: #BDE8F6;
		--antibody-bg: #9DC8D6;
		--header: #DDD;
		--antiheader: #333;
		--text: #F8F8F8;
		--error: #FFD9A0;
		--success-bg: darkgreen;
		--success-shadow: #004800;
		--success-text: #F8F8F8;
		--link: lightgreen;
		--focus: #FFE750;
		--inactive-text: #333;
		--cold: rgb(128, 200, 255);
		--hot-base: 255;
	}
}

/* Pédantix : comme l'original, même palette sombre quel que soit le thème du système. */
:root:has(body[data-game="pedantix"]) {
	color-scheme: dark;
	--back-bg: #A88588;
	--back-shadow: #785558;
	--body-edge: #7DA8B6;
	--body-bg: #4D7886;
	--body-shadow: #1D4856;
	--antibody-edge: #BDE8F6;
	--antibody-bg: #9DC8D6;
	--header: #DDD;
	--antiheader: #333;
	--text: #F8F8F8;
	--error: #FFD9A0;
	--success-bg: darkgreen;
	--success-shadow: #004800;
	--success-text: #F8F8F8;
	--link: lightgreen;
	--focus: #FFE750;
	--inactive-text: #333;
	--cold: rgb(128, 200, 255);
	--hot-base: 255;
}

body {
	background-color: var(--back-bg);
	margin: 0;
	text-align: center;
	font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Noto Color Emoji';
	text-rendering: optimizeLegibility;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.summary :focus-visible { outline-color: #000; }

.vh {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1em; top: 1em; z-index: 9; background: var(--summary-bg); color: #000; padding: .3em .6em; border-radius: 5px; }

/* Structure : colonne latérale dorée + panneau principal à onglet */
.page { display: flex; flex-direction: column; min-height: 100vh; }
.layout { display: flex; flex-grow: 1; }
.side { display: flex; align-items: flex-start; justify-content: center; order: -1; } /* après <main> dans le DOM, avant à l'écran */
.main { display: flex; flex: 1 0 auto; flex-direction: column; margin: 1em; margin-bottom: 0; text-align: left; min-width: 0; }

@media (min-width: 800px) and (orientation: landscape) {
	.layout { flex-direction: row; }
	.side { flex: 0 0 auto; margin: .5em; }
	.main { flex: 4 0 0; margin-left: 0; }
}

@media not all and (min-width: 800px) and (orientation: landscape) {
	.layout { flex-direction: column; }
	.main { margin-top: .5em; }
	/* En partie, le champ de saisie passe avant le panneau doré sur petit écran (= ordre du DOM). */
	body:not([data-game="pedantix"]).playing .side { order: 0; }
}

.summary {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 10px;
	margin-bottom: 5px;
	padding: 5px;
	padding-bottom: 1em;
	background-color: var(--summary-bg);
	box-shadow: inset 2px 2px 1px var(--summary-edge), 3px 3px 3px var(--back-shadow);
	color: #000;
	border-radius: 25px;
	width: 15em;
}
.summary h2 { font-size: 1.17em; margin: .8em 0 .4em; }
.summary p { margin: .4em 0 .8em; }
.summary #room { display: flex; flex-direction: column; align-items: center; width: 100%; }
.summary #room[hidden] { display: none; }
.summary .link { color: var(--summary-link); }

.yesterday {
	margin: 10px;
	padding: 10px;
	box-shadow: inset 2px 2px 2px var(--summary-shadow), 2px 2px var(--summary-edge);
	background-image: linear-gradient(var(--summary-shadow), var(--summary-edge));
	border-radius: 5px;
}
#copy-status { display: block; font-size: .85em; overflow-wrap: anywhere; user-select: all; }
#copy-status:empty { display: none; }

.story { border-collapse: collapse; margin: .5em auto; }
.story thead { background-image: linear-gradient(var(--summary-edge), var(--summary-shadow)); color: #000; }
.story th, .story td { padding: 0 .25em; }
.story th:last-child, .story td:last-child { padding-right: 10px; }
#players td.word, #ped-players td.word { white-space: nowrap; }
.nm { display: inline-block; max-width: 7em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; } /* seul le nom est tronqué, « (hôte) » reste visible */
#players .me { font-weight: bold; }
#players .host { font-size: .8em; }

/* Onglet titre */
.tabs { display: flex; }
.tab {
	position: relative;
	z-index: 2;
	display: block;
	width: max(50%, min(100%, 16rem));
	margin: 0;
	padding-top: 6px;
	text-align: center;
	border-radius: 25px 25px 0 0;
	font-weight: normal;
	font-size: 1rem;
	background-color: var(--body-bg);
	box-shadow: inset 2px 2px 1px var(--body-edge);
	color: var(--header);
	text-shadow: 2px 2px var(--antiheader);
}
.caption { display: block; font-size: 1.2em; margin-bottom: 20px; }

/* Logo nuage de mots, dessiné en CSS */
.logo { position: relative; display: block; width: 10em; height: 6.6em; margin: 0 auto 4px; text-shadow: none; }
.cloud {
	position: absolute; inset: 0;
	background:
		radial-gradient(circle at 24% 62%, #FFD700 23%, transparent 23.5%),
		radial-gradient(circle at 50% 38%, #FFD700 30%, transparent 30.5%),
		radial-gradient(circle at 76% 60%, #FFD700 23%, transparent 23.5%),
		radial-gradient(ellipse 46% 30% at 50% 72%, #FFD700 98%, transparent 100%);
	filter: drop-shadow(3px 3px 3px var(--body-edge));
}
.brand {
	position: absolute; left: 0; right: 0; top: 33%;
	font-family: 'Linux Libertine', 'Georgia', 'Times', serif;
	font-size: 1.7em; line-height: 1;
	color: #E8412C;
}
.w { position: absolute; line-height: 1; white-space: nowrap; font-size: .55em; color: #333; }
.w1 { left: 24%; top: 60%; font-size: .75em; color: #1E73BE; }
.w2 { left: 36%; top: 75%; font-size: .7em; }
.w3 { left: 66%; top: 21%; font-size: .45em; color: #1E73BE; }
.w4 { left: 40%; top: 10%; font-size: .45em; }
.w5 { left: 12%; top: 40%; font-size: .45em; }
.w6 { left: 76%; top: 58%; font-size: .6em; transform: rotate(-68deg); color: #1E73BE; }

#content {
	flex-grow: 1;
	background: var(--body-bg);
	box-shadow: inset 2px 2px 1px var(--body-edge), 3px 3px 3px var(--back-shadow);
	margin-top: -10px;
	padding: 10px;
	position: relative;
	border-radius: 10px;
	z-index: 1;
	color: var(--text);
}
#content:focus { outline: none; }
#content h2 { font-size: 1.05em; margin: .3em 0 .4em .2em; }

footer { margin: 1em; color: var(--header); text-shadow: 1px 1px var(--antiheader); }
footer a { color: var(--header); }

/* Formulaires */
.form {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: .5em 0;
	margin: 0 .2em;
	padding: .5em 0;
}
.form label { margin-left: .5em; min-width: 4em; }
input, button:not(.link):not(.sort) {
	font-size: 1.1em;
	margin-left: .5em;
	padding: .3em .4em;
	border-radius: 5px;
	border-width: 1px;
	font-family: inherit;
}
button { cursor: pointer; }
button:disabled { cursor: default; }
input[type="checkbox"] { font-size: 1em; margin: 0 .3em 0 0; }
#guess { width: min(15em, 60vw); }
.code { width: 4.5em; text-transform: uppercase; letter-spacing: .15em; font-family: monospace, monospace; }
.intro { margin: .3em .7em .6em; max-width: 34em; line-height: 1.4; }
.hint { margin: .2em .2em .5em; font-size: .9em; }
.hint:empty { display: none; }

.link {
	background: none; border: 0; padding: 0; margin: 0 .3em;
	font: inherit; color: var(--link); text-decoration: underline; cursor: pointer;
}

.error { font-weight: bold; font-size: 1.17em; color: var(--error); margin: 0 0 0 .7em; }
.error:empty { display: none; }
.home .error { margin: .3em .7em; }

.conn { margin: 0 0 .5em .7em; font-weight: bold; }
.conn:empty { display: none; }
.conn.lost { font-size: 1.17em; color: var(--error); } /* même traitement que la ligne d'erreur */

/* Fin de manche */
.success {
	margin: .2em 2px 1em;
	padding: .1em 1em .5em;
	background-color: var(--success-bg);
	box-shadow: inset 2px 2px 2px var(--success-shadow), 2px 2px var(--body-edge);
	color: var(--success-text);
	border-radius: 10px;
	animation: appear .6s linear;
}
.success:focus { outline: none; }
.success:focus-visible { outline: 2px solid var(--focus); }
.success .link { color: var(--link); }
.success .story { margin-left: 0; }
#secret-word { margin-left: .3em; }
#wait-host:empty { display: none; }
#new-round { margin-left: 0; }
@keyframes appear { from { opacity: 0; } }

/* Tableaux d'essais */
.boards { display: grid; gap: 0 2em; align-items: start; }
@media (min-width: 1000px) {
	.boards { grid-template-columns: minmax(0, 32em) minmax(16em, 26em); }
}
@media (max-width: 999px) {
	.feed { margin-top: .8em; }
	/* Sans autre joueur : ni titre ni texte d'aide à l'écran (restent lisibles par les lecteurs d'écran). */
	.feed:has(#feed[hidden]) :is(h2, .hint) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	#feed tbody tr:nth-child(n+4) { display: none; } /* garder la saisie et ses essais près du haut */
}

table.guessable { width: min(32em, 100%); border-collapse: separate; border-spacing: 0 1px; margin-top: .5em; font-size: clamp(.8rem, 3.6vw, 1rem); }
table.guessable td, table.guessable th { white-space: nowrap; width: auto; padding: 0 0 0 .3em; }
table.guessable td:last-child, table.guessable th:last-child { width: min(10em, 100%); }
.guessable th { font-weight: bold; }
.word { text-align: left; }
.number, .stat { text-align: right; font-variant-numeric: tabular-nums; }
.emoji { padding: 0 .3em; user-select: none; text-align: center; }
.progress { text-align: left; }
.sort { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; }
[aria-sort="ascending"] .sort, [aria-sort="descending"] .sort { text-decoration: underline; text-underline-offset: 3px; }

.latest tr { font-weight: bold; }
.latest td { padding-bottom: .5em; }
.temp { color: rgb(255, calc(var(--hot-base) - var(--p) / 12), 0); }
.temp.cold { color: var(--cold); }

.bar-wrap {
	display: inline-block;
	width: 100%;
	vertical-align: middle;
	background-color: #333;
	box-shadow: 1px 1px var(--body-edge);
	color: #000;
	font-weight: bold;
	border-radius: 5px;
	user-select: none;
}
.bar {
	display: inline-block;
	vertical-align: top;
	overflow: hidden; /* le texte BINGO ne déborde pas pendant l'animation */
	white-space: nowrap;
	box-sizing: border-box;
	width: calc(var(--p) * .1%);
	padding-left: .3em;
	border-radius: 5px;
	background: linear-gradient(to right, yellow, rgb(255, calc(255 - var(--p) / 4), 0));
}
.grow .bar { animation: grow 1s linear; }
@keyframes grow { from { width: 0; } }

.feed { min-width: 0; }
.feed table.guessable { margin-top: 0; }
#feed td.word { max-width: 8em; overflow: hidden; text-overflow: ellipsis; }

#nearest-box { margin-top: 1em; }

@media (prefers-reduced-motion: reduce) {
	.success, .grow .bar { animation: none; }
}

/* ---------- Pédantix (et onglet inactif) ---------- */
body:not([data-game="pedantix"]) .ped { display: none; }
[data-game="pedantix"] :is(#success, .boards, #nearest-box, #players, .scale) { display: none; }

.tab.inactive {
	order: 1;
	z-index: 0;
	flex: 1 1 0;
	min-width: 0;
	overflow: hidden;
	background-color: var(--antibody-bg);
	box-shadow: inset 2px 2px 1px var(--antibody-edge), 3px 3px 3px var(--back-shadow);
	color: var(--inactive-text);
	text-shadow: 2px 2px var(--header);
}
.tab.inactive .cloud { filter: drop-shadow(3px 3px 3px var(--antibody-edge)); }
body:not(.playing) .tab.inactive { cursor: pointer; }
.caption.serif { font-family: 'Linux Libertine', 'Georgia', 'Times', serif; }
@media (max-width: 599px) {
	.tab.inactive .caption { display: none; }
	.tab.inactive .logo { font-size: .42em; margin-top: 1.5em; }
	.tab.inactive .w { display: none; } /* mots du nuage illisibles à cette taille : on garde la marque */
}

.label { margin-left: .5em; min-width: 4em; }
.form .choice { min-width: 0; margin-left: 1em; }
input[type="radio"] { font-size: 1em; margin: 0 .3em 0 0; }

#ped-meter { margin: .6em 0 .2em; letter-spacing: 1px; }
#ped-guesses button { background: none; border: 0; padding: 0; margin: 0; min-width: 24px; min-height: 24px; font: inherit; color: inherit; cursor: pointer; }
#ped-guesses :is([aria-sort="ascending"], [aria-sort="descending"]) button { text-decoration: underline; text-underline-offset: 3px; }
#ped-guesses td.word { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
#ped-players .me { font-weight: bold; }
#ped-players .host { font-size: .8em; }
#ped-share-status { display: block; font-size: .85em; white-space: pre-line; }
#ped-share-status:empty { display: none; }
#ped-success .story { margin-left: 0; }
#ped-success a { color: var(--link); }
#ped-new-round { margin-left: 0; }
#ped-wait-host:empty { display: none; }

/* Fausse page Wikipédia : toujours claire, comme l'original. Gris/orange des mots proches : formule de l'original (écart de contraste accepté). */
#wiki {
	margin: .5em 0 0 2px;
	padding: .1em 1em;
	font-family: sans-serif;
	color: #202122;
	background: #F8F9FA;
	box-shadow: inset 2px 2px 2px #88898A, 2px 2px var(--body-edge);
	border-radius: 10px;
	user-select: none;
	overflow: auto;
}
#wiki.open { user-select: auto; }
#content #wiki h2 { font-family: 'Linux Libertine', 'Georgia', 'Times', serif; font-size: 1.8em; line-height: 1.5; margin: .4em 0; }
#article { line-height: 1.5; }
#wiki .w {
	position: static;
	display: inline-block;
	box-sizing: content-box;
	background-color: #333;
	box-shadow: 1px 1px 1px #B8B9BA;
	color: #333;
	border-radius: 3px;
	font-family: monospace;
	font-size: 1.2em;
	line-height: 1.2;
	white-space: nowrap;
	text-align: center;
	cursor: pointer;
	transition: color .3s linear, background-color .5s linear;
}
#wiki .w.len { color: #0DF; }
#wiki .w.x {
	display: inline;
	min-width: 0 !important;
	background-color: transparent;
	box-shadow: none;
	color: inherit;
	font: inherit;
	cursor: auto;
}
#wiki .w.x.flash { background-color: #6E6; padding: 0 .25em; }

@media (prefers-reduced-motion: reduce) {
	#wiki .w { transition: none; }
}

@media (forced-colors: active) {
	#wiki .w:not(.x) { border: 1px solid CanvasText; }
}
