/* ============================================================================
   FACETA — PIVOT « BASIQUE DESSIN ANIMÉ » (porteur 2026-09-11, cf BACKLOG.md
   §PIVOT DESIGN À TESTER) — vague 1 : plateau + gemmes + HUD passés en flat
   cartoon (aplats, contours nets, zéro glassmorphism). Override LOCAL À FACETA
   uniquement (tokens --cb-glass-* / --cb-overlay-blur redéfinis ci-dessous
   gagnent sur les fallbacks du kit car ce fichier charge APRÈS
   _kit/kit-design.css, cf index.html) : le reste de la flotte garde son look
   premium verre inchangé tant que ce test n'est pas validé (HOLD backlog).
   Mobile-first, tokens CB-ARCADE. Palette identité FACETA conservée (violet +
   or + vert), juste aplatie. RTL arabe complet, safe-areas iPhone XS/Pro,
   animations fluides & respectueuses, responsive 360px → 1920px+.
   ========================================================================== */
:root {
  /* Cartoon flat (vague 1) : zéro flou verre, contour net partout. */
  --cb-glass-blur: none;
  --cb-overlay-blur: none;
  --cb-glass-bg: var(--panel2, #241f3f);
  --cb-glass-bg-light: var(--panel3, #2d2752);
  --cb-overlay-bg: rgba(10, 8, 20, 0.74);
  /* (C7) Contour cartoon ADAPTATIF pour les panneaux/cartes (fond --panel / --field,
     lui-même sombre en thème sombre) : noir en clair, PAILLE en sombre — sinon un
     contour quasi-noir (#1a1628) sur un panneau quasi-noir (--panel2 #241f3f) est
     illisible (contraste ~1,3:1). --toon-outline-ink reste TOUJOURS sombre, pour les
     éléments posés sur un fond CLAIR/vif (or/violet/bleu) où le contour sombre est
     déjà lisible dans les deux thèmes (boutons primaires, pastilles actives…). */
  --toon-outline: #f0e4b8;
  --toon-outline-light: #f7eecb;
  --toon-outline-ink: #1a1628;
  --toon-outline-w: 3px;
  /* Ombres cartoon « sticker » : décalage net, zéro flou (au lieu du bokeh
     verre du kit --cb-shadow-*). */
  --cb-shadow-inset: none;
  --cb-shadow-xs: 0 2px 0 rgba(26, 22, 40, 0.30);
  --cb-shadow-md: 0 3px 0 rgba(26, 22, 40, 0.30);
  --cb-shadow-lg: 0 5px 0 rgba(26, 22, 40, 0.30);
  --cb-shadow-xl: 0 7px 0 rgba(26, 22, 40, 0.30);
  /* Import implicite des tokens du kit via _kit/kit-design.css */
  /* Palette FACETA : violet premium + or (cohérence CB-ARCADE) */
  --bg: #0e0f1a;
  /* (C8) Fonds de panneaux DESSINÉS, pas un simple assombrissement plat : un
     dégradé chaud à 2 tons (même logique que le cel-shading des gemmes —
     bandes franches, pas un glass flouté, `--cb-glass-blur`/`--cb-overlay-blur`
     restent `none`) donne de la « matière » aux cartes/HUD/plateau en sombre.
     Tous les usages de ces tokens sont en `background:` (jamais `rgba(var())`
     ni `border-color`), un dégradé y est donc un remplacement sans risque. */
  --panel: linear-gradient(160deg, #201a34 0%, #140f22 100%);
  --panel2: linear-gradient(145deg, #2c2452 0%, #1c1734 100%);
  --panel3: linear-gradient(150deg, #372d63 0%, #241f44 100%);
  --field: linear-gradient(180deg, #191426 0%, #100c1a 100%);
  --ghost: #2a244a;
  --grid: #3a3255;

  /* Texte : haut contraste WCAG AAA sur fond sombre */
  --ink: #f0edff;
  --muted: #b5aad0;
  --muted-light: #c9bfe0;

  /* Or premium du kit + vert CB-ARCADE comme accent alternatif */
  --accent: var(--cb-accent, #d4af37);
  --accent-ink: var(--cb-text-on-accent, #1a1628);
  --accent-bright: #f4dfa6;
  --accent-glimmer: #fef3c7;
  --accent-alt: var(--cb-primary, #38e08b);

  /* Sécurité : rouge premium WCAG AAA */
  --danger: var(--cb-danger, #ff5252);
  --danger-dark: var(--cb-danger-dark, #c41c3b);
  --cyan: #7ff4ff;

  /* Glows premium multi-layer : doré + violet harmonisés */
  --glow-gold: rgba(212, 175, 55, 0.25);
  --glow-gold-bright: rgba(212, 175, 55, 0.35);
  --glow-violet: rgba(168, 121, 255, 0.15);
  --glow-violet-bright: rgba(168, 121, 255, 0.25);

  /* Rayons premium (harmonisés avec kit) */
  --radius-lg: var(--cb-radius-xl, 20px);
  --radius-md: var(--cb-radius-lg, 14px);
  --radius-sm: var(--cb-radius-md, 12px);
  --radius-xs: var(--cb-radius-sm, 8px);

  /* Ombres : bokeh premium multi-layer (kit fallbacks) */
  --shadow: var(--cb-shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.55));
  --shadow-lg: var(--cb-shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.45));
  --shadow-sm: var(--cb-shadow-md, 0 8px 22px rgba(0, 0, 0, 0.35));
  --shadow-xs: var(--cb-shadow-xs, 0 2px 4px rgba(0, 0, 0, 0.12));
  --shadow-inset: var(--cb-shadow-inset, inset 0 1px 0 rgba(255, 255, 255, 0.08));

  /* Transitions premium (harmonisées, respectent prefers-reduced-motion) */
  --dur-instant: var(--cb-duration-instant, 0.08s);
  --dur-fast: var(--cb-duration-fast, 0.12s);
  --dur-normal: var(--cb-duration-normal, 0.18s);
  --dur-slow: var(--cb-duration-slow, 0.3s);
  --dur-deliberate: var(--cb-duration-deliberate, 0.4s);
  --ease-out: var(--cb-easing-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  --ease-in-out: var(--cb-easing-in-out, cubic-bezier(0.4, 0, 0.2, 1));
  --ease-bounce: var(--cb-easing-bounce, cubic-bezier(0.2, 0.9, 0.3, 1.2));

  /* Voile posé sur le fond kawaii de la carte des niveaux (§P0 GATE
     DISTRIBUTION point 5, .map-scroll) — alpha aligné sur le tint du plateau
     en sombre (drawBoardBackground, game.js), teinte alignée sur --panel3
     pour rester dans la charte violette. Retour porteur 2026-09-13 (contrôle
     visuel) : à 0.55 le voile noyait la scène sous un aplat quasi uni
     (« écrans encore violet vide ») — les noeuds/le chemin ont leur propre
     fond opaque (.map-nodes .node) donc n'ont pas besoin d'un voile aussi
     couvrant pour rester lisibles ; baissé pour que la scène se voie. */
  --map-scrim: rgba(46, 40, 84, 0.30);

  color-scheme: dark;
}
/* Thème CLAIR : piloté par [data-theme] posé par _kit/theme.js (toujours résolu,
   jamais absent — cf commentaire §MODE CLAIR plus bas) plutôt que par
   @media (prefers-color-scheme), pour suivre le choix explicite du hub. */
html[data-theme="light"] {
  /* (C7) Contour panneaux : noir, panneaux blancs/lavande → déjà lisible, pas de
     variante paille nécessaire ici (--toon-outline-ink garde la même valeur, non
     redéfini). */
  --toon-outline: #1a1628;
  --toon-outline-light: #2a1f45;
  --bg: #faf8ff;
  --panel: #ffffff;
  --panel2: #f3eeff;
  --panel3: #ede5ff;
  --field: #ede6fb;
  /* Voile plus couvrant qu'en sombre (aligné sur le tint clair du plateau,
     drawBoardBackground) : les scènes Kopilvia restent saturées, il en faut
     un peu plus pour garder le chemin/les noeuds lisibles sur fond clair.
     Retour porteur 2026-09-13 : à 0.72 la scène disparaissait quasiment sous
     un aplat lavande uni — baissé, les noeuds gardent leur propre fond opaque
     (.map-nodes .node) donc restent lisibles sans un voile aussi couvrant. */
  --map-scrim: rgba(237, 229, 255, 0.40);
  --ghost: #ebe4ff;
  --grid: #ddd0f3;

  /* Texte clair : fort contraste sur blanc */
  --ink: #2a1f45;
  --muted: #6b5a8f;
  --muted-light: #7a6a98;

  /* Or premium mode clair : plus foncé */
  --accent: #b8860b;
  --accent-ink: #ffffff;
  --accent-bright: #d4af37;
  --accent-glimmer: #e5c852;

  /* Glows mode clair : plus subtils mais cohérents */
  --glow-gold: rgba(184, 134, 11, 0.15);
  --glow-gold-bright: rgba(184, 134, 11, 0.22);
  --glow-violet: rgba(140, 100, 180, 0.12);
  --glow-violet-bright: rgba(140, 100, 180, 0.18);

  /* Sécurité */
  --danger: #c2274a;
  --danger-dark: #a01f3a;
  --cyan: #0f7f92;

  /* Ombres cartoon mode clair : décalage net, zéro flou */
  --shadow: 0 7px 0 rgba(80, 60, 150, 0.18);
  --shadow-lg: 0 5px 0 rgba(80, 60, 150, 0.16);
  --shadow-sm: 0 3px 0 rgba(80, 60, 150, 0.14);
  color-scheme: light;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 620px at 50% -10%, #2a2145 0%, #0e0f1a 62%);
  color: var(--ink);
  font-family: var(--cb-font-family, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 16px;
  font-weight: var(--cb-font-regular, 400);
  line-height: var(--cb-line-height-normal, 1.4);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  touch-action: none;
}

html[data-theme="light"],
html[data-theme="light"] body {
  background: radial-gradient(1200px 620px at 50% -10%, #f5ebff 0%, #faf8ff 62%);
}

/* iPhone notch + home indicator safe-areas + Dynamic Island */
@supports (padding: max(0px)) {
  #wrap {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }
}

#wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  min-height: 100%;
  width: 100%;
}

header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 0;
}

.brand {
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 22px;
  flex: 1;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 14px var(--glow-gold),
    0 0 28px var(--glow-violet);
  animation: brand-pulse 2.8s ease-in-out infinite;
  will-change: opacity, text-shadow;
}

@keyframes brand-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    text-shadow:
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 14px var(--glow-gold),
      0 0 28px var(--glow-violet);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.01);
    text-shadow:
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 22px var(--glow-gold-bright),
      0 0 44px var(--glow-violet-bright);
  }
}

.brand b,
.logo b {
  color: var(--accent);
}

/* HUD : niveau / coups / score — bandes supérieures premium avec glassmorphism */
.hud {
  width: 100%;
  display: flex;
  gap: 8px;
  animation: hud-fade-in var(--dur-normal) ease forwards;
  will-change: opacity, transform;
}

.hud[hidden] {
  display: none;
}

@keyframes hud-fade-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
    filter: blur(1px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: none;
  }
}

.stat {
  flex: 1;
  background: var(--cb-glass-bg, var(--panel2));
  border: var(--toon-outline-w) solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--cb-pad-sm, 10px) var(--cb-pad-xs, 6px);
  text-align: center;
  transition:
    background var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease,
    transform var(--dur-fast) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  will-change: box-shadow, background, border-color;
}

.stat:hover {
  background: var(--panel3);
  border-color: var(--accent-bright);
  box-shadow: var(--shadow-sm);
}

.stat .lbl {
  font-size: var(--cb-text-xs, 9px);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--cb-letter-spacing-caps, 1.2px);
  font-weight: var(--cb-font-bold, 700);
  opacity: 0.9;
}

.stat .val {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
  transition: color var(--dur-normal) ease, text-shadow var(--dur-normal) ease;
  text-shadow: 0 0 8px rgba(240, 202, 92, 0.2);
}

.stat.low .val {
  color: var(--danger);
  animation: stat-pulse 0.6s var(--ease-bounce);
  text-shadow:
    0 0 12px rgba(255, 107, 122, 0.4),
    0 0 24px rgba(255, 82, 82, 0.25);
}

@keyframes stat-pulse {
  0% {
    transform: scale(1);
    text-shadow:
      0 0 12px rgba(255, 107, 122, 0.4),
      0 0 24px rgba(255, 82, 82, 0.25);
  }
  50% {
    transform: scale(1.18);
    text-shadow:
      0 0 20px rgba(255, 107, 122, 0.7),
      0 0 36px rgba(255, 82, 82, 0.4);
  }
  100% {
    transform: scale(1);
    text-shadow:
      0 0 12px rgba(255, 107, 122, 0.4),
      0 0 24px rgba(255, 82, 82, 0.25);
  }
}

/* Objectifs du niveau : pastilles animées avec barre de progression */
.goals {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  animation: goals-fade-in var(--dur-normal) ease forwards;
}

@keyframes goals-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.goal {
  flex: 1 1 44%;
  background: var(--panel2);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  transition:
    background var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease,
    transform var(--dur-fast) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  will-change: box-shadow, background, border-color;
}

.goal:hover:not(.done) {
  background: var(--panel3);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.goal .gem {
  width: 16px;
  height: 16px;
  border-radius: 6px;
  flex: 0 0 auto;
}

.goal .txt {
  flex: 1;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.goal.done {
  color: var(--accent-bright);
  border-color: var(--accent);
  background: var(--panel3);
  box-shadow: var(--shadow-sm);
  animation: goal-complete var(--dur-normal) var(--ease-bounce);
}

.goal.done::after {
  content: '✓';
  font-weight: 900;
  color: var(--accent-bright);
  margin-inline-start: 2px;
}

@keyframes goal-complete {
  0% {
    transform: scale(0.8);
    opacity: 0;
    filter: blur(1px);
  }
  50% {
    transform: scale(1.12);
    filter: brightness(1.15);
  }
  75% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: none;
  }
}

/* Plateau de jeu : bezel cartoon flat, contour net (pivot dessin animé
   2026-09-11, vague 1 — remplace le bezel verre dépoli premium). */
.board-wrap {
  position: relative;
  width: 100%;
  padding: var(--cb-pad-sm, 10px);
  border-radius: var(--radius-lg);
  background: var(--panel2);
  border: var(--toon-outline-w) solid var(--accent);
  box-shadow: var(--shadow);
  backdrop-filter: none;
  transition:
    background var(--dur-slow) ease,
    border-color var(--dur-slow) ease,
    box-shadow var(--dur-slow) ease;
  max-width: calc(100vw - 24px);
}

/* Vague 2 : plus de lueur radiale (glassmorphism) sur le bezel — aplat
   uni + contour net (--toon-outline-w) suffisent, cf. `.board-wrap`.
   NB : `html[data-theme="light"] .board-wrap` est défini plus bas, à côté
   des autres surcharges mode clair (cf. §MODE CLAIR) — une seule source
   de vérité, pour ne pas laisser deux règles concurrentes sur ce sélecteur. */

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  touch-action: none;
  box-shadow: var(--cb-shadow-md, 0 3px 0 rgba(26, 22, 40, 0.30));
  image-rendering: crisp-edges;
  -webkit-touch-callout: none;
  user-select: none;
  transition: filter var(--dur-normal) ease, transform var(--dur-fast) ease;
  filter: saturate(1) brightness(1);
}

canvas:active {
  filter: saturate(1.05) brightness(1.02);
  transform: scale(0.998);
}

/* Opérabilité clavier du plateau (cf. game.js, gestionnaire keydown du
   canvas) : même anneau que les autres éléments focusables du kit. */
#c:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Actions : boutons d'aide, partage, réglages — dock responsive */
.actions {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.actions[hidden] {
  display: none;
}

/* Barre d'OUTILS d'aide : pastille de crédits + boutons premium (relief, gloss,
   coût en ◆). Elle vit juste sous le plateau, tactile et lisible. */
.toolbar {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 7px;
  /* Une seule RANGÉE homogène de 4 outils. `nowrap` + scroll horizontal de
     secours : jamais d'empilement, et si un écran très étroit déborde, ça glisse
     au lieu de casser. */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.toolbar::-webkit-scrollbar { display: none; }
.toolbar[hidden] { display: none; }

/* Porte-monnaie mutualisé CB-Arcade : 2 pastilles dans l'EN-TÊTE, à côté des
   vies (comme un solde) — 🪙 Jouer (confort, partagé client) + ◆ Gagner (serveur, SSV). */
.wchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.wchip.play {
  color: var(--accent-alt);
  background: var(--panel2);
  border: 2px solid var(--accent-alt);
  box-shadow: var(--shadow-xs);
}
.wchip.earn {
  color: var(--accent-bright);
  background: var(--panel2);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-xs);
}
.hchips { display: flex; align-items: center; gap: 7px; }

.tool-btn {
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
  /* Surcharge de la règle globale `button { width:100%; margin-top; uppercase }` :
     outil COMPACT en rangée, icône + (nom au-dessus, coût en dessous). */
  display: inline-flex;
  width: auto;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  overflow: visible;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  border: 2px solid var(--accent);
  background: var(--panel2);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--dur-fast) var(--ease-bounce),
    box-shadow var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    filter var(--dur-normal) ease;
}
.tool-btn .ico { font-size: 19px; line-height: 1; flex: 0 0 auto; display: inline-flex; }
.tool-btn .ico svg { width: 19px; height: 19px; }
.tool-btn .cost svg { width: 13px; height: 13px; vertical-align: -2px; }
.tool-btn .tmeta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  min-width: 0;
}
.tool-btn .tname {
  font-size: 10.5px;
  font-weight: 700;
  opacity: 0.92;
  white-space: nowrap;
}
.tool-btn .cost {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
}
.tool-btn .cost.gem-cost { color: var(--cyan); }   /* ▶ = gratuit via pub, pas un coût ◆ */
.tool-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--accent-bright);
  background: var(--panel3);
  box-shadow: var(--shadow-lg);
}
.tool-btn:active:not(:disabled) {
  transform: scale(0.92) translateY(-1px);
  box-shadow: var(--shadow-xs);
}
.tool-btn:disabled { opacity: 0.45; cursor: default; }
.tool-btn:focus-visible {
  outline: var(--cb-focus-ring, 2px solid var(--accent));
  outline-offset: var(--cb-focus-offset, 2px);
  box-shadow:
    var(--shadow-sm),
    var(--cb-focus-shadow, 0 0 0 6px rgba(255, 193, 7, 0.20));
}

/* Marteau dégainé : il reste enfoncé, cerclé de rouge — le prochain tap casse. */
.tool-btn.armed {
  border-color: var(--danger);
  background: var(--danger-dark);
  box-shadow: 0 0 0 3px rgba(255, 90, 100, 0.4);
  animation: tool-armed 1s ease-in-out infinite;
}
@keyframes tool-armed {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 90, 100, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(255, 90, 100, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .tool-btn.armed { animation: none; }
}

/* Booster de briefing CHOISI (bascule, pas une action ponctuelle comme le
   marteau ci-dessus) : cerclé d'or, fixe — un choix confirmé, pas une urgence. */
.tool-btn.picked {
  border-color: var(--accent-bright);
  background: var(--panel3);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.35);
}

/* Rangée de boosters du briefing : même rythme vertical que `.goal-list`
   juste au-dessus (marge symétrique), `.toolbar` fournit déjà la rangée. */
.boosters-label { margin: 8px 0 6px; text-align: start; }
#brief-boosters { margin: 0 0 10px; }

.chip {
  background: var(--panel2);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition:
    background var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    transform var(--dur-fast) ease,
    box-shadow var(--dur-normal) ease,
    filter var(--dur-normal) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  will-change: box-shadow, background, border-color, transform;
}
.chip .ico-svg { display: inline-flex; line-height: 1; }
.chip .ico-svg svg { width: 14px; height: 14px; }
.chip .ico-heart { color: var(--danger); }
.chip-btn svg { width: 14px; height: 14px; }

.chip-btn {
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  width: auto;
  margin: 0;
  border: 0;
  padding: 8px 14px;
  will-change: box-shadow, transform, background;
}

.chip-btn[hidden] {
  display: none;
}

.chip-btn:hover:not(:disabled) {
  background: var(--panel3);
  border-color: var(--accent-bright);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.chip-btn:active:not(:disabled) {
  transform: scale(0.92);
  box-shadow:
    var(--shadow-xs),
    var(--shadow-inset);
}

.chip-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 999px;
}

.chip.pulse {
  animation: chip-pop var(--dur-slow) var(--ease-bounce);
  will-change: transform, background, box-shadow;
}

@keyframes chip-pop {
  0% {
    transform: scale(0.9);
    box-shadow: var(--shadow-xs), 0 0 12px rgba(212, 175, 55, 0.12), 0 0 20px var(--glow-violet), var(--shadow-inset);
    filter: brightness(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.28);
    background: var(--panel3);
    box-shadow:
      0 0 32px var(--glow-gold-bright),
      0 0 56px var(--glow-violet-bright),
      var(--shadow-sm);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-xs), 0 0 12px rgba(212, 175, 55, 0.12), 0 0 20px var(--glow-violet), var(--shadow-inset);
    filter: brightness(1);
    opacity: 1;
  }
}

