/* Belote entre amis — feuille de style du client web */

:root {
	--tapis: #1f6b3a;
	--tapis-fonce: #124826;
	--bois: #3b2615;
	--texte: #f3efe4;
	--texte-doux: #c9d8cc;
	--or: #f2c14e;
	--rouge: #d64541;
	--panneau: rgba(10, 30, 18, 0.82);
	--bordure: rgba(255, 255, 255, 0.18);
	/* taille des cartes et des vidéos: proportionnelle à l'écran (largeur et
	   hauteur), plafonnée pour les très grands écrans */
	--carte-l: clamp(46px, min(6.4vw, 10.5vh), 220px);
	--carte-h: calc(var(--carte-l) * 1.452);
	--video-l: clamp(9rem, min(16vw, 24vh), 640px);
	--video-moi-l: clamp(6.5rem, min(10vw, 15vh), 360px);
	--rayon: 10px;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	height: 100%;
	background: var(--bois);
	color: var(--texte);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 1rem;
}

/* la taille du texte (et des éléments exprimés en rem / em) suit celle de
   l'écran, entre 15 px (portable, téléphone) et 24 px (très grand écran) */
html {
	font-size: clamp(15px, calc(0.55vw + 0.6vh), 24px);
}

[hidden] {
	display: none !important;
}

button {
	font: inherit;
	color: #1b1b1b;
	background: #ece6d6;
	border: 1px solid #b9b09a;
	border-radius: 8px;
	padding: 0.4em 0.95em;
	cursor: pointer;
}

button:hover {
	background: #fff8e6;
}

button.principal {
	background: var(--or);
	border-color: #c99b2a;
	font-weight: 600;
}

button:disabled {
	opacity: 0.5;
	cursor: default;
}

input {
	font: inherit;
	padding: 6px 8px;
	border-radius: 6px;
	border: 1px solid var(--bordure);
	background: rgba(255, 255, 255, 0.92);
	color: #1b1b1b;
}

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

.noir {
	color: #111;
}

.erreur {
	color: #ff9b8f;
	min-height: 1.2em;
}

/* --- Écran de connexion --- */

#ecran-connexion {
	min-height: 100%;
	display: grid;
	place-items: center;
	background: radial-gradient(circle at 50% 40%, var(--tapis), var(--tapis-fonce));
}

.panneau-connexion {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: min(360px, 92vw);
	padding: 28px;
	border-radius: 16px;
	background: #fbf7ec;
	color: #1b1b1b;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.panneau-connexion h1 {
	margin: 0 0 6px;
	text-align: center;
	font-size: 1.8rem;
}

.panneau-connexion label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.9rem;
}

.panneau-connexion .erreur {
	color: #b3261e;
	margin: 0;
}

/* --- Écran de jeu --- */

#ecran-jeu {
	height: 100%;
	display: grid;
	grid-template-columns: 1fr minmax(16rem, 20rem);
	grid-template-rows: auto 1fr auto;
	grid-template-areas:
		"bandeau bandeau"
		"tapis cote"
		"main cote";
}

#bandeau {
	grid-area: bandeau;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 20px;
	padding: 0.5rem 0.95rem;
	background: #20150b;
	border-bottom: 2px solid #5b3b1f;
}

#scores {
	display: flex;
	gap: 16px;
	flex-wrap: wrap;
	align-items: baseline;
}

.score-equipe {
	font-weight: 600;
}

.score-equipe .valeur {
	color: var(--or);
	font-size: 1.25rem;
	margin-left: 4px;
}

.score-detail {
	color: var(--texte-doux);
	font-size: 0.85rem;
}

#infos-donne {
	color: var(--texte-doux);
	display: flex;
	gap: 14px;
	align-items: center;
}

#infos-donne .atout {
	display: inline-block;
	font-size: 1.3rem;
	line-height: 1.2;
	padding: 0 5px;
	border-radius: 6px;
	background: #fffdf4;
}

#boutons-bandeau {
	display: flex;
	gap: 8px;
	align-items: center;
}

.bouton-admin {
	padding: 6px 12px;
	border-radius: 8px;
	border: 1px solid #b9b09a;
	background: #ece6d6;
	color: #1b1b1b;
	text-decoration: none;
}

.lien-admin {
	align-self: center;
	font-size: 0.8rem;
	color: #6b6350;
}

.option {
	font-size: 0.85rem;
	color: var(--texte-doux);
	display: flex;
	gap: 4px;
	align-items: center;
}

/* --- Tapis --- */

