/* Toc — direction artistique reprise de l'appli Scrabble (même famille) : fond bleu ciel, surfaces blanches,
   boutons carrés blancs au contour fin, accent bleu, plateau vert dans un cadre bleu nuit avec des trous crème.
   Thème clair / sombre (data-theme posé sur <html> par index.html puis par js/ui/reglages.js). */

:root {
  --bg: #a9d3f4;
  --surface: #ffffff;
  --surface-2: #e3f0fb;
  --text: #0f2238;
  --muted: #475f7a;
  --line: #7ba6cd;
  --bord: #2c4768;
  /* Plateau */
  --cadre: #2c4768;
  --tapis: #4f9e5f;
  --trait: #e4f1e2;
  --tile: #f1e6bf;
  --tile-text: #101214;
  --tile-edge: #b3a066;
  --contour: #0f2238;
  --ring: #1f62c0;
  /* Pions : bleu et jaune (partenaires) contre rouge et violet */
  --pion-0: #1f62c0;
  --pion-1: #e03a33;
  --pion-2: #f0b400;
  --pion-3: #7a5bb8;
  /* Main (bac bleu) */
  --rack: #1b5ea6;
  --carte-fond: #fffdf6;
  --carte-rouge: #cf2f25;
  --carte-noire: #101214;
  --chip: #d6e8fa;
  --chip-text: #164a94;
  --accent: #1f62c0;
  --accent-bord: #164a94;
  --accent-text: #ffffff;
  --lien: #143f82;
  --ok: #1c8a4a;
  --dernier: #f0a30a;
  --err: #cf2f25;
  --mt: #e03a33;
  --ombre: 0 2px 8px rgba(15, 34, 56, 0.2);
  --rayon: 8px;
  --texte: 1;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0e2238;
  --surface: #16314d;
  --surface-2: #1d3d5e;
  --text: #e8f1fb;
  --muted: #9db6d0;
  --line: #2f5276;
  --bord: #6e93b9;
  --cadre: #06131f;
  --tapis: #2f7040;
  --trait: #9fd0ab;
  --tile: #ecdfb2;
  --tile-edge: #a08e58;
  --contour: #06131f;
  --ring: #7fb0f5;
  --pion-0: #3b7ee0;
  --pion-1: #ea4a42;
  --pion-2: #f4c01c;
  --pion-3: #9073d4;
  --rack: #0f4a85;
  --carte-fond: #f7f2e4;
  --chip: #1f3f66;
  --chip-text: #b9d4fa;
  --accent: #4d8fe8;
  --accent-bord: #4d8fe8;
  --accent-text: #06162b;
  --lien: #b9d4fa;
  --ok: #54d08a;
  --dernier: #ffc233;
  --err: #ff7f72;
  --mt: #c8322c;
  --ombre: 0 2px 10px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

:root[data-texte='grand'] {
  --texte: 1.15;
}
:root[data-texte='tres-grand'] {
  --texte: 1.3;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  font-size: calc(16px * var(--texte));
}
button {
  font: inherit;
  color: inherit;
}
input,
select {
  font: inherit;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--lien);
}

