/* Page de jeux par correspondance. Couleurs en jetons : clair par défaut,
   sombre selon le système, ou forcé par data-theme sur <html>. */
:root {
  --fond: #f4f1ea;
  --surface: #ffffff;
  --texte: #1f1d1a;
  --texte-doux: #6b655c;
  --bordure: #d8d1c4;
  --accent: #2f6fb2;
  --case-claire: #e9dcc0;
  --case-sombre: #b58b5d;
  --coord: #7a6a55;
  --pion-blanc: #fbfaf6;
  --pion-blanc-bord: #8f8778;
  --pion-noir: #2a2724;
  --pion-noir-bord: #000000;
  --dernier: rgba(240, 196, 25, 0.55);
  --choisi: rgba(47, 111, 178, 0.55);
  --cible: rgba(30, 90, 160, 0.55);
  --prise: rgba(190, 40, 40, 0.7);
  --victoire: #2d7a3e;
  --defaite: #a33a2c;
  --erreur-fond: #fbe9e6;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #171614;
    --surface: #22201d;
    --texte: #ece7de;
    --texte-doux: #a39c90;
    --bordure: #3b3732;
    --accent: #7fb0e6;
    --case-claire: #9c8a6c;
    --case-sombre: #5e4a33;
    --coord: #c9b99c;
    --pion-blanc: #f1ede4;
    --pion-blanc-bord: #6d665a;
    --pion-noir: #141210;
    --pion-noir-bord: #6a625a;
    --dernier: rgba(230, 185, 30, 0.5);
    --choisi: rgba(110, 160, 220, 0.6);
    --cible: rgba(140, 190, 245, 0.65);
    --prise: rgba(235, 90, 80, 0.8);
    --victoire: #6cc283;
    --defaite: #ef8a7a;
    --erreur-fond: #3d2320;
    --ombre: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --fond: #171614;
  --surface: #22201d;
  --texte: #ece7de;
  --texte-doux: #a39c90;
  --bordure: #3b3732;
  --accent: #7fb0e6;
  --case-claire: #9c8a6c;
  --case-sombre: #5e4a33;
  --coord: #c9b99c;
  --pion-blanc: #f1ede4;
  --pion-blanc-bord: #6d665a;
  --pion-noir: #141210;
  --pion-noir-bord: #6a625a;
  --dernier: rgba(230, 185, 30, 0.5);
  --choisi: rgba(110, 160, 220, 0.6);
  --cible: rgba(140, 190, 245, 0.65);
  --prise: rgba(235, 90, 80, 0.8);
  --victoire: #6cc283;
  --defaite: #ef8a7a;
  --erreur-fond: #3d2320;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding: 0 16px 24px;
  overflow-x: hidden;
}

.entete {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
}
.entete h1 { font-size: 1.3rem; margin: 0; overflow-wrap: anywhere; }
.bouton-discret {
  font: inherit; font-size: 0.85rem;
  color: var(--texte-doux);
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.mise-en-page {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 760px) {
  .mise-en-page { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

/* --- joueurs --- */
.joueur {
  display: flex; align-items: center; gap: 8px;
  min-height: 2rem; padding: 4px 2px;
}
.joueur-nom { font-weight: 600; overflow-wrap: anywhere; }
.joueur-statut { color: var(--texte-doux); font-size: 0.9rem; overflow-wrap: anywhere; }
.joueur.au-trait .joueur-nom::after { content: " ●"; color: var(--accent); }
.jeton {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  flex-shrink: 0; border: 2px solid transparent;
}
.jeton.B { background: var(--pion-blanc); border-color: var(--pion-blanc-bord); }
.jeton.N { background: var(--pion-noir); border-color: var(--pion-noir-bord); }

/* --- plateau générique : grille de cases + coordonnées --- */
.plateau {
  --n-col: 8; --n-lig: 8;
  display: grid;
  grid-template-columns: 1.2rem repeat(var(--n-col), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n-lig), minmax(0, 1fr)) 1.2rem;
  width: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.coord {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; color: var(--coord);
}
.case {
  position: relative;
  border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit;
  background: var(--case-claire);
  display: flex; align-items: center; justify-content: center;
  cursor: default;
  min-width: 0; min-height: 0;
}
.case.sombre { background: var(--case-sombre); }
.case:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.case.jouable { cursor: pointer; }
.case.dernier::before, .case.choisie::before {
  content: ""; position: absolute; inset: 0;
}
.case.dernier::before { background: var(--dernier); }
.case.choisie::before { background: var(--choisi); }
.case.cible { cursor: pointer; }
.case.cible::after {
  content: ""; position: absolute;
  width: 30%; height: 30%; border-radius: 50%;
  background: var(--cible);
}
.case.cible.prise::after {
  width: 86%; height: 86%;
  background: transparent;
  border: 4px solid var(--prise);
}
.plateau.attente .case { cursor: progress; }

/* pièces : chaque jeu ajoute ses classes (voir js/jeux/) */
.piece { position: relative; z-index: 1; pointer-events: none; }
.pion {
  width: 72%; height: 72%; border-radius: 50%;
  box-shadow: var(--ombre);
}
.pion.B {
  background: radial-gradient(circle at 35% 30%, #ffffff, var(--pion-blanc) 55%);
  border: 2px solid var(--pion-blanc-bord);
}
.pion.N {
  background: radial-gradient(circle at 35% 30%, #5a544d, var(--pion-noir) 60%);
  border: 2px solid var(--pion-noir-bord);
}

/* --- panneau --- */
.panneau {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}
.tour { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; overflow-wrap: anywhere; }
.tour.victoire { color: var(--victoire); }
.tour.defaite { color: var(--defaite); }
.message {
  margin: 0 0 10px; padding: 8px 10px;
  border-radius: 6px; background: var(--erreur-fond);
  overflow-wrap: anywhere;
}
.historique h2, .regles summary { font-size: 1rem; margin: 12px 0 6px; }
.coups {
  margin: 0; padding: 0 0 0 3.2em;
  max-height: 22rem; overflow-y: auto;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "DejaVu Sans Mono", monospace;
  font-size: 0.95rem;
}
.coups li { padding: 1px 0; }
.coups .demi { display: inline-block; min-width: 4.5em; padding: 0 4px; border-radius: 4px; }
.coups .demi.dernier { background: var(--dernier); }
.discret { color: var(--texte-doux); font-size: 0.85rem; margin: 6px 0 0; }
.regles { margin-top: 10px; }
.regles summary { cursor: pointer; }
.regles p { margin: 6px 0; font-size: 0.95rem; }

/* 24/11/2026 : proposition de partie */
.proposition { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.proposition button, #abandonner { font: inherit; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
#abandonner { margin-top: 12px; }
[hidden] { display: none !important; }

/* 24/11/2026 : glisser-déposer */
.case.jouable { touch-action: none; cursor: grab; }
.case.en-vol > .piece { opacity: 0.3; }
.piece.fantome { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -50%) scale(1.08);
  cursor: grabbing; box-shadow: 0 6px 14px rgba(0,0,0,0.35); }
