/* ============================ polices ============================

   Servies depuis ce domaine, jamais depuis Google.

   Un @import vers fonts.googleapis.com transmettait l'adresse IP de chaque visiteur
   à Google AVANT tout consentement, ce qui est incompatible avec le bandeau publicitaire
   et avec la politique de confidentialité du jeu. Les fichiers sont donc hébergés ici.

   Licence : SIL Open Font License 1.1 pour Fredoka comme pour Nunito — l'hébergement
   local est explicitement permis. Les textes de licence sont dans ce dossier.

   Ce sont des polices VARIABLES : un seul fichier couvre toute la plage de graisses,
   d'où `font-weight: 500 700` plutôt qu'une déclaration par graisse. Les quatorze
   fichiers proposés par Google se réduisent ainsi à quatre, soit 116 Ko au lieu de 392.
   ================================================================ */

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('fonts/fredoka-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('fonts/fredoka-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ==========================================================================
   Le Mou-ton — système de design
   Style « Vibrant & Block-based » : blocs francs, bordures épaisses, ombres
   pleines décalées, couleurs saturées. Mobile d'abord.
   ========================================================================== */

:root {
  /* --- couleurs sémantiques (jamais de hex en dur dans les composants) --- */
  --bg:            #FFF1F2;
  --surface:       #FFFFFF;
  --surface-2:     #FFF7F8;
  --fg:            #881337;
  --fg-strong:     #4C0519;
  --fg-muted:      #7A5C63;

  --primary:       #E11D48;
  --on-primary:    #FFFFFF;
  --primary-dim:   #FB7185;

  --accent:        #2563EB;
  --on-accent:     #FFFFFF;

  --success:       #15803D;
  --danger:        #BE123C;
  --warning:       #B45309;

  --border:        #F9A8B4;
  --border-strong: #881337;
  --shadow:        #881337;
  --ring:          #2563EB;

  /* --- couleur des cartes selon leur valeur ---
     Le joueur doit savoir ce qu'il risque avant même de lire le thème. La couleur
     porte l'information, mais jamais seule : la valeur reste écrite en toutes lettres,
     pour rester lisible en cas de daltonisme. */
  --card-1-bg: #15803D; --card-1-fg: #FFFFFF;   /* 1 point  — vert   */
  --card-2-bg: #B45309; --card-2-fg: #FFFFFF;   /* 2 points — ambre  */
  --card-3-bg: #BE123C; --card-3-fg: #FFFFFF;   /* 3 points — rouge  */
  --card-f-bg: #6D28D9; --card-f-fg: #FFFFFF;   /* foudre   — violet */

  /* --- rythme : échelle 4 / 8 --- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-full: 999px;

  --border-w: 3px;
  --lift: 4px;              /* profondeur de l'ombre pleine */

  /* --- typographie --- */
  --font-display: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --font-body: 'Nunito', ui-sans-serif, -apple-system, 'Segoe UI', system-ui, sans-serif;

  --t-xs: 0.8125rem; --t-sm: 0.9375rem; --t-base: 1rem;
  --t-lg: 1.25rem;   --t-xl: 1.5rem;    --t-2xl: 2rem;  --t-3xl: 2.75rem;

  /* --- mouvement --- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in:  cubic-bezier(0.55, 0, 1, 0.45);
  --dur-fast: 140ms;
  --dur:      220ms;
  --dur-exit: 150ms;

  /* --- empilement --- */
  --z-base: 0; --z-sticky: 20; --z-overlay: 40; --z-modal: 100; --z-toast: 1000;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg:            #170B10;
    --surface:       #241319;
    --surface-2:     #2E1921;
    --fg:            #FFE4E6;
    --fg-strong:     #FFFFFF;
    --fg-muted:      #C4A2AB;

    --primary:       #FB7185;
    --on-primary:    #3F0715;
    --primary-dim:   #9F1239;

    --accent:        #7DA9FF;
    --on-accent:     #0B1E44;

    --success:       #4ADE80;
    --danger:        #FB7185;
    --warning:       #FBBF24;

    --border:        #4A2831;
    --border-strong: #6B3B47;
    --shadow:        #0B0508;
    --ring:          #7DA9FF;

    /* Sur fond sombre, on inverse : teinte claire, texte foncé. */
    --card-1-bg: #4ADE80; --card-1-fg: #052E16;
    --card-2-bg: #FBBF24; --card-2-fg: #3B2600;
    --card-3-bg: #FB7185; --card-3-fg: #3F0715;
    --card-f-bg: #A78BFA; --card-f-fg: #21103F;
  }
}