.appli {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.zone-principale {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.contenu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px;
  animation: apparition 0.18s ease-out;
}
@keyframes apparition {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* En-tête : le logo est un pion posé dans un trou crème sur le tapis vert. */
.entete {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.entete h1 {
  margin: 0;
  font-size: calc(23px * var(--texte));
  font-weight: 800;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--tapis);
  border: 2px solid var(--cadre);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.logo span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1f62c0;
  border: 2px solid #0f2238;
  box-shadow: 0 0 0 2px #f1e6bf;
}
.puce {
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1.5px solid var(--bord);
  color: var(--lien);
  font-size: calc(13px * var(--texte));
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Barre d'onglets */
.onglets {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  border-top: 2px solid var(--bord);
  background: var(--surface);
  padding: 4px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 5;
}
.onglets a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: calc(11px * var(--texte));
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  min-width: 64px;
  padding: 7px 0 4px;
  position: relative;
}
.onglets a.actif {
  color: var(--lien);
  font-weight: 700;
}
.onglets a.actif::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  right: 14px;
  height: 4px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}
.pastille {
  position: absolute;
  top: 2px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--mt);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Cartes (panneaux), statistiques */
.carte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rayon);
  padding: 14px;
}
.formulaire {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.carte-accent {
  background: var(--accent);
  border-color: var(--accent-bord);
  color: var(--accent-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.carte-accent .note {
  color: inherit;
  opacity: 0.88;
}
.carte-accent .bouton {
  background: var(--surface);
  color: var(--lien);
}
.carte-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats {
  display: flex;
  gap: 8px;
}
.stat {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--rayon);
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.stat .etiquette {
  font-size: calc(11px * var(--texte));
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .valeur {
  font-size: calc(19px * var(--texte));
  font-weight: 700;
}

/* Boutons : carrés blancs au contour fin, le principal est bleu. */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bouton {
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--text);
  font-size: calc(14px * var(--texte));
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}
.bouton:disabled {
  opacity: 0.45;
  cursor: default;
}
.bouton.principal {
  background: var(--accent);
  border-color: var(--accent-bord);
  color: var(--accent-text);
  font-size: calc(15px * var(--texte));
}
.bouton.large {
  flex: 1;
}
.bouton.discret {
  background: transparent;
  border-color: transparent;
  color: var(--lien);
  min-height: 40px;
}
.bouton.danger {
  color: var(--err);
}
.bouton.petit {
  min-height: 34px;
  padding: 0 8px;
  font-size: calc(12px * var(--texte));
}
.bouton-icone {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--bord);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* Listes */
.liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ligne {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rayon);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.ligne:disabled {
  opacity: 0.55;
  cursor: default;
}
.ligne.choisie {
  background: var(--chip);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ligne .principal {
  flex: 1;
  min-width: 0;
}
.ligne .mot {
  font-weight: 700;
}
.ligne .pts {
  font-weight: 800;
}
.ligne .note {
  overflow: hidden;
  text-overflow: ellipsis;
}
.mot.grand,
b.grand {
  font-size: calc(18px * var(--texte));
}
.ligne.invitation {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}
.rangee-invitation {
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: calc(12px * var(--texte));
  font-weight: 800;
  white-space: nowrap;
}
.badge.a-toi {
  background: var(--accent);
  color: var(--accent-text);
}
.badge.ok {
  background: var(--ok);
  color: #fff;
}
:root[data-theme='dark'] .badge.ok {
  color: #06162b;
}
.badge.neutre {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
h2 {
  font-size: calc(14px * var(--texte));
  font-weight: 700;
  color: var(--lien);
  margin: 8px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.note {
  font-size: calc(12px * var(--texte));
  color: var(--muted);
}
.centre {
  text-align: center;
}
.ecart-neg {
  color: var(--err);
}
.vide-etat {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
  line-height: 1.5;
}
.apercu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rayon);
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 46px;
  font-size: calc(14px * var(--texte));
}
.apercu.erreur {
  color: var(--err);
}

/* Feuilles (fenêtres en bas d'écran) */
.voile {
  position: fixed;
  inset: 0;
  background: rgba(6, 22, 40, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  animation: fondu 0.15s ease-out;
}
@keyframes fondu {
  from {
    opacity: 0;
  }
}
.feuille {
  background: var(--bg);
  border-top: 2px solid var(--bord);
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow: auto;
  border-radius: 14px 14px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: montee 0.2s ease-out;
}
@keyframes montee {
  from {
    transform: translateY(24px);
  }
}
.feuille h3 {
  margin: 0;
  font-size: calc(20px * var(--texte));
  font-weight: 800;
}
.feuille p {
  margin: 0;
}

/* Formulaires */
.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: calc(14px * var(--texte));
  font-weight: 600;
}
.champ input {
  min-height: 46px;
  border-radius: var(--rayon);
  border: 1.5px solid var(--bord);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-size: max(16px, calc(16px * var(--texte)));
  font-weight: 400;
}
.champ-code {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border-radius: var(--rayon);
  border: 1.5px solid var(--bord);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-size: max(16px, calc(16px * var(--texte)));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.champ-code.libre {
  text-transform: none;
  letter-spacing: normal;
}
.segments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.segments button {
  flex: 1;
  min-height: 44px;
  border-radius: var(--rayon);
  border: 1.5px solid var(--bord);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  min-width: 60px;
}
.segments button.actif {
  border-color: var(--accent-bord);
  background: var(--accent);
  color: var(--accent-text);
}
details.options > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--lien);
  font-size: calc(15px * var(--texte));
  padding: 4px 0;
}
details.options[open] {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rayon);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Réglages : des lignes dans une carte, avec un interrupteur ou un bouton à droite. */
.reglage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.carte > .reglage:first-child,
details > .reglage:first-of-type {
  border-top: 0;
}
.carte > .reglage:first-child {
  padding-top: 0;
}
.carte > .reglage:last-child {
  padding-bottom: 0;
}
.reglage .texte {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.reglage .titre {
  font-weight: 700;
  font-size: calc(15px * var(--texte));
}
.reglage .bouton {
  min-height: 40px;
  flex: none;
}
.interrupteur {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1.5px solid var(--bord);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.interrupteur::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--muted);
  transition: transform 0.15s;
}
.interrupteur[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent-bord);
}
.interrupteur[aria-checked='true']::after {
  background: var(--accent-text);
  transform: translateX(22px);
}

/* Avatars et icônes */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  color: #fff;
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  flex: none;
}
.avatar.avatar-icone {
  font-size: 24px;
  line-height: 1;
}
.avatar.vide {
  background: transparent;
  border: 2px dashed var(--line);
  color: var(--muted);
}
.choix-icones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.choix-icone {
  height: 46px;
  padding: 0;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.choix-icone.initiale {
  font-size: 18px;
  font-weight: 800;
  background: var(--muted);
  color: #fff;
}
.choix-icone.choisie {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  background: var(--surface-2);
}
.choix-icone.initiale.choisie {
  background: var(--accent);
}

.toast {
  margin: 8px 16px 0;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--rayon);
  font-size: calc(14px * var(--texte));
  font-weight: 600;
  text-align: center;
  box-shadow: var(--ombre);
  animation: descente 0.18s ease-out;
}
@keyframes descente {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}
.toast.erreur {
  background: var(--err);
  color: #fff;
}

/* ─── Salle d'attente ───────────────────────────────────────────────────── */
.titre-carte {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.table-attente {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    '. haut .'
    'gauche tapis droite'
    '. bas .';
  gap: 8px;
  align-items: stretch;
}
.table-attente > div {
  display: flex;
}
.table-attente .siege {
  flex: 1;
  justify-content: center;
}
.place-haut {
  grid-area: haut;
}
.place-gauche {
  grid-area: gauche;
}
.place-droite {
  grid-area: droite;
}
.place-bas {
  grid-area: bas;
}
.tapis-table {
  grid-area: tapis;
  min-height: 90px;
  border-radius: 8px;
  background: var(--tapis);
  border: 3px solid var(--cadre);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(12px * var(--texte));
  text-align: center;
  padding: 4px;
}
.tapis-table .note {
  color: #e4f1e2;
}
.siege {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--rayon);
  border: 1.5px solid var(--line);
  border-top: 5px solid var(--c);
  background: var(--surface-2);
  min-width: 0;
}
.siege.moi {
  border-color: var(--accent);
  border-top-color: var(--c);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.siege.libre {
  background: transparent;
  border-style: dashed;
  border-top-style: solid;
}
.nom-siege {
  font-weight: 700;
  font-size: calc(14px * var(--texte));
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.actions-siege {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}
.code-invitation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--rayon);
  background: var(--surface-2);
  border: 1.5px dashed var(--bord);
}
.code-invitation .code {
  font-size: calc(28px * var(--texte));
  font-weight: 800;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: var(--lien);
}

/* ─── Règles ────────────────────────────────────────────────────────────── */
.intro {
  margin: 0;
  line-height: 1.5;
}
.regles ul {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.valeurs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.valeur-carte {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.4;
  font-size: calc(14px * var(--texte));
}

/* ─── Cartes à jouer ────────────────────────────────────────────────────── */
.carte-jeu {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 66px;
  aspect-ratio: 62 / 88;
  padding: 0;
  border-radius: 7px;
  background: var(--carte-fond);
  border: 1.5px solid #2c4768;
  box-shadow: 0 2px 4px rgba(15, 34, 56, 0.3);
  color: var(--carte-noire);
  font-family: Georgia, 'Times New Roman', serif;
  cursor: pointer;
  transition:
    translate 0.15s,
    box-shadow 0.15s,
    opacity 0.15s;
  overflow: hidden;
  container-type: inline-size;
}
.carte-jeu.rouge {
  color: var(--carte-rouge);
}
.carte-jeu .coin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-size: max(11px, 22cqw);
}
.carte-jeu .coin b {
  font-size: max(14px, 30cqw);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.carte-jeu .coin.haut {
  top: 4%;
  left: 7%;
}
.carte-jeu .coin.bas {
  bottom: 4%;
  right: 7%;
  rotate: 180deg;
}
.carte-jeu .symbole-central {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: max(22px, 52cqw);
  padding-top: 8%;
}
/* Habillés : le personnage (figures.js) occupe le centre, entre les deux coins. */
.carte-jeu .symbole-central.figure {
  display: block;
  inset: 6% 26%;
  padding: 0;
}
/* Coins plus fins, pour laisser la place au personnage. */
.carte-jeu.habille .coin {
  font-size: max(9px, 18cqw);
}
.carte-jeu.habille .coin b {
  font-size: max(12px, 24cqw);
}
.carte-jeu.habille .coin.haut {
  left: 5%;
}
.carte-jeu.habille .coin.bas {
  right: 5%;
}
.carte-jeu .symbole-central.figure svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.carte-jeu.choisie {
  translate: 0 -8px;
  box-shadow:
    0 0 0 3px var(--dernier),
    0 8px 14px rgba(0, 0, 0, 0.3);
}
.carte-jeu.injouable {
  opacity: 0.42;
  filter: grayscale(0.6);
}
.carte-jeu[aria-disabled='true'] {
  cursor: default;
}
.carte-jeu .marque-carte {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--accent);
  color: var(--accent-text);
  font: 700 10px/1.5 system-ui, sans-serif;
  text-align: center;
}
.carte-jeu.petite {
  flex: none;
  width: 44px;
  max-width: none;
  cursor: default;
}

/* ─── Écran de jeu ──────────────────────────────────────────────────────── */
.appli.en-jeu {
  padding-bottom: 0;
}
.ecran-jeu {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - env(safe-area-inset-top));
}
.colonne-jeu {
  display: contents;
}
.barre-jeu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.barre-jeu .titre {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: calc(17px * min(var(--texte), 1.1));
  font-weight: 800;
}
.barre-jeu .titre .texte {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.barre-jeu .titre .sous {
  font-weight: 500;
  color: var(--muted);
  font-size: calc(14px * var(--texte));
  white-space: nowrap;
}
.zone-plateau {
  position: relative;
  aspect-ratio: 1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.plateau-toc {
  display: block;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Plateau (SVG) */
.plateau-toc .cadre {
  fill: var(--cadre);
}
.plateau-toc .tapis {
  fill: var(--tapis);
}
.plateau-toc .filet {
  fill: none;
  stroke: var(--trait);
  stroke-opacity: 0.35;
  stroke-width: 0.5;
}
.plateau-toc .trou {
  fill: var(--tile);
  stroke: var(--tile-edge);
  stroke-width: 0.4;
}
.plateau-toc .trou.trou-fonce {
  stroke: var(--contour);
  stroke-width: 0.4;
}
.plateau-toc .trou.repere {
  stroke: var(--contour);
  stroke-width: 1.1;
}
.plateau-toc .zone-base,
.plateau-toc .zone-allee,
.plateau-toc .zone-sortie {
  stroke: var(--contour);
  stroke-width: 0.65;
}
.plateau-toc .fleche-sens {
  fill: none;
  stroke: var(--trait);
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.plateau-toc .dernier-depart {
  fill: none;
  stroke: var(--dernier);
  stroke-width: 0.8;
  stroke-dasharray: 1.6 1.2;
}
.plateau-toc .dernier-arrivee {
  fill: none;
  stroke: var(--dernier);
  stroke-width: 1.3;
}
.plateau-toc .dernier-arrivee {
  rx: 4.6;
}
/* Pions */
.plateau-toc .ombre-pion {
  fill: #0f2238;
  opacity: 0.35;
}
.plateau-toc .corps-pion {
  stroke: var(--contour);
  stroke-width: 0.65;
}
.plateau-toc .reflet-pion {
  fill: #fff;
  opacity: 0.5;
}
.plateau-toc .forme-pion {
  fill: #fff;
  fill-opacity: 0.92;
  stroke: var(--contour);
  stroke-width: 0.2;
}
.plateau-toc .bouclier {
  display: none;
  fill: #fff;
  stroke: var(--contour);
  stroke-width: 0.35;
  transform: translate(2.6px, -2.6px) scale(0.85);
}
.plateau-toc .pion.protege .bouclier {
  display: block;
}
.plateau-toc .pion.candidat .corps-pion {
  stroke: #fff;
  stroke-width: 0.9;
}
.plateau-toc .pion.candidat .dessin-pion {
  animation: pouls-pion 1.1s ease-in-out infinite;
}
.plateau-toc .pion.choisi .corps-pion {
  stroke: var(--dernier);
  stroke-width: 1.2;
}
.plateau-toc .pion.choisi .dessin-pion {
  animation: none;
  scale: 1.12;
}
.plateau-toc .pion.capture-prevue .dessin-pion {
  opacity: 0.55;
}
@keyframes pouls-pion {
  50% {
    scale: 1.14;
  }
}
.plateau-toc .dessin-pion.fantome {
  opacity: 0.6;
}
.plateau-toc .fantome-pion {
  pointer-events: none;
}
.plateau-toc .croix-capture {
  stroke: var(--err);
  stroke-width: 1.3;
  stroke-linecap: round;
  pointer-events: none;
}
.plateau-toc .marque-cible {
  fill: rgba(255, 255, 255, 0.35);
  stroke: #fff;
  stroke-width: 0.9;
  stroke-dasharray: 1.5 1;
  pointer-events: none;
  animation: pouls-cible 1.2s ease-in-out infinite;
}
.plateau-toc .marque-cible.choisie {
  stroke: var(--dernier);
  stroke-width: 1.3;
  stroke-dasharray: none;
  animation: none;
}
@keyframes pouls-cible {
  50% {
    stroke-opacity: 0.4;
  }
}
.plateau-toc .zone-touche {
  fill: transparent;
  cursor: pointer;
  outline: none;
}
.plateau-toc .zone-touche:focus-visible {
  stroke: var(--ring);
  stroke-width: 0.8;
}
/* Étiquettes des joueurs */
.plateau-toc .etiquette .boite {
  fill: var(--surface);
  stroke: var(--bord);
  stroke-width: 0.45;
  opacity: 0.94;
}
.plateau-toc .etiquette.actif .boite {
  fill: var(--surface);
  stroke: var(--dernier);
  stroke-width: 1.2;
  opacity: 1;
}
.plateau-toc .etiquette.actif {
  filter: drop-shadow(0 0 1.2px var(--dernier));
}
.plateau-toc .avatar-plateau {
  stroke: var(--contour);
  stroke-width: 0.4;
}
.plateau-toc .avatar-texte {
  fill: #fff;
  font-size: 6.2px;
  font-weight: 800;
  text-anchor: middle;
}
.plateau-toc .avatar-texte.emoji {
  font-size: 6.6px;
}
.plateau-toc .dos-carte {
  fill: var(--rack);
  stroke: var(--surface);
  stroke-width: 0.4;
}
.plateau-toc .nb-cartes {
  fill: var(--text);
  font-size: 6.4px;
  font-weight: 800;
  text-anchor: end;
}
.plateau-toc .pseudo-plateau {
  fill: var(--text);
  font-size: 5.6px;
  font-weight: 700;
}
.plateau-toc .sous-plateau {
  fill: var(--muted);
  font-size: 4.4px;
  font-weight: 600;
}
.plateau-toc .etiquette.actif .sous-plateau {
  fill: var(--lien);
}
/* Centre : donne et dernière carte jouée */
.plateau-toc .texte-donne {
  fill: #fff;
  font-size: 5px;
  font-weight: 700;
  text-anchor: middle;
  opacity: 0.92;
}
.plateau-toc .texte-donne.petit {
  font-size: 4.2px;
  font-weight: 600;
}
.plateau-toc .emplacement-carte {
  fill: none;
  stroke: var(--trait);
  stroke-opacity: 0.5;
  stroke-width: 0.6;
  stroke-dasharray: 1.5 1.2;
}
.plateau-toc .carte-plateau .fond-carte {
  fill: #fffdf6;
  stroke: #2c4768;
  stroke-width: 0.7;
}
.plateau-toc .carte-plateau text {
  fill: #101214;
  font-family: Georgia, 'Times New Roman', serif;
}
.plateau-toc .carte-plateau.rouge text {
  fill: #cf2f25;
}
.plateau-toc .rang-carte {
  font-size: 6.6px;
  font-weight: 800;
  font-family: system-ui, sans-serif !important;
}
.plateau-toc .symbole-carte {
  font-size: 12px;
  text-anchor: middle;
}
.plateau-toc .symbole-carte.coin {
  font-size: 5.6px;
}
/* Personnage d'un habillé sur la carte du centre : sa couleur suit celle de la carte. */
.plateau-toc .carte-plateau {
  color: #101214;
}
.plateau-toc .carte-plateau.rouge {
  color: #cf2f25;
}

/* Main du joueur : le bac bleu de l'appli Scrabble. */
.chevalet {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  padding: 12px 10px 8px;
  background: var(--rack);
  border-bottom: 2px solid var(--cadre);
  min-height: 104px;
  transition: background 0.3s;
}
.chevalet.inactive .carte-jeu {
  cursor: default;
}
.main-vide {
  align-self: center;
  color: #d6e8fa;
  font-size: calc(14px * var(--texte));
}
.consigne {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  padding: 10px 16px;
  font-size: calc(15px * var(--texte));
  line-height: 1.35;
}
.consigne .mots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.puce-pion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3em;
  height: 1.3em;
  border-radius: 50%;
  background: var(--c);
  border: 1.5px solid var(--contour);
  color: #fff;
  font-size: 0.75em;
  vertical-align: -0.15em;
  flex: none;
}
.panneau-bas {
  margin-top: auto;
  background: var(--bg);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panneau-bas > .actions {
  padding: 0 12px;
}
.panneau-bas .bouton {
  min-height: 48px;
  padding: 0 12px;
}
.statut {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.statut .milieu {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.statut .texte {
  font-size: calc(13px * var(--texte));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pastille-couleur {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--tapis);
  border: 2px solid var(--cadre);
  display: flex;
  align-items: center;
  justify-content: center;
}
.jauge {
  height: 7px;
  border-radius: 2px;
  border: 1px solid var(--bord);
  background: var(--surface);
  overflow: hidden;
}
.jauge > div {
  height: 100%;
  background: var(--ok);
  transition: width 0.4s;
}
.jauge.adverse > div {
  background: var(--err);
}
.journal {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ligne-journal {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rayon);
  font-size: calc(14px * var(--texte));
  line-height: 1.35;
}
.fin-titre {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fin-embleme {
  font-size: 40px;
}
.fin-titre.gagne h3 {
  color: var(--ok);
}

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

/* Petits téléphones */
@media (max-width: 380px) {
  .barre-jeu {
    gap: 6px;
    padding: 6px 8px;
  }
  .barre-jeu .bouton-icone {
    width: 40px;
    height: 40px;
  }
  .chevalet {
    min-height: 96px;
    padding: 10px 6px 6px;
    gap: 5px;
  }
  .consigne {
    padding: 8px 12px;
  }
  .statut {
    padding-top: 6px;
  }
}
/* Écrans bas (petit téléphone en portrait) : tout se resserre pour que la consigne et les boutons restent visibles
   sous le plateau ; la barre de statut (pions rentrés) disparaît, les étiquettes du plateau suffisent. */
@media (max-height: 700px) and (max-width: 899px) {
  .ecran-jeu .statut {
    display: none;
  }
  .ecran-jeu .barre-jeu {
    padding: 4px 8px;
  }
  .ecran-jeu .barre-jeu .bouton-icone {
    width: 40px;
    height: 40px;
  }
  .chevalet {
    min-height: 84px;
    padding: 8px 6px 5px;
  }
  .carte-jeu {
    max-width: 52px;
  }
  .consigne {
    padding: 6px 12px;
    min-height: 0;
    font-size: calc(14px * var(--texte));
  }
  .panneau-bas {
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
}

/* Grand écran (≥ 900 px), comme l'appli Scrabble : le plateau à gauche, aussi grand que la hauteur le permet, et
   à droite une colonne avec la barre du haut, la main, la consigne, les boutons et le statut. */
@media (min-width: 900px) {
  .appli.en-jeu {
    max-width: none;
  }
  .ecran-jeu {
    --cote: clamp(340px, 30vw, 460px);
    --ecart: 24px;
    --marge: 16px;
    --jeu: min(calc(100dvh - 2 * var(--marge) - env(safe-area-inset-top)), calc(100vw - var(--cote) - var(--ecart) - 2 * var(--marge)));
    display: grid;
    grid-template-columns: var(--jeu) var(--cote);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: var(--ecart);
    justify-content: center;
    flex: none;
    margin-block: auto;
    height: calc(var(--jeu) + 2 * var(--marge));
    min-height: 0;
    padding: var(--marge);
  }
  .ecran-jeu > .zone-plateau {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    width: var(--jeu);
  }
  .ecran-jeu > .barre-jeu {
    grid-column: 2;
    grid-row: 1;
    padding: 0 0 12px;
  }
  .ecran-jeu > .colonne-jeu {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
  }
  .ecran-jeu .chevalet {
    flex: none;
    border-radius: 10px;
    border-bottom: 0;
    padding: 18px 12px 12px;
  }
  .ecran-jeu .consigne {
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--rayon);
  }
  .panneau-bas > .actions {
    padding: 0;
  }
  .ecran-jeu .panneau-bas {
    padding-top: 0;
    gap: 12px;
  }
  .ecran-jeu .statut {
    padding: 10px 12px;
    border: 1.5px solid var(--bord);
    border-radius: var(--rayon);
    background: var(--surface);
  }
  .voile {
    align-items: center;
  }
  .feuille {
    max-width: 480px;
    border: 2px solid var(--bord);
    border-radius: 14px;
    padding-bottom: 18px;
  }
}

/* Conseils de l'IA */
.ligne.conseil {
  cursor: default;
  align-items: flex-start;
}
.bouton-conseil {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.raisons {
  margin: 4px 0 0;
  padding-left: 1.1em;
  font-size: calc(13px * var(--texte));
  line-height: 1.4;
}

/* Choix du coup : boutons plus serrés que les boutons de menu */
.choix-coup .bouton {
  min-height: 44px;
  padding: 0 12px;
}
.choix-coup .bouton.choix-sept {
  flex: 1 0 52px;
  padding: 0 6px;
  font-size: calc(16px * min(var(--texte), 1.15));
}

/* ─── Analyse de fin de partie ──────────────────────────────────────────── */
.visionneuse {
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-margin-top: 8px;
}
.nav-tours {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-tours .principal {
  flex: 1;
  min-width: 0;
}
.nav-tours .bouton-icone:disabled {
  opacity: 0.35;
}
.nav-tours .suivant svg {
  transform: scaleX(-1);
}
.curseur-tours {
  width: 100%;
  accent-color: var(--accent);
}
.visionneuse .zone-plateau {
  border-radius: 6px;
  overflow: hidden;
}
.main-analyse {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cartes-analyse {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: 10px;
  background: var(--rack);
}
.cartes-analyse .carte-jeu.choisie {
  translate: 0 -4px;
}
.meilleur-coup {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--rayon);
  border: 2px solid var(--ok);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.meilleur-coup.choisi {
  box-shadow: inset 0 0 0 2px var(--ok);
}
.meilleur-coup .principal {
  flex: 1;
  min-width: 0;
}
.meilleur-coup .etiquette {
  font-size: calc(12px * var(--texte));
  font-weight: 700;
  color: var(--ok);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.apercu.ok {
  color: var(--ok);
  font-weight: 700;
}
.barre-eval {
  position: relative;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid var(--bord);
  background: #2b2f36;
  overflow: hidden;
}
.barre-eval .part-nous {
  height: 100%;
  background: linear-gradient(90deg, #1f62c0, #4d8fe8);
  transition: width 0.4s;
}
.barre-eval .texte-eval {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.ligne-eval {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 4px;
}
.courbe {
  display: block;
  width: 100%;
  height: auto;
}
.courbe .fond-courbe {
  fill: var(--surface);
  stroke: var(--line);
}
.courbe .mi-courbe {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
  stroke-width: 0.8;
}
.courbe .legende-courbe {
  fill: var(--muted);
  font-size: 8px;
}
.courbe .ligne-courbe {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.courbe .curseur-courbe {
  stroke: var(--dernier);
  stroke-width: 1.5;
}
.courbe .point-courbe {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 0.8;
}
.courbe .zone-courbe {
  fill: transparent;
  cursor: pointer;
}
.point-courbe.qualif-ok {
  fill: var(--ok);
}
.point-courbe.qualif-moyen {
  fill: var(--dernier);
}
.point-courbe.qualif-mauvais {
  fill: var(--err);
}
.badge.qualif-ok,
.stat.qualif-ok .valeur {
  color: var(--ok);
}
.badge.qualif-ok {
  background: var(--surface-2);
}
.badge.qualif-bon {
  background: var(--surface-2);
  color: var(--lien);
}
.badge.qualif-moyen {
  background: var(--dernier);
  color: #2b1a00;
}
.badge.qualif-mauvais {
  background: var(--err);
  color: #fff;
}
.stat.qualif-moyen .valeur {
  color: #b87500;
}
:root[data-theme='dark'] .stat.qualif-moyen .valeur {
  color: var(--dernier);
}
.stat.qualif-mauvais .valeur {
  color: var(--err);
}
.bilan-analyse {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bilan-analyse .stats {
  flex-wrap: wrap;
}
.bilan-analyse .stat {
  min-width: 70px;
}
.ligne-avec-action {
  display: flex;
  gap: 6px;
}
.ligne-avec-action > .ligne {
  flex: 1;
  min-width: 0;
}
.ligne-avec-action > .bouton {
  height: auto;
  flex: none;
}
.bilan-analyse .stat .etiquette {
  white-space: normal;
}

/* Plateau triangulaire (jeu à 3) : liseré bleu nuit et tapis aux coins arrondis. */
.plateau-toc .cadre-triangle {
  fill: var(--cadre);
  stroke: var(--cadre);
  stroke-width: 21;
  stroke-linejoin: round;
}
.plateau-toc .tapis-triangle {
  fill: var(--tapis);
  stroke: var(--tapis);
  stroke-width: 14;
  stroke-linejoin: round;
}
.plateau-toc .carte-plateau.joker text {
  fill: #6b4bb5;
}
.plateau-toc .rang-carte.joker {
  font-size: 4.2px;
  text-anchor: middle;
  letter-spacing: 0.04em;
}
.plateau-toc .copie-joker {
  font-size: 4px;
  font-weight: 700;
  text-anchor: middle;
  font-family: system-ui, sans-serif !important;
}
.carte-jeu.joker {
  color: #6b4bb5;
}
.carte-jeu .titre-joker {
  position: absolute;
  top: 7%;
  left: 0;
  right: 0;
  text-align: center;
  font: 800 max(9px, 17cqw) / 1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.04em;
}
:root[data-theme='dark'] .carte-jeu.joker {
  color: #5a3da3;
}

/* Message bref de l'écran de jeu (carte reçue, commentaire, erreur), dans la consigne : il ne couvre rien. */
.avis-jeu {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--chip-text);
  font-size: calc(13px * var(--texte));
  font-weight: 700;
  animation: fondu 0.2s ease-out;
}
.avis-jeu.erreur {
  background: var(--err);
  color: #fff;
}
/* Joker : cartes posées pendant la donne, et choix de la carte copiée. */
.cartes-posees {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.cartes-posees .carte-jeu.petite {
  width: 32px;
}
.carte-jeu.petite .coin {
  font-size: 10px;
}
.carte-jeu.petite .coin b {
  font-size: 12px;
}
.choix-coup .bouton.choix-comme {
  flex: 1 0 96px;
}
.carte-jeu .marque-carte {
  font-size: 9px;
  line-height: 1.25;
  padding: 1px 2px;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Avancement des 3 joueurs (jeu à 3) */
.avancement-3 {
  gap: 2px;
}
.ligne-avancement {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40%;
  align-items: center;
  gap: 8px;
}
.puce-pion.grande {
  width: 28px;
  height: 28px;
  font-size: 14px;
}
/* Salle d'attente à 3 : deux places en haut, une en bas, autour d'un tapis en triangle. */
.table-attente.table-3 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    'hg hd'
    'tapis tapis'
    'bas bas';
}
.table-3 .place-haut-gauche {
  grid-area: hg;
}
.table-3 .place-haut-droite {
  grid-area: hd;
}
.table-3 .place-bas {
  grid-area: bas;
  justify-content: center;
}
.table-3 .place-bas .siege {
  flex: 0 1 50%;
}
.tapis-triangle-attente {
  min-height: 110px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border: 0;
  padding-top: 34px;
  background: var(--tapis);
  box-shadow: inset 0 0 0 3px var(--cadre);
}
.ordre-jeu {
  margin: 10px 0 0;
  text-align: center;
}
.barre-eval .repere-neutre {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  opacity: 0.8;
}
.sous-reglage {
  margin-left: 14px;
  padding-left: 12px;
  border-left: 3px solid var(--line);
}
.sous-reglage > .reglage {
  border-top: 0;
}
.ligne-conseils {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--rayon);
  border: 1px dashed var(--line);
  font-size: calc(13px * var(--texte));
  color: var(--muted);
}
.ligne-conseils > span {
  flex: 1;
}
.ligne-conseils .reglage {
  flex: 1;
  border-top: 0;
  padding: 0;
}
.ligne-conseils .reglage .titre {
  font-size: calc(14px * var(--texte));
}
/* Choix du niveau des IA */
.choix-niveau .reglage {
  border-top: 1px solid var(--line);
}
.choix-niveau .liste-niveaux {
  margin-bottom: 10px;
}
.liste-niveaux .ligne {
  background: var(--surface-2);
}
.liste-niveaux .ligne.choisie {
  background: var(--chip);
}
