/*
 * Identite Funkyz : accent #FFBA00 sur fond noir, Roboto.
 * Reprise de l'e-boutique (boutique/app/assets/css/main.css) sans dependance :
 * la page du participant doit se charger en une fraction de seconde sur un
 * telephone en 3G au fond d'une salle.
 */

:root {
	--gold: #ffba00;
	--gold-dark: #b88200;
	--bg: #0a0a0a;
	--panel: rgba(255, 255, 255, 0.06);
	--panel-strong: rgba(255, 255, 255, 0.1);
	--border: rgba(255, 255, 255, 0.14);
	--text: #eee;
	--muted: #9a9a9a;
	--green: #21c55d;
	--red: #ef4444;
	--yellow: #ffe000;
}

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

html,
body {
	margin: 0;
	padding: 0;
	min-height: 100%;
}

body {
	background: radial-gradient(circle at 50% 0%, #1c1710 0%, var(--bg) 60%);
	color: var(--text);
	font-family: Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
	font-size: 16px;
	line-height: 1.4;
	overscroll-behavior: none;
}

h1 {
	margin: 0;
	font-size: 1.6rem;
	font-weight: 900;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

h1 span {
	color: var(--gold);
}

button {
	font: inherit;
	color: inherit;
	border: 0;
	background: none;
	cursor: pointer;
	touch-action: manipulation;
}

input {
	font: inherit;
	color: inherit;
	background: rgba(0, 0, 0, 0.45);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.7rem 0.9rem;
	width: 100%;
}

input:focus {
	outline: 2px solid var(--gold);
	outline-offset: 1px;
}

.panel {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.7rem 1.2rem;
	border-radius: 10px;
	background: var(--panel-strong);
	border: 1px solid var(--border);
	font-weight: 700;
}

.button:active {
	transform: translateY(1px);
}

.button.primary {
	background: var(--gold);
	border-color: var(--gold);
	color: #171100;
}

.button:disabled {
	opacity: 0.4;
	cursor: default;
}

.hidden {
	display: none !important;
}

/* ------------------------------------------------------------------ */
/* Icônes                                                              */
/* ------------------------------------------------------------------ */

/*
 * Le porte-symboles n'est jamais rendu. `display: none` sur le conteneur
 * empêcherait certains navigateurs de résoudre les `<use>` : on le sort du flux
 * autrement.
 */
.sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}

/*
 * Les icônes suivent la taille et la couleur du texte qui les entoure : une
 * seule règle, et elles s'accordent partout sans réglage au cas par cas.
 */
.icon {
	width: 1.15em;
	height: 1.15em;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	vertical-align: -0.18em;
}

/* Compteur des autres parties ouvertes, sur « Changer de partie ». */
.badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.25rem;
	height: 1.25rem;
	padding: 0 0.35rem;
	border-radius: 999px;
	background: var(--gold);
	color: #171100;
	font-size: 0.72rem;
	font-weight: 900;
	line-height: 1;
}

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

/* ------------------------------------------------------------------ */
/* Page du participant                                                 */
/* ------------------------------------------------------------------ */

.player {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	min-height: 100svh;
	padding: max(0.9rem, env(safe-area-inset-top)) 0.9rem max(0.9rem, env(safe-area-inset-bottom));
	max-width: 520px;
	margin: 0 auto;
	text-align: center;
}

.player header {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.tagline {
	font-size: 0.8rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--muted);
}

#join-form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.field {
	display: flex;
	gap: 0.5rem;
}

/* Le code de partie : quatre caractères lus au fond d'une salle. */
.code-input {
	text-align: center;
	font-size: 1.6rem;
	font-weight: 900;
	letter-spacing: 0.35em;
	text-indent: 0.35em;
	text-transform: uppercase;
	color: var(--gold);
}

.identity {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.6rem;
	padding: 0.7rem 0.9rem;
	text-align: left;
}

