/* Compagnon de jeu, pensé d'abord pour le téléphone : une colonne, une barre d'onglets en bas, des cibles de 44 px au moins.
   Un seul thème, choisi : tapis de jeu vert, feuille claire, jaune pour ce qui est actif. */
:root {
  color-scheme: dark;
  --tapis: #1f3a30;
  --tapis-fonce: #183027;
  --tapis-clair: #2a4a3e;
  --trait: #3d5b4e;
  --trait-fort: #6f8f80;
  --texte: #f4f1e8;
  --texte-doux: #a9c2b5;
  --jaune: #f3c64f;
  --feuille: #f4f1e8;
  --feuille-trait: #d9d5c7;
  --encre: #1a2a23;
  --encre-doux: #55655c;
  --heros: #7fd0bd;
  --sdm: #f08a6c;
  --sdm-fonce: #b3402a;
  --police: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --barre-h: 64px;
  --bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--tapis); color: var(--texte); font: 16px/1.4 var(--police); overscroll-behavior-y: contain; }
h1, h2, h3, p { margin: 0; }
h1 { font-weight: 700; font-size: clamp(1.7rem, 7vw, 2.3rem); line-height: 1.04; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-weight: 700; font-size: 1.3rem; letter-spacing: -.01em; }
h3 { font-weight: 600; font-size: .85rem; color: var(--texte-doux); }
a { color: var(--jaune); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--jaune); outline-offset: 2px; }
.feuille :focus-visible { outline-color: var(--encre); }
.doux { color: var(--texte-doux); }
.petit { font-size: .88rem; }
.sur { font-size: .88rem; color: var(--texte-doux); }

/* ── Structure ── */
.vue {
  max-width: 720px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) calc(var(--barre-h) + var(--bas) + 28px) max(14px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 18px; min-height: 100dvh;
}
.barre {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--tapis-fonce); border-top: 1px solid var(--trait);
  padding: 0 max(6px, env(safe-area-inset-right, 0px)) var(--bas) max(6px, env(safe-area-inset-left, 0px));
}
.barre a {
  height: var(--barre-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--texte-doux); text-decoration: none; font-size: .76rem; font-weight: 600;
}
.barre svg { width: 26px; height: 26px; }
.barre a.actif { color: var(--jaune); }
.barre a.actif span { color: var(--texte); }
@media (min-width: 760px) { .barre { left: 50%; right: auto; transform: translateX(-50%); width: 720px; border: 1px solid var(--trait); border-bottom: 0; border-radius: 16px 16px 0 0; } }