#tapis {
	grid-area: tapis;
	position: relative;
	display: grid;
	grid-template-columns: minmax(90px, 1fr) minmax(0, 3fr) minmax(90px, 1fr);
	grid-template-rows: auto minmax(0, 1fr) auto;
	grid-template-areas:
		". haut ."
		"gauche centre droite"
		". bas .";
	gap: 6px;
	padding: 10px;
	background: radial-gradient(ellipse at 50% 45%, #2b8a4c 0%, var(--tapis) 45%, var(--tapis-fonce) 100%);
	box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
	overflow: hidden;
	min-height: 0;
}

#place-haut {
	grid-area: haut;
}

#place-gauche {
	grid-area: gauche;
}

#place-droite {
	grid-area: droite;
}

#place-bas {
	grid-area: bas;
}

#centre {
	grid-area: centre;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 0;
}

/* --- Places des joueurs --- */

.place {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	position: relative;
	min-width: 0;
}

.place .media video {
	display: block;
	width: var(--video-l);
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 10px;
	background: #000;
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
	cursor: pointer;
}

/* sa propre place (en bas): la vidéo à côté du nom, pour ne pas empiéter sur le centre */
#place-bas {
	flex-direction: row;
	gap: 10px;
}

#place-bas .media video {
	width: var(--video-moi-l);
}

/* en face: la vidéo à côté du nom, pour laisser la hauteur au centre de la table */
#place-haut.avec-video {
	flex-direction: row;
	gap: 14px;
}

.place .media video.locale {
	transform: scaleX(-1); /* miroir, comme dans une glace */
	cursor: default;
}

.place .media video.sans-image {
	display: none; /* le son continue */
}

.place .media video.muette {
	outline: 3px solid var(--rouge);
	opacity: 0.6;
}

.place.a-qui .media video {
	box-shadow: 0 0 0 3px var(--or), 0 0 14px rgba(242, 193, 78, 0.65);
}

.place .contenu {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	position: relative;
	max-width: 100%;
}

.badge.micro-coupe {
	background: var(--rouge);
}

button.media.actif {
	background: #9fd3a8;
}

.place .identite {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0.25rem 0.65rem 0.25rem 0.25rem;
	border-radius: 999px;
	background: var(--panneau);
	border: 2px solid transparent;
	max-width: 100%;
}

.place.a-qui .identite {
	border-color: var(--or);
	box-shadow: 0 0 14px rgba(242, 193, 78, 0.65);
}

.place .avatar {
	width: 2.3rem;
	height: 2.3rem;
	border-radius: 50%;
	object-fit: cover;
	background: #eee;
	flex: none;
}

.place .nom {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.place .sous-titre {
	font-size: 0.75rem;
	color: var(--texte-doux);
	white-space: nowrap;
}

.badge {
	display: inline-block;
	font-size: 0.7rem;
	padding: 1px 6px;
	border-radius: 999px;
	margin-left: 4px;
	vertical-align: middle;
}

.badge.nous {
	background: #3f7fd1;
}

.badge.eux {
	background: #b5553c;
}

.badge.preneur {
	background: var(--or);
	color: #222;
}

.badge.donneur {
	background: #ddd;
	color: #222;
}

.badge.deconnecte {
	background: #777;
}

.place .bulle {
	position: absolute;
	top: -6px;
	z-index: 5;
	padding: 4px 10px;
	border-radius: 12px;
	background: #fffdf4;
	color: #1b1b1b;
	font-weight: 600;
	font-size: 0.9rem;
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
	white-space: nowrap;
	animation: apparition 0.25s ease-out;
}

#place-bas .bulle {
	top: auto;
	bottom: calc(100% + 4px);
}

.place .dos {
	display: flex;
	height: calc(var(--carte-h) * 0.55);
}

.place .dos img {
	width: calc(var(--carte-l) * 0.55);
	height: calc(var(--carte-h) * 0.55);
	margin-left: calc(var(--carte-l) * -0.38);
	border-radius: 4px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.place .dos img:first-child {
	margin-left: 0;
}

/* mode debug: cartes des autres joueurs face visible */
.place .visibles {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	max-width: 100%;
}

.place .visibles .carte {
	width: calc(var(--carte-l) * 0.62);
	height: calc(var(--carte-h) * 0.62);
	margin-left: calc(var(--carte-l) * -0.3);
}

.place .visibles .carte:first-child {
	margin-left: 0;
}

/* sur les côtés, la place est étroite: cartes plus serrées, sur une ligne */
#place-gauche .visibles,
#place-droite .visibles {
	flex-wrap: nowrap;
}

#place-gauche .visibles .carte:not(:first-child),
#place-droite .visibles .carte:not(:first-child) {
	margin-left: calc(var(--carte-l) * -0.42);
}