.identity .name {
	font-size: 1.15rem;
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.identity .edit,
.code-block .edit {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	flex: none;
}

.identity .edit {
	color: var(--muted);
	font-size: 0.85rem;
	text-decoration: underline;
}

.stats {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.6rem;
}

.stat {
	padding: 0.6rem 0.4rem;
}

.stat .label {
	font-size: 0.72rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.stat .value {
	font-size: 1.9rem;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	line-height: 1.1;
}

.stat .value.podium {
	color: var(--green);
}

.stat .value.out {
	color: var(--red);
}

.buzzer-zone {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

/*
 * Le buzzer. Sa couleur porte toute l'information de la manche, c'est donc elle
 * qui est enorme et non le texte : blanc = attente, jaune = a vous, vert = dans
 * les premiers, rouge = trop tard.
 */
.buzzer {
	position: relative;
	width: min(78vw, 44svh, 340px);
	aspect-ratio: 1;
	border-radius: 50%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.2rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	border: 6px solid rgba(0, 0, 0, 0.35);
	transition: background-color 0.12s, box-shadow 0.12s, transform 0.08s;
	user-select: none;
}

.buzzer .big {
	font-size: clamp(1.7rem, 11.5vw, 3.2rem);
	line-height: 1;
}

.buzzer .small {
	font-size: 0.8rem;
	opacity: 0.75;
	max-width: 80%;
}

.buzzer.idle {
	background: #ececec;
	color: #333;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 18px 40px rgba(0, 0, 0, 0.5);
}

.buzzer.open {
	background: var(--yellow);
	color: #241f00;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3), 0 0 60px rgba(255, 224, 0, 0.45);
	animation: pulse 1s ease-in-out infinite;
}

.buzzer.won {
	background: var(--green);
	color: #04200f;
	box-shadow: 0 0 60px rgba(33, 197, 93, 0.4);
}

.buzzer.lost {
	background: var(--red);
	color: #2b0000;
	box-shadow: 0 0 40px rgba(239, 68, 68, 0.35);
}

.buzzer.open:active {
	transform: scale(0.96);
}

@keyframes pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.035); }
}

@media (prefers-reduced-motion: reduce) {
	.buzzer.open { animation: none; }
}

.legend {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem 1rem;
	font-size: 0.78rem;
	color: var(--muted);
}

.legend span {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.dot {
	width: 0.75rem;
	height: 0.75rem;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.4);
}

.dot.idle { background: #ececec; }
.dot.open { background: var(--yellow); }
.dot.won { background: var(--green); }
.dot.lost { background: var(--red); }

.status {
	font-size: 0.8rem;
	color: var(--muted);
	min-height: 1.2em;
}

.status.error {
	color: #ff9a9a;
}

/* ------------------------------------------------------------------ */
/* Page d'animation                                                    */
/* ------------------------------------------------------------------ */

.admin {
	max-width: 1200px;
	margin: 0 auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.admin-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

.admin-bar .who {
	font-size: 0.85rem;
	color: var(--muted);
}

.controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	align-items: center;
}

.big-toggle {
	flex: 1 1 260px;
	min-height: 4.5rem;
	border-radius: 14px;
	font-size: 1.6rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	border: 1px solid var(--border);
	background: #ececec;
	color: #222;
	transition: background-color 0.12s;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.7rem;
}

.big-toggle .icon {
	width: 1.5rem;
	height: 1.5rem;
}

.big-toggle.open {
	background: var(--yellow);
	color: #241f00;
	box-shadow: 0 0 40px rgba(255, 224, 0, 0.35);
}

.round-info {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.85rem;
	color: var(--muted);
	flex: none;
}

.players {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 0.6rem;
}

.player-card {
	display: grid;
	grid-template-columns: 1fr auto auto auto auto;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.65rem;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 12px;
}

/* Les places recompensees ressortent : c'est ce que l'animateur lit en premier. */
.player-card.podium {
	border-color: var(--green);
	background: rgba(33, 197, 93, 0.12);
}

.player-card.late {
	border-color: rgba(239, 68, 68, 0.5);
	background: rgba(239, 68, 68, 0.08);
}

.player-card.offline {
	opacity: 0.45;
}

.player-card .who {
	min-width: 0;
}

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

.player-card .detail {
	font-size: 0.72rem;
	color: var(--muted);
}

.player-card .cell {
	text-align: center;
	min-width: 2.4rem;
}

.player-card .cell .label {
	font-size: 0.6rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--muted);
}

.player-card .cell .value {
	font-size: 1.25rem;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	line-height: 1;
}

.player-card .cell .value.rank {
	color: var(--green);
}

.player-card .arrows {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
}