:root[data-theme='dark'] {
  --bg:            #170B10;
  --surface:       #241319;
  --surface-2:     #2E1921;
  --fg:            #FFE4E6;
  --fg-strong:     #FFFFFF;
  --fg-muted:      #C4A2AB;
  --primary:       #FB7185;
  --on-primary:    #3F0715;
  --primary-dim:   #9F1239;
  --accent:        #7DA9FF;
  --on-accent:     #0B1E44;
  --success:       #4ADE80;
  --danger:        #FB7185;
  --warning:       #FBBF24;
  --border:        #4A2831;
  --border-strong: #6B3B47;
  --shadow:        #0B0508;
  --ring:          #7DA9FF;
  --card-1-bg: #4ADE80; --card-1-fg: #052E16;
  --card-2-bg: #FBBF24; --card-2-fg: #3B2600;
  --card-3-bg: #FB7185; --card-3-fg: #3F0715;
  --card-f-bg: #A78BFA; --card-f-fg: #21103F;
}

/* ============================ base ============================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* Taille par défaut des icônes. Sans elle, un <svg> sans dimension prend toute la
   largeur disponible et fait exploser la mise en page. Les règles plus spécifiques
   (.brand svg, .trophy svg…) restent prioritaires. */
svg { width: 20px; height: 20px; flex: none; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--fg-strong);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: var(--t-2xl); font-weight: 700; }
h2 { font-size: var(--t-xl);  font-weight: 600; }
h3 { font-size: var(--t-lg);  font-weight: 600; }

p { margin: 0 0 var(--sp-3); max-width: 68ch; }
a { color: var(--accent); text-underline-offset: 3px; }

/* Anneau de focus visible partout — jamais supprimé. */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--sp-3); top: -100px; z-index: var(--z-toast);
  background: var(--surface); color: var(--fg-strong);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-4); font-weight: 700;
  transition: top var(--dur) var(--ease-out);
}
.skip-link:focus { top: var(--sp-3); }

/* ============================ mise en page ============================ */

.app {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  /* Les replis à 0px sont indispensables : sans eux, un env() non résolu invalide
     tout le calc() et la marge intérieure disparaît. */
  padding:
    calc(env(safe-area-inset-top, 0px) + var(--sp-4))
    calc(env(safe-area-inset-right, 0px) + var(--sp-4))
    calc(env(safe-area-inset-bottom, 0px) + var(--sp-8))
    calc(env(safe-area-inset-left, 0px) + var(--sp-4));
}

.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5); min-height: 48px;

}
.topbar .spacer { flex: 1; }

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg);
  color: var(--fg-strong); text-decoration: none;
  /* C'est le libellé qui cède quand la place manque, jamais les boutons : en cours
     de partie un bouton « Quitter » s'ajoute aux cinq icônes, et la somme dépassait
     la largeur de l'écran — une icône sortait du cadre, constaté sur Pro Max.
     Replier sur deux lignes était pire : le bouton isolé chevauchait la barre d'état. */
  flex: 0 1 auto; min-width: 0; overflow: hidden;
}
.brand svg { width: 34px; height: 34px; flex: none; }
/* Sans cela, l'ajout d'une icône dans la barre suffit à casser le titre sur plusieurs
   lignes : les boutons, de largeur fixe, poussent le seul élément compressible. */
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sur les écrans étroits, on garde le mouton seul plutôt que d'écraser les boutons :
   l'icône suffit à identifier l'app, et la barre reste utilisable au pouce. */
@media (max-width: 420px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .topbar { gap: var(--sp-2); }
}

.stack   { display: grid; gap: var(--sp-4); }
.stack-2 { display: grid; gap: var(--sp-2); }
.row     { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.row > .grow { flex: 1 1 auto; }

/* Un élément de grille ou de flex vaut par défaut `min-width: auto` : il refuse de
   passer sous la largeur de son contenu et déborde du conteneur. C'est la cause
   habituelle des barres de défilement horizontales sur mobile. */
.stack > *, .stack-2 > *, .row > * { min-width: 0; }

section[hidden], [hidden] { display: none !important; }

/* ============================ blocs ============================ */

.card {
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 var(--lift) 0 var(--shadow);
  padding: var(--sp-5);
}
.card.flat { box-shadow: none; border-color: var(--border); }
.card.tint { background: var(--surface-2); }

.card-title {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.card-title svg { width: 22px; height: 22px; flex: none; color: var(--primary); }

.hint { color: var(--fg-muted); font-size: var(--t-sm); margin: 0; }

.divider { height: var(--border-w); background: var(--border); border: 0; border-radius: 2px; margin: var(--sp-4) 0; }

/* ============================ contrôles ============================ */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--fg-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 48px; padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-display); font-weight: 600; font-size: var(--t-base);
  color: var(--btn-fg); background: var(--btn-bg);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-full);
  box-shadow: 0 var(--lift) 0 var(--shadow);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 20px; height: 20px; flex: none; }

