/* Mastermind — l'habillage.
 *
 * On copie le jeu de plateau : un cadre ivoire, des trous creusés, des pions
 * en demi-sphère brillante. Les couleurs sont celles des pions Invicta.
 * Le fond derrière le plateau, lui, se change dans les réglages.
 */

/* ---------------------------------------------------------------- couleurs */
:root {
  /* Les huit pions. Les six premiers = Mastermind classique. */
  --rouge:  #c62d2a;  --rouge-h:  #e8564f;
  --jaune:  #edbb2b;  --jaune-h:  #ffdc6b;
  --vert:   #2d8c47;  --vert-h:   #55bd70;
  --bleu:   #1f62bd;  --bleu-h:   #4f95e8;
  --noir:   #24262b;  --noir-h:   #5a5f69;
  --blanc:  #f4f1e8;  --blanc-h:  #ffffff;
  --orange: #de7420;  --orange-h: #ffa254;
  --brun:   #7a4a2c;  --brun-h:   #a8734c;

  /* LE PLATEAU — d'après la photo du Parker Super Mastermind de Jérémie :
     plastique brun ROUGE (terracotta), gravures creusées, trous cernés d'un
     anneau en relief. */
  --plateau:      #92503e;
  --plateau-haut: #a25c48;
  --plateau-bas:  #7d4232;
  --anneau:       #ab6552;      /* le bourrelet en relief autour des trous */
  --gravure:      #5e2f22;      /* les chiffres, creusés dans le plastique */
  --encre:        #3a2d20;

  /* Les trous. Volontairement TRÈS sombres et cernés d'un liseré clair :
     c'est ce qui permet de voir d'un coup d'oeil qu'un trou est vide et non
     occupé par un pion noir. */
  --creux:        #1d1008;
  --creux-fond:   #0c0603;
  --creux-liseré: rgba(255, 210, 180, .5);

  --cache-vert:      #8a4a39;
  --cache-vert-haut: #9d5945;

  --indice-noir: #17181c;
  --indice-blanc: #fbfaf6;

  /* Fond par défaut : bois. Uni et calme — pas de grand dégradé théâtral. */
  --fond: #4b3527;
  --texte-fond: #f3e8d5;

  /* La taille d'un trou et d'un pion. Recalculée par `ajusterPlateau()` pour
     que les 12 rangées, le code secret et la palette tiennent TOUS dans
     l'écran, sans avoir à défiler. 34 px est la valeur de confort ; sur un
     petit téléphone ça descend, mais jamais sous 16 px. */
  --taille-trou: 34px;

  --rayon: 14px;
  --ombre-plateau: 0 14px 30px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .18) inset;
}

/* Les fonds proposés dans les réglages. Des couleurs de table, posées à
   plat : le jeu date de 1970, il n'a pas besoin d'un décor de logiciel. */
