/* Enfilade — le problème d'un seul tour
   Copyright (c) 2026 Tristan Cazenave. Tous droits réservés — voir LICENSE.

   Tout est dimensionné par le pouce : la carte fait 360 px de large et n'est
   jamais réduite en dessous ; le reste s'arrange autour. */

:root {
  --fond: #1b1f1a; --surface: #242a22; --ligne: #3a4335;
  --texte: #e7ece2; --texte-doux: #9fae95;
  --accent: #cfe0a8; --accent-sombre: #8fa87a; --danger: #d8452f;
  /* Quatre terrains, quatre valeurs franchement distinctes : sur un écran de
     téléphone en plein jour, deux verts voisins sont le même vert. */
  --libre: #4d5a43; --couvert: #2a3826; --bloc: #12140f; --hauteur: #7d8a5c;
  --nous: #cfe0a8; --eux: #d8452f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }

.ecran { display: flex; flex-direction: column; min-height: 100%; }

#barre {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--ligne);
}
.pousse { flex: 1; }
#phase { font-weight: 650; font-size: 14px; }

.btn {
  appearance: none; background: var(--surface); border: 1px solid var(--ligne);
  color: var(--texte); border-radius: 10px; padding: 10px 14px; cursor: pointer;
  min-height: 44px;                    /* la cible tactile, jamais moins */
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-primaire { background: var(--accent); border-color: var(--accent-sombre);
  color: #1b1f1a; font-weight: 650; }
.btn-mini { padding: 6px 10px; min-height: 36px; font-size: 13px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }

.seg { display: inline-flex; border: 1px solid var(--ligne); border-radius: 999px;
  overflow: hidden; }
.seg button { appearance: none; background: transparent; border: 0;
  color: var(--texte-doux); font-size: 12px; letter-spacing: .08em;
  padding: 6px 10px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #1b1f1a; }

#zone-carte { padding: 8px; display: flex; justify-content: center; }
#carte { width: 100%; max-width: 420px; height: auto; touch-action: manipulation; }

/* ── la carte
   Les cases sous le feu sont peintes, et c'est la seule chose que l'œil doit
   attraper : un rouge franc, par-dessus le terrain. */
.case { stroke: #0f120e; stroke-width: 1.2; }
.case.libre { fill: var(--libre); }
.case.couvert { fill: var(--couvert); }
.case.bloc { fill: var(--bloc); }
.case.hauteur { fill: var(--hauteur); }
.case.atteignable { stroke: var(--accent); stroke-width: 2.2; }
.case.feu { fill: color-mix(in srgb, var(--danger) 46%, var(--libre)); }
.case.feu.couvert { fill: color-mix(in srgb, var(--danger) 40%, var(--couvert)); }
.case.feu.hauteur { fill: color-mix(in srgb, var(--danger) 40%, var(--hauteur)); }
.case.dernier { stroke: #fff; stroke-width: 2; }
.liseré-objectif { fill: none; stroke: var(--accent); stroke-width: 3;
  stroke-dasharray: 6 4; pointer-events: none; }

.unite circle { stroke: #0f120e; stroke-width: 2; }
.unite.nous circle { fill: var(--nous); }
.unite.eux circle { fill: var(--eux); }
.unite text { font-size: 16px; font-weight: 700; fill: #1b1f1a; pointer-events: none; }
.unite.eux text { fill: #fff; }
.unite.choisie circle { stroke: #fff; stroke-width: 3.5; }
.unite.cible circle { stroke: var(--accent); stroke-width: 3.5; }
.unite .barre { stroke: #0f120e; stroke-width: 3; }
.unite.muette circle { opacity: .55; }

.dit { margin: 0; padding: 4px 14px 0; color: var(--texte-doux); font-size: 14px;
  min-height: 2.6em; }
.dit b { color: var(--texte); }
.dit.perdu { color: var(--danger); }
.dit.gagne { color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
.actions:empty { padding: 0; }

#pied { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ligne); flex-wrap: wrap; }

.modale { position: fixed; inset: 0; background: #0b0e0acc; display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 20; }
/* `display:flex` écrase la règle du navigateur pour [hidden] : sans cette
   ligne, la modale reste ouverte pour toujours. */
.modale[hidden] { display: none; }
.modale-boite { background: var(--surface); border-radius: 14px; max-width: 34rem;
  width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.modale-tete { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--ligne); }
.modale-tete h2 { margin: 0; font-size: 18px; flex: 1; }
.modale-corps { padding: 14px 16px; overflow: auto; }
.modale-corps h3 { font-size: 14px; color: var(--accent); margin: 14px 0 6px; }
.modale-corps p, .modale-corps li { color: #cfd8c6; font-size: 14px; }
.modale-corps ol { padding-left: 1.2em; }
/* Les fiches des unites : ce que chacune est *pour*, puis ses chiffres. */
.modale-corps ul.unites { list-style: none; margin: 8px 0 0; padding: 0; }
.modale-corps ul.unites li { margin: 0 0 12px; font-size: 14px; color: #cfd8c6; }
.modale-corps ul.unites b { color: var(--accent); }
.modale-corps .chiffres { color: var(--texte-doux); font-size: 12.5px;
  font-variant-numeric: tabular-nums; }
.modale-pied { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--ligne); }

.fiche { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px;
  color: var(--texte-doux); padding: 0 14px; }
.fiche b { color: var(--texte); font-weight: 650; }

@media (max-width: 400px) {
  #zone-carte { padding: 4px; }
  .btn { padding: 9px 11px; }
}
