/* Style du jeu de belote : téléphone vertical, tapis vert. */
:root {
  --tapis: #1d6b3a;
  --tapis-clair: #2e8f52;
  --tapis-fonce: #0f4223;
  --or: #f2c14e;
  --or-fonce: #b8892a;
  --texte: #ffffff;
  --texte-doux: #d7eadc;
  --bouton-texte: #2a1f00;
  --rouge: #c62828;
  --ombre: 0 3px 8px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, Roboto, "Segoe UI", Arial, sans-serif;
  color: var(--texte);
  background: var(--tapis-fonce);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  touch-action: manipulation;
}

.ecran {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* Grain de feutre (bruit dessiné par le navigateur) + lumière au centre */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 42%, var(--tapis-clair) 0%, var(--tapis) 50%, var(--tapis-fonce) 100%);
}
/* Fondu seulement quand on arrive sur un écran (pas à chaque carte jouée) */
.ecran.entree { animation: apparait 0.25s ease-out; }
@keyframes apparait { from { opacity: 0; } }

/* ---------- Boutons ---------- */
.bouton {
  display: block; width: 100%;
  padding: 15px 18px;
  border: none; border-radius: 14px;
  font: inherit; font-size: 19px; font-weight: 700;
  background: linear-gradient(#f7cf68, var(--or));
  color: var(--bouton-texte);
  box-shadow: 0 4px 0 var(--or-fonce), var(--ombre);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.bouton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--or-fonce); }
.bouton.secondaire {
  background: rgba(255, 255, 255, 0.1);
  color: var(--texte);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}
.bouton.secondaire:active { transform: scale(0.98); }
.bouton:disabled { opacity: 0.4; }

/* ---------- Cartes ---------- */
.carte {
  position: absolute;
  width: 72px; height: 108px;
  border-radius: 7px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}
.carte .carte-svg { width: 100%; height: 100%; display: block; }
.carte.interdite { filter: saturate(0.45) brightness(0.72); transform: translateY(8px); }
.carte.jouable { transform: translateY(-16px); animation: leve 0.25s ease-out; }
@keyframes leve { from { transform: translateY(0); } }
.carte.secoue { animation: secoue 0.35s; }
@keyframes secoue { 20%, 60% { margin-left: -6px; } 40%, 80% { margin-left: 6px; } }

/* Carte qui arrive au centre depuis la place du joueur */
.carte.arrive { animation: arrive 0.32s cubic-bezier(.2, .8, .3, 1); }
@keyframes arrive {
  from { transform: translate(var(--dx), var(--dy)) rotate(var(--r0, 0deg)) scale(0.85); }
}
/* Pli ramassé vers le gagnant */
.carte.ramasse { animation: ramasse 0.42s ease-in forwards; }
@keyframes ramasse { to { transform: translate(var(--wx), var(--wy)) scale(0.45); opacity: 0; } }
/* Cartes distribuées dans sa main */
.carte.nouvelle { animation: distribue 0.38s cubic-bezier(.2, .8, .3, 1) backwards; }
@keyframes distribue { from { transform: translate(var(--nx, 0), -330px) rotate(-25deg) scale(0.6); opacity: 0; } }
.carte.gagne-pli { filter: drop-shadow(0 0 7px var(--or)) drop-shadow(0 0 2px var(--or)); }
.carte[data-action] { cursor: pointer; }

/* ---------- Accueil ---------- */
.accueil { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 28px 36px; }
.accueil .eventail { position: relative; width: 220px; height: 170px; margin-bottom: 10px; }
.accueil .eventail .carte { width: 92px; height: 138px; left: 64px; top: 18px; transform-origin: 50% 120%; animation: deploie 0.6s cubic-bezier(.2, .8, .3, 1) backwards; }
.accueil .eventail .carte:nth-child(1) { animation-delay: 0.05s; }
.accueil .eventail .carte:nth-child(2) { animation-delay: 0.12s; }
.accueil .eventail .carte:nth-child(3) { animation-delay: 0.19s; }
.accueil .eventail .carte:nth-child(4) { animation-delay: 0.26s; }
@keyframes deploie { from { transform: rotate(0deg); opacity: 0; } }
.accueil h1 {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 56px; letter-spacing: 1px;
  color: var(--or);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.accueil .bienvenue { font-size: 22px; margin-top: 4px; }
.accueil .record {
  margin: 20px 0 28px; padding: 10px 18px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.22); color: var(--texte-doux); font-size: 16px;
}
.accueil .record strong { color: var(--texte); font-size: 18px; }
.accueil .boutons { width: 100%; display: grid; gap: 14px; }

