/* La Veillée · feuille unique.
   ──────────────────────────────────────────────────────────────────────────
   Une soirée tranquille : du papier crème, de l'encre noire chaude, et une
   seule couleur forte, le bleu canard de la lampe. Les couleurs vives qui
   restent (vert, rouge, une teinte par joueur) servent à LIRE : une bonne
   réponse, une aiguille, une catégorie. Jamais de décor.

   Règles de la maison tenues ici, chacune payée ailleurs dans le dépôt :
   · aucun champ sous 16 px (au-dessous, iOS zoome au premier tap) ;
   · cibles tactiles de 44 px au moins ;
   · la rangée d'actions ancrée en bas réserve la zone sûre des iPhone ;
   · un seul bloc sombre, accroché à [data-theme="dark"] (theme-init.js le
     pose toujours) ;
   · un élément masqué par `hidden` le reste, même quand une règle lui pose
     un `display` (piège [hidden] du dépôt) ;
   · aucun style en ligne : la CSP du site l'interdit, le dessin du cadran
     passe par des classes et des attributs SVG. */

:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6da;
  --card: #fffdf8;
  --ink: #1c1a17;
  --muted: #5c564d;
  --line: #d8d0c1;
  --accent: #0f6a7a;
  --on-accent: #ffffff;
  --accent-soft: rgba(15, 106, 122, 0.1);
  --ok: #2d6a3e;
  --ok-soft: rgba(45, 106, 62, 0.12);
  --ko: #a8402f;
  --ko-soft: rgba(168, 64, 47, 0.1);
  /* Une teinte par joueur (les aiguilles du cadran), puis les catégories de
     cartes du Fil du temps, qui les réemploient. */
  --j0: #0f6a7a;
  --j1: #b4552d;
  --j2: #6a4a9f;
  --j3: #2d6a3e;
  --j4: #9a7a1f;
  --j5: #8a3b5c;
  --shadow: 0 1px 0 rgba(28, 26, 23, 0.06), 0 10px 30px -18px rgba(28, 26, 23, 0.35);
  /* La nuit des gravures (le noir de fin-haut.webp et fin-bas.webp, FIN_NUIT
     de tools/soiree_images.py) et ses encres : l'écran de fin reste sombre
     dans les deux thèmes. */
  --nuit: #131313;
  --nuit-encre: #f3ecdc;
  --nuit-muted: #cfc6b3;
  --nuit-ligne: rgba(243, 236, 220, 0.2);
  --nuit-carte: rgba(243, 236, 220, 0.07);
  --nuit-accent: #4cc2d2;
  --nuit-on-accent: #06252b;
  --radius: 14px;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #14120f;
  --paper-2: #1d1a16;
  --card: #221f1a;
  --ink: #f1ede4;
  --muted: #b0a99d;
  --line: #3b362e;
  --accent: #4cc2d2;
  --on-accent: #06252b;
  --accent-soft: rgba(76, 194, 210, 0.12);
  --ok: #7fcf93;
  --ok-soft: rgba(127, 207, 147, 0.14);
  --ko: #f0907a;
  --ko-soft: rgba(240, 144, 122, 0.12);
  --j0: #4cc2d2;
  --j1: #f0a07a;
  --j2: #bda3f2;
  --j3: #7fcf93;
  --j4: #e6c15a;
  --j5: #e58aae;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 14px 34px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); letter-spacing: -0.015em; line-height: 1.12; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 16px; height: 16px; }

/* ── La barre ─────────────────────────────────────────────────────────── */
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.marque {
  display: inline-flex; align-items: center;
  min-height: 44px; min-width: 0; padding: 0 6px 0 0;
  background: none; border: 0; cursor: pointer;
}
/* Le logo de l'app, découpé par tools/app_logo.py : une image de fond, la
   variante claire ou sombre selon le thème. Le rapport d'aspect est celui du
   PNG (1217 × 256) : faux, le dessin flotterait dans une case trop large ou
   trop étroite. Le nom accessible est porté par role="img" dans la page. */