/* Célébration des cascades : bandeau premium avec spring bounce spectaculaire */
.celebrate {
  position: absolute;
  inset-inline: 0;
  top: 28%;
  text-align: center;
  pointer-events: none;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--accent-bright);
  text-shadow:
    0 4px 18px rgba(0, 0, 0, 0.6),
    0 0 32px var(--glow-gold-bright),
    0 0 48px var(--glow-violet);
  opacity: 0;
  will-change: transform, opacity, text-shadow;
}

.celebrate.show {
  animation: celebrate-pop var(--dur-slow) var(--ease-bounce) both;
}

@keyframes celebrate-pop {
  0% {
    opacity: 0;
    transform: scale(0.25) rotate(-15deg) translateY(24px);
    text-shadow:
      0 0 0 rgba(0, 0, 0, 0),
      0 0 0 rgba(212, 175, 55, 0),
      0 0 0 rgba(168, 121, 255, 0);
    filter: blur(3px);
  }
  15% {
    opacity: 1;
    filter: blur(0);
  }
  25% {
    opacity: 1;
    transform: scale(1.35) rotate(4deg) translateY(-4px);
    text-shadow:
      0 6px 24px rgba(0, 0, 0, 0.7),
      0 0 48px var(--glow-gold-bright),
      0 0 72px var(--glow-violet-bright);
  }
  45% {
    transform: scale(1.05) rotate(-1deg) translateY(0);
    text-shadow:
      0 4px 20px rgba(0, 0, 0, 0.6),
      0 0 40px var(--glow-gold-bright),
      0 0 56px var(--glow-violet);
  }
  85% {
    opacity: 0.8;
    transform: scale(1.02) translateY(-20px);
  }
  100% {
    opacity: 0;
    transform: scale(0.95) translateY(-32px) rotate(8deg);
    text-shadow:
      0 0 0 rgba(0, 0, 0, 0),
      0 0 0 rgba(212, 175, 55, 0),
      0 0 0 rgba(168, 121, 255, 0);
    filter: blur(3px);
  }
}

