/* ==================================================================
   frugio — style.css
   Identité « Sashiko » (voir DESIGN.md) : fil écru sur toile indigo,
   bordures cousues, Zen Maru Gothic (affichage) + Atkinson (corps).
   Sombre « toile » = défaut ; clair « lin » = inversion exacte.
   ================================================================== */

/* ---------------- Polices auto-hébergées (OFL) ---------------- */
@font-face {
  font-family: 'Zen Maru Gothic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../../assets/fonts/zenmaru-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../assets/fonts/atkinson-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../../assets/fonts/atkinson-400i.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../../assets/fonts/atkinson-700.woff2') format('woff2');
}

/* ---------------- Palette sashiko — sombre « toile » = DÉFAUT ------ */
:root {
  --bg: #17263b;             /* toile aizome */
  --surface: #1f3150;
  --surface-2: #24365a;
  --text: #ede4d3;           /* fil écru */
  --text-muted: #8fa3c2;
  --text-faint: #5e729a;
  --thread: #ede4d3;
  --accent: #ede4d3;
  --accent-ink: #17263b;
  --accent-soft: #2b4066;
  --garance: #d9573f;        /* LE rouge — un seul endroit par écran */
  --danger: var(--garance);
  --error: var(--garance);

  --board-bg: #17263b;
  --cell-bg: #1f3150;
  --cell-bg-alt: #223756;
  --grid-line: #2b4066;
  --grid-line-bold: #3a5178;
  --cell-ink: #ede4d3;
  --cell-thread: #d8cbb2;    /* fil intérieur du point cousu */
  --cell-mark: #7e92b5;
  --cell-hover: rgba(237, 228, 211, 0.07);
  --clue-ink: #8fa3c2;
  --clue-done: #3e547a;
  --clue-bg: #17263b;

  --gold: var(--garance);    /* alias hérité (flamme de streak) */

  --stitch: 1.5px dashed var(--text-faint);
  --stitch-strong: 1.5px dashed var(--text-muted);
  --shadow: none;
  --radius: 10px;
  --r: 6px;
  --spring: cubic-bezier(0.3, 1.6, 0.5, 1); /* easing « ressort » commun */
  --soft: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-display: 'Zen Maru Gothic', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  --font-data: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', monospace;

  --grid-paper: rgba(237, 228, 211, 0.035); /* trame du tissu */
}

/* Clair « lin naturel » automatique (système)… */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f2ede2;
    --surface: #faf7ef;
    --surface-2: #e9e2d2;
    --text: #24365a;
    --text-muted: #5e729a;
    --text-faint: #8fa3c2;
    --thread: #24365a;
    --accent: #24365a;
    --accent-ink: #f2ede2;
    --accent-soft: #e4dcc9;
    --garance: #c2452f;

    --board-bg: #f2ede2;
    --cell-bg: #faf7ef;
    --cell-bg-alt: #f2ecdd;
    --grid-line: #d8d0bf;
    --grid-line-bold: #b8ae97;
    --cell-ink: #24365a;
    --cell-thread: #45587e;
    --cell-mark: #5e729a;
    --cell-hover: rgba(36, 54, 90, 0.07);
    --clue-ink: #3e547a;
    --clue-done: #b8ae97;
    --clue-bg: #f2ede2;

    --grid-paper: rgba(36, 54, 90, 0.04);
  }
}

/* …et clair forcé par le réglage. */
:root[data-theme='light'] {
  --bg: #f2ede2;
  --surface: #faf7ef;
  --surface-2: #e9e2d2;
  --text: #24365a;
  --text-muted: #5e729a;
  --text-faint: #8fa3c2;
  --thread: #24365a;
  --accent: #24365a;
  --accent-ink: #f2ede2;
  --accent-soft: #e4dcc9;
  --garance: #c2452f;

  --board-bg: #f2ede2;
  --cell-bg: #faf7ef;
  --cell-bg-alt: #f2ecdd;
  --grid-line: #d8d0bf;
  --grid-line-bold: #b8ae97;
  --cell-ink: #24365a;
  --cell-thread: #45587e;
  --cell-mark: #5e729a;
  --cell-hover: rgba(36, 54, 90, 0.07);
  --clue-ink: #3e547a;
  --clue-done: #b8ae97;
  --clue-bg: #f2ede2;

  --grid-paper: rgba(36, 54, 90, 0.04);
}