.marque-logo {
  display: block; height: 32px; aspect-ratio: 1217 / 256;
  background: url("brand/logo.png") left center / contain no-repeat;
}
:root[data-theme="dark"] .marque-logo { background-image: url("brand/logo-dark.png"); }
.barre-actions { display: flex; gap: 6px; }
.ico-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: none; border: 1px solid transparent; cursor: pointer; color: var(--ink);
}
.ico-btn:focus-visible, .btn:focus-visible, .marque:focus-visible, .retour:focus-visible,
.puce:focus-visible, .compteur-btn:focus-visible, .lien-btn:focus-visible, .joueur-suppr:focus-visible,
.jeu-carte:focus-visible, .tuile:focus-visible, .mode:focus-visible, .lien-ico:focus-visible, .reponse:focus-visible,
.emplacement-btn:focus-visible, .onglet:focus-visible, .segment:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ── La page ──────────────────────────────────────────────────────────── */
.page {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.ecran { display: flex; flex-direction: column; gap: 18px; padding-bottom: 8px; }
.ecran-tete { display: flex; flex-direction: column; gap: 8px; }
.ecran-titre { font-size: 30px; outline: none; }
.ecran-sous { color: var(--muted); }
.retour {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; margin-left: -8px; padding: 0 10px 0 4px;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
  color: var(--muted); font-weight: 600;
}
.surtitre, .progression {
  font: 600 12px/1.3 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
}

/* ── Boutons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px;
  border-radius: var(--radius); border: 1px solid transparent;
  font: 600 17px/1.2 var(--font-text); cursor: pointer; text-decoration: none; text-align: center;
  transition: transform 0.12s var(--ease), background-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-large { min-height: 56px; font-size: 18px; width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: none; color: var(--ink); border: 1px dashed var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.lien-btn {
  align-self: flex-start;
  min-height: 44px; padding: 0 2px;
  background: none; border: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.rangee { display: flex; gap: 10px; flex-wrap: wrap; }
.rangee .btn { flex: 1 1 140px; }

/* La rangée d'actions de chaque écran : collée en bas, au-dessus de la barre
   gestuelle des iPhone. */
.actions {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; gap: 10px;
  margin: 8px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, transparent);
}

/* ── Messages ─────────────────────────────────────────────────────────── */
.msg { padding: 12px 14px; border-radius: 12px; font-size: 16px; }
.msg.is-err { background: var(--ko-soft); color: var(--ink); border: 1px solid var(--ko); }
.msg.is-ok { background: var(--ok-soft); color: var(--ink); border: 1px solid var(--ok); }
.msg.is-info { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: 16px;
  box-shadow: var(--shadow);
}