/* Toast : notifications brèves — dock bas avec safe-area iOS, aplat cartoon
   (vague 2 — remplace le fond verre dépoli + glow). */
.toast {
  position: fixed;
  inset-inline: 0;
  bottom: max(18px, calc(18px + env(safe-area-inset-bottom)));
  margin-inline: auto;
  width: max-content;
  max-width: 88vw;
  z-index: 9;
  background: var(--panel2);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0;
  transform: translateY(12px) scale(0.92);
  transition:
    opacity var(--dur-normal) ease-out,
    transform var(--dur-normal) ease-out;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
  will-change: transform, opacity;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- OVERLAYS — modale backdrop cartoon flat (pivot vague 1/2, zéro
   glassmorphism : scrim uni, zéro flou) ---- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--cb-overlay-bg, rgba(10, 8, 20, 0.74));
  backdrop-filter: var(--cb-overlay-blur, none);
  -webkit-backdrop-filter: var(--cb-overlay-blur, none);
  z-index: 5;
  padding: max(12px, env(safe-area-inset-top, 12px))
           max(12px, env(safe-area-inset-right, 12px))
           max(12px, env(safe-area-inset-bottom, 12px))
           max(12px, env(safe-area-inset-left, 12px));
  animation: overlay-in var(--dur-fast) ease forwards;
}