.entete { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.entete h1 { font-size: 1.5rem; }

/* Bande d'étapes, à faire défiler du doigt */
.bande { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 2px 14px; scroll-snap-type: x proximity; }
.bande::-webkit-scrollbar { display: none; }
.bande a { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1.5px solid var(--trait); color: var(--texte); text-decoration: none; font-weight: 600; font-size: .93rem; white-space: nowrap; scroll-snap-align: center; }
.bande .num { color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.bande .fait { color: var(--texte-doux); }
.bande .fait .num { color: var(--jaune); }
.bande .actif { background: var(--jaune); border-color: var(--jaune); color: var(--tapis-fonce); }
.bande .actif .num { color: var(--tapis-fonce); }

/* ── Feuille : la chose à faire maintenant ── */
.feuille { background: var(--feuille); color: var(--encre); border-radius: 10px; padding: 20px 18px; display: flex; flex-direction: column; gap: 18px; }
.feuille .doux, .feuille h3, .feuille .sur { color: var(--encre-doux); }
.feuille a { color: var(--encre); }
.pied { display: flex; flex-direction: column; gap: 10px; }
.bloc { display: flex; flex-direction: column; gap: 12px; }
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }
.texte { font-size: 1.08rem; line-height: 1.45; }
.puces { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 6px; }
hr { border: 0; border-top: 1px solid var(--trait); margin: 0; width: 100%; }

/* ── Boutons ── */
.bouton { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 26px; border: 2px solid transparent; background: var(--tapis); color: var(--texte); font-weight: 700; font-size: 1.02rem; text-decoration: none; text-align: center; }
.feuille a.bouton { color: var(--texte); }
.bouton:active { transform: scale(.98); }
.bouton.contour, .feuille a.bouton.contour { background: none; border-color: currentColor; color: inherit; font-weight: 600; }
.bouton.petit { min-height: 44px; padding: 0 16px; font-size: .92rem; }
.bouton.en-ligne { display: inline-flex; }
.bouton.heros.choisi { background: #2f7d6e; color: #fff; border-color: #2f7d6e; }
.bouton.sdm.choisi { background: var(--sdm-fonce); color: #fff; border-color: var(--sdm-fonce); }
.bouton.danger { color: var(--sdm); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rond { width: 48px; height: 48px; border-radius: 50%; border: 2px solid currentColor; background: none; font-size: 1.4rem; font-weight: 700; line-height: 1; display: grid; place-items: center; flex: none; }
.rond:disabled { opacity: .3; }

/* ── Champs ── */
.champ { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--texte-doux); min-width: 0; }
input[type=text], input[type=number], input[type=search], textarea, select { background: var(--tapis-fonce); border: 1px solid var(--trait); border-radius: 8px; padding: 0 12px; min-height: 48px; color: var(--texte); width: 100%; font-size: 1rem; }
textarea { min-height: 7rem; padding: 12px; resize: vertical; }
input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--tapis); flex: none; margin: 0; }

/* ── Listes à cocher ── */
.coches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.coches label { display: flex; gap: 14px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--feuille-trait); font-size: 1.05rem; line-height: 1.35; }
.coches li:last-child label { border-bottom: 0; }
.coches input:checked + span { color: var(--encre-doux); text-decoration: line-through; text-decoration-thickness: 1px; }
.coches .note { display: block; font-size: .85rem; color: var(--encre-doux); text-decoration: none; }
.pastille { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 10px; background: var(--tapis); color: var(--jaune); white-space: nowrap; }