/* L'enfoncement utilise transform : aucun décalage du contenu voisin. */
.btn:active:not(:disabled) { transform: translateY(var(--lift)); box-shadow: 0 0 0 var(--shadow); }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: color-mix(in srgb, var(--btn-bg) 88%, var(--fg-strong)); }
}

.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); }
.btn-accent  { --btn-bg: var(--accent);  --btn-fg: var(--on-accent); }
.btn-danger  { --btn-bg: var(--surface); --btn-fg: var(--danger); }
.btn-ghost   { box-shadow: none; border-color: var(--border); }
.btn-block   { width: 100%; }
.btn-lg      { min-height: 60px; font-size: var(--t-lg); padding: var(--sp-4) var(--sp-6); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: 0 var(--lift) 0 var(--border); }

/* Bouton icône seule — toujours accompagné d'un aria-label. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; flex: none;
  color: var(--fg-strong); background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
  touch-action: manipulation;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(0.94); }

/* --- champs --- */

.field { display: grid; gap: var(--sp-2); }
.field > label { font-weight: 700; font-size: var(--t-sm); color: var(--fg-strong); }
.field .hint { margin-top: calc(var(--sp-1) * -1); }

.input {
  width: 100%; min-height: 52px;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-body); font-size: var(--t-base); /* 16px : évite le zoom iOS */
  color: var(--fg-strong); background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--fg-muted); opacity: 1; }
.input:focus-visible { outline-offset: 1px; }

.input-code {
  font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700;
  letter-spacing: 0.35em; text-align: center; text-transform: uppercase;
  padding-left: 0.35em;
}

/* --- groupes de choix (paramètres) --- */

.choices { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice { position: relative; flex: 1 1 auto; min-width: 96px; }
.choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span {
  display: grid; gap: 2px; justify-items: center; text-align: center;
  min-height: 48px; padding: var(--sp-2) var(--sp-3);
  background: var(--surface); color: var(--fg);
  border: var(--border-w) solid var(--border);
  border-radius: var(--r-md);
  font-weight: 700; font-size: var(--t-sm);
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.choice span small { font-weight: 600; font-size: var(--t-xs); color: var(--fg-muted); line-height: 1.3; }
.choice input:checked + span {
  background: var(--primary); color: var(--on-primary); border-color: var(--border-strong);
}
.choice input:checked + span small { color: inherit; opacity: 0.85; }
.choice input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 2px; }
.choice input:active + span { transform: scale(0.97); }
.choice input:disabled + span { opacity: 0.45; cursor: not-allowed; }

/* ============================ éléments de jeu ============================ */

.code-display {
  display: grid; justify-items: center; gap: var(--sp-1);
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--t-3xl); letter-spacing: 0.28em; text-indent: 0.28em;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.scores { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.score {
  flex: 1 1 128px; min-width: 0;
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3);
}
.score.active { border-color: var(--primary); background: var(--surface-2); }
.score .value {
  font-family: var(--font-display); font-size: var(--t-2xl); font-weight: 700;
  color: var(--fg-strong); font-variant-numeric: tabular-nums; line-height: 1;
}
.score .label { font-size: var(--t-xs); color: var(--fg-muted); font-weight: 700; }
.score .members {
  font-size: var(--t-xs); color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* La carte de jeu — pièce maîtresse de l'écran. */
.playcard {
  background: var(--primary); color: var(--on-primary);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 var(--lift) 0 var(--shadow);
  padding: var(--sp-5);
  text-align: center;
  animation: card-in var(--dur) var(--ease-out) both;
}
/* Une couleur par valeur de carte. La classe est posée par le client d'après les
   données du serveur ; en son absence, la carte garde la couleur primaire. */
.playcard.lvl-1 { background: var(--card-1-bg); color: var(--card-1-fg); }
.playcard.lvl-2 { background: var(--card-2-bg); color: var(--card-2-fg); }
.playcard.lvl-3 { background: var(--card-3-bg); color: var(--card-3-fg); }
.playcard.lvl-foudre {
  background: var(--card-f-bg); color: var(--card-f-fg);
  border-style: solid;
}

.playcard .kind {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: var(--t-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-full);
  /* currentColor suit la couleur du texte de la carte : le badge reste lisible
     quelle que soit la teinte de fond, en thème clair comme en sombre. */
  background: color-mix(in srgb, currentColor 18%, transparent);
}

/* Les quatre tirets d'une carte foudre : on voit d'un coup d'œil où on en est. */
.dashes { display: flex; gap: var(--sp-2); justify-content: center; margin-top: var(--sp-3); }
.dash {
  width: 28px; height: 6px; border-radius: var(--r-full);
  background: color-mix(in srgb, currentColor 25%, transparent);
}
.dash.done { background: currentColor; }
.dash.now  { background: currentColor; animation: dash-pulse 1s ease-in-out infinite; }
@keyframes dash-pulse { 50% { opacity: .45; } }
.playcard .theme {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--t-xl); line-height: 1.2; margin: var(--sp-3) 0 0;
  text-wrap: balance;
}
@media (min-width: 480px) { .playcard .theme { font-size: var(--t-2xl); } }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.timer {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 800; font-variant-numeric: tabular-nums;
}
.timer-track {
  flex: 1; height: 10px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--on-primary) 25%, transparent);
  overflow: hidden;
}
.timer-fill { height: 100%; background: var(--on-primary); transform-origin: left center; }
.timer.low { color: var(--warning); }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.people li {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border: 2px solid var(--border);
  border-radius: var(--r-md);
  animation: row-in var(--dur) var(--ease-out) both;
}
.people li .who { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
  border: 2px solid var(--border-strong);
  font-family: var(--font-display); font-weight: 700;
}
.avatar.bot { background: var(--accent); color: var(--on-accent); }
.avatar svg { width: 20px; height: 20px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px var(--sp-2); border-radius: var(--r-full);
  background: var(--border); color: var(--fg-strong);
}
.chip.you { background: var(--primary); color: var(--on-primary); }
.chip.host { background: var(--accent); color: var(--on-accent); }