.badge.debug {
	background: #8e44ad;
	font-size: 0.8rem;
}

.place button {
	font-size: 0.8rem;
	padding: 3px 10px;
}

/* --- Pli au centre --- */

#pli {
	position: relative;
	width: calc(var(--carte-l) * 3.3);
	height: calc(var(--carte-h) * 2.3);
	flex: none;
}

.emplacement,
#retournee {
	position: absolute;
	width: var(--carte-l);
	height: var(--carte-h);
}

#pli-haut {
	left: calc(50% - var(--carte-l) / 2);
	top: 0;
}

#pli-bas {
	left: calc(50% - var(--carte-l) / 2);
	bottom: 0;
}

#pli-gauche {
	left: 0;
	top: calc(50% - var(--carte-h) / 2);
}

#pli-droite {
	right: 0;
	top: calc(50% - var(--carte-h) / 2);
}

#retournee {
	left: calc(50% - var(--carte-l) / 2);
	top: calc(50% - var(--carte-h) / 2);
}

.carte {
	display: block;
	width: var(--carte-l);
	height: var(--carte-h);
	border-radius: calc(var(--carte-l) * 0.07);
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
	background: #fff;
	user-select: none;
	-webkit-user-drag: none;
}

.emplacement .carte.gagnante {
	box-shadow: 0 0 0 3px var(--or), 0 0 18px rgba(242, 193, 78, 0.9);
}

.emplacement .carte.arrive-haut {
	animation: arrive-haut 0.35s ease-out;
}

.emplacement .carte.arrive-bas {
	animation: arrive-bas 0.35s ease-out;
}

.emplacement .carte.arrive-gauche {
	animation: arrive-gauche 0.35s ease-out;
}

.emplacement .carte.arrive-droite {
	animation: arrive-droite 0.35s ease-out;
}

.emplacement .carte.vers-haut,
.emplacement .carte.vers-bas,
.emplacement .carte.vers-gauche,
.emplacement .carte.vers-droite {
	transition: transform 0.4s ease-in, opacity 0.4s ease-in;
	opacity: 0;
}

.emplacement .carte.vers-haut {
	transform: translateY(-180%) scale(0.6);
}

.emplacement .carte.vers-bas {
	transform: translateY(180%) scale(0.6);
}

.emplacement .carte.vers-gauche {
	transform: translateX(-220%) scale(0.6);
}

.emplacement .carte.vers-droite {
	transform: translateX(220%) scale(0.6);
}

@keyframes arrive-haut {
	from { transform: translateY(-120%); opacity: 0; }
}

@keyframes arrive-bas {
	from { transform: translateY(120%); opacity: 0; }
}

@keyframes arrive-gauche {
	from { transform: translateX(-150%); opacity: 0; }
}

@keyframes arrive-droite {
	from { transform: translateX(150%); opacity: 0; }
}

@keyframes apparition {
	from { transform: scale(0.6); opacity: 0; }
}

/* --- Panneau d'action (enchères, démarrage) --- */

#panneau-action {
	min-height: 44px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	align-items: center;
	text-align: center;
}

/* symbole de couleur lisible sur le fond sombre (le ♠ et le ♣ sont noirs) */
#panneau-action .message span.noir,
#panneau-action .message span.rouge {
	display: inline-block;
	padding: 0 0.3em;
	border-radius: 5px;
	background: #fffdf4;
}

#panneau-action .message {
	padding: 0.4em 0.95em;
	border-radius: var(--rayon);
	background: var(--panneau);
}

#panneau-action .conseil {
	width: 100%;
	font-size: 0.85rem;
	color: var(--texte-doux);
}

button.couleur {
	font-size: 1.3rem;
	min-width: 52px;
	padding: 4px 10px;
	background: #fffdf4;
}

button.couleur.rouge {
	color: var(--rouge);
}

button.couleur.noir {
	color: #111;
}

button.conseille {
	outline: 3px solid #7cc4ff;
	outline-offset: 2px;
}

/* --- Main du joueur --- */

#main-joueur {
	grid-area: main;
	display: flex;
	justify-content: center;
	align-items: flex-end;
	min-height: calc(var(--carte-h) * 1.18 + 12px);
	padding: 8px 10px 10px;
	background: linear-gradient(var(--tapis-fonce), #0b2f18);
}

#main-joueur .carte {
	margin-left: calc(var(--carte-l) * -0.18);
	transition: transform 0.15s ease-out, filter 0.15s, box-shadow 0.15s;
	filter: brightness(0.72);
}