html[data-theme="light"] .overlay {
  background: rgba(42, 31, 69, 0.5);
}

.overlay.show,
.overlay.leaving {
  display: flex;
}

/* Sortie animée (retour porteur 2026-09-13, gate P0 point 4 : « pas de coupe
   sèche » entre les écrans) : `hideAllOverlays()`/`show(el,false)` (src/game.js)
   ajoutent cette classe au lieu de retirer `.show` d'un coup — l'écran quitté
   s'estompe PENDANT que le suivant apparaît par-dessus (`z-index` sous le défaut,
   `pointer-events:none` pour ne jamais voler un clic au nouvel écran), au lieu de
   disparaître au frame suivant. `prefers-reduced-motion` écrase déjà toutes les
   `animation-duration` à 0.01ms plus bas dans ce fichier. */
.overlay.leaving {
  z-index: 4;
  pointer-events: none;
  animation: overlay-out var(--dur-fast) ease forwards;
}

.overlay.leaving .card {
  animation: card-out var(--dur-fast) ease forwards;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlay-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes card-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-10px) scale(0.94); }
}

.overlay .card {
  background: var(--cb-glass-bg, var(--panel2));
  border: var(--toon-outline-w) solid var(--accent);
  border-radius: var(--radius-xl);
  padding: var(--cb-pad-lg, 24px) var(--cb-pad-md, 20px);
  width: min(380px, 92vw);
  /* 88vh sur-estime la zone visible mobile (la barre d'adresse mange du vh) et ignore
     le padding safe-area de .overlay : la carte peut déborder et cacher ses boutons
     du bas. dvh = hauteur de viewport dynamique (tient compte de la barre mobile),
     avec repli vh pour les vieux navigateurs ; on retranche le padding vertical réel
     de .overlay (safe-area haut+bas, min 24px au total) pour que la carte tienne
     toujours dans la zone visible. */
  max-height: 88vh;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: card-in var(--dur-normal) var(--ease-bounce) both;
  position: relative;
  will-change: transform, opacity;
  /* Firefox : belle scrollbar fine, pas celle du système */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 65%, transparent) transparent;
}

/* WebKit/Chromium : scrollbar fine, pouce verre-dépoli/or de la charte, PAS la scrollbar système */
.overlay .card::-webkit-scrollbar {
  width: 9px;
}
.overlay .card::-webkit-scrollbar-track {
  background: transparent;
}
.overlay .card::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 65%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.overlay .card::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent-bright) 80%, transparent);
  background-clip: padding-box;
}
.overlay .card::-webkit-scrollbar-corner {
  background: transparent;
}

/* Vague 2 : plus de sheen radial (glassmorphism) sur la carte — l'aplat +
   le contour net (--toon-outline-w) suffisent à la lire, cf. `.overlay .card`. */

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.92) rotateX(8deg);
    filter: blur(1px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0);
    filter: none;
  }
}

.overlay h2 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}

.overlay .big {
  font-size: 48px;
  font-weight: 900;
  color: var(--accent-bright);
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
  /* Contour cartoon net (vague 2) au lieu du halo flouté : liseré sombre
     façon étiquette BD, cohérent avec le reste du pivot. --toon-outline-ink
     (C7) : toujours sombre, ce liseré encre le texte lui-même, pas un contour
     de panneau — doit rester lisible dans les deux thèmes. */
  text-shadow:
    -1px -1px 0 var(--toon-outline-ink),
    1px -1px 0 var(--toon-outline-ink),
    -1px 1px 0 var(--toon-outline-ink),
    1px 1px 0 var(--toon-outline-ink);
}
.overlay .big.icon-broken-heart {
  display: flex;
  justify-content: center;
  color: var(--danger);
  text-shadow: none;
}
.overlay .big.icon-broken-heart svg { width: 48px; height: 48px; }

.overlay .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.logo {
  font-weight: 900;
  letter-spacing: 5px;
  font-size: 38px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 24px var(--glow-gold-bright),
    0 0 40px var(--glow-violet);
  animation: logo-glow 3s ease-in-out infinite;
  will-change: text-shadow;
}

@keyframes logo-glow {
  0%, 100% {
    text-shadow:
      0 4px 12px rgba(0, 0, 0, 0.3),
      0 0 24px var(--glow-gold-bright),
      0 0 40px var(--glow-violet);
  }
  50% {
    text-shadow:
      0 4px 12px rgba(0, 0, 0, 0.3),
      0 0 36px var(--glow-gold-bright),
      0 0 56px var(--glow-violet-bright);
  }
}

.card.home .stats {
  display: flex;
  gap: 8px;
  margin: 14px 0 8px;
}

.lives-line {
  margin-bottom: 10px;
  font-size: 13px;
}

/* Le CHAPITRE — la seule ligne qui dise où l'on en est dans les 405 niveaux.
   Discrète au-dessus du titre : elle situe, elle ne crie pas. */
.brief-chapter {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 4px;
}
.brief-chapter:empty { display: none; }

/* ---- BOUTONS — système cohérent avec transitions premium ---- */
button {
  border: 0;
  border-radius: var(--radius-md);
  padding: var(--cb-pad-md, 13px) var(--cb-pad-md, 15px);
  font-size: var(--cb-text-lg, 15px);
  font-weight: var(--cb-font-bold, 800);
  width: 100%;
  cursor: pointer;
  margin-top: var(--cb-gap-lg, 9px);
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: var(--cb-letter-spacing-caps, 0.02em);
  transition:
    transform var(--dur-fast) ease,
    box-shadow var(--dur-normal) ease,
    filter var(--dur-normal) ease,
    opacity var(--dur-normal) ease,
    background var(--dur-normal) ease,
    color var(--dur-normal) ease;
  position: relative;
  overflow: hidden;
}