/* ---------- Table ---------- */
/* Le tapis : un ovale plus clair au centre */
.table .ovale {
  position: absolute; left: 7%; right: 7%; top: 170px; bottom: 215px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.09);
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 70%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.12);
}

.barre-score {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  height: 66px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.25));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.barre-score .menu {
  width: 42px; height: 42px; border: none; border-radius: 12px;
  background: rgba(255, 255, 255, 0.14); color: var(--texte); font-size: 22px;
}
.barre-score .equipes { display: flex; gap: 6px; align-items: center; }
.barre-score .equipe { text-align: center; min-width: 62px; }
.barre-score .equipe .nom { font-size: 11px; color: var(--texte-doux); text-transform: uppercase; letter-spacing: 1px; }
.barre-score .equipe .pts { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; }
.barre-score .equipe .pts.bouge { animation: compte 0.6s; }
@keyframes compte { 30% { transform: scale(1.3); color: var(--or); } }
.barre-score .objectif { font-size: 11px; color: var(--texte-doux); padding: 0 2px; text-align: center; line-height: 1.25; }
.barre-score .atout {
  display: flex; align-items: center; gap: 6px; min-width: 92px;
  background: #fffdf6; color: #222; border-radius: 12px; padding: 5px 9px;
  font-size: 12px; font-weight: 700; line-height: 1.15;
  box-shadow: var(--ombre);
}
.barre-score .atout.vide { visibility: hidden; }
.barre-score .atout svg { width: 24px; height: 24px; }
.barre-score .atout .par { font-weight: 500; color: #555; }

/* Les places autour de la table */
.siege { position: absolute; display: flex; flex-direction: column; align-items: center; z-index: 2; }
.siege .avatar {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 23px; font-weight: 800;
  border: 3px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--ombre);
  transition: box-shadow 0.2s;
}
.siege.partenaire .avatar { background: linear-gradient(#fff8e6, #f3e2b8); color: #6b4a00; }
.siege.adversaire .avatar { background: linear-gradient(#eef3f8, #cfdbe7); color: #24415e; }
.siege.a-son-tour .avatar { border-color: var(--or); animation: halo 1.2s ease-in-out infinite; }
@keyframes halo { 50% { box-shadow: 0 0 0 7px rgba(242, 193, 78, 0.35), var(--ombre); } }
.siege .nom {
  margin-top: -9px; position: relative;
  background: rgba(0, 0, 0, 0.55); border-radius: 10px; padding: 2px 10px;
  font-size: 14px; font-weight: 700;
}
.siege .etiquettes { display: flex; gap: 4px; margin-top: 4px; min-height: 16px; }
.etiquette { font-size: 10px; font-weight: 800; border-radius: 6px; padding: 2px 6px; letter-spacing: 0.5px; }
.etiquette.preneur { color: var(--bouton-texte); background: var(--or); }
.etiquette.donneur { color: #fff; background: rgba(0, 0, 0, 0.4); }
.siege .bulle {
  position: absolute; z-index: 4; white-space: nowrap;
  background: #fff; color: #222; font-size: 14px; font-weight: 700;
  padding: 6px 11px; border-radius: 14px; box-shadow: var(--ombre);
}
.siege .bulle.pop { animation: pop 0.3s cubic-bezier(.3, 1.6, .5, 1); }
.siege .bulle.annonce { background: var(--or); color: var(--bouton-texte); }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }

/* Les cartes cachées des robots, en petit éventail */
.eventail-robot { position: absolute; width: 0; height: 0; z-index: 1; }
.eventail-robot .carte { width: 34px; height: 51px; left: -17px; top: -51px; transform-origin: 50% 100%; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4)); }

.pli { position: absolute; left: 0; right: 0; top: 285px; height: 300px; z-index: 2; }
.pli .carte { width: 76px; height: 114px; }
.info-pli {
  position: absolute; left: 0; right: 0; top: 248px; text-align: center; z-index: 2;
  font-size: 15px; font-weight: 700; color: var(--or); animation: apparait 0.2s;
}

.main { position: absolute; left: 0; right: 0; bottom: 18px; height: 160px; z-index: 3; }
.main .carte { width: 88px; height: 132px; bottom: 6px; }

.nom-moi { position: absolute; left: 0; right: 0; bottom: 178px; text-align: center; font-weight: 700; font-size: 15px; z-index: 3; }
.nom-moi span { background: rgba(0, 0, 0, 0.4); padding: 4px 14px; border-radius: 12px; transition: background 0.2s; }
.nom-moi.a-son-tour span { background: var(--or); color: var(--bouton-texte); }
.nom-moi .etiquette { margin-left: 6px; vertical-align: 2px; }

.consigne {
  position: absolute; left: 0; right: 0; bottom: 212px; z-index: 3;
  text-align: center; font-size: 16px; font-weight: 600; color: #fff;
  animation: respire 1.6s ease-in-out infinite;
}
@keyframes respire { 50% { opacity: 0.55; } }
.annonce-moi {
  position: absolute; left: 50%; bottom: 236px; transform: translateX(-50%); z-index: 4;
  background: var(--or); color: var(--bouton-texte); font-weight: 800; font-size: 16px;
  padding: 6px 14px; border-radius: 14px; box-shadow: var(--ombre);
  animation: pop 0.3s cubic-bezier(.3, 1.6, .5, 1);
}

/* Panneau d'enchères (Prendre / Passer / couleur) */
.encheres {
  position: absolute; left: 50%; top: 226px; z-index: 3;
  transform: translateX(-50%);
  width: 214px; padding: 14px;
  border-radius: 20px;
  background: rgba(8, 40, 20, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: center;
}
.encheres.neuf { animation: apparait 0.25s; }
.encheres .titre { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.encheres .retournee { position: relative; width: 76px; height: 114px; margin: 0 auto 12px; }
.encheres .retournee .carte { left: 0; top: 0; width: 76px; height: 114px; }
.encheres.neuf .retournee .carte { animation: retourne 0.5s ease-out; }
@keyframes retourne { from { transform: rotateY(90deg); } }
.encheres .ligne { display: flex; gap: 10px; }
.encheres .ligne .bouton { padding: 12px 6px; font-size: 18px; }
.encheres .couleurs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.encheres .couleurs button {
  height: 62px; border: none; border-radius: 14px; background: #fffdf6;
  display: grid; place-items: center; box-shadow: 0 3px 0 #c9c0a8;
}
.encheres .couleurs button:active { transform: translateY(2px); box-shadow: none; }
.encheres .couleurs button svg { width: 34px; height: 34px; }

/* ---------- Fenêtre par-dessus la table ---------- */
.voile { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 5; animation: apparait 0.3s; }
.fenetre {
  position: absolute; left: 18px; right: 18px; top: 50%; z-index: 6;
  transform: translateY(-50%);
  background: #fbf7ee; color: #1f1f1f;
  border-radius: 22px; padding: 22px 18px 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  animation: monte 0.4s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes monte { from { transform: translateY(-30%); opacity: 0; } }
.fenetre h2 { font-size: 23px; text-align: center; }
.fenetre h2.ok { color: #1d7a3d; }
.fenetre h2.ko { color: var(--rouge); }
.fenetre .question { text-align: center; font-size: 17px; line-height: 1.4; margin: 4px 0 18px; }
.fenetre .boutons-fenetre { display: grid; gap: 10px; }
.fenetre .bouton.secondaire { color: #1f1f1f; border-color: rgba(0, 0, 0, 0.18); background: transparent; }
.fenetre .resultat { text-align: center; margin: 6px 0 14px; font-size: 15px; color: #444; line-height: 1.4; }
.fenetre .resultat .ok { color: #1d7a3d; font-weight: 800; }
.fenetre .resultat .ko { color: var(--rouge); font-weight: 800; }
.fenetre table { width: 100%; border-collapse: collapse; font-size: 16px; margin-bottom: 16px; font-variant-numeric: tabular-nums; }
.fenetre th, .fenetre td { padding: 8px 6px; text-align: right; }
.fenetre th:first-child, .fenetre td:first-child { text-align: left; color: #555; }
.fenetre thead th { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #555; border-bottom: 2px solid #e3dccb; }
.fenetre tr.total td { font-weight: 800; border-top: 2px solid #e3dccb; color: #1f1f1f; }
.fenetre tr.cumul td { font-weight: 800; font-size: 20px; color: var(--tapis); }

/* ---------- Fin de partie ---------- */
.fin-partie { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 28px 36px; text-align: center; }
.fin-partie .coupe { width: 140px; height: 140px; animation: rebond 0.9s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes rebond { from { transform: scale(0.2) rotate(-20deg); opacity: 0; } }
.fin-partie h1 { font-family: Georgia, "Noto Serif", serif; font-size: 46px; color: var(--or); margin-top: 10px; animation: apparait 0.6s 0.3s backwards; }
.fin-partie .gagnants { font-size: 20px; margin-top: 6px; animation: apparait 0.6s 0.5s backwards; }
.fin-partie .final { display: flex; gap: 14px; margin: 28px 0 10px; animation: apparait 0.6s 0.7s backwards; }
.fin-partie .final > div { background: rgba(0, 0, 0, 0.25); border-radius: 16px; padding: 14px 18px; min-width: 130px; }
.fin-partie .final .nom { font-size: 13px; color: var(--texte-doux); text-transform: uppercase; letter-spacing: 1px; }
.fin-partie .final .pts { font-size: 34px; font-weight: 800; }
.fin-partie .final .gagne { box-shadow: inset 0 0 0 3px var(--or); }
.fin-partie .nouveau-record { color: var(--or); font-weight: 700; margin-bottom: 30px; }
.fin-partie .boutons { width: 100%; display: grid; gap: 14px; margin-top: 18px; position: relative; z-index: 2; }
.confetti { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; z-index: 1; animation: tombe linear forwards; }
@keyframes tombe { to { transform: translateY(900px) rotate(720deg); } }

/* ---------- Réglages et règles ---------- */
.reglages { padding: 0 18px; }
.entete {
  display: flex; align-items: center; gap: 12px;
  height: 66px; margin: 0 -18px 12px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.3);
  position: sticky; top: 0; z-index: 2;
}
.entete button {
  border: none; background: rgba(255, 255, 255, 0.14); color: var(--texte);
  font: inherit; font-size: 16px; font-weight: 700; padding: 9px 12px; border-radius: 10px;
}
.entete h1 { font-size: 22px; }
.reglage { background: rgba(0, 0, 0, 0.22); border-radius: 16px; padding: 16px; margin-bottom: 14px; position: relative; z-index: 1; }
.reglage label, .reglage .libelle { display: block; font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.reglage .aide { font-size: 13px; color: var(--texte-doux); margin-top: 8px; }
.reglage input[type=text] {
  width: 100%; font: inherit; font-size: 18px; padding: 12px 14px;
  border-radius: 12px; border: none; color: #1f1f1f; background: #fff;
  user-select: text; -webkit-user-select: text;
}
.choix { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 4px; gap: 4px; }
.choix button { border: none; border-radius: 9px; padding: 11px 4px; font: inherit; font-size: 15px; font-weight: 700; background: transparent; color: var(--texte); transition: background 0.2s; }
.choix button.actif { background: var(--or); color: var(--bouton-texte); }
.interrupteur-ligne { display: flex; align-items: center; justify-content: space-between; }
.interrupteur-ligne .libelle { margin: 0; }
.interrupteur { width: 60px; height: 34px; border-radius: 17px; background: var(--or); position: relative; border: none; transition: background 0.2s; }
.interrupteur::after { content: ""; position: absolute; top: 4px; left: 30px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.interrupteur.eteint { background: rgba(255, 255, 255, 0.25); }
.interrupteur.eteint::after { left: 4px; }
.reglages .pied { text-align: center; font-size: 13px; color: var(--texte-doux); margin-top: 22px; position: relative; z-index: 1; }
.regles p { font-size: 15px; line-height: 1.45; color: var(--texte-doux); margin-top: 6px; }
.regles p b { color: var(--texte); }

/* ---------- Anciennes classes utilisées par la maquette ---------- */
.joueur { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 14px; font-weight: 700; }
.joueur .avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; font-weight: 800; background: #f4efe2; color: var(--tapis-fonce); border: 3px solid rgba(255, 255, 255, 0.5); }
.joueur .role { font-size: 11px; font-weight: 600; color: var(--texte-doux); }
.joueur .bulle { position: absolute; z-index: 2; white-space: nowrap; background: #fff; color: #222; font-size: 14px; font-weight: 700; padding: 5px 10px; border-radius: 12px; }
.preneur-badge, .donneur-badge { font-size: 10px; font-weight: 800; border-radius: 6px; padding: 1px 5px; }
.preneur-badge { color: var(--bouton-texte); background: var(--or); }
.donneur-badge { color: #fff; background: rgba(0, 0, 0, 0.35); }
.dos-main { position: absolute; }
.dos-main .carte { width: 30px; height: 45px; filter: none; }