#main-joueur .carte:first-child {
	margin-left: 0;
}

#main-joueur.libre .carte,
#main-joueur .carte.jouable {
	filter: none;
}

#main-joueur .carte.jouable {
	cursor: pointer;
	transform: translateY(-14%);
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(242, 193, 78, 0.75);
}

#main-joueur .carte.jouable:hover,
#main-joueur .carte.jouable:focus-visible {
	transform: translateY(-24%);
	outline: none;
}

#main-joueur .carte.conseillee {
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5), 0 0 0 3px #7cc4ff;
}

#main-joueur .vide {
	color: var(--texte-doux);
	align-self: center;
}

/* --- Colonne de droite --- */

#cote {
	grid-area: cote;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: #17241b;
	border-left: 2px solid #5b3b1f;
}

#cote h2 {
	margin: 0;
	padding: 8px 12px 4px;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--texte-doux);
}

#dernier-pli {
	display: flex;
	gap: 4px;
	padding: 4px 12px 10px;
	min-height: calc(var(--carte-h) * 0.5 + 14px);
	align-items: center;
	font-size: 0.85rem;
	color: var(--texte-doux);
}

#dernier-pli .carte {
	width: calc(var(--carte-l) * 0.5);
	height: calc(var(--carte-h) * 0.5);
}

#dernier-pli .carte.gagnante {
	box-shadow: 0 0 0 2px var(--or);
}

#chat {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-top: 1px solid var(--bordure);
}

#chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 4px 12px;
	font-size: 0.9rem;
	min-height: 80px;
}

#chat-messages .msg {
	margin: 4px 0;
	overflow-wrap: anywhere;
}

#chat-messages .msg .heure {
	color: #7f948a;
	font-size: 0.75rem;
	margin-right: 4px;
}

#chat-messages .msg .auteur {
	font-weight: 600;
	color: var(--or);
}

#chat-messages .msg.systeme {
	color: var(--texte-doux);
	font-style: italic;
}

#form-chat {
	display: flex;
	gap: 6px;
	padding: 8px;
}

#form-chat input {
	flex: 1;
	min-width: 0;
}

/* --- Fenêtres (résultat de donne, démarrage) --- */

#superposition {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: grid;
	place-items: center;
	background: rgba(0, 0, 0, 0.45);
}

#fenetre {
	width: min(440px, 92vw);
	padding: 22px 24px;
	border-radius: 16px;
	background: #fbf7ec;
	color: #1b1b1b;
	box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
	text-align: center;
}

#fenetre h2 {
	margin-top: 0;
}

#fenetre table {
	margin: 10px auto;
	border-collapse: collapse;
}

#fenetre td,
#fenetre th {
	padding: 4px 14px;
	border-bottom: 1px solid #ddd2b8;
}

#fenetre .issue {
	font-weight: 700;
	font-size: 1.1rem;
}

#fenetre .issue.chute {
	color: #b3261e;
}

#fenetre .issue.faite,
#fenetre .issue.capot {
	color: #1e7b34;
}

#fenetre .prets {
	color: #666;
	font-size: 0.85rem;
}

#toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 30;
	padding: 10px 18px;
	border-radius: var(--rayon);
	background: #2b2b2b;
	color: #fff;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* --- Petits écrans (téléphone) --- */

@media (max-width: 820px) {
	:root {
		--carte-l: clamp(38px, 11vw, 70px);
		--video-l: calc(var(--carte-l) * 1.7);
		--video-moi-l: calc(var(--carte-l) * 1.25);
	}

	#ecran-jeu {
		height: auto;
		min-height: 100%;
		grid-template-columns: 1fr;
		grid-template-rows: auto minmax(360px, 62vh) auto auto;
		grid-template-areas:
			"bandeau"
			"tapis"
			"main"
			"cote";
	}

	#tapis {
		grid-template-columns: minmax(64px, 1fr) minmax(0, 3fr) minmax(64px, 1fr);
	}

	#cote {
		border-left: none;
		border-top: 2px solid #5b3b1f;
		height: 340px;
	}

	.place .sous-titre {
		display: none;
	}

	.place .identite {
		gap: 4px;
		padding: 2px 6px 2px 2px;
	}

	.place .avatar {
		width: 24px;
		height: 24px;
	}

	.place .nom {
		font-size: 0.85rem;
	}

	#place-gauche .badge,
	#place-droite .badge {
		display: none;
	}

	.place .bulle {
		font-size: 0.8rem;
		padding: 3px 8px;
	}

	#main-joueur .carte {
		margin-left: calc(var(--carte-l) * -0.3);
	}
}