.reveal { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.reveal li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  border: 2px solid var(--border); background: var(--surface-2);
  animation: row-in var(--dur) var(--ease-out) both;
}
.reveal li .said { font-family: var(--font-display); font-weight: 700; color: var(--fg-strong); }

.verdict {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-4); font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg);
}
.verdict svg { width: 26px; height: 26px; flex: none; }
.verdict.ok    { color: var(--success); }
.verdict.ko    { color: var(--danger); }
.verdict.doubt { color: var(--warning); }

.banner {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 2px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--fg);
  font-size: var(--t-sm);
}
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--primary); }
.banner.error { border-style: solid; border-color: var(--danger); color: var(--danger); font-weight: 700; }

/* Bandeau « document à compléter » — volontairement impossible à ignorer,
   pour qu'aucune page légale ne parte en production avec des crochets dedans. */
.banner[data-draft] {
  border-style: solid; border-width: var(--border-w); border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--fg-strong);
}
.banner[data-draft] svg { color: var(--warning); }

.pot {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 800; color: var(--warning);
  font-size: var(--t-sm);
}
.pot svg { width: 18px; height: 18px; }

.trophy { display: grid; justify-items: center; gap: var(--sp-3); text-align: center; }
.trophy svg { width: 72px; height: 72px; color: var(--primary); }

/* ============================ pages de contenu ============================ */

.prose h2 { margin: var(--sp-6) 0 var(--sp-2); }
.prose h3 { margin: var(--sp-5) 0 var(--sp-2); }
.prose ul, .prose ol { margin: 0 0 var(--sp-4); padding-left: var(--sp-5); }
.prose li { margin-bottom: var(--sp-2); }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-4); font-size: var(--t-sm); }
.prose th, .prose td { text-align: left; padding: var(--sp-2); border-bottom: 2px solid var(--border); vertical-align: top; }
.prose th { font-family: var(--font-display); color: var(--fg-strong); }
.prose .lead { font-size: var(--t-lg); color: var(--fg-strong); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.sitefooter {
  margin-top: var(--sp-7); padding-top: var(--sp-4);
  border-top: 2px solid var(--border);
  display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4);
  font-size: var(--t-xs); color: var(--fg-muted);
}
.sitefooter a { color: var(--fg-muted); }
.sitefooter .grow { flex: 1 1 auto; }

/* ============================ mouvement réduit ============================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================ grands écrans ============================ */

@media (min-width: 768px) {
  .app { padding-left: var(--sp-6); padding-right: var(--sp-6); }
  h1 { font-size: var(--t-3xl); }
}

/* ============================ publicité ============================ */

/* Une publicité doit se distinguer nettement du jeu : sinon on trompe le joueur,
   et les régies comme les magasins l'interdisent explicitement. */
.ad-tag {
  margin: 0 0 var(--sp-2);
  font-size: var(--t-xs); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-muted);
}