button:active:not(:disabled) {
  transform: scale(var(--cb-active-scale, 0.96));
}

button:disabled {
  opacity: var(--cb-disabled-opacity, 0.45);
  cursor: var(--cb-disabled-cursor, default);
}

button:focus-visible {
  outline: var(--cb-focus-ring, 2px solid var(--accent));
  outline-offset: var(--cb-focus-offset, 2px);
  box-shadow:
    var(--cb-focus-shadow, 0 0 0 6px rgba(255, 193, 7, 0.20));
}

/* Primaire : accent or avec effet verre, ombre dorée premium spectaculaire */
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  font-weight: var(--cb-font-bold, 800);
  text-shadow: none;
  position: relative;
  overflow: hidden;
  will-change: box-shadow, filter, transform;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.btn-primary:active:not(:disabled) {
  box-shadow: var(--shadow-xs);
  transform: scale(0.95) translateY(-1px);
}

/* Secondaire / fantôme : aplat uni + contour net (cartoon flat, vague 2 —
   remplace le fond verre dépoli + glow). */
.btn-ghost {
  background: var(--panel2);
  color: var(--ink);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  position: relative;
  will-change: box-shadow, background, border-color, transform;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--panel3);
  border-color: var(--accent-bright);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.btn-ghost:active:not(:disabled) {
  background: var(--panel3);
  transform: scale(0.97);
}

.btn-ghost small {
  display: block;
  font-weight: 600;
  opacity: 0.75;
  font-size: 11px;
  margin-top: 2px;
}

/* Bouton pub récompensée : aplat bleu-violet uni + contour net (cartoon
   flat, vague 2 — remplace le dégradé + glow spectaculaire). */
.btn-rewarded {
  background: #6f8dff;
  color: #fff;
  box-shadow: var(--shadow-sm);
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  font-weight: 800;
  position: relative;
  overflow: hidden;
  will-change: box-shadow, filter, transform;
}

.btn-rewarded:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.btn-rewarded:active:not(:disabled) {
  box-shadow: var(--shadow-xs);
  transform: scale(0.96);
}

.btn-rewarded small {
  display: block;
  font-weight: 600;
  opacity: 0.9;
  font-size: 11px;
  margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
}

.row > button {
  margin-top: 0;
  width: auto;
  flex: 1 1 0;
}

.row > input {
  flex: 2 1 0;
  min-width: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* ---- CHAMPS DE SAISIE — inputs avec focus visible ---- */
.field {
  text-align: start;
  margin: 12px 0 4px;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  background: var(--field);
  border: var(--toon-outline-w) solid var(--toon-outline);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: var(--cb-pad-sm, 12px) var(--cb-pad-sm, 13px);
  font-size: var(--cb-text-lg, 15px);
  font-family: inherit;
  font-weight: var(--cb-font-bold, 700);
  transition:
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease,
    background var(--dur-normal) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  will-change: border-color, box-shadow, background;
}

input::placeholder {
  color: var(--muted);
  font-weight: var(--cb-font-semibold, 600);
  opacity: 0.75;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--field);
  box-shadow:
    var(--shadow-sm),
    0 0 0 3px rgba(212, 175, 55, 0.25);
  transition: box-shadow var(--dur-normal) ease;
}

input:focus-visible,
select:focus-visible {
  outline: none;
}

/* ---- ÉTOILES — éclosent une par une, ombre dorée premium spectaculaire ---- */
.stars {
  font-size: 36px;
  letter-spacing: 8px;
  margin: 8px 0 4px;
  display: flex;
  justify-content: center;
  gap: 2px;
  will-change: transform;
}

.stars .off {
  opacity: 0.18;
  filter: grayscale(0.8);
}

.stars .lit {
  display: inline-block;
  color: var(--accent-bright);
  text-shadow:
    0 0 24px rgba(240, 202, 92, 0.9),
    0 0 48px var(--glow-gold-bright),
    0 0 64px var(--glow-violet);
  animation: star-pop var(--dur-slow) var(--ease-bounce) both;
  filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.5));
  will-change: transform, opacity;
}

@keyframes star-pop {
  0% {
    transform: scale(0.08) rotate(-45deg) translateY(12px);
    opacity: 0;
    filter: blur(1px);
    text-shadow:
      0 0 0 rgba(240, 202, 92, 0),
      0 0 0 rgba(212, 175, 55, 0),
      0 0 0 rgba(168, 121, 255, 0);
  }
  30% {
    opacity: 1;
    filter: blur(0);
  }
  50% {
    transform: scale(1.68) rotate(8deg) translateY(-2px);
    text-shadow:
      0 0 40px rgba(240, 202, 92, 1),
      0 0 80px var(--glow-gold-bright),
      0 0 120px var(--glow-violet-bright);
  }
  75% {
    transform: scale(0.98) rotate(-2deg) translateY(0);
    text-shadow:
      0 0 30px rgba(240, 202, 92, 0.85),
      0 0 60px var(--glow-gold-bright),
      0 0 80px var(--glow-violet);
  }
  100% {
    transform: scale(1) rotate(0) translateY(0);
    opacity: 1;
    text-shadow:
      0 0 24px rgba(240, 202, 92, 0.9),
      0 0 48px var(--glow-gold-bright),
      0 0 64px var(--glow-violet);
  }
}

/* ---- LISTE D'OBJECTIFS — briefing avant le niveau ---- */
.goal-list {
  list-style: none;
  margin: 8px 0 6px;
  padding: 0;
  text-align: start;
}

.goal-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel2);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 700;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
  box-shadow: var(--shadow-xs);
}

.goal-list li:hover {
  background: var(--panel3);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px);
}

.goal-list .gem {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  flex: 0 0 auto;
}

/* ---- CLASSEMENT ENTRE AMIS — tabs + leaderboard ---- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 8px;
}

.tab {
  flex: 1;
  background: var(--panel2);
  color: var(--muted);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 800;
  margin: 0;
  cursor: pointer;
  transition:
    background var(--dur-normal) ease,
    color var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease,
    transform var(--dur-fast) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  position: relative;
  will-change: box-shadow, background, border-color, transform;
}

.tab:hover:not(.on) {
  background: var(--panel3);
  border-color: var(--toon-outline-light);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.tab.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--toon-outline-ink);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.group-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.group-bar .pill {
  background: var(--panel2);
  color: var(--muted);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  width: auto;
  margin: 0;
  cursor: pointer;
  transition:
    background var(--dur-normal) ease,
    color var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
}

.group-bar .pill:hover:not(.on) {
  background: var(--panel3);
  border-color: var(--toon-outline-light);
}

.group-bar .pill.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--toon-outline-ink);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.lb {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 34vh;
  overflow-y: auto;
  text-align: start;
}

.lb li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition:
    background var(--dur-normal) ease,
    transform var(--dur-fast) ease,
    box-shadow var(--dur-normal) ease,
    border-color var(--dur-normal) ease;
  border: var(--toon-outline-w) solid transparent;
  box-shadow: none;
  will-change: box-shadow, transform, background;
}

.lb li:nth-child(odd) {
  background: var(--panel2);
  border-color: var(--toon-outline);
}

.lb li:nth-child(even) {
  background: var(--panel);
}

.lb li:hover:not(.me) {
  background: var(--panel3);
  border-color: var(--toon-outline-light);
  box-shadow: var(--shadow-xs);
  transform: translateX(3px);
}

.lb li.me {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  border-color: var(--toon-outline-ink);
  position: relative;
}

.lb .rank {
  width: 22px;
  color: var(--muted);
  font-weight: 800;
}

.lb li.me .rank {
  color: var(--accent-ink);
}

.lb .who {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb .pts {
  font-weight: 800;
}

.lb .empty {
  color: var(--muted);
  font-size: 13px;
  padding: 22px 9px;
  text-align: center;
}

/* ---- BOUTIQUE — lignes de produits IAP ---- */
.shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: start;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    background 0.18s ease;
  border-radius: 8px;
  margin: -2px 0;
  padding: 12px 8px;
}