/* ---------------- Base ---------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  /* La feuille de grille : quadrillage 24 px à ~3 % de contraste. */
  background-image:
    linear-gradient(var(--grid-paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-paper) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* ---------------- Écrans ---------------- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.screen.active { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 56px;
}
.topbar h2 {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13.5px;
}
.stat-errors { color: var(--error); }

.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------------- Boutons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: var(--r);
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:focus-visible { outline: 2px dashed var(--thread); outline-offset: 3px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--thread); border: 1.5px solid var(--thread); color: var(--accent-ink); }
.btn-primary:focus-visible { outline-color: var(--text-muted); }
.btn-ghost { background: transparent; border: var(--stitch-strong); color: var(--text); }
.btn-danger { background: transparent; color: var(--garance); min-height: 44px; }
.btn-big { width: 100%; font-size: 17px; min-height: 56px; margin-top: 18px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: var(--stitch);
  border-radius: var(--r);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  transition: transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------------- Accueil ---------------- */
.screen-home {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.home-inner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 2px;
}
.logo h1 {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.logo-px {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  grid-auto-rows: 12px;
  gap: 4px;
}
.logo-px i {
  border-radius: 2.5px; /* petits points cousus */
  background: var(--surface-2);
}
.logo-px i.on { background: var(--thread); }
.tagline {
  color: var(--text-muted);
  margin-bottom: 18px;
  text-align: center;
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}
.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  transition: transform 0.15s ease;
}
.card:active { transform: scale(0.97); }
.card-emoji { font-size: 26px; margin-bottom: 6px; }
.card-title { font-size: 17px; font-weight: 800; }
.card-sub { font-size: 13px; color: var(--text-muted); }
.card-resume {
  width: 100%;
  background: var(--accent-soft);
  flex-direction: column;
}
.card-resume .card-title { color: var(--accent); }

/* ---------------- Galerie ---------------- */
.gallery-section-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 22px 4px 10px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 12px;
}
.puzzle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border-radius: var(--radius);
  padding: 12px 8px 10px;
  transition: transform 0.15s ease;
  border: 1.5px dashed transparent;
}
.puzzle-card:active { transform: scale(0.95); }
.puzzle-card.solved { border-color: var(--text-faint); }
/* Chaque dessin vit tendu dans un tambour à broder (double cercle). */
.puzzle-card canvas {
  width: 58px;
  height: 58px;
  padding: 21px;
  border-radius: 50%;
  background: var(--cell-bg);
  box-shadow:
    inset 0 0 0 2px var(--text-faint),
    0 0 0 2.5px var(--text-muted);
  image-rendering: pixelated;
}
.puzzle-card .pz-name {
  font-size: 12px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.puzzle-card .pz-name.mystery { color: var(--text-muted); font-weight: 600; }
.puzzle-card .pz-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* ---------------- Illimité ---------------- */
.endless-setup { max-width: 480px; width: 100%; margin: 0 auto; }
.endless-setup h3 {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 22px 4px 10px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 46px;
  padding: 10px 20px;
  border: var(--stitch);
  border-radius: var(--r);
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
  transition: transform 0.12s ease;
}
.chip:active { transform: scale(0.95); }
.chip.active {
  background: var(--thread);
  border-color: var(--thread);
  color: var(--accent-ink);
}
.hint {
  margin: 18px 4px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------------- Jeu ---------------- */
#screen-game { background: var(--board-bg); }

.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 6px;
}
#board {
  position: absolute;
  inset: 0;
  touch-action: none; /* toute la gestuelle est gérée par le moteur */
  display: block;
}

.zoom-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0.92;
}
.zoom-controls .icon-btn {
  background: var(--surface);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: var(--stitch);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn:not(:disabled):active { transform: scale(0.92); }

/* Toggle ■ / ✕ — le contrôle central du mobile */
.tool-toggle {
  display: flex;
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--radius);
  padding: 5px;
  gap: 4px;
}
.tool-mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 54px;
  border-radius: var(--r);
  color: var(--cell-mark);
  transition: background 0.15s ease;
}
.tool-mode .pxi { width: 24px; height: 24px; }
.tool-mode.active { background: var(--accent-soft); color: var(--thread); }

/* ---------------- Modales ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 10, 16, 0.45);
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } }

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: var(--stitch);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  animation: slide-up 0.26s var(--soft);
}
@keyframes slide-up { from { transform: translateY(40px); opacity: 0.6; } }

@media (min-width: 560px) {
  .modal { align-items: center; }
  .modal-card { border: var(--stitch); border-radius: var(--radius); padding-bottom: 24px; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-head h2 { font-size: 20px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  font-weight: 600;
  font-size: 15px;
}

.seg {
  display: flex;
  background: transparent;
  border: var(--stitch);
  border-radius: var(--r);
  padding: 3px;
  gap: 2px;
}
.seg button {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
}
.seg button.active {
  background: var(--thread);
  color: var(--accent-ink);
}

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 999px; /* boucle de fil */
  border: var(--stitch);
  background: transparent;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex: none;
}
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.28s var(--spring), background 0.18s ease; /* glissement à ressort */
}
.switch[aria-checked='true'] { border-color: var(--thread); }
.switch[aria-checked='true'] i { transform: translateX(20px); background: var(--thread); }