body[data-fond="noyer"]   { --fond: #4b3527; --texte-fond: #f3e8d5; }
body[data-fond="feutre"]  { --fond: #1c5a3c; --texte-fond: #e8f5ec; }
body[data-fond="ardoise"] { --fond: #333940; --texte-fond: #e7ecf2; }
body[data-fond="nuit"]    { --fond: #1d2a52; --texte-fond: #e4eaff; }
body[data-fond="creme"]   { --fond: #ddcfb2; --texte-fond: #3a3020; }

/* ------------------------------------------------------------------- base */
* { box-sizing: border-box; }

/* ⚠️ CETTE RÈGLE N'EST PAS DÉCORATIVE — NE PAS L'ENLEVER.
 *
 * Le navigateur cache un élément portant l'attribut `hidden` avec une règle
 * `[hidden] { display: none }`. Mais DÈS QU'UNE de nos classes déclare son
 * propre `display` — `.pointage { display: flex }`, `.bandeau-file`,
 * `.piste` — cette déclaration l'emporte et l'élément RESTE VISIBLE, même
 * avec `hidden` à true.
 *
 * Résultat vécu : le pointage à deux joueurs et le bouton « Envoyer
 * maintenant » s'affichaient en pleine partie solo, alors que le code les
 * avait bel et bien marqués `hidden`. Pire, les bancs d'essai vérifiaient
 * `element.hidden === true` — l'attribut, pas ce qui est à l'écran — et
 * passaient au vert. Un test plus facile que la réalité ment.
 *
 * Depuis : on teste la HAUTEUR RÉELLE de l'élément, jamais l'attribut. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  /* ⚠️ `clip` et non `hidden` : `overflow-x: hidden` crée un contexte de
     défilement qui CASSE `position: sticky` chez les descendants — la palette
     du bas cessait de coller. `clip` bloque le débordement sans cet effet. */
  overflow-x: clip;
}

body {
  background: var(--fond) fixed;
  color: var(--texte-fond);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior-y: contain;
}

.ecran { display: none; }
.ecran.actif { display: block; animation: paraitre .25s ease; }

@keyframes paraitre { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.enveloppe {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

/* ------------------------------------------------------------------ titres */
.logo {
  text-align: center;
  margin: 22px 0 6px;
}
.logo h1 {
  margin: 0;
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 10px 26px rgba(0,0,0,.4);
}
.logo .sous { opacity: .72; font-size: 13px; letter-spacing: .22em; text-transform: uppercase; }

.logo-pions { display: flex; gap: 7px; justify-content: center; margin-bottom: 12px; }
.logo-pions .pion { width: 22px; height: 22px; }

h2.titre-ecran {
  text-align: center;
  font-size: 19px;
  letter-spacing: .05em;
  margin: 6px 0 16px;
}

/* ------------------------------------------------------------------ boutons */
.bouton {
  display: block;
  width: 100%;
  padding: 15px 18px;
  margin: 9px 0;
  border: 0;
  border-radius: var(--rayon);
  background: linear-gradient(#f3e7cc, #ddc9a2);
  color: var(--encre);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 4px 0 #a8916a, 0 8px 18px rgba(0,0,0,.3);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.bouton:hover { filter: brightness(1.04); }
.bouton:active { transform: translateY(3px); box-shadow: 0 1px 0 #a8916a, 0 3px 10px rgba(0,0,0,.3); }
.bouton:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.bouton.vedette { background: linear-gradient(#e8a13f, #c9761d); color: #2b1a06; box-shadow: 0 4px 0 #8d5312, 0 8px 18px rgba(0,0,0,.35); }
.bouton.vedette:active { box-shadow: 0 1px 0 #8d5312, 0 3px 10px rgba(0,0,0,.3); }
.bouton.discret { background: rgba(255,255,255,.1); color: var(--texte-fond); box-shadow: none; border: 1px solid rgba(255,255,255,.2); font-weight: 500; }
.bouton.discret:active { transform: translateY(1px); }
.bouton.petit { width: auto; display: inline-block; padding: 9px 16px; font-size: 14px; margin: 4px; }

.rangee-boutons { display: flex; gap: 9px; }
.rangee-boutons .bouton { margin: 9px 0; }

/* ------------------------------------------------------------------ champs */
.champ {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--rayon);
  background: rgba(0,0,0,.28);
  color: var(--texte-fond);
  font: inherit;
  font-size: 17px;
  text-align: center;
}
.champ:focus { outline: 2px solid #e8a13f; outline-offset: 1px; }
.champ::placeholder { color: rgba(255,255,255,.4); }
body[data-fond="creme"] .champ { background: rgba(255,255,255,.55); border-color: rgba(0,0,0,.18); }
body[data-fond="creme"] .champ::placeholder { color: rgba(0,0,0,.35); }

label.etiquette { display: block; font-size: 13px; opacity: .75; margin: 16px 0 6px; letter-spacing: .05em; }

/* ------------------------------------------------------------------- pions */
.pion {
  width: var(--taille-trou);
  height: var(--taille-trou);
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
  background: radial-gradient(circle at 32% 28%, var(--haut) 0%, var(--bas) 62%, var(--bas) 100%);
  box-shadow:
    0 2px 4px rgba(0,0,0,.4),
    0 -1px 2px rgba(0,0,0,.25) inset,
    0 2px 3px rgba(255,255,255,.35) inset;
}
/* Le reflet : c'est lui qui donne l'impression d'une bille de plastique. */
.pion::after {
  content: '';
  position: absolute;
  top: 14%; left: 22%;
  width: 34%; height: 26%;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  filter: blur(1px);
  pointer-events: none;
}

/* Le pion NOIR est le cas délicat : posé dans un creux sombre, il peut se
   confondre avec un trou vide. On lui donne un liseré clair et un reflet
   plus franc — il doit se lire comme une bille POSÉE, pas comme un trou. */
.pion[data-couleur="noir"] {
  box-shadow:
    0 2px 4px rgba(0,0,0,.5),
    0 0 0 1.5px rgba(255, 240, 220, .45),
    0 2px 3px rgba(255,255,255,.3) inset;
}
.pion[data-couleur="noir"]::after { background: rgba(255,255,255,.8); }

.pion[data-couleur="rouge"]  { --haut: var(--rouge-h);  --bas: var(--rouge); }
.pion[data-couleur="jaune"]  { --haut: var(--jaune-h);  --bas: var(--jaune); }
.pion[data-couleur="vert"]   { --haut: var(--vert-h);   --bas: var(--vert); }
.pion[data-couleur="bleu"]   { --haut: var(--bleu-h);   --bas: var(--bleu); }
.pion[data-couleur="noir"]   { --haut: var(--noir-h);   --bas: var(--noir); }
.pion[data-couleur="blanc"]  { --haut: var(--blanc-h);  --bas: #ddd8c8; }
.pion[data-couleur="orange"] { --haut: var(--orange-h); --bas: var(--orange); }
.pion[data-couleur="brun"]   { --haut: var(--brun-h);   --bas: var(--brun); }

/* --------------------------------------------------------------- le plateau
 * Le plastique brun taupe du jeu d'origine, criblé de petits trous de
 * rangement sur les marges — c'est ce piquetage qui donne au plateau son
 * air de vrai objet plutôt que de rectangle dessiné. */
.plateau {
  background:
    /* le piquetage des marges */
    radial-gradient(circle at center, rgba(0,0,0,.42) 1.6px, transparent 1.9px) 0 0 / 11px 11px,
    linear-gradient(var(--plateau-haut), var(--plateau) 22%, var(--plateau-bas));
  border-radius: 14px;
  padding: 12px 10px;
  box-shadow: var(--ombre-plateau);
  border: 1px solid rgba(0, 0, 0, .28);
}

.rangees {
  display: flex;
  flex-direction: column-reverse;      /* la rangée 1 en BAS, la 12 en haut */
  gap: 2px;
}

/* --------------------------------------------------------------- le cache
 * En HAUT du plateau, sous le couvercle coulissant : c'est là que dort le
 * code secret sur le Parker. On monte vers lui, rangée après rangée. */
.cache {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: linear-gradient(var(--cache-vert-haut), var(--cache-vert));
  box-shadow:
    0 2px 5px rgba(0,0,0,.35) inset,
    0 1px 0 rgba(255, 190, 160, .35);
  color: #ffe2d3;
  min-height: 54px;
}
.cache .etiquette-cache {
  font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  font-weight: 700; opacity: .72; flex: 1;
}
.cache .trous { display: flex; gap: 8px; }
.cache.revele { background: linear-gradient(#b06a53, #8a4a39); }

/* Un trou du cache, encore masqué : le plastique fumé du couvercle. */
.cache .secret-cache {
  width: var(--taille-trou); height: var(--taille-trou); border-radius: 50%;
  background: repeating-linear-gradient(45deg,
    rgba(0,0,0,.3), rgba(0,0,0,.3) 3px, rgba(0,0,0,.14) 3px, rgba(0,0,0,.14) 6px);
  box-shadow: 0 1px 3px rgba(0,0,0,.45) inset, 0 1px 0 rgba(255,190,160,.25);
}

/* ------------------------------------------------------ la piste de points
 * La colonne de petits trous numérotés 1 à 71, le long du bord droit du
 * plateau. C'est le compteur du vrai jeu — et c'est LUI qui explique le 71 :
 * arrivé au bout de la piste, c'est fini. Duel seulement, le solo n'a rien
 * à y compter. */
.piste {
  display: flex;
  flex-direction: column-reverse;      /* 1 en bas, 71 en haut */
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  overflow: hidden;                    /* jamais plus haut que les rangées */
  padding: 5px 4px;
  margin-left: 6px;
  border-radius: 5px;
  background: linear-gradient(var(--plateau-bas), var(--plateau));
  box-shadow: 0 1px 0 rgba(255,190,160,.22) inset;
  flex: 0 0 auto;
}
/* ⚠️ Les crans SE COMPRIMENT (`flex: 1 1 0`) au lieu d'imposer leur taille.
   À 7 px fixes, 71 crans réclament 568 px de haut et forçaient tout le
   plateau à cette hauteur — le duel débordait de 400 px sur un petit
   téléphone. Ici la piste prend la hauteur des rangées, un point c'est tout. */
.piste .cran {
  width: 7px;
  height: auto;
  flex: 1 1 0;
  min-height: 2px;
  max-height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, var(--creux-fond), var(--creux));
  box-shadow: 0 1px 0 rgba(255, 200, 170, .3);
}
/* La cheville de pointage de chaque joueur. */
.piste .cran.moi   { background: radial-gradient(circle at 32% 26%, #ffd88a, #d8912c); box-shadow: 0 0 0 1px rgba(255,240,200,.6); }
.piste .cran.autre { background: radial-gradient(circle at 32% 26%, #9fd8ff, #3f8fd0); box-shadow: 0 0 0 1px rgba(220,240,255,.6); }
.piste .cran.dizaine { box-shadow: 0 1px 0 rgba(255, 200, 170, .3), -6px 0 0 -2.5px rgba(255,210,180,.45); }

.plateau-corps { display: flex; align-items: stretch; }
.plateau-corps > .rangees { flex: 1; min-width: 0; }

/* --------------------------------------------------------------- les rangées */
/* L'ordre du vrai plateau, de gauche à droite :
 *      numéro de rangée  →  petits trous d'indices  →  gros trous du code
 */
.rangee {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 5px;
  border-radius: 5px;
}
.rangee.active {
  background: rgba(255, 226, 170, .16);
  box-shadow: 0 0 0 1.5px rgba(255, 216, 150, .6);
}
/* La rangée où l'on DÉPOSE garde des trous confortables même quand le reste
   du plateau rapetisse : les rangées déjà jouées, on ne fait que les lire,
   mais celle-là il faut la viser au doigt. */
.rangee.active .trou {
  width: max(28px, var(--taille-trou));
  height: max(28px, var(--taille-trou));
}
.rangee.active .trou .pion {
  width: 100%;
  height: 100%;
}

/* Le numéro, gravé creux dans le plastique — à GAUCHE. */
.rangee .numero {
  order: 1;
  width: 16px;
  font-size: 11px;
  font-weight: 800;
  color: var(--gravure);
  text-shadow: 0 1px 0 rgba(255, 190, 160, .28);
  text-align: right;
  flex: 0 0 auto;
}
.rangee.active .numero { color: #ffe0b0; text-shadow: 0 1px 1px rgba(0,0,0,.5); }

.rangee .indices { order: 2; }
.rangee .trous { order: 3; display: flex; gap: 7px; flex: 1; }

/* ------------------------------------------------------------------- un trou
 * ⚠️ IL DOIT ÊTRE IMPOSSIBLE DE CONFONDRE UN TROU VIDE AVEC UN PION NOIR.
 *
 * Le trou est un CREUX : sombre, ombré en HAUT (la lumière ne l'atteint pas),
 * avec un liseré clair sur son bord bas — le relief du plastique. Le pion,
 * lui, est bombé et porte un reflet vif en haut à gauche. Les deux éclairages
 * sont inversés, donc l'oeil tranche tout de suite, même en tout petit. */
.trou {
  width: var(--taille-trou); height: var(--taille-trou);
  border-radius: 50%;
  flex: 0 0 auto;
  /* Le bourrelet en relief qui cercle chaque trou sur le vrai plateau. */
  background:
    radial-gradient(circle at 50% 50%,
      var(--creux-fond) 0%, var(--creux) 60%,
      var(--anneau) 61%, var(--plateau-bas) 100%);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, .7) inset,        /* l'ombre du creux, en haut */
    0 -1px 2px rgba(255, 220, 190, .14) inset,
    0 1px 0 var(--creux-liseré);              /* le bord éclairé, en bas */
  position: relative;
  display: grid;
  place-items: center;
}
.trou.cible { outline: 2px dashed rgba(190, 130, 40, .9); outline-offset: 2px; }
.rangee.active .trou { cursor: pointer; }
.rangee.active .trou:active { transform: scale(.94); }

/* Le pion qui se pose : un petit rebond, rien de plus. */
.trou .pion { animation: poser .22s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes poser { from { transform: scale(.4) translateY(-14px); opacity: .4; } to { transform: none; opacity: 1; } }

/* --------------------------------------------------------- pions-indices */
/* Les pions-indices, EN LIGNE (le réglage de la maison).
 *
 * Note : sur le jeu d'origine ils sont en carré 2x2 — l'inventeur y tenait,
 * pour qu'on ne puisse pas relier un indice à un pion précis. En ligne, il
 * faut donc bien se rappeler qu'ils ne sont PAS dans l'ordre des pions. */
.indices {
  display: flex;
  gap: 3px;
  padding: 4px 5px;
  border-radius: 20px;
  background: rgba(0, 0, 0, .2);
  box-shadow: 0 1px 2px rgba(0,0,0,.3) inset, 0 1px 0 rgba(255,255,255,.15);
  flex: 0 0 auto;
}

/* Un emplacement d'indice vide : petit creux, même logique que les gros. */
.indice {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: radial-gradient(circle at 50% 32%, #0f0a06, #241a10);
  box-shadow: 0 1px 2px rgba(0,0,0,.7) inset, 0 1px 0 rgba(255,235,205,.3);
}
/* Le pion noir : bombé, avec un reflet net. C'est le reflet qui le distingue
   du creux vide — sans lui, les deux se ressemblent à cette taille. */
.indice.noir {
  background: radial-gradient(circle at 32% 26%, #6e727d 0%, #2c2e34 45%, var(--indice-noir) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.22);
}
.indice.blanc {
  background: radial-gradient(circle at 32% 26%, #ffffff 0%, #f0ece0 45%, #cfc9b8 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.5);
}
/* Les indices apparaissent un par un, très vite : on voit le verdict tomber.
 *
 * ⚠️ PAS de `backwards` ici, et ce n'est pas un oubli. Avec lui, l'état de
 * départ (scale 0 = invisible) s'applique AVANT que l'animation démarre. Si
 * le navigateur gèle les animations — onglet en arrière-plan, économie de
 * batterie, page non composée — les indices restent invisibles et le joueur
 * ne voit tout simplement pas sa réponse. Sans `backwards`, l'état par
 * défaut est l'indice VISIBLE : l'animation n'est qu'un bonus. */
.indice.neuf { animation: pop .28s cubic-bezier(.34, 1.56, .64, 1); }
/* Et le départ n'est pas `scale(0)` : une animation figée à son premier
   keyframe laisserait l'indice INVISIBLE. À 0.4 il reste lisible en toute
   circonstance, et le petit rebond se voit pareil. */
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }

/* ---------------------------------------------------------- la zone basse
 * Les pions et les deux boutons restent collés en bas de l'écran. Sans ça,
 * avec douze rangées au plateau, il faudrait remonter chercher la palette
 * après chaque coup — insupportable au pouce sur un téléphone. */
.zone-basse {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 12px -14px 0;
  padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .55) 22%);
  backdrop-filter: blur(3px);
}
body[data-fond="creme"] .zone-basse {
  background: linear-gradient(to bottom, transparent, rgba(255, 250, 240, .8) 22%);
}

/* ------------------------------------------------------------ la palette */
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.1);
}
body[data-fond="creme"] .palette { background: rgba(0,0,0,.09); }

/* Les pions de la palette restent un peu plus gros que ceux du plateau :
   c'est eux qu'on attrape au doigt, ils ne doivent jamais devenir minuscules. */
.palette .pion {
  width: max(32px, calc(var(--taille-trou) + 5px));
  height: max(32px, calc(var(--taille-trou) + 5px));
  cursor: grab;
  transition: transform .12s;
  touch-action: none;              /* sinon le glissé fait défiler la page */
}
.palette .pion:hover { transform: translateY(-3px) scale(1.06); }
.palette .pion.choisi {
  transform: translateY(-4px) scale(1.12);
  box-shadow: 0 0 0 3px rgba(255, 216, 120, .95), 0 6px 12px rgba(0,0,0,.45);
}
.palette .pion.epuise { opacity: .28; pointer-events: none; }

/* Le pion qu'on traîne au bout du doigt. */
#fantome {
  position: fixed;
  z-index: 99;
  width: 44px; height: 44px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
  display: none;
}

/* ------------------------------------------------------------- barre du bas */
/* Les deux boutons du bas restent volontairement COMPACTS : chaque pixel
   qu'ils prennent est un pixel de moins pour le plateau. Ils gardent quand
   même 42 px de haut, la hauteur minimale pour viser au pouce sans se
   tromper. */
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions .bouton {
  margin: 0;
  padding: 11px 14px;
  font-size: 14.5px;
  min-height: 42px;
  border-radius: 11px;
  box-shadow: 0 3px 0 #a8916a, 0 4px 10px rgba(0,0,0,.28);
}
.actions .bouton:active { box-shadow: 0 1px 0 #a8916a, 0 2px 6px rgba(0,0,0,.28); }
.actions .bouton.vedette { box-shadow: 0 3px 0 #8d5312, 0 4px 10px rgba(0,0,0,.3); }
.actions .bouton.vedette:active { box-shadow: 0 1px 0 #8d5312, 0 2px 6px rgba(0,0,0,.3); }
.actions .bouton.confirmer { flex: 2; }
.actions .bouton.vider { flex: 1; font-size: 13.5px; }

/* ------------------------------------------------------------ barre du haut */
.barre {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.barre .retour {
  border: 0; background: rgba(0,0,0,.28); color: var(--texte-fond);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 19px; cursor: pointer; flex: 0 0 auto;
}
.barre .retour:active { transform: scale(.93); }
.barre .info { flex: 1; text-align: center; font-size: 14px; line-height: 1.35; }
.barre .info strong { display: block; font-size: 16px; letter-spacing: .04em; }
.barre .info span { opacity: .7; font-size: 12px; }

/* ------------------------------------------------------------- le pointage */
/* Compact : chaque pixel pris ici est un pixel de moins pour le plateau.
   Le nom et les points tiennent sur UNE ligne. */
.pointage {
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
}
.pointage .joueur {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,.26);
  border: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: baseline;
  gap: 7px;
  transition: box-shadow .2s;
}
body[data-fond="creme"] .pointage .joueur { background: rgba(0,0,0,.1); }
.pointage .joueur.actif { box-shadow: 0 0 0 2px #e8a13f; }
.pointage .joueur .nom {
  font-size: 12.5px; opacity: .85; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pointage .joueur .pts { font-size: 19px; font-weight: 800; line-height: 1; flex: 0 0 auto; }
.pointage .joueur .etat { font-size: 10.5px; opacity: .6; flex: 0 0 auto; }
.pointage .joueur .pastille { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #63d18a; margin-right: 4px; }
.pointage .joueur .pastille.absent { background: #8b8b8b; }

/* ------------------------------------------------------------- les panneaux */
.panneau {
  padding: 14px 16px;
  border-radius: var(--rayon);
  background: rgba(0,0,0,.26);
  border: 1px solid rgba(255,255,255,.12);
  margin: 12px 0;
}
body[data-fond="creme"] .panneau { background: rgba(0,0,0,.09); }
.panneau h3 { margin: 0 0 8px; font-size: 15px; letter-spacing: .04em; }
.panneau p { margin: 6px 0; font-size: 14px; line-height: 1.5; opacity: .88; }
.panneau .fort { font-weight: 700; opacity: 1; }

.consigne {
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  padding: 7px 12px;
  margin: 0 0 8px;
  border-radius: 9px;
  background: rgba(232, 161, 63, .18);
  border: 1px solid rgba(232, 161, 63, .4);
  line-height: 1.45;
}
.consigne.attente { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); }

/* --------------------------------------------------------------- le salon */
.liste-parties { display: flex; flex-direction: column; gap: 9px; margin: 12px 0; }
.carte-partie {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--rayon);
  background: rgba(0,0,0,.26);
  border: 1px solid rgba(255,255,255,.12);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.carte-partie:hover { transform: translateX(3px); box-shadow: 0 0 0 1px rgba(232,161,63,.5); }
.carte-partie .code-partie {
  font-size: 21px; font-weight: 800; letter-spacing: .12em;
  font-family: "Consolas", ui-monospace, monospace;
  color: #f0c479;
}
.carte-partie .details { flex: 1; font-size: 13px; opacity: .85; line-height: 1.4; }
.carte-partie .fermee { opacity: .45; }

.vide {
  text-align: center;
  padding: 26px 16px;
  opacity: .6;
  font-size: 14px;
  line-height: 1.6;
}

/* ------------------------------------------------------------- le palmarès */
.onglets { display: flex; gap: 6px; margin-bottom: 12px; }
.onglets button {
  flex: 1; padding: 10px; border: 0; border-radius: 10px;
  background: rgba(0,0,0,.26); color: var(--texte-fond);
  font: inherit; font-size: 14px; cursor: pointer;
}
.onglets button.actif { background: #e8a13f; color: #2b1a06; font-weight: 700; }

table.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tableau th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; opacity: .6; padding: 8px 6px; font-weight: 600;
}
table.tableau td { padding: 9px 6px; border-top: 1px solid rgba(255,255,255,.1); }
table.tableau tr.podium td { font-weight: 700; }
table.tableau .rang { width: 30px; opacity: .65; }
table.tableau tr.podium .rang { opacity: 1; }
table.tableau .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- les réglages */
.reglage {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.1);
}
.reglage:last-child { border-bottom: 0; }
.reglage .texte { flex: 1; }
.reglage .texte b { display: block; font-size: 15px; }
.reglage .texte small { opacity: .65; font-size: 12.5px; line-height: 1.45; display: block; margin-top: 2px; }

.bascule {
  width: 52px; height: 30px; border-radius: 15px; border: 0;
  background: rgba(255,255,255,.2); position: relative; cursor: pointer;
  flex: 0 0 auto; transition: background .2s;
}
.bascule::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.bascule[aria-checked="true"] { background: #4caf72; }
.bascule[aria-checked="true"]::after { transform: translateX(22px); }

.choix-fonds { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.choix-fond {
  width: 54px; height: 54px; border-radius: 12px; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s;
}
.choix-fond:hover { transform: scale(1.06); }
.choix-fond.actif { border-color: #ffd88a; box-shadow: 0 0 0 3px rgba(255,216,138,.3); }
.choix-fond[data-f="noyer"]   { background: linear-gradient(135deg, #6b4426, #241609); }
.choix-fond[data-f="feutre"]  { background: linear-gradient(135deg, #1e6b45, #0a2d1d); }
.choix-fond[data-f="ardoise"] { background: linear-gradient(135deg, #3a4048, #14171a); }
.choix-fond[data-f="nuit"]    { background: linear-gradient(135deg, #24356b, #0b1029); }
.choix-fond[data-f="creme"]   { background: linear-gradient(135deg, #f0e6d2, #c6b593); }

/* -------------------------------------------------------------- le dialogue
 * Un message important se LIT et se ferme d'un OK. Jamais un bandeau qui
 * s'évapore avant qu'on ait fini de lire. */
.voile {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.68);
  display: grid; place-items: center;
  padding: 20px;
  animation: paraitre .2s ease;
}
.voile[hidden] { display: none; }
.dialogue {
  max-width: 400px; width: 100%;
  background: linear-gradient(#f3e7cc, #e0cda6);
  color: var(--encre);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.55);
  text-align: center;
  animation: monter .28s cubic-bezier(.34, 1.3, .64, 1);
}
@keyframes monter { from { transform: translateY(18px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.dialogue h3 { margin: 0 0 10px; font-size: 20px; }
.dialogue p { margin: 8px 0; font-size: 15px; line-height: 1.55; }
.dialogue .pions-revele { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.dialogue .bouton { margin-top: 16px; }

/* Le code révélé fait une petite vague : on regarde la réponse.
   Même règle que pour les indices : pas de `backwards`, sinon un navigateur
   qui gèle les animations cacherait le code au lieu de le montrer. */
.pions-revele .pion { animation: vague .5s ease; }
@keyframes vague {
  0% { transform: translateY(14px) scale(.7); opacity: .35; }   /* jamais 0 */
  60% { transform: translateY(-5px) scale(1.06); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* ----------------------------------------------------- le coup hors ligne */
.bandeau-file {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  margin: 12px 0;
  border-radius: 12px;
  background: rgba(90, 140, 200, .18);
  border: 1px solid rgba(120, 170, 230, .45);
}
.bandeau-file .texte { flex: 1; font-size: 13.5px; line-height: 1.4; }
.bandeau-file .bouton { margin: 0; flex: 0 0 auto; }

/* Le rond qui tourne : le coup est en route, pas perdu. */
.rond-attente {
  width: 18px; height: 18px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .28);
  border-top-color: #8fc0f0;
  animation: tourner 1s linear infinite;
}
@keyframes tourner { to { transform: rotate(360deg); } }

/* La rangée déposée hors ligne : présente, mais en suspens. */
.rangee.en-attente { opacity: .72; }
.rangee.en-attente .indices.attente {
  background: rgba(90, 140, 200, .22);
  animation: respirer 1.6s ease-in-out infinite;
}
@keyframes respirer { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

/* --------------------------------------------------------------- le chrono */
.chrono { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ petits écrans */
/* ⚠️ Plus de tailles fixes par media query : c'est `ajusterPlateau()` qui
   fixe `--taille-trou` d'après la hauteur RÉELLE de l'écran, pour que tout
   le plateau tienne sans défiler. Une taille en dur ici la contredirait. */
@media (max-width: 400px) {
  .rangee { gap: 5px; padding: 3px 4px; }
  .rangee .trous { gap: 6px; }
  /* Pas de marge sous la palette : elle est déjà collée au bas de l'écran
     et porte son propre `safe-area`. Ces pixels-là servent au plateau. */
  .enveloppe { padding: 8px 8px 0; }
  .palette { gap: 8px; padding: 9px; }
}
@media (max-width: 340px) {
  .rangee .trous { gap: 4px; }
  .rangee { gap: 4px; }
}

/* Le mode super a 5 trous : on resserre l'écart pour gagner de la largeur. */
body[data-positions="5"] .rangee .trous { gap: 5px; }
@media (max-width: 400px) {
  body[data-positions="5"] .rangee .trous { gap: 4px; }
  body[data-positions="5"] .rangee { gap: 4px; }
}

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