.shop-row:hover {
  background: rgba(36, 31, 63, 0.4);
  transform: translateX(2px);
}

.shop-info {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
}

.shop-info small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}

.shop-row button {
  width: auto;
  margin: 0;
  padding: 10px 14px;
  font-size: 14px;
  white-space: nowrap;
}

/* ---- TUTORIEL — gemmes spéciales et leurs combos ---- */
.tuto-list {
  list-style: none;
  margin: 8px 0 6px;
  padding: 0;
  text-align: start;
}

.tuto-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--panel2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 7px;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
  box-shadow: var(--shadow-xs);
}

.tuto-row:hover {
  background: var(--panel3);
  border-color: var(--toon-outline-light);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px);
}

.tuto-pair {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.tuto-ico {
  display: block;
  border-radius: 10px;
}

.tuto-info {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
}

.tuto-info small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.35;
}

.tuto-head {
  margin: 16px 0 2px;
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ---- BOOSTER CHIP — gemme offerte avec glow premium continu spectaculaire ---- */
.chip-btn.booster {
  animation: booster-glow 2.6s var(--ease-in-out) infinite;
  position: relative;
  overflow: hidden;
  background: var(--panel2);
  border-color: rgba(212, 175, 55, 0.3);
}

.chip-btn.booster:disabled {
  animation: none;
  opacity: 0.45;
}

.chip-btn.booster:hover:not(:disabled) {
  background: var(--panel3);
  border-color: rgba(212, 175, 55, 0.4);
}

@keyframes booster-glow {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(212, 175, 55, 0),
      0 0 0 0 rgba(168, 121, 255, 0),
      var(--shadow-xs),
      var(--shadow-inset);
  }
  50% {
    box-shadow:
      0 0 20px 4px var(--glow-gold-bright),
      0 0 32px 6px var(--glow-violet-bright),
      var(--shadow-sm),
      var(--shadow-inset);
  }
}

/* ---- RÉGLAGES — interrupteurs toggle premium ---- */
.switches {
  margin: 6px 0;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--grid);
  text-align: start;
  transition: background 0.18s ease;
}

.switch-info {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
}

.switch-info small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}

/* Toggle switch premium avec animation fluide */
.switch {
  flex: 0 0 auto;
  width: 54px;
  height: 32px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(58, 50, 85, 0.7), rgba(50, 43, 75, 0.6));
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  transition:
    background var(--dur-normal) ease,
    border-color var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease;
  cursor: pointer;
  box-shadow:
    var(--shadow-xs),
    0 0 10px rgba(212, 175, 55, 0.06),
    var(--shadow-inset);
  backdrop-filter: none;
  will-change: box-shadow, background, border-color;
}

.switch:hover:not(.on) {
  background: linear-gradient(135deg, rgba(58, 50, 85, 0.85), rgba(50, 43, 75, 0.75));
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    var(--shadow-sm),
    0 0 12px rgba(212, 175, 55, 0.08),
    var(--shadow-inset);
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--muted);
  transition:
    transform var(--dur-normal) var(--ease-bounce),
    background var(--dur-normal) ease,
    box-shadow var(--dur-normal) ease;
  box-shadow:
    var(--shadow-xs),
    0 0 6px rgba(0, 0, 0, 0.2);
  will-change: transform;
}

.switch.on {
  background: linear-gradient(135deg, var(--accent), #c5a028);
  border-color: rgba(244, 223, 166, 0.5);
  box-shadow:
    0 0 24px var(--glow-gold-bright),
    0 0 40px var(--glow-violet),
    var(--shadow-sm),
    var(--shadow-inset);
}

.switch.on::after {
  transform: translateX(22px);
  background: var(--accent-ink);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.4),
    0 0 10px rgba(212, 175, 55, 0.2);
}

[dir="rtl"] .switch.on::after {
  transform: translateX(-22px);
  inset-inline-start: auto;
  inset-inline-end: 3px;
}

/* RTL Layout & Direction Flips */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] header {
  flex-direction: row-reverse;
}

[dir="rtl"] .hchips {
  flex-direction: row-reverse;
}

[dir="rtl"] .toolbar {
  flex-direction: row-reverse;
}

[dir="rtl"] .goal {
  flex-direction: row-reverse;
}

[dir="rtl"] .goal .txt {
  text-align: right;
}

[dir="rtl"] .actions {
  justify-content: flex-start;
}