#btn-reset-progress { margin-top: 14px; width: 100%; }

/* ---------------- Victoire ---------------- */
.modal-win-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.win-kicker {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 13px;
}
/* L'œuvre finale, tendue dans un tambour à broder (double cercle). */
#win-art {
  width: 150px;
  height: 150px;
  padding: 42px;
  image-rendering: pixelated;
  border-radius: 50%;
  background: var(--cell-bg);
  box-shadow:
    inset 0 0 0 2.5px var(--text-faint),
    0 0 0 3px var(--text-muted);
  animation: art-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes art-pop { from { transform: scale(0.7); opacity: 0; } }
#win-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: 0.5px; }
.win-stats { color: var(--text-muted); font-weight: 600; }
.win-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  width: 100%;
}
.win-actions .btn { flex: 1; }

/* ---------------- Voile de génération ---------------- */
.gen-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(4px);
  color: var(--text-muted);
  font-weight: 600;
}
/* Trois points qui se cousent en séquence, en douceur. */
.spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: transparent;
  box-shadow: -18px 0 0 var(--thread), 0 0 0 var(--surface-2), 18px 0 0 var(--surface-2);
  animation: px-seq 1s ease-in-out infinite;
}
@keyframes px-seq {
  0%, 100% { box-shadow: -18px 0 0 var(--thread), 0 0 0 var(--surface-2), 18px 0 0 var(--surface-2); }
  33%      { box-shadow: -18px 0 0 var(--surface-2), 0 0 0 var(--thread), 18px 0 0 var(--surface-2); }
  66%      { box-shadow: -18px 0 0 var(--surface-2), 0 0 0 var(--surface-2), 18px 0 0 var(--thread); }
}

/* ---------------- Tutoriel, indices, accessibilité ---------------- */

/* Masqué visuellement mais lu par les lecteurs d'écran. */
.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;
}

/* Focus clavier net sur le plateau. */
#board:focus-visible {
  outline: 2px dashed var(--thread);
  outline-offset: -3px;
}

.stat-hints { color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }

.tool-hint { font-size: 22px; }

/* Icônes pixel maison (sprite ../assets/icons.svg) — jamais d'emoji. */
.pxi { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; flex: none; }
.card-emoji { color: var(--accent); }
.daily-flame, .flame-ico, .win-streak .flame { color: var(--gold); }

/* Coach marks du tutoriel : carte fixe au-dessus de la barre d'outils. */
.coach {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 25;
  max-width: 440px;
  margin: 0 auto;
  background: var(--surface);
  border: 1.5px dashed var(--thread);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
  animation: coach-in 0.3s var(--spring);
}
@keyframes coach-in { from { transform: translateY(16px); opacity: 0; } }
.coach p { font-size: 14.5px; line-height: 1.45; font-weight: 600; }
.coach-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.coach-dots { display: flex; gap: 5px; }
.coach-dots i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface-2);
}
.coach-dots i.on { background: var(--thread); }
.coach .btn { min-height: 38px; padding: 7px 14px; font-size: 13px; }

.modal-tutorial-card { text-align: center; }

/* Première visite : la proposition est peinte dès le premier rendu (le
   drapeau est lu en inline dans <head>); main.js reprend la main à
   l'init en retirant la classe. Aucune animation d'entrée dans ce cas :
   le modal fait partie du premier rendu (stabilité du LCP). */
html.tut-offer #modal-tutorial { display: flex !important; animation: none; }
html.tut-offer #modal-tutorial .modal-card { animation: none; }
.tutorial-body { color: var(--text-muted); margin: 6px 0 14px; }
.btn-wide { width: 100%; margin-top: 12px; }

/* ---------------- Game feel ---------------- */

/* Bouton son compact dans la barre du jeu */
.icon-btn-sound {
  width: 40px;
  height: 40px;
  font-size: 17px;
  background: transparent;
}

/* Titre du dessin révélé, lettre par lettre, sous l'œuvre */
.reveal-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4%;
  text-align: center;
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  pointer-events: none;
}
.reveal-title span {
  display: inline-block;
  will-change: transform, opacity;
  white-space: pre;
}

/* Confettis : divs animées en transform/opacity uniquement */
.confetti-p {
  position: fixed;
  width: 9px;
  height: 13px;
  border-radius: 3px;
  z-index: 60;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Toast (« Partie sauvegardée ») */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 70;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 12px 20px;
  border: var(--stitch);
  border-radius: 999px; /* une boucle de fil */
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: transform 0.3s var(--spring), opacity 0.2s ease;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Streak sur la carte de fin */
.win-streak {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 800;
  font-size: 16px;
}
.win-streak .flame {
  display: inline-block;
  font-size: 20px;
  will-change: transform;
}
.win-stats #win-time { font-variant-numeric: tabular-nums; }

/* ---------------- Accueil : liens secondaires ---------------- */
.home-links { display: flex; gap: 10px; }
.about-link {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px;
}
.about-link:hover { color: var(--accent); }

/* Footer global (toutes les pages, exigence AdSense) : fils de liens. */
.game-footer, .site-footer-static {
  margin-top: 16px;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  font-size: 12.5px;
  line-height: 2.1;
  text-align: center;
  color: var(--text-faint);
}
.site-footer-static { max-width: 640px; margin: 0 auto; user-select: text; }
.game-footer a, .site-footer-static a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding: 2px 1px;
}
.game-footer a:hover, .site-footer-static a:hover { color: var(--thread); }