.ad-slot {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  background: var(--surface-2);
  text-align: center;
  overflow: hidden;
}
.ad-slot ins { display: block; }

.ad-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: var(--sp-4);
  background: rgb(0 0 0 / .72);
  backdrop-filter: blur(3px);
}
.ad-overlay-box {
  width: min(100%, 420px);
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  text-align: center;
}
.ad-overlay-slot {
  min-height: 200px;
  display: grid; place-items: center;
  margin-bottom: var(--sp-4);
}

/* ============================ consentement ============================ */

.consent {
  position: fixed; inset: auto 0 0 0; z-index: 110;
  padding: var(--sp-3);
  display: grid; place-items: end center;
}
.consent-box {
  width: min(100%, 560px);
  display: grid; gap: var(--sp-3);
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  box-shadow: 0 12px 40px rgb(0 0 0 / .35);
}
.consent-box h2 { margin: 0; font-size: var(--t-lg); }
.consent-box p { margin: 0; font-size: var(--t-sm); }
.consent-actions { display: grid; gap: var(--sp-2); grid-template-columns: 1fr 1fr; }

/* Le bandeau occupe le bas de l'écran : sans cette marge, il masque les derniers
   éléments de la page, dont les liens légaux qu'il est censé rendre accessibles. */
body:has(#consent-banner:not([hidden])) .sitefooter { padding-bottom: 220px; }

/* ============================ écran bloquant ============================ */

/* L'acceptation des conditions couvre toute la page : tant qu'elle n'est pas donnée,
   rien d'autre n'est atteignable, ni à la souris ni au clavier. */
.gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: var(--sp-4);
  background: var(--bg);
  overflow-y: auto;
}
.gate-box {
  width: min(100%, 480px);
  display: grid; gap: var(--sp-4); justify-items: center; text-align: center;
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 var(--lift) 0 var(--shadow);
  padding: var(--sp-6) var(--sp-5);
}
.gate-box p { margin: 0; }

/* ============================ personnages ============================ */

.persos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--sp-3);
}

.perso {
  display: grid; justify-items: center; gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-2);
  background: var(--surface-2);
  border: var(--border-w) solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: center;
  color: inherit;
  font: inherit;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.perso:active { transform: scale(.96); }
.perso[aria-pressed='true'] { border-color: var(--primary); background: var(--surface); }
.perso svg { width: 56px; height: 56px; }
.perso .nom { font-weight: 700; font-size: var(--t-xs); }
.perso .cond { font-size: var(--t-xs); color: var(--fg-muted); }

/* Un personnage verrouillé reste visible : c'est ce qui donne envie de le débloquer.
   Il est simplement grisé, et son bouton n'est pas activable. */
.perso.verrouille { opacity: .55; }
.perso.verrouille svg { filter: grayscale(1); }

/* Le personnage en grand, sur l'écran de progression.
   Sans cette règle, la taille en attribut du SVG est écrasée par le `svg { width: 20px }`
   global : le mouton s'affiche en timbre-poste. */
.perso-xl { display: grid; justify-items: center; }
.avatar-perso { padding: 0; background: transparent; }
.avatar-perso svg { width: 30px; height: 30px; }
.perso-xl svg { width: 120px; height: 120px; }

/* ============================ progression ============================ */

.jauge {
  height: 12px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--fg-muted) 25%, transparent);
  overflow: hidden;
}
.jauge > i {
  display: block; height: 100%;
  background: var(--primary);
  transition: width var(--dur) var(--ease-out);
}

.medailles { display: flex; flex-wrap: wrap; gap: var(--sp-2); list-style: none; padding: 0; margin: 0; }
.medaille {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 700;
}

/* ============================ chat ============================ */

.chat {
  list-style: none; margin: 0; padding: var(--sp-3);
  display: grid; gap: var(--sp-2);
  max-height: 220px; overflow-y: auto;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  /* Le défilement du chat ne doit pas entraîner celui de la page derrière lui. */
  overscroll-behavior: contain;
}
.chat:empty::after {
  content: 'Personne n\'a encore rien dit.';
  color: var(--fg-muted);
}
.chat li { display: grid; gap: 2px; }
.chat .qui { font-weight: 800; color: var(--fg-strong); font-size: var(--t-xs); }
.chat .quoi { overflow-wrap: anywhere; }
.chat li.moi .qui { color: var(--primary); }

/* Un joueur déconnecté doit se voir : sans ça, les autres attendent une réponse
   qui ne viendra pas, sans comprendre pourquoi. */
.people li.absent { opacity: .55; }
.people li.absent .who::after {
  content: ' — déconnecté';
  font-size: var(--t-xs); color: var(--fg-muted); font-weight: 400;
}