[dir="rtl"] .goal-list li,
[dir="rtl"] .tuto-row {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .recap li {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .recap .bar {
  inset-inline-start: auto;
  inset-inline-end: 0;
  border-radius: 3px 0 0 3px;
}

[dir="rtl"] .lb li {
  flex-direction: row-reverse;
  text-align: right;
}

.legal {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.legal a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  transition: color 0.18s ease;
}

.legal a:hover {
  color: var(--accent-bright);
}

.credits {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.version {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ---- ÉCRAN DE FIN — victoire/défaite avec animations premium ---- */
/* Confettis HTML5 canvas par-dessus tout, déclenchés par game.js */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.confetti.show {
  opacity: 1;
}

/* Écran victoire/défaite : aplat cartoon (vague 2 — remplace le halo doré
   flouté + l'ombre à inset par un contour net + ombre sticker plate). */
.card.result {
  position: relative;
  overflow: hidden;
  border-color: var(--accent);
  box-shadow: var(--shadow);
  animation: result-in var(--dur-slow) cubic-bezier(0.2, 1.5, 0.5, 1) both;
  will-change: transform, opacity;
}

.card.result.lost {
  border-color: var(--danger);
  box-shadow: var(--shadow);
  /* Échec = pas de zoom/rebond festif (ça reste `result-in` pour la victoire) :
     une secousse sobre qui s'amortit, puis un simple fondu. Retour porteur
     2026-09-10 : « un shake sobre + fondu pour un échec ». */
  animation: result-in-lose 0.45s ease-out both;
}

@keyframes result-in-lose {
  0%   { transform: translateX(0); opacity: 0; }
  15%  { transform: translateX(-9px); opacity: 0.7; }
  35%  { transform: translateX(7px); opacity: 0.9; }
  55%  { transform: translateX(-4px); opacity: 1; }
  75%  { transform: translateX(2px); }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes result-in {
  0% {
    transform: scale(0.72) translateY(24px) rotateX(15deg);
    opacity: 0;
    filter: blur(2px);
  }
  60% {
    transform: scale(1.02) translateY(-2px) rotateX(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0) rotateX(0);
    opacity: 1;
    filter: none;
  }
}

/* Ruban tournant : sunburst cartoon (aplats alternés, vague 2 — remplace le
   rayonnement conic flouté/translucide par des rayons pleins nets, façon
   éclat de bande dessinée derrière un badge). */
.card.result .ribbon {
  position: absolute;
  top: -140px;
  inset-inline-start: 50%;
  width: 420px;
  height: 420px;
  margin-inline-start: -210px;
  pointer-events: none;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(212, 175, 55, 0.16) 0deg 15deg,
    transparent 15deg 30deg
  );
  animation: ribbon-spin 16s linear infinite;
}

@keyframes ribbon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.card.result > * {
  position: relative;
}

.overlay .big.count {
  text-shadow:
    -1px -1px 0 var(--toon-outline-ink),
    1px -1px 0 var(--toon-outline-ink),
    -1px 1px 0 var(--toon-outline-ink),
    1px 1px 0 var(--toon-outline-ink);
}

/* ---- SUGAR RUSH — bandeau bonus, aplat cartoon (vague 2 — remplace le
   dégradé + le glow + le reflet animé) ---- */
.rush {
  margin: 12px 0 6px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: #fff;
  background: #7d4fd6;
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  animation: rush-in var(--dur-slow) var(--ease-bounce) both;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  will-change: transform, opacity;
}

.rush[hidden] {
  display: none;
}

.rush .rush-title {
  display: block;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 16px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.rush small {
  display: block;
  color: #ffe9c4;
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
  position: relative;
  z-index: 1;
  opacity: 0.95;
}

.rush b {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  color: #f4dfa6;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes rush-in {
  0% {
    transform: scale(0.5) rotate(-8deg) translateY(-12px);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotate(1deg) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0) translateY(0);
    opacity: 1;
  }
}

/* ---- RÉCAPITULATIF — objectifs atteints et barres de progression ---- */
.recap-head {
  margin: 14px 0 4px;
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}

.recap {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: start;
}

.recap li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel2);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px 13px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  box-shadow: var(--shadow-xs);
}

.recap li:hover:not(.done) {
  background: var(--panel3);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.recap li.done {
  color: var(--accent-bright);
  background: var(--panel3);
}

.recap li.done::after {
  content: '✓';
  font-weight: 900;
  margin-inline-start: 2px;
}

.recap .what {
  flex: 1;
  min-width: 0;
}

.recap b {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.recap .bar {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  height: 3px;
  width: var(--k);
  background: var(--muted);
  border-radius: 0 3px 3px 0;
  transition: width 0.18s ease, background 0.18s ease;
}

.recap li.done .bar {
  background: var(--accent);
}

/* ---- RÉCOMPENSE QUOTIDIENNE — calendrier 7 jours (src/meta.js) ---- */
.daily-list {
  list-style: none;
  margin: 10px 0 4px;
  padding: 0;
  text-align: start;
}

.daily-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  background: var(--panel2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  box-shadow: var(--shadow-xs);
}

.daily-list li.done {
  color: var(--muted);
  background: var(--panel3);
}

.daily-list li.done .daily-day::before {
  content: '✓ ';
  color: var(--accent-bright);
  font-weight: 900;
}

.daily-list li.current {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.daily-list li.locked {
  opacity: 0.55;
}

.daily-reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.daily-hearts {
  display: inline-flex;
  gap: 2px;
}

.daily-hearts .ico-heart {
  color: var(--danger);
}

.daily-hearts .ico-svg svg {
  width: 12px;
  height: 12px;
  display: block;
}

[dir="rtl"] .daily-list li {
  flex-direction: row-reverse;
  text-align: right;
}

/* Bouton d'accueil : glow "prêt" tant qu'un jour est réclamable — même
   animation que la gemme offerte (.chip-btn.booster), pour rester cohérent
   avec le seul autre indicateur "quelque chose de gratuit t'attend". */
.btn-rewarded#btn-daily.ready {
  animation: booster-glow 2.6s var(--ease-in-out) infinite;
}

/* ---- SUCCÈS — collection de badges long terme (src/achievements.js) ---- */
.achv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 4px;
  padding: 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}

.achv-grid li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--panel2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  box-shadow: var(--shadow-xs);
  transition: opacity 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.achv-icon {
  display: inline-flex;
  line-height: 1;
  color: var(--ink);
}

.achv-icon svg {
  width: 26px;
  height: 26px;
}

.achv-name {
  font-size: 10.5px;
  font-weight: 700;
}

.achv-grid li.locked {
  opacity: 0.45;
  filter: grayscale(1);
}

.achv-grid li.unlocked {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.achv-grid li.unlocked .achv-icon {
  color: var(--accent-bright);
}

/* ---- CARTE DES NIVEAUX — chemin visuel façon Candy Crush (src/levelmap.js,
   positions/tracé posés par game.js:renderMap()) ---- */
.overlay .map-card {
  width: min(340px, 92vw);
}

.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 10px;
}

.map-chapter {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-scroll {
  max-height: 54vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 14px;
  /* Repli 100% uni tant que le fond kawaii du chapitre consulté n'est pas
     chargé (renderMap() pose `background-image` en inline dès qu'il l'est) —
     cf §P0 GATE DISTRIBUTION point 5. */
  background: var(--panel3);
  background-size: cover;
  background-position: center;
  padding: 18px 0;
}

.map-track {
  position: relative;
  z-index: 1;
  width: 78%;
  margin: 0 auto;
}

.map-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-line path {
  fill: none;
  stroke: rgba(212, 175, 55, 0.35);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1 11;
}

.map-nodes {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

.map-nodes .node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel2);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.map-nodes .node:active:not(.locked) {
  transform: translate(-50%, -50%) scale(0.9);
}

/* Focus clavier — même patron doré que le reste de l'UI (a/button/input/
   select:focus-visible ci-dessous), posé séparément car .node est un
   <li role="button">, jamais couvert par ce sélecteur générique. */
.map-nodes .node:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: var(--shadow-xs), 0 0 0 4px rgba(212, 175, 55, 0.25);
}

.node-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.node-stars {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--accent-bright);
  line-height: 1;
  margin-top: 2px;
}

.node-lock {
  display: inline-flex;
  opacity: 0.8;
  color: var(--ink);
}

.node-lock svg {
  width: 18px;
  height: 18px;
}

.map-nodes .node.locked {
  opacity: 0.45;
  filter: grayscale(1);
  cursor: default;
}

.map-nodes .node.done {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.map-nodes .node.current {
  border-color: var(--accent-bright);
  animation: booster-glow 2.6s var(--ease-in-out) infinite;
  z-index: 6;                 /* la pastille « Jouer » passe au-dessus des voisins */
}

/* Pastille d'appel à l'action « ▶ Jouer » ancrée au niveau courant (retour
   porteur 2026-09-13 : rendre évident qu'on TOUCHE le niveau pour jouer). */
.node-cta {
  position: absolute;
  bottom: calc(100% + 11px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--accent-bright);
  color: #1b1226;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  animation: cta-bounce 1.15s var(--ease-in-out) infinite;
}
.node-cta svg { width: 13px; height: 13px; stroke: #1b1226; fill: #1b1226; }
.node-cta::after {           /* petit triangle qui pointe vers le niveau */
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent-bright);
}
@keyframes cta-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .node-cta { animation: none; }
}

.map-nodes .node.current .node-num {
  color: var(--accent-bright);
}

.node-hand {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid var(--accent-bright);
  color: var(--accent-bright);
  box-shadow: var(--shadow-xs);
}

.node-hand svg {
  width: 10px;
  height: 10px;
}

/* ---- GEM INDICATORS — gelée (jelly), objectives visuels ---- */
.gem.jelly {
  background: #6fc8ff;
  border: 2px solid rgba(255, 255, 255, 0.7);
}

.piece-ico {
  background: transparent;
}

.goal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--panel3);
  font-size: 17px;
  font-weight: 900;
  flex: 0 0 auto;
  box-shadow: var(--shadow-xs);
}
.goal-chip svg { width: 18px; height: 18px; }