/* ── Tour de jeu ── */
.tour { position: sticky; top: 0; z-index: 10; background: var(--tapis); margin: -14px -14px 0; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--trait); }
.round { display: flex; flex-direction: column; align-items: center; line-height: 1; flex: none; }
.round span { font-size: .72rem; color: var(--texte-doux); font-weight: 600; }
.round b { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.joueurs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; margin-right: -14px; padding-right: 14px; }
.joueurs::-webkit-scrollbar { display: none; }
.joueur { flex: none; min-height: 46px; padding: 0 16px; border-radius: 23px; border: 2px solid var(--trait-fort); background: none; color: var(--texte); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.joueur.joue { border-color: var(--trait); color: var(--texte-doux); text-decoration: line-through; }
.joueur.actif { background: var(--jaune); border-color: var(--jaune); color: var(--tapis-fonce); font-weight: 700; text-decoration: none; }
.joueur.sdm { border-color: var(--sdm); }
.joueur.sdm.actif { background: var(--sdm); border-color: var(--sdm); color: #2a0f08; }
.joueur.ko::after { content: "à terre"; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: var(--sdm-fonce); color: #fff; }

.jauges { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.jauge { display: flex; flex-direction: column; gap: 6px; }
.jauge .ligne { flex-wrap: nowrap; justify-content: space-between; }
.jauge .valeur { font-size: 1.8rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.jauge .valeur small { font-size: .95rem; font-weight: 500; color: var(--encre-doux); }
.conditions { display: flex; gap: 6px; flex-wrap: wrap; }
.condition { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1.5px solid #bdb8a6; background: none; color: var(--encre-doux); font-weight: 600; font-size: .92rem; }
.condition.active { background: var(--sdm-fonce); border-color: var(--sdm-fonce); color: #fff; }
.deux-actions { display: flex; align-items: center; gap: 12px; }
.deux-actions h2 { flex: 1; }
.action-pion { width: 56px; height: 56px; border-radius: 50%; border: 2.5px solid var(--encre); background: none; font-weight: 700; font-size: 1.15rem; color: var(--encre); flex: none; }
.action-pion.faite { background: var(--encre); color: var(--feuille); }
.actions { display: flex; flex-direction: column; gap: 14px; }
.actions div { display: flex; flex-direction: column; gap: 2px; }
.actions span { color: var(--encre-doux); font-size: .95rem; line-height: 1.35; }
.actions .bouton { align-self: flex-start; margin-top: 6px; }
details.repli { border-top: 1px solid var(--feuille-trait); border-bottom: 1px solid var(--feuille-trait); }
details.repli summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; font-weight: 700; cursor: pointer; list-style: none; }
details.repli summary::-webkit-details-marker { display: none; }
details.repli summary::after { content: "+"; font-size: 1.4rem; font-weight: 500; }
details.repli[open] summary::after { content: "−"; }
details.repli .actions { padding-bottom: 16px; }
.encart { background: #e9e4d3; border-radius: 8px; padding: 14px 16px; font-size: 1.02rem; }
.encart.alerte { background: var(--sdm-fonce); color: #fff; }
.alerte-tapis { background: var(--sdm); color: #2a0f08; border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }
.alerte-tapis .bouton { background: #2a0f08; color: #fff; }

/* ── Pions ── */
.compteur { display: flex; flex-direction: column; gap: 8px; }
.compteur .tete { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; color: var(--texte-doux); }
.compteur .tete b { color: var(--texte); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 1.05rem; }
.pions { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 5px; max-width: 420px; }
.pion { height: 48px; border-radius: 16px; border: 2px solid var(--trait); background: none; padding: 0; }
.pion.plein { background: var(--jaune); border-color: var(--jaune); }
.pion.seuil { border-color: var(--jaune); }
.compteur.atteint .pion.plein { background: var(--sdm); border-color: var(--sdm); }
.compteur .message { font-size: .9rem; color: var(--sdm); font-weight: 600; }
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: var(--texte-doux); line-height: 1.35; }

/* ── Campagne et groupe ── */
.score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score div { display: flex; flex-direction: column; gap: 2px; }
.score b { font-size: 2.2rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.score .h b { color: var(--heros); } .score .s b { color: var(--sdm); } .score .o b { color: var(--jaune); }
.fiche { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px 0; border-top: 1px solid var(--trait); }
.fiche .large { grid-column: 1 / -1; }
.xp { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.xp b { font-size: 1.9rem; font-weight: 700; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; color: var(--texte); }
.or-boutons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

/* ── Règles ── */
.chapitres { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.chapitres a { display: grid; grid-template-columns: 2rem 1fr auto; gap: 10px; align-items: center; min-height: 60px; padding: 8px 0; border-top: 1px solid var(--trait); color: var(--texte); text-decoration: none; }
.chapitres .num { color: var(--texte-doux); font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }
.chapitres .vu .num { color: var(--jaune); }
.chapitres b { display: block; font-weight: 600; line-height: 1.2; }
.chapitres small { color: var(--texte-doux); font-size: .85rem; line-height: 1.25; display: block; }
.chapitres svg { color: var(--trait-fort); }
.points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; font-size: 1.1rem; line-height: 1.4; }
.points li { padding-left: 20px; position: relative; }
.points li::before { content: ""; position: absolute; left: 0; top: .55em; width: 8px; height: 8px; border-radius: 50%; background: var(--encre); }
.verif { font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #f0d9a0; color: #5a4208; white-space: nowrap; }

@media (min-width: 560px) {
  .feuille { padding: 28px; }
  .pied { flex-direction: row; justify-content: space-between; align-items: center; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
  .fiche { grid-template-columns: 1.4fr 1.2fr .7fr .7fr; }
  .fiche .large { grid-column: auto; }
  .fiche .xp-case { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) { .pion, .joueur, .action-pion, .condition { transition: background-color .12s, border-color .12s; } }