.arrow {
	width: 2rem;
	height: 1.6rem;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: center;
}

.arrow .icon {
	width: 1rem;
	height: 1rem;
	stroke-width: 3;
}

.arrow.up { color: var(--green); }
.arrow.down { color: var(--red); }

.remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.6rem;
	height: 1.6rem;
	border-radius: 6px;
	color: var(--muted);
}

.remove .icon {
	width: 0.95rem;
	height: 0.95rem;
}

.remove:hover {
	color: var(--red);
	background: rgba(239, 68, 68, 0.12);
}

.player-card .name-button {
	display: block;
	width: 100%;
	text-align: left;
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.empty {
	padding: 2rem 1rem;
	text-align: center;
	color: var(--muted);
}

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

.empty .icon,
.legend .icon {
	vertical-align: -0.22em;
}

.admin-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	justify-content: space-between;
	align-items: center;
	font-size: 0.85rem;
	color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Salon : le choix de la partie a animer                              */
/* ------------------------------------------------------------------ */

.section-title {
	margin: 0;
	font-size: 0.78rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
	font-weight: 700;
}

.game-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 0.6rem;
}

.game-item {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	padding: 0.8rem 0.9rem;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 12px;
	text-align: left;
	width: 100%;
}

.game-item:hover {
	border-color: var(--gold);
	background: var(--panel-strong);
}

.game-item .code {
	font-size: 1.6rem;
	font-weight: 900;
	letter-spacing: 0.12em;
	color: var(--gold);
	font-variant-numeric: tabular-nums;
}

.game-item .about {
	min-width: 0;
	flex: 1;
}

.game-item .icon {
	color: var(--muted);
}

.game-item:hover .icon {
	color: var(--gold);
}

.game-item .title {
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.game-item .detail {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	font-size: 0.75rem;
	color: var(--muted);
	white-space: nowrap;
}

/* Point clignotant : une manche est ouverte dans cette partie, en ce moment. */
.game-item .live {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--yellow);
	animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
	.game-item .live { animation: none; }
}

/* ------------------------------------------------------------------ */
/* Bandeau d'invitation de la partie animée                            */
/* ------------------------------------------------------------------ */

.game-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
	padding: 0.8rem 1rem;
}

.code-block {
	flex: 1 1 220px;
	min-width: 0;
}

.code-block .label {
	font-size: 0.65rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
}

.code-block .code {
	font-size: 2.4rem;
	font-weight: 900;
	letter-spacing: 0.2em;
	line-height: 1.1;
	color: var(--gold);
}

.code-block .join {
	font-size: 0.85rem;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.code-block .edit {
	margin-top: 0.2rem;
	font-size: 0.75rem;
	color: var(--muted);
	text-decoration: underline;
}

.qr {
	flex: none;
	width: 96px;
	height: 96px;
	background: #fff;
	border-radius: 8px;
	padding: 5px;
	display: flex;
}

.qr svg {
	width: 100%;
	height: 100%;
}

.game-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.game-actions .button {
	font-size: 0.85rem;
	padding: 0.5rem 0.8rem;
}

/* Invitation plein écran, à montrer ou projeter à la salle. */
.overlay {
	position: fixed;
	inset: 0;
	z-index: 10;
	background: #0a0a0a;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: 1.5rem;
	text-align: center;
}

.invite-name {
	font-size: 1.2rem;
	color: var(--muted);
}

.invite-qr {
	width: min(52vh, 80vw);
	background: #fff;
	border-radius: 16px;
	padding: 14px;
	display: flex;
}

.invite-qr svg {
	width: 100%;
	height: auto;
}

.invite-code {
	font-size: clamp(3rem, 14vw, 7rem);
	font-weight: 900;
	letter-spacing: 0.15em;
	line-height: 1;
	color: var(--gold);
}

.invite-url {
	font-size: clamp(1rem, 3.5vw, 1.6rem);
	color: var(--text);
}

.invite-hint {
	font-size: 0.8rem;
	color: var(--muted);
}

.login {
	max-width: 420px;
	margin: 12svh auto;
	padding: 1.4rem;
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
}

.login h1 {
	font-size: 1.3rem;
}

.login .error {
	color: #ff9a9a;
	font-size: 0.85rem;
	min-height: 1.2em;
}