/* ── Accueil ──────────────────────────────────────────────────────────── */
.hero { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.hero-titre { font-size: clamp(38px, 11vw, 56px); letter-spacing: -0.03em; }
.hero-texte { font-size: 18px; color: var(--muted); }
.atouts {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  font-weight: 600; font-size: 15px;
}
.atouts li { display: inline-flex; align-items: center; gap: 6px; }
.atouts .ico { color: var(--accent); }
.hero-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

.jeux { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
/* La carte d'un jeu : sa gravure en tête (img/jeux/<jeu>.webp, 3:2), le nom
   et la règle en une phrase écrits par la page. */
.jeu-carte {
  display: flex; flex-direction: column;
  width: 100%; padding: 0; overflow: hidden; text-align: left; cursor: pointer;
  border-radius: 18px; border: 1px solid var(--line); background: var(--card);
  transition: transform 0.12s var(--ease), border-color 0.15s;
}
.jeu-carte:active { transform: scale(0.99); }
.jeu-carte-image {
  display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 3 / 2;
  object-fit: cover; background: var(--nuit);
}
.jeu-carte-texte { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 14px 16px 16px; }
.jeu-carte-nom { font: 700 21px/1.15 var(--font-display); letter-spacing: -0.015em; }
.jeu-carte-sous { color: var(--muted); font-size: 15px; line-height: 1.35; }
.jeu-carte-meta { font: 600 11px/1.4 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }

.rejoindre-accueil {
  display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
  padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
}
.rejoindre-label { font-weight: 700; font-size: 16px; }
.rejoindre-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.rejoindre { display: flex; flex-direction: column; gap: 10px; }
.champ-code { font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.champ-code::placeholder { letter-spacing: 0.08em; }

.section-titre { font-size: 24px; }
.regles { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.regle {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
}
.regle h3 { font-size: 19px; }
.regle p { color: var(--muted); font-size: 16px; }
.regle p strong { color: var(--ink); }
.signature {
  display: flex; flex-direction: column; gap: 6px;
  margin: 12px 0 calc(24px + env(safe-area-inset-bottom)); padding-top: 16px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 15px;
}
.signature a { color: var(--ink); font-weight: 600; }

/* ── Joueurs et réglages ──────────────────────────────────────────────── */
.joueurs { display: flex; flex-direction: column; gap: 8px; }
.joueur { display: grid; grid-template-columns: 30px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.joueur-num { font: 600 14px/1 var(--font-mono); color: var(--muted); text-align: center; }
.champ {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font: 500 17px/1.3 var(--font-text);
}
.champ:disabled { opacity: 0.7; }
.champ::placeholder { color: var(--muted); opacity: 0.8; }
.champ:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.joueur-suppr {
  display: grid; place-items: center; width: 44px; height: 44px;
  background: none; border: 0; border-radius: 12px; cursor: pointer; color: var(--muted);
}
.btn-ajout { width: 100%; }

.bloc {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--line);
}
.bloc-titre { font-size: 19px; }
.bloc-aide { color: var(--muted); font-size: 15px; }
.en-jeu { font-size: 15px; color: var(--muted); }

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  min-height: 64px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer; color: var(--ink);
}
.mode[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 11px; }
.mode-nom { font-weight: 700; font-size: 16px; }
.mode-aide { color: var(--muted); font-size: 14px; line-height: 1.3; }

.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.segment {
  min-height: 48px; padding: 6px 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-weight: 700; font-size: 17px; color: var(--ink);
}
.segment small { font-weight: 500; font-size: 13px; color: var(--muted); }
.segment[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.segment[aria-pressed="true"] small { color: var(--paper); opacity: 0.8; }

.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font-weight: 600; font-size: 15px; color: var(--ink);
}
.puce[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.puce-nb { font-weight: 500; opacity: 0.7; margin-left: 4px; }

/* Les thèmes du quiz : une tuile par thème, sa gravure et son nom. */
.tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tuile {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  min-width: 0; padding: 6px 6px 8px; border-radius: 14px; text-align: center;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
}
.tuile-image {
  display: grid; place-items: center; width: 100%; max-width: 100%; height: auto; aspect-ratio: 1;
  margin-bottom: 4px; border-radius: 10px; object-fit: cover; background: var(--nuit); color: var(--nuit-encre);
}
.tuile-sans .ico { width: 34%; height: auto; aspect-ratio: 1; stroke-width: 1.4; }
.tuile-nom { font-weight: 700; font-size: 14px; line-height: 1.2; overflow-wrap: anywhere; }
.tuile-nb { font: 500 11px/1.4 var(--font-mono); color: var(--muted); }
.tuile-coche {
  position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; padding: 4px;
  border-radius: 50%; background: var(--accent); color: var(--on-accent); stroke-width: 2.4;
}
.tuile[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 5px 5px 7px; }
.tuiles.has-choix .tuile[aria-pressed="false"] { opacity: 0.5; }

/* ── Chacun son téléphone ─────────────────────────────────────────────── */
.liens { display: flex; flex-direction: column; gap: 8px; }
.lien {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center;
  min-height: 60px; padding: 8px 8px 8px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.lien.is-hote { background: var(--paper-2); }
.lien-texte { display: flex; flex-direction: column; min-width: 0; }
.lien-nom { font-weight: 700; overflow-wrap: anywhere; }
.lien-statut { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.lien-statut::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--line);
}
.lien-statut.is-ouvert::before { background: var(--accent); }
.lien-statut.is-vu::before { background: var(--ok); }
.lien-actions { display: flex; gap: 2px; }
.lien-ico {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: none; cursor: pointer; color: var(--ink);
}
.qr { display: block; width: min(64vw, 240px); aspect-ratio: 1; margin: 0 auto; border-radius: 12px; background: #fff; padding: 8px; }
.qr-code { text-align: center; font: 700 26px/1.2 var(--font-mono); letter-spacing: 0.12em; color: var(--ink); }
.qr-lien { text-align: center; font-size: 14px; overflow-wrap: anywhere; }

.bandeau {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding: 10px 14px; border-radius: 12px; font-size: 15px;
  background: var(--paper-2); border: 1px solid var(--line);
}
.bandeau .ico { color: var(--accent); }
.etat-lien { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 24px 0 8px; }
.etat-ico {
  width: 54px; height: 54px; color: var(--accent);
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.attente-carte {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 16px;
  border-radius: 22px; border: 1px dashed var(--line); color: var(--muted); text-align: center;
}
.attente-ico { width: 40px; height: 40px; }

/* ── Le relais : un seul téléphone qui passe de main en main ──────────── */
.relais {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 0 8px; text-align: center;
}
.relais-initiale {
  display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); border: 2px solid var(--accent);
  font: 700 44px/1 var(--font-display);
}
.relais-titre { font-size: clamp(28px, 8vw, 38px); outline: none; overflow-wrap: anywhere; }
.relais-aide { color: var(--muted); max-width: 36ch; }

/* ── Le jeu, commun aux trois ─────────────────────────────────────────── */
.jeu { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }
.jeu-titre { font-size: clamp(26px, 7.5vw, 34px); outline: none; overflow-wrap: anywhere; }
.question-texte { font: 700 clamp(22px, 6.2vw, 28px)/1.22 var(--font-display); letter-spacing: -0.012em; outline: none; }
.jeu-corps { display: flex; flex-direction: column; gap: 16px; }

.scores { display: flex; flex-wrap: wrap; gap: 8px; }
.score {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 12px;
  border-radius: 999px; background: var(--paper-2); border: 2px solid transparent;
  font-size: 15px;
}
.score-nom { font-weight: 700; overflow-wrap: anywhere; }
.score.is-moi { border-color: var(--ink); }
.score.is-actif { border-color: var(--accent); background: var(--accent-soft); }
.score-detail { display: inline-flex; align-items: center; gap: 4px; font: 600 14px/1 var(--font-mono); color: var(--muted); }
.score-detail .ico { color: var(--ok); }
.gain { font: 700 15px/1 var(--font-display); color: var(--ok); }
.gain.is-nul { color: var(--muted); font-weight: 500; }

.attente { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.attente.is-prete { color: var(--ok); }
.note {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 12px 14px; border-radius: var(--radius); background: var(--paper-2); font-size: 16px;
}
.note .ico { color: var(--accent); margin-top: 2px; }

/* ── Le Grand Quiz ────────────────────────────────────────────────────── */
.question-tete { display: flex; align-items: center; gap: 12px; min-width: 0; }
.question-tete .progression { min-width: 0; }
.question-theme { flex: none; width: 56px; height: 56px; border-radius: 12px; background: var(--nuit); }
.reponses { display: flex; flex-direction: column; gap: 10px; }
.reponse {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; min-height: 58px; padding: 10px 14px 10px 12px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card);
  color: var(--ink); cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.15s;
}
.reponse:active:not(:disabled) { transform: scale(0.99); }
.reponse:disabled { cursor: default; }
.lettre {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--paper-2); font: 700 15px/1 var(--font-mono); color: var(--muted);
}
.reponse-texte { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.choix-noms { display: block; font-weight: 500; font-size: 14px; color: var(--muted); margin-top: 2px; }
.reponse.is-choisi { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 13px 9px 11px; }
.reponse.is-choisi .lettre { background: var(--accent); color: var(--on-accent); }
.reponse.is-masque { opacity: 0.35; text-decoration: line-through; }
.reponse.is-revele { cursor: default; }
.reponse.is-bonne { border: 2px solid var(--ok); background: var(--ok-soft); padding: 9px 13px 9px 11px; }
.reponse.is-bonne .lettre { background: var(--ok); color: var(--card); }
.reponse.is-faux { border: 2px solid var(--ko); background: var(--ko-soft); padding: 9px 13px 9px 11px; }
.reponse.is-faux .lettre { background: var(--ko); color: var(--card); }
.reponse-ico { color: var(--ink); }
.is-bonne .reponse-ico { color: var(--ok); }
.is-faux .reponse-ico { color: var(--ko); }

/* ── Sur la même onde ─────────────────────────────────────────────────── */
.indice {
  display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center;
  padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--ink);
}
.indice-de { font: 600 12px/1.3 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.indice-texte { font: 700 clamp(24px, 7vw, 32px)/1.15 var(--font-display); overflow-wrap: anywhere; }

.cadran { display: flex; flex-direction: column; gap: 6px; }
.cadran-svg { display: block; width: 100%; height: auto; max-height: 280px; overflow: visible; }
.cadran-fond { fill: var(--paper-2); stroke: var(--line); stroke-width: 1; }
.cadran-graduation { stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; }
.moyeu { fill: var(--ink); }
.zone { stroke: none; fill: var(--accent); }
.zone.z2 { opacity: 0.16; }
.zone.z3 { opacity: 0.32; }
.zone.z4 { opacity: 0.6; }
.cible-trait { stroke: var(--ink); stroke-width: 1.6; stroke-dasharray: 3 2.4; stroke-linecap: round; }
.aiguille { stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.aiguille.a-moi { stroke: var(--accent); stroke-width: 3.2; }
.aiguille.a0 { stroke: var(--j0); }
.aiguille.a1 { stroke: var(--j1); }
.aiguille.a2 { stroke: var(--j2); }
.aiguille.a3 { stroke: var(--j3); }
.aiguille.a4 { stroke: var(--j4); }
.aiguille.a5 { stroke: var(--j5); }
.cadran-bouts { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 17px; }
.cadran-bout { min-width: 0; overflow-wrap: anywhere; max-width: 46%; }
.cadran-bout.is-droite { text-align: right; }

.curseur {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; margin: 0; padding: 0; background: transparent; cursor: pointer;
}
.curseur::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
.curseur::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.curseur::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 34px; height: 34px; margin-top: -14px;
  border-radius: 50%; background: var(--accent); border: 4px solid var(--card); box-shadow: var(--shadow);
}
.curseur::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  border: 4px solid var(--card); box-shadow: var(--shadow);
}
.curseur:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

.resultats { display: flex; flex-direction: column; gap: 6px; }
.resultat {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  min-height: 44px; padding: 6px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
}
.pastille { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.pastille.a0 { background: var(--j0); }
.pastille.a1 { background: var(--j1); }
.pastille.a2 { background: var(--j2); }
.pastille.a3 { background: var(--j3); }
.pastille.a4 { background: var(--j4); }
.pastille.a5 { background: var(--j5); }
.resultat-nom { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.resultat-info { color: var(--muted); font-size: 14px; }

/* ── Le Fil du temps ──────────────────────────────────────────────────── */
.cat-histoire { --cat: var(--j1); }
.cat-sciences { --cat: var(--j0); }
.cat-numerique { --cat: var(--j2); }
.cat-culture { --cat: var(--j5); }
.cat-sport { --cat: var(--j3); }
.cat-x { --cat: var(--muted); }

/* La pioche (le dos des cartes) et la carte qu'on vient d'en tirer. */
.tirage { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center; }
.pioche { position: relative; align-self: start; }
.pioche-dos {
  display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 2 / 3;
  border-radius: 8px; background: var(--nuit);
  box-shadow: 3px 3px 0 var(--paper), 4px 4px 0 var(--line), 7px 7px 0 var(--paper), 8px 8px 0 var(--line);
}
.pioche-nb {
  position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%);
  min-width: 30px; padding: 2px 7px; border-radius: 999px; text-align: center;
  background: var(--ink); color: var(--paper); font: 700 12px/1.4 var(--font-mono);
}
.carte-jeu.is-tiree { animation: veillee-tirer 0.5s var(--ease) both; transform-origin: left center; }
@keyframes veillee-tirer {
  from { opacity: 0; transform: perspective(700px) translateX(-36px) rotateY(-70deg); }
  to { opacity: 1; transform: none; }
}
.carte-jeu {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 16px 18px; border-radius: 18px; background: var(--card);
  border: 2px solid var(--ink); border-left: 8px solid var(--cat, var(--ink));
  box-shadow: var(--shadow);
}
.carte-jeu.is-juste { border-color: var(--ok); border-left-color: var(--ok); }
.carte-jeu.is-rate { border-color: var(--ko); border-left-color: var(--ko); }
.etiquette {
  align-self: flex-start; padding: 2px 9px; border-radius: 999px; background: var(--paper-2);
  font: 600 11px/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.carte-jeu-titre { font: 700 clamp(22px, 6.4vw, 28px)/1.15 var(--font-display); letter-spacing: -0.012em; overflow-wrap: anywhere; }
.carte-jeu-an { font: 700 clamp(26px, 8vw, 34px)/1 var(--font-mono); color: var(--ink); }
.carte-jeu.is-juste .carte-jeu-an { color: var(--ok); }
.carte-jeu.is-rate .carte-jeu-an { color: var(--ko); }

.onglets { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.onglet {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 600; font-size: 15px;
}
.onglet.is-actif { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.frise {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding-left: 22px; border-left: 3px solid var(--line); margin-left: 6px;
}
.carte-frise {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px; border-radius: 12px; background: var(--card);
  border: 1px solid var(--line); border-left: 6px solid var(--cat, var(--muted));
}
.carte-frise::before {
  content: ""; position: absolute; left: -33px; top: 50%; width: 14px; height: 14px;
  margin-top: -7px; border-radius: 50%; background: var(--cat, var(--muted)); border: 3px solid var(--paper);
}
.carte-an { font: 700 15px/1.3 var(--font-mono); color: var(--cat, var(--ink)); }
.carte-titre { font-weight: 600; overflow-wrap: anywhere; }
.carte-frise.is-neuve { border-color: var(--ok); border-left-color: var(--ok); background: var(--ok-soft); }
.carte-frise.is-neuve .carte-an { color: var(--ok); }
.carte-frise.is-fantome { border-style: dashed; border-color: var(--ko); border-left-color: var(--ko); background: var(--ko-soft); }
.carte-frise.is-fantome .carte-an { color: var(--ko); }

/* « En savoir plus » : l'introduction de l'article Wikipédia, sous la carte. */
.plus-btn {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  min-height: 44px; padding: 0 4px; background: none; border: 0; cursor: pointer;
  color: var(--accent); font: 600 15px/1.2 var(--font-text);
}
.plus-btn[aria-expanded="true"] { color: var(--ink); }
.plus-btn.is-ico { position: absolute; top: 0; right: 0; width: 44px; justify-content: center; padding: 0; color: var(--muted); }
.plus-btn.is-ico[aria-expanded="true"] { color: var(--accent); }
.plus-btn:focus-visible, .plus-source a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.carte-frise.a-plus { padding-right: 46px; }
.plus-panneau { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 6px; }
.plus-texte { font-size: 16px; line-height: 1.45; color: var(--ink); }
.plus-source { font-size: 13px; line-height: 1.4; color: var(--muted); }
.plus-source a { color: var(--accent); }

.emplacement { position: relative; }
.emplacement-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 6px 12px; border-radius: 12px;
  border: 2px dashed var(--accent); background: none; color: var(--accent);
  font-weight: 600; font-size: 15px; cursor: pointer; text-align: center;
}
.emplacement-btn.is-choisi { border-style: solid; background: var(--accent-soft); color: var(--ink); }
.emplacement-btn.is-choisi .ico { color: var(--accent); }

/* ── Fin de partie ────────────────────────────────────────────────────── */
/* La scène de fin : la lampe en haut (fin-haut.webp), les amis vus de dos en
   bas (fin-bas.webp), le noir de la gravure entre les deux. Les marges
   (en % de la largeur, comme les images) gardent le classement hors des
   silhouettes, quel que soit le nombre de joueurs. Ses jetons sont ceux de la
   nuit, dans les deux thèmes. */
.fin-scene {
  --card: var(--nuit-carte); --paper-2: var(--nuit-ligne); --line: var(--nuit-ligne);
  --ink: var(--nuit-encre); --muted: var(--nuit-muted);
  --accent: var(--nuit-accent); --accent-soft: rgba(76, 194, 210, 0.14); --on-accent: var(--nuit-on-accent);
  display: flex; flex-direction: column; gap: 14px;
  padding: 42% 18px 58%; border-radius: 20px; overflow: hidden;
  color: var(--ink);
  background:
    url("img/fin-haut.webp") center top / 100% auto no-repeat,
    url("img/fin-bas.webp") center bottom / 100% auto no-repeat,
    var(--nuit);
}
.podium { display: flex; flex-direction: column; gap: 8px; }
.podium-ligne {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  min-height: 56px; padding: 8px 14px 8px 10px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.podium-ligne.is-premier { border: 2px solid var(--accent); background: var(--accent-soft); padding: 7px 13px 7px 9px; }
.podium-rang { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper-2); font: 700 15px/1 var(--font-mono); }
.is-premier .podium-rang { background: var(--accent); color: var(--on-accent); }
.podium-nom { display: inline-flex; align-items: center; gap: 8px; font: 700 19px/1.2 var(--font-display); min-width: 0; }
.podium-qui { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.podium-detail { font: 500 13px/1.3 var(--font-text); color: var(--muted); }
.podium-nom .ico { color: var(--accent); }
.podium-pts { font: 600 14px/1.2 var(--font-mono); color: var(--muted); text-align: right; }
.fin-actions { margin-top: 4px; }
.soiree { display: flex; flex-direction: column; gap: 10px; }
.soiree-liste { display: flex; flex-direction: column; gap: 6px; }
.soiree-ligne {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  min-height: 44px; padding: 6px 12px; border-radius: 12px; background: var(--paper-2);
}
.soiree-nom { font-weight: 600; overflow-wrap: anywhere; }
.soiree-pts { font: 700 15px/1 var(--font-display); }
.soiree-tete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; }

/* ── Modale ───────────────────────────────────────────────────────────── */
.modale { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modale-fond { position: absolute; inset: 0; background: rgba(12, 10, 8, 0.55); }
.modale-carte {
  position: relative; width: min(100%, 440px); max-height: calc(100dvh - 32px); overflow: auto;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 20px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
}
.modale-titre { font-size: 22px; }
.modale-corps { color: var(--muted); display: flex; flex-direction: column; gap: 10px; }
.modale-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modale-actions .btn { flex: 1 1 140px; }
/* Le temps d'une modale, et pendant toute la partie, la pastille « Admin » du
   Portfolio s'efface : elle flotte en bas à gauche au-dessus de tout, et elle
   se posait sur les boutons ancrés en bas d'écran. */
body.has-modal #mn-admin-pill, body.en-partie #mn-admin-pill { display: none; }

@media (max-width: 560px) {
  .modale { align-items: flex-end; padding: 0; }
  .modale-carte { width: 100%; border-radius: 20px 20px 0 0; max-height: 92dvh; }
}

@media (max-width: 360px) {
  .modes { grid-template-columns: minmax(0, 1fr); }
  .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resultat { grid-template-columns: 14px minmax(0, 1fr) auto; }
  .resultat-info { display: none; }
}

@media (min-width: 720px) {
  .page { padding-top: 32px; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { width: auto; flex: 1 1 0; }
  .actions { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .reponse, .jeu-carte, .tuile, .ambiance { transition: none; }
  .carte-jeu.is-tiree { animation: none; }
  .btn:active, .reponse:active, .jeu-carte:active { transform: none; }
}

/* ── Le Blind test ─────────────────────────────────────────────────────── */
/* Le disque tourne quand l'extrait joue ; la barre suit la lecture. La
   pochette et le titre tombent à la révélation. */
.bt-platine { display: flex; align-items: center; gap: 18px; min-width: 0; }
.bt-platine.is-muette { justify-content: center; }
.bt-disque { width: 132px; height: 132px; flex: none; }
.bt-platine.is-muette .bt-disque { width: 112px; height: 112px; }
.bt-disque-vinyle { fill: var(--nuit); stroke: var(--line); stroke-width: 0.6; }
.bt-disque-sillon { fill: none; stroke: var(--nuit-muted); stroke-opacity: 0.4; stroke-width: 0.6; }
.bt-disque-etiquette { fill: var(--accent); }
.bt-disque-reflet { fill: none; stroke: var(--nuit-encre); stroke-opacity: 0.35; stroke-width: 1.4; stroke-linecap: round; }
.bt-disque-trou { fill: var(--nuit-encre); }
.bt-disque.is-tourne { animation: bt-tourne 3.2s linear infinite; }
@keyframes bt-tourne { to { transform: rotate(360deg); } }
.bt-disque { transform-origin: 50% 50%; }
.bt-lecture { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.bt-barre { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.bt-barre-plein { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.25s linear; }
.bt-temps { font: 600 14px/1 var(--font-mono); color: var(--muted); }
.bt-lecture .btn { align-self: flex-start; width: auto; min-width: 160px; }
/* À la révélation, la platine se fait discrète : la barre et Pause suffisent. */
.jeu-bt.is-revele .bt-disque { display: none; }
.bt-saisie { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bt-champ { display: flex; gap: 8px; min-width: 0; }
.bt-champ .champ { flex: 1; min-width: 0; font-size: 18px; }
.champ-masque { -webkit-text-security: disc; text-security: disc; }
.bt-rang { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding: 3px 6px;
  border-radius: 99px; background: var(--ok-soft); color: var(--ok); font: 700 13px/1 var(--font-display); }
.bt-rang.is-dehors, .bt-rang.is-vide { background: var(--paper-2); color: var(--muted); font-weight: 500; }
.bt-reponse { display: flex; align-items: center; gap: 16px; min-width: 0; }
.bt-pochette { width: 132px; height: 132px; flex: none; border-radius: 10px; object-fit: cover; box-shadow: var(--shadow); background: var(--paper-2); }
.bt-reponse-texte { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bt-reponse-texte .jeu-titre { overflow-wrap: anywhere; }
.bt-detail { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.bt-lien { font-size: 14px; color: var(--accent); text-underline-offset: 3px; }
.bt-trouves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bt-trouve {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; min-height: 52px; padding: 8px 14px; text-align: left; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
button.bt-trouve { cursor: pointer; }
.bt-trouve.is-trouve { border-color: var(--ok); background: var(--ok-soft); }
.bt-trouve.is-moi { border-width: 2px; }
.bt-qui { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bt-prop { color: var(--muted); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .bt-disque.is-tourne { animation: none; }
  .bt-barre-plein { transition: none; }
}

/* ── Le grand écran : paysage, plein écran, télé ──────────────────────── */
/* Le calque de l'ambiance (ambiance.js) est derrière la page, jamais devant :
   il ne reçoit aucun toucher et n'existe qu'au moment d'une question. */
.ambiance {
  position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%;
  pointer-events: none; opacity: 0; transition: opacity 0.6s var(--ease);
}
.ambiance.is-on { opacity: 1; }
.page { position: relative; z-index: 1; }
.ico-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* `body.grand` : le téléphone tenu en large (`paysage`), ou le plein écran
   demandé (`tele`). Seuls les écrans de la partie changent : les réglages
   restent sur une colonne. La hauteur est la rareté : la barre se fait
   petite et ne colle plus, les réponses passent deux par deux. */
body.grand .barre {
  position: relative;
  padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px;
}
body.grand .marque-logo { height: 26px; }
body.grand.en-partie .barre { background: transparent; border-bottom-color: transparent; }
body.tele.en-partie .marque { display: none; }
body.tele.en-partie .barre { justify-content: flex-end; }
body.grand.en-partie .page { max-width: 1040px; padding-top: 6px; }
body.grand.en-partie .ecran { gap: 12px; }
body.grand .jeu { gap: 12px; }
body.grand .question-theme { width: 40px; height: 40px; border-radius: 10px; }
body.grand .question-texte { font-size: clamp(24px, 3.8vw, 42px); }
body.grand .jeu-titre { font-size: clamp(24px, 3.4vw, 38px); }
body.grand .jeu-quiz .reponses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.grand .reponse { min-height: 54px; padding-block: 6px; }
body.grand .reponse-texte { font-size: 19px; }
body.grand .actions { align-items: center; justify-content: center; }
body.grand .actions { padding-block: 8px calc(8px + env(safe-area-inset-bottom)); }
body.grand .actions .btn-large { max-width: 480px; min-height: 50px; }
/* Au relais, le bouton n'a rien à recouvrir : pas de bande par-dessus l'ambiance. */
body.grand .relais .actions { position: static; background: none; margin: 8px 0 0; padding: 0; }
body.grand .relais { padding: 4px 0 0; gap: 8px; }
body.grand .relais-initiale { width: 64px; height: 64px; font-size: 30px; }
body.grand .relais-titre { font-size: clamp(26px, 4vw, 46px); }
body.grand .relais-aide { max-width: 60ch; font-size: 19px; }
body.grand .fin-scene { max-width: 560px; margin-inline: auto; }
/* Le Blind test à la télé : un grand disque, une grande pochette, le titre
   lisible du fond du salon. */
body.grand .bt-disque { width: 180px; height: 180px; }
body.grand .bt-pochette { width: 200px; height: 200px; }
body.grand .bt-reponse-texte .jeu-titre { font-size: clamp(28px, 4.4vw, 52px); }
body.grand .bt-detail { font-size: 20px; }
body.grand .bt-trouves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Sur la même onde : le cadran à gauche, tout le reste à droite. Les rangées
   sont sans écart (une rangée vide ne coûte rien), chaque élément porte le
   sien. */
body.grand .jeu-onde {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  column-gap: 24px; row-gap: 0; align-items: start;
}
body.grand .jeu-onde > * { grid-column: 2; margin-bottom: 10px; }
body.grand .jeu-onde > .cadran { grid-column: 1; grid-row: 1 / span 9; }
body.grand .jeu-onde .actions { position: static; background: none; margin: 0 0 10px; padding: 0; }

/* En fin de fichier : une media query n'ajoute aucune priorité, seul l'ordre
   tranche. Sur un appareil sans souris, :hover colle après le tap. */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.06); }
  .btn-secondary:hover, .compteur-btn:hover, .puce:hover, .segment:hover, .onglet:hover { border-color: var(--ink); }
  .jeu-carte:hover, .reponse:hover:not(:disabled):not(.is-revele) { border-color: var(--accent); }
  .tuile:hover { border-color: var(--ink); }
  .ico-btn:hover { border-color: var(--line); }
  .joueur-suppr:hover, .lien-ico:hover { color: var(--ink); background: var(--paper-2); }
  .mode:hover { border-color: var(--ink); }
  .emplacement-btn:hover { background: var(--accent-soft); }
}
