/* LITZ (Lights Out) — style kawaii sticker (standard FACETA, cf BACKLOG.md
   §PIVOT DESIGN / §PROGRAMME AUTONOME, vague 3 : 32/66, suite alphabétique
   après `linkz`). Override LOCAL à litz, chargé APRÈS /_kit/kit-design.css
   (même patron que faceta/mahzo/kakz/linkz) : contour épais net, aplats +
   une seule ombre PLATE (zéro flou), reflet kawaii en 2ᵉ couche de
   `background` (jamais en ::after après le contenu), panneaux en dégradé
   2 tons. Remplace l'ancien glassmorphism (backdrop-filter, ombres bokeh
   floutées, glow radial des cases). Les CHAPITRES (fond de plateau, accent
   de case allumée) gardent leur propre palette vive théme-invariante — comme
   le plateau canvas des autres jeux, c'est l'identité visuelle du contenu,
   pas le chrome — seul le HABILLAGE (header, chips, boutons, cartes,
   overlays, toast) reçoit le traitement kawaii complet. */

:root {
  --brand-gold: #ffc20e;
  --brand-gold-dark: #d9a300;

  --bg-primary: #0b0f16;
  --bg-secondary: #131a26;
  --text-primary: #f2f5fa;
  --text-secondary: #9aa8bd;
  --border: rgba(255, 255, 255, 0.14);

  --chapter-accent: var(--brand-gold);
  --chapter-accent2: #64b5f6;
  --chapter-bg1: #1c2436;
  --chapter-bg2: #0d1220;

  /* (C8) panneaux en dégradé 2 tons (matière), pas un aplat plat. */
  --panel: linear-gradient(160deg, #1c2436 0%, #0f1420 100%);
  --panel-2: linear-gradient(150deg, #222c42 0%, #141a28 100%);
  --field: linear-gradient(165deg, #171e2e 0%, #0c0f18 100%);

  /* Contour : --toon-outline ADAPTATIF (or clair sur fond sombre, encre foncée sur
     fond clair) pour panneaux/chips/cartes ; --toon-outline-ink TOUJOURS foncé, pour
     les éléments posés sur un fond vif (boutons pleins), lisible dans les
     deux thèmes (même leçon FACETA C7 / kakz / linkz). */
  --toon-outline: var(--brand-gold);
  --toon-outline-ink: #241a02;
  --toon-outline-w: 2.5px;
  --kawaii-sheen: radial-gradient(circle at 30% 26%, rgba(255, 255, 255, .32), rgba(255, 255, 255, 0) 48%);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark light;
}

html[data-theme="light"] {
  --bg-primary: #f4f6fb;
  --bg-secondary: #ffffff;
  --text-primary: #171a2b;
  --text-secondary: #5a6579;
  --border: rgba(10, 15, 25, 0.12);
  --panel: #ffffff;
  --panel-2: #fff6e0;
  --field: #fffaf0;
  --toon-outline: #a8710a;
  --toon-outline-ink: #a8710a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--cb-font-family, system-ui), -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.muted { color: var(--text-secondary); }

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(255, 194, 14, 0.10), transparent 60%),
              var(--bg-primary);
}

/* ---------- header / HUD ---------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  flex: 0 0 auto;
  z-index: 5;
}

.icon-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: var(--toon-outline-w) solid var(--toon-outline);
  background: var(--panel-2);
  color: var(--toon-outline);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 var(--toon-outline-ink);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s;
}
.icon-btn svg { width: 20px; height: 20px; display: block; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--toon-outline-ink); }

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand b { color: var(--toon-outline); }

.hud-chips {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--toon-outline);
  box-shadow: 0 3px 0 var(--toon-outline-ink);
}
.chip-ic { display: inline-flex; line-height: 1; }
.chip-ic svg { width: 16px; height: 16px; display: block; }
.chip-lives { border-color: color-mix(in srgb, #ff5d6c 55%, var(--toon-outline)); }
.chip-play { border-color: var(--toon-outline); }
.chip-earn { border-color: color-mix(in srgb, #7c4dff 55%, var(--toon-outline)); }

/* ---------- screens ---------- */
main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  opacity: 0;
}

.screen.active {
  display: flex;
  animation: screenIn 0.32s var(--ease-out);
  opacity: 1;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.glass-card {
  background: var(--kawaii-sheen), var(--panel);
  border: var(--toon-outline-w) solid var(--toon-outline);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 var(--toon-outline-ink);
}

.screen-title {
  margin: 4px 0 14px;
  font-size: 1.3rem;
  font-weight: 800;
}

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s;
  font-family: inherit;
}
.btn svg { width: 1.1em; height: 1.1em; display: inline-block; vertical-align: -0.2em; }
.btn:active { transform: translateY(3px); }

.btn-primary {
  background: var(--kawaii-sheen), linear-gradient(180deg, var(--brand-gold), var(--brand-gold-dark));
  color: #241a02;
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  box-shadow: 0 5px 0 var(--toon-outline-ink);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--toon-outline-ink); }

