:root {
  --fond: #22333b;
  --fond-clair: #2f4858;
  --texte: #f2ece3;
  --texte-discret: #a9bcc7;

  --case: #e7dcc8;
  --case-bord: #c3b49a;
  --mot-triple: #d9544d;
  --mot-double: #eda29b;
  --lettre-triple: #2f6f9f;
  --lettre-double: #9ec9e2;

  /* Couleurs des joueurs, choisies pour un œil qui confond rouge et vert :
     elles jouent sur l'axe bleu–jaune et sur de forts écarts de clarté.
     Fabrice les distingue sans peine : pas de symbole en plus. */
  --c0: #a8cdf3;  --c0-bord: #2f6db5;  --c0-texte: #10243a;
  --c1: #fde68a;  --c1-bord: #b8940f;  --c1-texte: #3a2f08;
  --c2: #f3a24f;  --c2-bord: #9a5212;  --c2-texte: #3a1f05;
  --c3: #45484f;  --c3-bord: #17181b;  --c3-texte: #f4f4f4;

  /* Lettre en cours de pose : blanche à pointillés, reconnaissable à sa forme
     et non à sa teinte. */
  --provisoire: #ffffff;
  --provisoire-bord: #22333b;

  --principal: #2f7fc1;

  --plateau: min(100vw - 10px, 100dvh - 250px);
  --taille-case: calc(var(--plateau) / 15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overscroll-behavior: none;
  background: var(--fond);
  color: var(--texte);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; display: flex; flex-direction: column; }

.ecran { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px; }
.ecran[hidden] { display: none; }

/* ---------- Bandeau ---------- */

.bandeau {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 10px;
  background: var(--fond-clair);
  /* iOS 27 peut étendre son voile flou sous la zone sûre en mode portrait.
     Les scores restent donc volontairement 10 px plus bas. */
  padding-top: max(16px, calc(env(safe-area-inset-top) + 10px));
}
.bandeau[hidden] { display: none; }

/* En portrait sur iPhone, le voile du système descend plus bas que la zone
   sûre déclarée : on écarte franchement les scores de cette zone. */
@media (max-width: 699px) and (orientation: portrait) {
  .bandeau {
    padding-top: max(30px, calc(env(safe-area-inset-top) + 24px));
  }
}

.scores { display: flex; gap: 6px; flex: 1; min-width: 0; }

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 62px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 2px solid transparent;
}
.score--c0 { background: var(--c0); color: var(--c0-texte); }
.score--c1 { background: var(--c1); color: var(--c1-texte); }
.score--c2 { background: var(--c2); color: var(--c2-texte); }
.score--c3 { background: var(--c3); color: var(--c3-texte); }
.score.actif { border-color: #fff; box-shadow: 0 0 0 2px #fff; }
.score.moi .score-nom { text-decoration: underline; text-underline-offset: 2px; }

.score { flex: 1 1 0; min-width: 0; max-width: 110px; }
.score-nom {
  max-width: 100%;
  font-size: 10px; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.score-points { font-size: 20px; font-weight: 700; line-height: 1; }

.infos {
  flex-basis: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.3;
}
.infos .discret { display: inline; }

/* L'adversaire vient de jouer : le bandeau se teinte et respire doucement. */
.bandeau--votre-tour {
  background: #2b5f8f;
  animation: respiration 1.6s ease-in-out 3;
}
.bandeau--votre-tour #tour-info { font-weight: 700; color: #e3f1ff; }

@keyframes respiration {
  0%, 100% { background: #2b5f8f; }
  50%      { background: #4a8bc9; }
}

.reveil .plateau { animation: surlignage 1.1s ease-out 2; }

@keyframes surlignage {
  0%   { box-shadow: 0 0 0 0 rgba(74, 139, 201, .9); }
  100% { box-shadow: 0 0 0 14px rgba(74, 139, 201, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .bandeau--votre-tour, .reveil .plateau { animation: none; }
}
.discret { display: block; color: var(--texte-discret); font-size: 11px; }

.btn-son {
  all: unset;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border-radius: 8px;
}
.btn-son:hover { background: rgba(255, 255, 255, .1); }
.btn-son.coupe { opacity: .45; }

/* ---------- Plateau ---------- */

.plateau {
  width: var(--plateau);
  height: var(--plateau);
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 1px;
  padding: 2px;
  background: #6b5b45;
  border-radius: 4px;
  touch-action: none;
  margin: 0 auto;
}

.case {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--case);
  color: #4a4132;
  font-size: calc(var(--taille-case) * 0.34);
  font-weight: 700;
  text-align: center;
  line-height: 1;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.case--MT { background: var(--mot-triple);    color: #4a1410; }
.case--MD { background: var(--mot-double);    color: #5a1c17; }
.case--LT { background: var(--lettre-triple); color: #eaf4fb; }
.case--LD { background: var(--lettre-double); color: #16394f; }
.case--centre { background: var(--mot-double); }
.case--centre::after { content: "★"; font-size: calc(var(--taille-case) * 0.6); color: #7c2b23; }

.case.occupee {
  font-size: calc(var(--taille-case) * 0.62);
  font-weight: 800;
  border-radius: 3px;
}
.case.occupee::after { content: none; }

.case--c0 { background: var(--c0); color: var(--c0-texte); box-shadow: inset 0 0 0 1.5px var(--c0-bord); }
.case--c1 { background: var(--c1); color: var(--c1-texte); box-shadow: inset 0 0 0 1.5px var(--c1-bord); }
.case--c2 { background: var(--c2); color: var(--c2-texte); box-shadow: inset 0 0 0 1.5px var(--c2-bord); }
.case--c3 { background: var(--c3); color: var(--c3-texte); box-shadow: inset 0 0 0 1.5px var(--c3-bord); }

.case--provisoire {
  background: var(--provisoire);
  color: #10202a;
  outline: 2px dashed var(--provisoire-bord);
  outline-offset: -3px;
}

/* Essai posé hors de son tour : terne, pour ne jamais être confondu avec un
   coup que l'on s'apprête vraiment à valider. */
.case--essai {
  background: #9aa5ae;
  color: #253038;
  box-shadow: inset 0 0 0 1.5px #5f6a73;
  opacity: .9;
}

.plateau--essai { outline: 2px dashed #9aa5ae; outline-offset: 2px; }

/* Dernier coup joué : surbrillance dorée pour repérer immédiatement les lettres posées */
.case--dernier-coup {
  position: relative;
  z-index: 2;
  box-shadow: inset 0 0 0 2px #f59e0b, 0 0 6px rgba(245, 158, 11, 0.55);
  animation: lueur-dernier-coup 2s ease-in-out infinite alternate;
}

@keyframes lueur-dernier-coup {
  0%   { box-shadow: inset 0 0 0 2px #f59e0b, 0 0 4px rgba(245, 158, 11, 0.4); }
  100% { box-shadow: inset 0 0 0 2.5px #ffd166, 0 0 9px rgba(255, 209, 102, 0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .case--dernier-coup { animation: none; box-shadow: inset 0 0 0 2px #ffd166; }
}

.case--joker { font-style: italic; opacity: .92; }

.case .valeur {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: calc(var(--taille-case) * 0.3);
  font-weight: 600;
  opacity: .75;
}

.case.cible { outline: 2px solid #ffd166; outline-offset: -2px; }

.plateau--lecture .case { cursor: default; }

/* ---------- Chevalet et actions ---------- */

.barre-basse {
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: 520px;
  padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  background: var(--fond);
}

.chevalet {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.tuile {
  all: unset;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #f6efe2;
  color: #2b241a;
  border-radius: 6px;
  box-shadow: 0 2px 0 #b8a98f;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}
.tuile .valeur { position: absolute; right: 3px; bottom: 1px; font-size: 10px; font-weight: 600; opacity: .7; }
.tuile.selectionnee { outline: 3px solid #ffd166; outline-offset: 1px; transform: translateY(-3px); }
.tuile.vide { background: transparent; box-shadow: none; cursor: default; }

/* Lettre partie sur le plateau : son emplacement devient un creux sombre, pour
   qu'on voie du premier coup d'œil ce qui reste réellement en main.
   Sélecteur à trois classes : il doit l'emporter sur le grisage hors tour. */
.chevalet .tuile.engagee {
  background: #16202a;
  color: rgba(242, 236, 227, .22);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .55);
  opacity: 1;
  filter: none;
}
.chevalet .tuile.engagee .valeur { opacity: .2; }

/* Hors de son tour : le chevalet reste manipulable (ranger ses lettres, essayer
   un mot), mais doit se voir au premier coup d'œil comme inactif. */
.chevalet--inactif .tuile {
  filter: grayscale(.85);
  opacity: .6;
  box-shadow: 0 2px 0 #6f6a60;
}
.chevalet--inactif .tuile.selectionnee { opacity: .85; outline-color: #b9b2a4; }

.actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.barre-basse .actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.barre-basse .action {
  min-width: 0;
  min-height: 42px;
  padding: 0 4px;
  font-size: 13.5px;
}
.actions--centre { margin-top: 12px; }

.action {
  all: unset;
  flex: 1 1 auto;
  min-width: 74px;
  min-height: 44px;
  padding: 0 10px;
  text-align: center;
  background: var(--fond-clair);
  color: var(--texte);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.action:disabled, .action[disabled] { opacity: .4; cursor: default; }
.action--principale { background: var(--principal); color: #fff; }
.action--danger { background: #5a2a24; color: #ffd9d2; box-shadow: inset 0 0 0 2px #c96b5d; }
.action--discrete { background: transparent; color: var(--texte-discret); font-weight: 500; }
.action--large { width: min(100%, 520px); flex: 0 0 auto; margin: 6px 0 4px; line-height: 44px; }
.action.choisi { outline: 3px solid #ffd166; outline-offset: 1px; }

.message { min-height: 20px; margin: 6px 0; font-size: 13px; text-align: center; color: #ffd166; }
.message.erreur { color: #ff9d8a; }

/* ---------- Écran de choix ---------- */

#ecran-accueil { justify-content: center; gap: 14px; }
#ecran-accueil h1 { font-size: 34px; margin: 0; letter-spacing: .06em; }
.accroche { margin: 0; color: var(--texte-discret); }
.choix-joueurs { display: flex; flex-direction: column; gap: 12px; width: min(100%, 320px); }
.version-app {
  display: block;
  margin: 0 auto 4px;
  color: var(--texte-discret);
  font-size: 10px;
  letter-spacing: .08em;
  opacity: .45;
}
.version-app--bouton {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 12px;
  font: inherit;
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--texte-discret);
  opacity: .45;
  cursor: pointer;
}
.zone-version {
  flex: 1;
  min-height: 26px;
  position: relative;
  width: 100%;
}
.zone-version .version-app {
  position: absolute;
  top: 66.666%;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

/* ---------- Saisie du code et du mot de passe ---------- */

.formulaire-code { display: flex; flex-direction: column; gap: 8px; width: min(100%, 320px); }
.formulaire-code[hidden] { display: none; }
.formulaire-code .action { line-height: 44px; }

.champ-code, .champ-texte {
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: #f6efe2;
  color: #2b241a;
  font: inherit;
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}
.champ-code {
  min-height: 60px;
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.aide { width: min(100%, 520px); color: var(--texte-discret); font-size: 12.5px; margin: 8px 0; }
.intertitre {
  width: min(100%, 520px);
  margin: 16px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--texte-discret);
}

/* ---------- Tableau de bord du chef ---------- */

.carte-partie {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--fond-clair);
  border-radius: 10px;
}
.carte-partie .partie-dates { margin: 0; }
.carte-actions { display: flex; gap: 6px; }
.carte-actions .action { min-height: 38px; min-width: 0; font-size: 13.5px; line-height: 38px; }
.carte-actions .corbeille-bouton { flex: 0 0 44px; background: transparent; color: var(--texte-discret); }

.puces { display: flex; flex-wrap: wrap; gap: 5px; }
.puce {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  border: 2px solid transparent;
}
.puce--c0 { background: var(--c0); color: var(--c0-texte); }
.puce--c1 { background: var(--c1); color: var(--c1-texte); }
.puce--c2 { background: var(--c2); color: var(--c2-texte); }
.puce--c3 { background: var(--c3); color: var(--c3-texte); }
.puce--main { border-color: #fff; }
.puce--main::after { content: " ◀"; }

/* ---------- Création d'une partie ---------- */

.choix-nombre { display: flex; gap: 8px; width: min(100%, 320px); margin-bottom: 10px; }
.choix-nombre .action { font-size: 20px; line-height: 44px; }
.form-creation { width: min(100%, 420px); }
.ligne-invite {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--fond-clair);
  border-left: 8px solid;
}
.ligne-invite--c1 { border-left-color: var(--c1); }
.ligne-invite--c2 { border-left-color: var(--c2); }
.ligne-invite--c3 { border-left-color: var(--c3-texte); }

/* ---------- Codes des joueurs ---------- */

.liste-codes { width: min(100%, 420px); display: flex; flex-direction: column; gap: 8px; }
.ligne-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  border-radius: 10px;
}
.ligne-code--c0 { background: var(--c0); color: var(--c0-texte); }
.ligne-code--c1 { background: var(--c1); color: var(--c1-texte); }
.ligne-code--c2 { background: var(--c2); color: var(--c2-texte); }
.ligne-code--c3 { background: var(--c3); color: var(--c3-texte); }
.code-nom { flex: 1; font-weight: 700; }
.code-valeur {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .15em;
  -webkit-user-select: all;
  user-select: all;
}
.ligne-code .action { flex: 0 0 auto; min-height: 36px; line-height: 36px; font-size: 13px; }
.code-courriel { flex-basis: 100%; font-size: 12px; opacity: .8; }

/* ---------- Fin de partie ---------- */

.classement { width: min(100%, 320px); padding-left: 28px; font-size: 17px; line-height: 1.7; }
.classement .gagnant { font-weight: 800; color: #ffd166; }

.liens a { color: var(--texte-discret); font-size: 14px; }

.menu-liens {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 320px);
  margin-top: 10px;
}
.menu-liens .action { text-align: center; line-height: 44px; }
.menu-liens .action[hidden] { display: none; }

/* ---------- Historique ---------- */

.liste-parties { width: min(100%, 520px); display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.ligne-partie {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--fond-clair);
  border-radius: 8px;
  overflow: hidden;
}

.partie-resume {
  all: unset;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  cursor: pointer;
}
.partie-resume:hover { background: rgba(255, 255, 255, .06); }

.partie-scores { font-size: 15px; font-weight: 700; }
.partie-issue { font-size: 13px; color: #ffd166; }
.partie-dates { font-size: 11px; color: var(--texte-discret); }

.corbeille {
  all: unset;
  flex: 0 0 auto;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--texte-discret);
}
.corbeille:hover { background: #7a3b33; color: #ffd9d2; }

.rejeu-entete {
  width: min(100%, 520px);
  margin: 4px auto 8px;
  font-size: 13px;
  color: var(--texte-discret);
  text-align: center;
}

.rejeu-commandes { display: flex; align-items: center; gap: 8px; width: min(100%, 520px); margin-top: 8px; }
.rejeu-commandes input[type=range] { flex: 1; }
.rejeu-commandes .action { flex: 0 0 auto; min-width: 52px; }

/* ---------- Modale ---------- */

.modale {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modale[hidden] { display: none; }

.modale-boite {
  background: var(--fond-clair);
  border-radius: 12px;
  padding: 16px;
  width: min(100%, 380px);
  max-height: 90dvh;
  overflow-y: auto;
}
.modale-boite h3 { margin: 0 0 10px; font-size: 17px; }

.grille-lettres { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.grille-lettres button {
  all: unset;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6efe2;
  color: #2b241a;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}
.grille-lettres button.choisie { outline: 3px solid #ffd166; }

/* ---------- Accueil ---------- */

.accueil-parties { width: min(100%, 420px); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.accueil-parties .accroche { margin: 0; }
.attente {
  padding: 18px 16px;
  border-radius: 12px;
  background: var(--fond-clair);
  color: var(--texte-discret);
  line-height: 1.45;
}
.attente-titre { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: var(--texte); }
.carte-partie--accueil { background: transparent; padding: 0; }
.carte-partie--bouton { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  padding: 10px; background: var(--fond-clair); border-radius: 10px; }
.carte-partie--bouton:hover, .carte-partie--bouton:focus-visible { outline: 2px solid #ffd166; }
.choix-joueurs { width: 100%; }

.gros-bouton {
  all: unset;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.gros-bouton:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }
.gros-bouton:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.gros-bouton-nom { font-size: 22px; font-weight: 800; }
.gros-bouton-etat { font-size: 12px; opacity: .8; }
.gros-bouton--c0 { background: var(--c0); color: var(--c0-texte); }
.gros-bouton--c1 { background: var(--c1); color: var(--c1-texte); }
.gros-bouton--c2 { background: var(--c2); color: var(--c2-texte); }
.gros-bouton--c3 { background: var(--c3); color: var(--c3-texte); }

/* ---------- Fenêtres : mot de passe, joueurs, dictionnaire, lettres ---------- */

.mot-de-passe {
  margin: 10px 0;
  padding: 12px;
  border-radius: 10px;
  background: #f6efe2;
  color: #2b241a;
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: .25em;
  -webkit-user-select: all;
  user-select: all;
}
.modale-boite p { line-height: 1.45; }
.modale-boite .champ-code, .modale-boite .champ-texte { width: 100%; }
.modale-boite > .actions .action[hidden] { display: none; }

.ligne-joueur {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
}
.ligne-joueur-nom { flex: 1; font-weight: 600; font-size: 14px; }
.ligne-joueur .action { flex: 0 0 auto; min-height: 34px; line-height: 34px; font-size: 13px; }
.ligne-joueur--c0 { background: var(--c0); color: var(--c0-texte); }
.ligne-joueur--c1 { background: var(--c1); color: var(--c1-texte); }
.ligne-joueur--c2 { background: var(--c2); color: var(--c2-texte); }
.ligne-joueur--c3 { background: var(--c3); color: var(--c3-texte); }

.ordre-jeu { font-size: 17px; line-height: 1.6; font-weight: 700; }

.recherche { display: flex; gap: 6px; margin-bottom: 10px; }
.recherche .action { flex: 0 0 auto; line-height: 44px; }
.champ-mot { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.verdict { padding: 14px; border-radius: 10px; text-align: center; font-size: 16px; margin-bottom: 10px; }
/* Accepté / refusé : bleu contre brique, et un symbole ✓ / ✗ en tête. */
.verdict--connu { background: #24598a; color: #fff; }
.verdict--inconnu { background: #5a2a24; color: #ffd9d2; box-shadow: inset 0 0 0 2px #c96b5d; }
.verdict--vide { background: rgba(0, 0, 0, .18); color: var(--texte-discret); }
#modale-corps > .action { display: block; width: 100%; line-height: 44px; }
#modale-corps > .action[hidden] { display: none; }

.grille-restantes { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; }
.restante {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  border-radius: 6px;
  background: #f6efe2;
  color: #2b241a;
}
.restante b { font-size: 18px; }
.restante span { font-size: 12px; }
.restante--epuisee { opacity: .3; text-decoration: line-through; }

/* ---------- Feuille de match ---------- */

.feuille { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.feuille-ligne {
  padding: 6px 8px 6px 10px;
  border-radius: 8px;
  background: var(--fond-clair);
  border-left: 6px solid transparent;
  font-size: 13.5px;
}
.feuille-ligne[tabindex] { cursor: pointer; }
.feuille-ligne--c0 { border-left-color: var(--c0); }
.feuille-ligne--c1 { border-left-color: var(--c1); }
.feuille-ligne--c2 { border-left-color: var(--c2); }
.feuille-ligne--c3 { border-left-color: var(--c3-texte); }
.feuille-ligne--neutre { border-left-color: #ffd166; background: #3a3524; }
.feuille-ligne--active { outline: 2px solid #ffd166; }
.feuille-tete { display: flex; justify-content: space-between; gap: 8px; }
.feuille-texte { font-weight: 600; }
.feuille-points { font-weight: 800; white-space: nowrap; }
.feuille-detail { margin: 4px 0 0; color: #f2e6c4; }
.feuille-scores { margin: 3px 0 0; font-size: 11.5px; color: var(--texte-discret); }

.legende {
  width: min(100%, 520px);
  min-height: 40px;
  margin: 6px auto;
  font-size: 13.5px;
  text-align: center;
  color: #ffd166;
}
.legende-detail { display: block; margin-top: 4px; color: var(--texte); font-size: 13px; }
.explication { width: min(100%, 420px); text-align: left; }
.explication .legende-detail { margin-top: 6px; }

.rejeu-corps { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.rejeu-feuille { width: min(100%, 520px); }
.rejeu-commandes .action { min-width: 44px; padding: 0 6px; }

.puce--gagnant { border-color: #ffd166; }

/* ---------- Jeu : deux rangées d'actions, Valider en double largeur ---------- */

.jeu-plateau, .jeu-commandes { width: 100%; display: flex; flex-direction: column; align-items: center; }
.barre-basse .actions { grid-template-columns: repeat(4, 1fr); }
.barre-basse #btn-valider { grid-column: span 2; }
.journal-lateral { display: none; }

@media (min-width: 700px) {
  :root { --plateau: min(560px, 100dvh - 250px); }
  .barre-basse .actions { grid-template-columns: repeat(4, 1fr); }
}

/* Ordinateur : plateau à gauche, chevalet, actions et derniers coups à droite. */
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  :root { --plateau: min(720px, 100dvh - 100px, 100vw - 470px); }
  #ecran-jeu:not([hidden]) {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    padding: 12px;
  }
  .jeu-plateau { width: auto; }
  .jeu-commandes { width: 400px; align-items: stretch; }
  .jeu-commandes .message { min-height: 40px; text-align: left; }
  .barre-basse { position: static; max-width: none; padding: 0; }
  .journal-lateral { display: block; margin-top: 8px; max-height: calc(100dvh - 330px); overflow-y: auto; }
  .journal-lateral .intertitre { margin-top: 4px; }

  .rejeu-corps { flex-direction: row; align-items: flex-start; justify-content: center; }
  .rejeu-plateau { display: flex; flex-direction: column; align-items: center; }
  .rejeu-feuille { width: 380px; max-height: calc(100dvh - 140px); overflow-y: auto; }
}

/* ---------- Retouches ---------- */

/* Une lettre posée a l'allure d'une vraie tuile, en relief et un peu en
   retrait de la case : on la distingue des cases colorées sans se fier à la
   teinte (les cases LD sont bleu clair, comme les lettres du premier joueur). */
.case.occupee:not(.case--provisoire):not(.case--essai) {
  margin: 1px;
  border-radius: 4px;
  translate: 0 -1px;
}
.case--c0.occupee, .case--c1.occupee, .case--c2.occupee, .case--c3.occupee {
  filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, .55));
}
.case--c0 { box-shadow: inset 0 0 0 2px var(--c0-bord); }

/* Les boutons posés sur un fond déjà clair (cartes, fenêtres) prennent le
   fond sombre, sans quoi ils s'y fondent. */
.carte-partie .action:not(.action--principale):not(.action--danger):not(.corbeille-bouton),
.modale-boite .action:not(.action--principale):not(.action--danger) {
  background: var(--fond);
}
.action--large { box-sizing: border-box; }

@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  .score { max-width: 150px; padding: 4px 12px; }
  .score-nom { font-size: 12px; }
  .score-points { font-size: 26px; }
  .infos { font-size: 15px; }
}

.carte-demande { flex-direction: column; }
.demande-mot { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .08em; }
#zone-demandes { width: min(100%, 520px); }
#zone-demandes[hidden] { display: none; }

/* Ordinateur : le bandeau rejoint la colonne de droite, au-dessus du chevalet. */
.bandeau.bandeau--colonne {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 10px;
}
.bandeau--colonne .scores { gap: 6px; }
.bandeau--colonne .score { max-width: none; padding: 4px 6px; }
.bandeau--colonne .score-nom { font-size: 11px; }
.bandeau--colonne .score-points { font-size: 24px; }
.bandeau--colonne .btn-son { width: 34px; height: 34px; }
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  :root { --plateau: min(760px, 100dvh - 30px, 100vw - 470px); }
}

/* Les prénoms tiennent mieux en minuscules (Alexandre plutôt qu'ALEXAN…). */
.score { padding: 2px 4px; }
.score-nom { text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 600; }
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  :root { --plateau: min(760px, 100dvh - 30px, 100vw - 510px); }
  .jeu-commandes { width: 440px; }
  .bandeau--colonne .score-nom { font-size: 12.5px; }
}

/* Deux lignes toujours réservées au message : le plateau, dimensionné sur la
   place restante (ui.js), ne saute pas quand le texte s'allonge. */
.jeu-commandes .message { min-height: 2.7em; margin: 4px 0; display: flex; align-items: center; justify-content: center; }
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  .jeu-commandes .message { justify-content: flex-start; }
  #ecran-jeu:not([hidden]) { padding: 12px; }
  .jeu-commandes { width: min(440px, 46vw); }
}

/* Le chef qui regarde une partie sans y jouer. */
.jeu--spectateur .chevalet,
.jeu--spectateur .barre-basse .actions .action:not(#btn-menu) { display: none; }
.jeu--spectateur .barre-basse .actions { grid-template-columns: 1fr; }
.choix-role .action { font-size: 15px !important; }
.ligne-invite--c0 { border-left-color: var(--c0); }

/* Des mots proposés attendent la décision du chef : le bouton Menu le signale. */
.action.action--alerte { background: #8a6d12; color: #fff6d6; box-shadow: inset 0 0 0 2px #ffd166; }
.action--pleine { display: block; width: 100%; box-sizing: border-box; line-height: 44px; margin-top: 8px; }

/* Numéro de version cliquable : discret mais lisible, sous les boutons. */
.btn-version {
  all: unset;
  align-self: center;
  margin-top: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(169, 188, 199, .35);
  color: var(--texte-discret);
  font-size: 12.5px;
  letter-spacing: .03em;
  cursor: pointer;
}
.btn-version:hover, .btn-version:focus-visible { color: var(--texte); border-color: #ffd166; }
.menu-liens .btn-version { text-align: center; }

/* =====================================================================
   Refonte de la présentation (v7)
   ===================================================================== */

/* ---------- Téléphone : boutons plus grands, derniers coups dessous ---------- */
.barre-basse .action { min-height: 46px; font-size: 14.5px; }
.journal-lateral { display: block; width: 100%; max-width: 520px; margin: 8px auto 0; }
.journal-lateral .intertitre { margin: 0 0 4px; width: auto; }
.journal-lateral .feuille { overflow-y: auto; }
.journal-lateral.journal--masque { display: none; }

/* ---------- Dernier coup : double contour, visible sur toutes les couleurs ---------- */
.case--dernier-coup {
  box-shadow: inset 0 0 0 2px #1b2a33, inset 0 0 0 4px #ffb703;
}
@keyframes lueur-dernier-coup {
  0%   { box-shadow: inset 0 0 0 2px #1b2a33, inset 0 0 0 4px #ffb703, 0 0 3px rgba(255, 183, 3, .45); }
  100% { box-shadow: inset 0 0 0 2px #1b2a33, inset 0 0 0 4.5px #ffd166, 0 0 10px rgba(255, 209, 102, .9); }
}

/* ---------- Écran de fin : podium et plateau final ---------- */
#fin-contenu { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#fin-titre { margin: 6px 0 2px; text-align: center; font-size: 24px; }
.podium { list-style: none; margin: 0; padding: 0; width: min(100%, 420px); display: flex; flex-direction: column; gap: 6px; }
.podium-ligne {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; font-size: 16px; font-weight: 700;
}
.podium-ligne--c0 { background: var(--c0); color: var(--c0-texte); }
.podium-ligne--c1 { background: var(--c1); color: var(--c1-texte); }
.podium-ligne--c2 { background: var(--c2); color: var(--c2-texte); }
.podium-ligne--c3 { background: var(--c3); color: var(--c3-texte); }
.podium-ligne--premier { font-size: 18px; padding: 12px; box-shadow: 0 0 0 3px #ffd166; }
.podium-rang { min-width: 34px; font-weight: 800; }
.podium-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-points { white-space: nowrap; }
.plateau-fin { --plateau: min(92vw, 340px); --taille-case: calc(var(--plateau) / 15); margin: 2px auto; }
.explication { width: min(100%, 420px); font-size: 13.5px; margin: 0; }
.actions--fin { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: min(100%, 420px); }
.actions--fin .action { min-width: 0; padding: 0 4px; line-height: 44px; font-size: 13.5px; }

/* ---------- Feuille de match : plateau à la hauteur de l'écran ---------- */
.rejeu-tete { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 1180px; margin: 0 auto 8px; }
.rejeu-tete .action { flex: 0 0 auto; min-width: 0; min-height: 40px; line-height: 40px; }
.rejeu-tete .rejeu-entete { flex: 1; width: auto; margin: 0; text-align: left; }
.rejeu-plateau { display: flex; flex-direction: column; align-items: center; }
.rejeu-plateau .rejeu-commandes { width: var(--plateau); max-width: 100%; margin-top: 8px; }
.rejeu-plateau .legende { width: var(--plateau); max-width: 100%; min-height: 64px; margin: 6px 0 0; }

/* ---------- Ordinateur ---------- */
@media (min-width: 640px) and (min-aspect-ratio: 6/5) {
  /* Le menu et la fin s'affichent dans la colonne, le plateau reste visible. */
  .jeu--panneau .jeu-commandes > .message,
  .jeu--panneau .barre-basse,
  .jeu--panneau .journal-lateral { display: none; }
  .jeu-commandes .panneau { width: 100%; margin-top: 10px; align-items: stretch; }
  .jeu-commandes .panneau h2 { margin: 0 0 8px; font-size: 20px; }
  .jeu-commandes .menu-liens { width: 100%; margin: 0; }
  .jeu-commandes #plateau-fin, .jeu-commandes #btn-voir-plateau { display: none; }
  .jeu-commandes #fin-contenu { align-items: stretch; }
  .jeu-commandes #fin-titre { text-align: left; }
  .jeu-commandes .podium, .jeu-commandes .explication, .jeu-commandes .actions--fin { width: 100%; }
  .jeu-commandes .actions--fin { grid-template-columns: 1fr 1fr; }

  /* Moins de place perdue entre les scores et le chevalet. */
  .jeu-commandes .message { min-height: 1.5em; margin: 6px 0; }
  .journal-lateral { max-width: none; margin: 8px 0 0; }

  /* Feuille de match : plateau à gauche, feuille à droite, pleine hauteur. */
  #ecran-rejeu:not([hidden]) { padding: 12px; }
  .rejeu-corps { flex-direction: row; align-items: flex-start; justify-content: center; gap: 20px; }
  .rejeu-feuille { width: 380px; max-height: calc(100dvh - 80px); overflow-y: auto; }
  .rejeu-feuille .intertitre { margin-top: 0; }

  /* Accueil resserré : il tient dans une fenêtre basse. */
  #ecran-accueil { justify-content: flex-start; padding-top: 3vh; gap: 10px; }
  #ecran-accueil h1 { font-size: 28px; }
  .accueil-parties { width: min(100%, 640px); }
  .choix-joueurs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .gros-bouton { padding: 10px 12px; }

  /* Tableau de bord : cartes sur deux colonnes quand il y a la place. */
  #ecran-chef .liste-parties, #ecran-chef .intertitre, #zone-demandes, #ecran-chef .action--large { width: min(100%, 940px); }
  #liste-en-cours, #liste-terminees { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 8px; }
}
/* Le curseur du rejeu se rétrécit plutôt que de faire déborder la page. */
.rejeu-commandes input[type=range] { min-width: 0; }
.rejeu-commandes { gap: 6px; }

/* Ordre de jeu annoncé au lancement d'une partie : une pastille par joueur. */
.ordre-jeu li { margin: 4px 0; }
.ordre-jeu .puce { display: inline-block; }