/* ---------------- Invite d'installation ---------------- */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 460px;
  margin: 0 auto;
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--radius);
  padding: 14px 14px 14px 18px;
  animation: banner-in 0.35s var(--spring);
}
@keyframes banner-in { from { transform: translateY(24px); opacity: 0; } }
.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--text-muted);
}
.install-text strong { font-size: 15px; color: var(--text); }
.install-actions { display: flex; align-items: center; gap: 6px; }
.install-actions .btn { min-height: 44px; padding: 10px 16px; }

/* ---------------- Stats ---------------- */
.stats-area { max-width: 480px; width: 100%; margin: 0 auto; }
.stat-card {
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
}
.stat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.stat-card-head strong { color: var(--text); font-size: 16px; font-family: var(--font-data); font-variant-numeric: tabular-nums; }

.daily-card { display: flex; align-items: center; gap: 14px; }
.daily-flame {
  font-size: 34px;
  line-height: 1;
  will-change: transform;
}
.daily-flame.off { filter: grayscale(1); opacity: 0.45; }
.daily-text { display: flex; flex-direction: column; gap: 2px; }
.daily-text strong { font-size: 18px; }
.daily-text span { font-size: 13px; color: var(--text-muted); }

.progress-track {
  height: 10px;
  border-radius: 999px; /* le fil court dans sa coulisse */
  background: var(--surface-2);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--thread);
  transform-origin: left center;
  transform: scaleX(0); /* animé en transform uniquement (60 fps) */
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.stats-section {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 22px 4px 0;
}
.stat-sizes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat-size-card {
  background: var(--surface);
  border: var(--stitch);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-size-card .sz { font-weight: 800; font-size: 15px; }
.stat-size-card .cnt { color: var(--accent); font-weight: 800; font-size: 20px; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.stat-size-card .bt { color: var(--text-muted); font-size: 12px; font-family: var(--font-data); font-variant-numeric: tabular-nums; }

.stat-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-mini { display: flex; flex-direction: column; gap: 4px; }
.stat-mini span { font-size: 13px; color: var(--text-muted); font-weight: 700; }
.stat-mini strong { font-size: 24px; font-family: var(--font-data); font-variant-numeric: tabular-nums; }

/* ---------------- Partager ---------------- */
.btn-share {
  width: 100%;
  gap: 8px;
  margin-top: 4px;
}
/* Sur la carte du Défi du jour, Partager devient l'action principale. */
.btn-share.btn-share-primary {
  background: var(--accent);
  color: var(--accent-ink);
  min-height: 56px;
  font-size: 16px;
}

/* ---------------- Défi du jour ---------------- */
.card-daily {
  width: 100%;
  border: 1.5px dashed var(--thread); /* le fil fort du CTA principal */
  position: relative;
}
.daily-kicker {
  display: flex;
  gap: 6px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 12px;
  margin-bottom: 2px;
}
.card-daily .card-sub {
  font-variant-numeric: tabular-nums;
}
.win-countdown {
  color: var(--text-muted);
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- Pages statiques (à propos) ---------------- */
.page-body {
  user-select: text;
  overflow-y: auto;
}
.prose {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 22px calc(48px + env(safe-area-inset-bottom));
  line-height: 1.65;
  font-size: 16px;
}
.prose h1 { font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: 0.3px; margin: 18px 0 14px; }
.prose h2 { font-size: 20px; margin: 28px 0 10px; }
.prose p { margin: 10px 0; }
.prose ul { margin: 10px 0 10px 22px; }
.prose li { margin: 6px 0; }
.prose a { color: var(--accent); font-weight: 600; }
.prose-back { font-size: 14px; }
.prose-back a { text-decoration: none; }
.prose-cta { margin-top: 30px; }
.prose-cta .btn { text-decoration: none; }

/* ---------------- Desktop ---------------- */
@media (min-width: 720px) {
  .topbar { padding: 12px 24px; }
  .scroll-area { padding-left: 24px; padding-right: 24px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .puzzle-card canvas { width: 72px; height: 72px; padding: 26px; }
  .board-wrap { margin: 0 24px; }
  .logo h1 { font-size: 54px; }
}

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