.btn-ghost {
  background: var(--panel-2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  color: var(--toon-outline);
  box-shadow: 0 4px 0 var(--toon-outline-ink);
}
.btn-ghost:active { box-shadow: 0 1px 0 var(--toon-outline-ink); }

.btn-lg { width: 100%; padding: 18px; font-size: 1.1rem; }

/* ---------- home ---------- */
#screen-home { align-items: center; justify-content: center; }

.home-card {
  max-width: 420px;
  width: 100%;
  padding: 32px 26px;
  text-align: center;
  margin: auto;
}

.logo-mark {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.logo-mark b { color: var(--toon-outline); }

.tagline { color: var(--text-secondary); margin: 0 0 24px; }

.home-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 8px 0 20px;
}

#screen-home .btn { width: 100%; margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
#campaign-progress { font-weight: 500; opacity: 0.75; font-size: 0.78rem; }

/* ---------- map ---------- */
.map-chapters {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 20px;
}

.chapter-block {
  border-radius: var(--radius-lg);
  padding: 16px;
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  background: linear-gradient(135deg, var(--ch-bg1, var(--panel)), var(--ch-bg2, var(--panel-2)));
  box-shadow: 0 5px 0 var(--toon-outline-ink);
  position: relative;
  overflow: hidden;
}
.chapter-block.locked { filter: grayscale(0.6); opacity: 0.55; }

.chapter-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  color: #fff;
}
.chapter-head .num {
  font-size: 0.75rem;
  font-weight: 800;
  opacity: 0.6;
}
.chapter-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.chapter-desc { font-size: 0.78rem; color: rgba(255,255,255,0.75); margin: 0 0 12px; }

.level-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
}

/* Cases de niveau : posées SUR le panneau vif du chapitre (théme-invariant,
   comme le plateau) — restent en blanc translucide dans les deux thèmes. */
.level-node {
  aspect-ratio: 1;
  border-radius: 50%;
  border: var(--toon-outline-w) solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s;
  position: relative;
}
.level-node svg { width: 18px; height: 18px; display: block; }
.level-node:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.level-node.locked { cursor: not-allowed; opacity: 0.55; box-shadow: none; }
.level-node.done {
  background: linear-gradient(135deg, var(--ch-accent, var(--brand-gold)), var(--ch-accent2, #fff));
  color: #241a02;
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.level-node.current { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.35), 0 3px 0 rgba(0,0,0,0.3); }
.level-node .stars { font-size: 0.55rem; letter-spacing: 1px; }

/* ---------- quick play menu ---------- */
#screen-quickplay { align-items: center; justify-content: center; }
.menu-card { max-width: 380px; width: 100%; padding: 28px; text-align: center; margin: auto; }
.difficulty-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- game ---------- */
#screen-game { padding: 10px 12px; gap: 10px; }

.game-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex: 0 0 auto;
}
.game-hud .chip { font-variant-numeric: tabular-nums; }
#pause-btn { margin-left: 8px; }

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

.fx-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.grid {
  --cols: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: clamp(4px, 1.4vw, 10px);
  width: min(92vw, calc(100dvh - 260px), 520px);
  aspect-ratio: 1;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--chapter-bg1), var(--chapter-bg2));
  border: var(--toon-outline-w) solid var(--toon-outline-ink);
  box-shadow: 0 6px 0 var(--toon-outline-ink);
}

.cell {
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 0;
  aspect-ratio: 1;
  transition: background 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), transform 0.1s var(--ease-out);
  background: rgba(255, 255, 255, 0.05);
}
.cell:hover { filter: brightness(1.1); }
.cell:active { transform: scale(0.92); }

.cell.on {
  background: var(--chapter-accent);
  border-color: rgba(0, 0, 0, 0.4);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  animation: cellPop 0.2s var(--ease-bounce);
}

.cell.focused { outline: 2px solid #fff; outline-offset: 2px; }

.cell.hint-pulse {
  box-shadow: 0 0 0 4px var(--brand-gold);
  animation: hintPulse 0.9s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes cellPop {
  0% { transform: scale(0.82); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---------- tools bar ---------- */
.tools-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.tool-btn {
  border: var(--toon-outline-w) solid var(--toon-outline);
  background: var(--panel-2);
  color: var(--toon-outline);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 46px;
  min-height: 46px;
  justify-content: center;
  box-shadow: 0 3px 0 var(--toon-outline-ink);
  transition: transform 0.12s var(--ease-out), box-shadow 0.12s;
}
.tool-btn svg { width: 20px; height: 20px; display: block; }
.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--toon-outline-ink); }
.tool-paid { border-color: var(--brand-gold); box-shadow: 0 3px 0 color-mix(in srgb, var(--brand-gold) 55%, #000); }
.tool-cost {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--brand-gold);
}
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.68);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.overlay.show { display: flex; animation: overlayFade 0.2s var(--ease-out); }

@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
  max-width: 380px;
  width: 100%;
  padding: 28px 24px;
  text-align: center;
  animation: cardPop 0.35s var(--ease-bounce);
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

.overlay-card h2 { margin: 0 0 10px; font-size: 1.4rem; }
.overlay-card p { color: var(--text-secondary); margin: 0 0 18px; }
.overlay-card .btn { width: 100%; margin-bottom: 8px; }

.stars {
  font-size: 2.2rem;
  letter-spacing: 6px;
  color: var(--brand-gold);
  margin: 10px 0;
}
.stars .dim { color: var(--border); }

.life-timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--brand-gold); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--panel-2);
  border: var(--toon-outline-w) solid var(--toon-outline);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: transform 0.3s var(--ease-out);
  z-index: 100;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 4px 0 var(--toon-outline-ink);
}
.toast.show { transform: translateX(-50%) translateY(0); }

[dir="rtl"] .toast { direction: rtl; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (max-width: 420px) {
  .home-card, .menu-card { padding: 22px 18px; }
  .logo-mark { font-size: 2.1rem; }
}