.goal-chip.score {
  color: var(--accent-bright);
}

.goal-chip.time {
  color: var(--accent-bright);
}

.goal-chip.jelly {
  color: var(--cyan);
}

/* ---- ACCESSIBILITÉ — focus keyboard rings cohérents & premium ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow:
    0 0 0 4px rgba(212, 175, 55, 0.25),
    inset 0 0 0 1px rgba(212, 175, 55, 0.5);
}

/* Touch device feedback (no hover, use active instead) */
@media (hover: none) and (pointer: coarse) {
  button:active:not(:disabled) {
    filter: brightness(1.05);
  }

  .chip-btn:active:not(:disabled),
  .tool-btn:active:not(:disabled) {
    filter: brightness(1.05) saturate(1.05);
  }
}

/* ---- SURVOL DESKTOP — micro-feedback sans tactile ---- */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-2px);
  }

  .btn-ghost:hover:not(:disabled) {
    background: rgba(45, 39, 82, 0.85);
    border-color: var(--accent-bright);
  }

  .btn-rewarded:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-2px);
  }

  .chip-btn:hover:not(:disabled) {
    background: rgba(30, 26, 48, 0.85);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
  }

  .lb li:hover:not(.me) {
    filter: brightness(1.08);
  }

  .card:hover {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(212, 175, 55, 0.08), var(--shadow-inset);
  }
}

/* ---- MOUVEMENT RÉDUIT — couper animations décoratives ---- */
@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;
  }

  .chip.pulse,
  .celebrate.show,
  .stars .lit,
  .card.result,
  .rush,
  .booster-glow {
    animation: none !important;
  }
}

/* ---- HIGH CONTRAST MODE — renforcer les contrastes pour accessibilité ---- */
@media (prefers-contrast: more) {
  :root {
    --ink: #ffffff;
    --muted: #c9bfe0;
    --accent: #e5c852;
  }

  button:focus-visible,
  input:focus-visible,
  select:focus-visible {
    outline-width: 3px;
  }
}

/* ---- RESPONSIVE — breakpoints mobile-first (360px, 480px, 680px, 1024px+) ---- */
@media (max-width: 380px) {
  #wrap {
    gap: 6px;
    padding: 8px;
  }
  .brand { font-size: 18px; letter-spacing: 2px; }
  .hud { gap: 6px; }
  .stat { padding: 8px 4px; }
  .stat .lbl { font-size: 8px; }
  .stat .val { font-size: 18px; }
  .goals { gap: 4px; }
  .goal { flex: 1 1 100%; font-size: 11px; padding: 6px 8px; }
  .toolbar { gap: 4px; }
  .tool-btn { padding: 6px 6px; }
  .tool-btn .tname { font-size: 9px; }
  .tool-btn .cost { font-size: 11px; }
  .overlay .card { width: min(320px, 90vw); padding: 20px 16px; }
  .overlay h2 { font-size: 20px; }
  .logo { font-size: 32px; letter-spacing: 3px; }
}

@media (max-width: 480px) and (orientation: landscape) {
  #wrap { gap: 4px; padding: 6px; }
  .brand { font-size: 18px; }
  .stat .val { font-size: 18px; }
}

@media (min-width: 681px) {
  .overlay .card { width: min(420px, 94vw); }
}

/* ============================================================================
   MODE CLAIR — variante CLAIRE de la teinte du jeu (pourpre / or).
   Le mode SOMBRE reste la scène profonde ; en CLAIR, les SURFACES passent en
   lavande clair et le TEXTE (tokens --ink/--muted, déjà foncés en clair) devient
   lisible : plus jamais de texte foncé sur fond foncé, ni clair sur clair.
   Bloc unique et centralisé = réutilisable tel quel sur toute la flotte.
   (Le fond du plateau canvas suit la même logique côté game.js : BOARD_THEMES
   vs BOARD_THEMES_LIGHT selon le thème résolu par _kit/theme.js.)
   Piloté par [data-theme="light"] (posé par _kit/theme.js, toujours résolu)
   plutôt que par @media (prefers-color-scheme), pour suivre le choix
   explicite du hub — cf commentaire au sommet du fichier.
   ========================================================================== */
html[data-theme="light"] .overlay .card,
html[data-theme="light"] .card.result {
  background: #f9f6ff;
  border-color: rgba(94, 74, 168, 0.18);
  box-shadow: var(--shadow);
}
html[data-theme="light"] .stat,
html[data-theme="light"] .btn-ghost,
html[data-theme="light"] .chip,
html[data-theme="light"] .tool-btn,
html[data-theme="light"] .wchip,
html[data-theme="light"] .goal,
html[data-theme="light"] .goal-list li,
html[data-theme="light"] .tuto-row,
html[data-theme="light"] .recap li,
html[data-theme="light"] .daily-list li,
html[data-theme="light"] .achv-grid li,
html[data-theme="light"] .map-nodes .node {
  background: #f3eeff;
  border-color: rgba(94, 74, 168, 0.18);
  color: var(--ink);
}
html[data-theme="light"] .goal-list li:hover,
html[data-theme="light"] .tuto-row:hover,
html[data-theme="light"] .recap li:hover:not(.done) {
  background: #e2d7f0;
  border-color: rgba(94, 74, 168, 0.25);
}
html[data-theme="light"] .board-wrap {
  background: #f0eafb;
  border-color: rgba(94, 74, 168, 0.16);
  box-shadow: var(--shadow-lg);
}
/* L'OR/VERT mode clair : saturés et foncés pour contraste AAA sur blanc/lavande. */
html[data-theme="light"] .stat .val,
html[data-theme="light"] .hud .val,
html[data-theme="light"] .wchip.earn {
  color: #996600;
  text-shadow: none;
}
html[data-theme="light"] .wchip.play { color: #1f7a4d; text-shadow: none; }
/* Champs et petites surfaces des overlays. */
html[data-theme="light"] input,
html[data-theme="light"] .switch,
html[data-theme="light"] .shop-row,
html[data-theme="light"] .tab,
html[data-theme="light"] .pill,
html[data-theme="light"] .group-bar,
html[data-theme="light"] .lb li {
  background: #f9f6ff;
  border-color: rgba(94, 74, 168, 0.16);
  color: var(--ink);
}
/* Boutons primaires en mode clair : or riche → contraste maximal (aplat uni,
   vague 2 — plus de dégradé). */
html[data-theme="light"] .btn-primary {
  background: #c5a028;
  color: #1a1628;
  border-color: rgba(212, 175, 55, 0.6);
}
html[data-theme="light"] .btn-primary:hover:not(:disabled) {
  background: #d4af37;
  filter: brightness(1) saturate(1);
}
/* Boutons fantôme et récompensés en mode clair (aplat uni). */
html[data-theme="light"] .btn-ghost {
  background: #f3eeff;
  border-color: rgba(94, 74, 168, 0.2);
}
html[data-theme="light"] .btn-ghost:hover:not(:disabled) {
  background: #e2d7f0;
  border-color: rgba(94, 74, 168, 0.25);
}
html[data-theme="light"] .btn-rewarded {
  background: #93a9ff;
  box-shadow: var(--shadow-sm);
}
html[data-theme="light"] .btn-rewarded:hover:not(:disabled) {
  filter: brightness(0.95) saturate(1.05);
}
/* Cartes de résultats avec meilleure visibilité (aplat uni). */
html[data-theme="light"] .card.result.lost {
  background: #f9e6e6;
  border-color: rgba(194, 39, 74, 0.25);
}
