/* ==========================================================================
   L'AVENTURE DE MILO — STYLES
   Organisation : variables > base > décor > UI générique > Milo > dialogue
   > écrans (accueil, recherche, quiz, cœurs, coffre, câlin) > easter eggs
   > responsive > accessibilité
   ========================================================================== */

:root{
  /* Palette */
  --pink-50:#fff6fa;
  --pink-100:#ffe7f1;
  --pink-200:#ffd2e6;
  --pink-300:#ffb3d8;
  --pink-400:#ff8fc4;
  --pink-500:#ff6fae;
  --pink-600:#f1509a;
  --cream:#fffaf3;
  --cream-deep:#fff2df;
  --lavender-100:#f1e6ff;
  --lavender-300:#dcc3f8;
  --lavender-500:#b895ec;
  --gold-300:#ffe0a3;
  --gold-500:#f0b94d;
  --ink:#4a3452;
  --ink-soft:#8a7391;
  --white:#ffffff;

  --milo-black:#2a2530;
  --milo-black-deep:#1c1821;
  --milo-muzzle:#3c3542;
  --milo-sheen:#463d4e;

  --shadow-pink:0 12px 28px rgba(241,80,154,0.22);
  --shadow-soft:0 6px 16px rgba(138,90,120,0.16);

  --radius-lg:28px;
  --radius-md:20px;
  --radius-sm:12px;

  /* Panneaux "verre" — un seul système de lisibilité réutilisé partout
     (dialogue, quiz, objets, final), pas une variante par environnement.
     À ~88-94% d'opacité, c'est la couleur du panneau qui garantit le
     contraste, pas ce qu'il y a derrière : reste lisible sur les 6 fonds
     illustrés sans réglage particulier. Le flou est un bonus esthétique,
     jamais ce qui porte la lisibilité (robuste sans backdrop-filter). */
  --panel-bg:rgba(255,252,250,0.88);
  --panel-bg-strong:rgba(255,252,250,0.94);
  --panel-border:1px solid rgba(255,255,255,0.6);
  --panel-border-glow:1px solid rgba(255,224,163,0.55);
  --panel-shadow:0 10px 26px rgba(74,52,82,0.18);
  --panel-blur:blur(10px);
  --panel-blur-strong:blur(14px);
  --text-primary:var(--ink);
  --text-secondary:var(--ink-soft);
  --text-shadow-soft:0 1px 3px rgba(255,255,255,0.9), 0 1px 1px rgba(255,255,255,0.6);

  --font-heading:'Baloo 2', 'Baloo 2 Fallback', ui-rounded, 'Segoe UI Rounded', system-ui, sans-serif;
  --font-body:'Nunito', 'Nunito Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;

  color-scheme: light;
}

/* ==========================================================================
   POLICES — auto-hébergées (assets/fonts/), plus d'appel à Google Fonts.
   Seules les graisses réellement utilisées dans tout le projet sont
   servies (vérifié par relevé des font-weight sur toutes les pages) :
   Baloo 2 en 600/700/800 (jamais 500), Nunito en 400/600/700 (jamais 800).
   Sous-ensemble "latin" uniquement (couvre fr/en/es/de/it/pt) — même
   sous-ensemble que celui réellement chargé depuis Google Fonts
   auparavant. Licence SIL Open Font License 1.1, voir
   assets/fonts/OFL-Baloo2.txt et assets/fonts/OFL-Nunito.txt. */
@font-face{
  font-family:'Baloo 2';
  src:url('assets/fonts/baloo2-600.woff2') format('woff2');
  font-weight:600;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Baloo 2';
  src:url('assets/fonts/baloo2-700.woff2') format('woff2');
  font-weight:700;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Baloo 2';
  src:url('assets/fonts/baloo2-800.woff2') format('woff2');
  font-weight:800;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Nunito';
  src:url('assets/fonts/nunito-400.woff2') format('woff2');
  font-weight:400;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Nunito';
  src:url('assets/fonts/nunito-600.woff2') format('woff2');
  font-weight:600;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Nunito';
  src:url('assets/fonts/nunito-700.woff2') format('woff2');
  font-weight:700;
  font-style:normal;
  font-display:swap;
}

/* Fallbacks ajustés (CLS, audit Performance ID 218) — size-adjust/
   ascent-override/descent-override calculés à partir des métriques RÉELLES
   des fichiers .woff2 (fontTools : unitsPerEm, OS/2.sTypoAscender/
   sTypoDescender, OS/2.sxHeight) comparées à celles de Segoe UI
   (C:\Windows\Fonts\segoeui.ttf, même méthode) — jamais de valeur inventée.
   Segoe UI est le fallback RÉELLEMENT utilisé tant que Baloo 2/Nunito ne
   sont pas chargés sur Windows (ui-rounded/Segoe UI Rounded ne résolvent à
   aucune police installée par défaut ; system-ui résout à Segoe UI). Sur
   les plateformes où le fallback réel diffère (ex. macOS/ui-rounded), ces
   @font-face ne matchent local() à rien et sont simplement ignorées par le
   navigateur (repli normal sur la chaîne existante, sans régression).
   N'affecte que la fenêtre de swap : la typographie finale (une fois Baloo
   2/Nunito chargées) est strictement inchangée. */
@font-face{
  font-family:'Baloo 2 Fallback';
  src:local('Segoe UI');
  size-adjust:92%;
  ascent-override:117.17%;
  descent-override:56.96%;
  line-gap-override:0%;
}
@font-face{
  font-family:'Nunito Fallback';
  src:local('Segoe UI');
  size-adjust:96.8%;
  ascent-override:104.44%;
  descent-override:36.47%;
  line-gap-override:0%;
}

/* Polices arabes — auto-hébergées (assets/fonts/), mêmes conditions que
   Baloo 2/Nunito ci-dessus : jamais servies aux 6 autres langues (voir
   l'override html[lang="ar"] plus bas, seul point qui les référence).
   Graisses alignées EXACTEMENT sur celles déjà utilisées par
   --font-heading (600/700/800) et --font-body (400/600/700) — aucune
   graisse inexistante n'est demandée, aucun gras synthétique nécessaire.
   Licence SIL Open Font License 1.1, voir assets/fonts/
   OFL-Baloo-Bhaijaan-2.txt et assets/fonts/OFL-Cairo.txt. Fichiers
   récupérés et vérifiés (Phase D2) — non reconvertis, non modifiés ici. */
@font-face{
  font-family:'Baloo Bhaijaan 2';
  src:url('assets/fonts/baloo-bhaijaan2-600.woff2') format('woff2');
  font-weight:600;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Baloo Bhaijaan 2';
  src:url('assets/fonts/baloo-bhaijaan2-700.woff2') format('woff2');
  font-weight:700;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Baloo Bhaijaan 2';
  src:url('assets/fonts/baloo-bhaijaan2-800.woff2') format('woff2');
  font-weight:800;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Cairo';
  src:url('assets/fonts/cairo-400.woff2') format('woff2');
  font-weight:400;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Cairo';
  src:url('assets/fonts/cairo-600.woff2') format('woff2');
  font-weight:600;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Cairo';
  src:url('assets/fonts/cairo-700.woff2') format('woff2');
  font-weight:700;
  font-style:normal;
  font-display:swap;
}

/* Override arabe centralisé — seul endroit du projet qui référence Baloo
   Bhaijaan 2/Cairo. Ne redéfinit QUE les deux variables déjà utilisées
   partout (--font-heading/--font-body, voir :root ci-dessus) : aucune
   règle CSS supplémentaire n'est nécessaire ailleurs dans le site, tout
   sélecteur qui consomme déjà ces variables en bénéficie automatiquement
   dès que <html lang="ar"> est posé (voir i18n.js — i18nInit/
   i18nSetLocale/i18nSetRuntimeLocale posent document.documentElement.lang).
   Spécificité : [lang="ar"] sur html (0,0,1,1) l'emporte naturellement sur
   :root (0,0,1,0), sans !important. Les 6 autres langues (fr/en/es/de/it/
   pt) ne correspondent jamais à ce sélecteur et gardent donc strictement
   Baloo 2 + Nunito. */
html[lang="ar"]{
  --font-heading:'Baloo Bhaijaan 2', system-ui, sans-serif;
  --font-body:'Cairo', system-ui, sans-serif;
}

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

html, body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100%;
  overflow-x:hidden;
  background:
    radial-gradient(120% 80% at 15% 0%, var(--env-grad-1, var(--lavender-100)) 0%, transparent 55%),
    radial-gradient(120% 90% at 85% 10%, var(--env-grad-2, var(--pink-100)) 0%, transparent 55%),
    var(--env-base, var(--cream));
  font-family:var(--font-body);
  color:var(--ink);
  -webkit-tap-highlight-color:transparent;
  transition:background 0.6s ease;
}

body{
  min-height:100dvh;
}

button{
  font-family:inherit;
  border:none;
  background:none;
  padding:0;
  margin:0;
  color:inherit;
  cursor:pointer;
  touch-action:manipulation;
  -webkit-user-select:none;
  user-select:none;
}

button:focus-visible, [tabindex]:focus-visible{
  outline:3px solid var(--lavender-500);
  outline-offset:3px;
  border-radius:var(--radius-sm);
}

h1,h2,h3{
  font-family:var(--font-heading);
  margin:0;
}

p{ margin:0; }

img, svg{ display:block; max-width:100%; }

#app{
  position:relative;
  min-height:100dvh;
  width:100%;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display:flex;
  flex-direction:column;
  align-items:center;
  isolation:isolate;
}

/* ==========================================================================
   DÉCOR DE FOND
   ========================================================================== */

.bg-decor{
  position:fixed;
  inset:0;
  z-index:0;
  overflow:hidden;
  pointer-events:none;
  /* PASSE 3K — décor purement visuel (aria-hidden, aucun texte), positionné
     uniquement en left/right explicites : direction neutralisée pour que
     le basculement décor CSS → illustration (.has-illustration) ne soit
     plus compté comme un layout shift sous dir="rtl" (CLS AR mesuré ~0,12
     → 0). Positions des éléments du décor vérifiées identiques en RTL avec
     et sans cette règle, sur les 6 environnements. */
  direction:ltr;
}

/* Illustration peinte de l'environnement actif — voir ENVIRONMENT_ASSETS
   (environments.js) et applyGameConfig() (script.js). object-fit:cover
   garantit qu'elle n'est jamais étirée/écrasée ; object-position varie par
   environnement ET par gabarit (voir règles .env-theme.env-<clé> plus bas)
   pour garder la zone importante de chaque composition visible. Invisible
   tant qu'elle n'a pas fini de charger : le décor CSS/SVG existant reste
   seul visible pendant ce temps, puis en secours permanent si elle échoue. */
.env-illustration{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:var(--env-illus-pos, 50% 50%);
  opacity:0;
  transition:opacity 1.1s ease;
}
.has-illustration .env-illustration{ opacity:1; }

.blob{
  position:absolute;
  border-radius:50%;
  filter:blur(50px);
  opacity:0.55;
}

.blob-1{
  width:46vmax; height:46vmax;
  top:-18vmax; left:-14vmax;
  background:var(--env-blob-1, var(--pink-200));
  animation:blob-drift-a 22s ease-in-out infinite;
}
.blob-2{
  width:38vmax; height:38vmax;
  bottom:-16vmax; right:-12vmax;
  background:var(--env-blob-2, var(--lavender-300));
  animation:blob-drift-b 26s ease-in-out infinite;
}
.blob-3{
  width:30vmax; height:30vmax;
  bottom:10vmax; left:-10vmax;
  background:var(--env-blob-3, var(--gold-300));
  opacity:0.35;
  animation:blob-drift-a 30s ease-in-out infinite reverse;
}

/* Soleil / lune d'ambiance, propre à chaque environnement */
.env-sun{
  position:absolute;
  width:var(--env-sun-size, 200px);
  height:var(--env-sun-size, 200px);
  top:var(--env-sun-top, 8%);
  left:var(--env-sun-left, auto);
  right:var(--env-sun-right, 8%);
  border-radius:50%;
  background:radial-gradient(circle, var(--env-sun-color-1, #ffd9a8) 0%, var(--env-sun-color-2, transparent) 70%);
  opacity:var(--env-sun-opacity, 0.55);
  display:var(--env-sun-display, block);
  filter:blur(2px);
}

/* Silhouette d'horizon (collines, montagnes, forêt, château...) */
.env-horizon{
  position:absolute;
  left:0; right:0; bottom:0;
  height:var(--env-horizon-height, 110px);
  background:var(--env-horizon-color, var(--pink-300));
  opacity:var(--env-horizon-opacity, 0.3);
  clip-path:var(--env-horizon-clip, polygon(0% 55%, 10% 42%, 22% 50%, 35% 38%, 50% 48%, 65% 36%, 80% 46%, 100% 34%, 100% 100%, 0% 100%));
}

@keyframes blob-drift-a{
  0%,100%{ transform:translate(0,0) scale(1); }
  50%{ transform:translate(4vmax,3vmax) scale(1.08); }
}
@keyframes blob-drift-b{
  0%,100%{ transform:translate(0,0) scale(1); }
  50%{ transform:translate(-3vmax,-4vmax) scale(1.05); }
}

#ambient-particles{
  position:fixed;
  inset:0;
  z-index:1;
  overflow:hidden;
  pointer-events:none;
}

.ambient-particle{
  position:absolute;
  bottom:-40px;
  opacity:0;
  color:var(--pink-400);
  animation-name:float-up;
  animation-timing-function:ease-in;
  animation-fill-mode:forwards;
  will-change:transform, opacity;
}
.ambient-particle svg{ width:100%; height:100%; fill:currentColor; }
.ambient-particle.shape-star{ color:var(--env-star-color, var(--gold-500)); }
.ambient-particle.shape-petal{ color:var(--env-petal-color, var(--pink-300)); }
.ambient-particle.shape-heart{ color:var(--pink-400); }
.ambient-particle.shape-firefly{
  border-radius:50%;
  background:radial-gradient(circle, var(--env-firefly-color, #ffe9a3) 0%, transparent 72%);
  box-shadow:0 0 8px var(--env-firefly-color, #ffe9a3);
}
.ambient-particle.shape-bubble{
  border-radius:50%;
  border:2px solid var(--env-bubble-color, #bdeee6);
  background:radial-gradient(circle at 35% 30%, rgba(255,255,255,0.65), transparent 60%);
}

@keyframes float-up{
  0%{ transform:translateY(0) rotate(0deg) scale(0.6); opacity:0; }
  10%{ opacity:0.85; }
  85%{ opacity:0.7; }
  100%{ transform:translateY(-110vh) rotate(40deg) scale(1); opacity:0; }
}
@keyframes float-up-spin{
  0%{ transform:translateY(0) rotate(0deg) scale(0.6); opacity:0; }
  10%{ opacity:0.85; }
  85%{ opacity:0.7; }
  100%{ transform:translateY(-110vh) rotate(360deg) scale(1); opacity:0; }
}
.env-theme.env-snow .ambient-particle.shape-star{ animation-name:float-up-spin; }

/* Burst de particules (récupération, coffre, etc.) */
.burst-particle{
  position:fixed;
  z-index:25;
  pointer-events:none;
  color:var(--pink-500);
  animation:burst-out 0.7s ease-out forwards;
  will-change:transform, opacity;
}
.burst-particle svg{ width:100%; height:100%; fill:currentColor; }

@keyframes burst-out{
  0%{ transform:translate(0,0) scale(0.4); opacity:1; }
  100%{ transform:var(--burst-end, translate(40px,-40px)) scale(1); opacity:0; }
}

/* Pluie de cœurs (final du câlin) */
.rain-heart{
  position:fixed;
  top:-40px;
  z-index:25;
  color:var(--pink-400);
  pointer-events:none;
  animation-name:rain-fall;
  animation-timing-function:linear;
  animation-fill-mode:forwards;
}
.rain-heart svg{ width:100%; height:100%; fill:currentColor; }

@keyframes rain-fall{
  0%{ transform:translateY(0) rotate(0deg); opacity:0; }
  10%{ opacity:0.9; }
  100%{ transform:translateY(110vh) rotate(-30deg); opacity:0.6; }
}

/* ==========================================================================
   ENVIRONNEMENTS — palette de fond, soleil/lune, horizon, particules
   Activés via la classe `env-<clé>` posée sur <html> (voir applyGameConfig
   dans script.js). L'interface (boutons, dialogue, Milo) n'est volontairement
   pas retouchée ici : seul le décor de fond change d'un environnement à l'autre.
   ========================================================================== */

.env-theme.env-sakura{
  --env-grad-1:var(--lavender-100);
  --env-grad-2:var(--pink-100);
  --env-base:var(--cream);
  --env-blob-1:var(--pink-200);
  --env-blob-2:var(--lavender-300);
  --env-blob-3:var(--gold-300);
  --env-sun-color-1:#ffd9a8;
  --env-sun-color-2:transparent;
  --env-sun-top:10%;
  --env-sun-right:8%;
  --env-sun-size:220px;
  --env-sun-opacity:0.55;
  --env-horizon-color:var(--pink-300);
  --env-horizon-opacity:0.3;
  --env-horizon-height:110px;
  --env-horizon-clip:polygon(0% 55%, 10% 42%, 22% 50%, 35% 38%, 50% 48%, 65% 36%, 80% 46%, 100% 34%, 100% 100%, 0% 100%);
  --env-star-color:var(--gold-500);
  --env-petal-color:#ffcfe6;
  --env-illus-pos:50% 42%;
}
@media (max-width:640px){
  .env-theme.env-sakura{ --env-illus-pos:46% 42%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-sakura{ --env-illus-pos:50% 68%; }
}

/* Une fois l'illustration Sakura chargée, le décor CSS/SVG existant
   (redondant avec l'image : arbres, pont, lanternes, sol fleuri, ciel/
   soleil...) s'efface. Il reste le secours automatique tant que l'image
   n'a pas fini de charger, ou si elle échoue (voir .env-illustration). */
.env-theme.env-sakura.has-illustration .blob,
.env-theme.env-sakura.has-illustration .env-sun,
.env-theme.env-sakura.has-illustration .env-horizon,
.env-theme.env-sakura.has-illustration .deco-sakura-1,
.env-theme.env-sakura.has-illustration .deco-sakura-2,
.env-theme.env-sakura.has-illustration #env-scene{
  display:none;
}

/* Deux petites lueurs chaudes pulsantes, en plus des pétales (particules,
   inchangées) — pour faire vivre l'illustration sans redessiner ce qu'elle
   montre déjà. Positionnées par rapport à l'écran (pas à l'image) pour
   rester dans la bande centrale toujours visible, quel que soit le
   recadrage object-fit selon l'appareil. */
.illus-glow{
  position:absolute;
  display:none;
  border-radius:50%;
  filter:blur(6px);
  animation:lantern-glow 3.2s ease-in-out infinite;
}
.illus-glow-sakura-1,
.illus-glow-sakura-2{
  width:30px; height:30px;
  bottom:20%;
  background:radial-gradient(circle, #ffdca0 0%, transparent 70%);
}
.illus-glow-sakura-1{ left:32%; animation-delay:0.4s; }
.illus-glow-sakura-2{ right:30%; bottom:24%; }
.env-theme.env-sakura.has-illustration .illus-glow-sakura-1,
.env-theme.env-sakura.has-illustration .illus-glow-sakura-2{ display:block; }

.illus-glow-forest-1,
.illus-glow-forest-2{
  width:26px; height:26px;
  bottom:16%;
  background:radial-gradient(circle, #ffb8de 0%, transparent 70%);
}
.illus-glow-forest-1{ left:30%; animation-delay:0.5s; }
.illus-glow-forest-2{ right:28%; bottom:19%; }
.env-theme.env-forest.has-illustration .illus-glow-forest-1,
.env-theme.env-forest.has-illustration .illus-glow-forest-2{ display:block; }

/* Un seul accent, discret : la composition tropicale est déjà simple et
   lumineuse, inutile d'en rajouter (voir README/analyse). Léger reflet
   chaud sur l'eau, renforcé au moment du final. */
.illus-glow-tropical-1{
  width:50px; height:24px;
  left:50%;
  bottom:22%;
  border-radius:50%;
  background:radial-gradient(ellipse, #ffcf9e 0%, transparent 72%);
}
.env-theme.env-tropical.has-illustration .illus-glow-tropical-1{ display:block; }

.illus-glow-snow-1,
.illus-glow-snow-2{
  width:26px; height:26px;
  bottom:14%;
  background:radial-gradient(circle, #ffdca0 0%, transparent 70%);
}
.illus-glow-snow-1{ left:12%; animation-delay:0.3s; }
.illus-glow-snow-2{ right:12%; bottom:16%; }
.env-theme.env-snow.has-illustration .illus-glow-snow-1,
.env-theme.env-snow.has-illustration .illus-glow-snow-2{ display:block; }

/* Nuit : l'illustration a déjà beaucoup d'étoiles et une lune peinte —
   aucun accent supplémentaire pendant le jeu (voir README/analyse, "les
   animations doivent rester rares"). Cette lueur reste masquée en
   permanence et n'apparaît que pendant le final (voir plus bas). */
.illus-glow-night-1{
  width:34px; height:34px;
  right:26%;
  bottom:30%;
  background:radial-gradient(circle, #ffe9a3 0%, transparent 70%);
}

/* Féerique : la composition est déjà la plus chargée des six — comme pour
   la Nuit, aucun accent supplémentaire pendant le jeu, réservé au final. */
.illus-glow-fairy-1{
  width:34px; height:34px;
  left:34%;
  bottom:24%;
  background:radial-gradient(circle, #e3c9ff 0%, transparent 70%);
}

.env-theme.env-forest{
  --env-grad-1:#e3f0da;
  --env-grad-2:#d5ead9;
  --env-base:#f5f3e6;
  --env-blob-1:#bfe3c2;
  --env-blob-2:#8fd0c4;
  --env-blob-3:#d9c98f;
  --env-sun-display:none;
  --env-horizon-color:#3f6b4a;
  --env-horizon-opacity:0.32;
  --env-horizon-height:130px;
  --env-horizon-clip:polygon(0% 70%, 4% 35%, 8% 62%, 12% 30%, 16% 58%, 20% 28%, 24% 55%, 28% 25%, 32% 60%, 36% 32%, 40% 55%, 44% 28%, 48% 58%, 52% 30%, 56% 62%, 60% 26%, 64% 56%, 68% 32%, 72% 60%, 76% 28%, 80% 58%, 84% 34%, 88% 62%, 92% 30%, 96% 56%, 100% 40%, 100% 100%, 0% 100%);
  --env-star-color:#e8c96a;
  --env-petal-color:#6fae6f;
  --env-firefly-color:#ffe9a3;
  --env-illus-pos:50% 44%;
}
@media (max-width:640px){
  .env-theme.env-forest{ --env-illus-pos:50% 42%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-forest{ --env-illus-pos:50% 66%; }
}

/* Une fois l'illustration Forêt chargée, le décor CSS/SVG existant
   (redondant : arbres, fougères, champignons, faisceau de lumière, sol...)
   s'efface — secours automatique tant que l'image n'a pas chargé. */
.env-theme.env-forest.has-illustration .blob,
.env-theme.env-forest.has-illustration .env-horizon,
.env-theme.env-forest.has-illustration .deco-forest-1,
.env-theme.env-forest.has-illustration .deco-forest-2,
.env-theme.env-forest.has-illustration #env-scene{
  display:none;
}

.env-theme.env-tropical{
  --env-grad-1:#cdeee6;
  --env-grad-2:#ffe0c2;
  --env-base:#fff8ec;
  --env-blob-1:#7fd8c9;
  --env-blob-2:#ffcf9e;
  --env-blob-3:#ffe08a;
  --env-sun-color-1:#ff9a6b;
  --env-sun-color-2:transparent;
  --env-sun-top:52%;
  --env-sun-right:12%;
  --env-sun-size:260px;
  --env-sun-opacity:0.6;
  --env-horizon-color:#1f9c8a;
  --env-horizon-opacity:0.32;
  --env-horizon-height:90px;
  --env-horizon-clip:polygon(0% 65%, 15% 58%, 30% 66%, 45% 56%, 60% 64%, 75% 55%, 90% 62%, 100% 56%, 100% 100%, 0% 100%);
  --env-star-color:#ffd27a;
  --env-petal-color:#3fae9c;
  --env-bubble-color:#bdeee6;
  --env-illus-pos:50% 46%;
}
@media (max-width:640px){
  .env-theme.env-tropical{ --env-illus-pos:52% 46%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-tropical{ --env-illus-pos:50% 70%; }
}

/* Une fois l'illustration Tropical chargée, le décor CSS/SVG existant
   (redondant : palmiers, bateau, mer, sable, coquillages, hibiscus...)
   s'efface — secours automatique tant que l'image n'a pas chargé. */
.env-theme.env-tropical.has-illustration .blob,
.env-theme.env-tropical.has-illustration .env-sun,
.env-theme.env-tropical.has-illustration .env-horizon,
.env-theme.env-tropical.has-illustration .deco-tropical-1,
.env-theme.env-tropical.has-illustration .deco-tropical-2,
.env-theme.env-tropical.has-illustration #env-scene{
  display:none;
}

.env-theme.env-snow{
  --env-grad-1:#e8f2fb;
  --env-grad-2:#eef1fb;
  --env-base:#fbfcff;
  --env-blob-1:#cfe6fb;
  --env-blob-2:#d9d6f5;
  --env-blob-3:#ffe3b0;
  --env-sun-color-1:#fff6e0;
  --env-sun-color-2:transparent;
  --env-sun-top:8%;
  --env-sun-right:auto;
  --env-sun-left:12%;
  --env-sun-size:160px;
  --env-sun-opacity:0.45;
  --env-horizon-color:#7a90b8;
  --env-horizon-opacity:0.35;
  --env-horizon-height:150px;
  --env-horizon-clip:polygon(0% 85%, 8% 25%, 16% 68%, 24% 15%, 32% 62%, 40% 10%, 48% 58%, 56% 22%, 64% 52%, 72% 8%, 80% 48%, 88% 28%, 96% 58%, 100% 38%, 100% 100%, 0% 100%);
  --env-star-color:#eaf6ff;
  --env-petal-color:#cfe6fb;
  --env-illus-pos:50% 44%;
}
@media (max-width:640px){
  .env-theme.env-snow{ --env-illus-pos:50% 42%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-snow{ --env-illus-pos:50% 68%; }
}

/* Une fois l'illustration Neige chargée, le décor CSS/SVG existant
   (redondant : sapins, chalet, bonhomme de neige, empreintes...) s'efface
   — secours automatique tant que l'image n'a pas chargé. */
.env-theme.env-snow.has-illustration .blob,
.env-theme.env-snow.has-illustration .env-sun,
.env-theme.env-snow.has-illustration .env-horizon,
.env-theme.env-snow.has-illustration .deco-snow-1,
.env-theme.env-snow.has-illustration .deco-snow-2,
.env-theme.env-snow.has-illustration #env-scene{
  display:none;
}

.env-theme.env-night{
  --env-grad-1:#3d3a6b;
  --env-grad-2:#4a3a6b;
  --env-base:#f1eefc;
  --env-blob-1:#736bbf;
  --env-blob-2:#4d4a86;
  --env-blob-3:#ffe9a3;
  --env-sun-color-1:#f5f3ff;
  --env-sun-color-2:transparent;
  --env-sun-top:8%;
  --env-sun-right:auto;
  --env-sun-left:10%;
  --env-sun-size:150px;
  --env-sun-opacity:0.85;
  --env-horizon-color:#34315c;
  --env-horizon-opacity:0.22;
  --env-horizon-height:70px;
  --env-horizon-clip:polygon(0% 88%, 50% 78%, 100% 88%, 100% 100%, 0% 100%);
  --env-star-color:#d8d3ff;
  --env-illus-pos:50% 42%;
}
@media (max-width:640px){
  .env-theme.env-night{ --env-illus-pos:50% 40%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-night{ --env-illus-pos:50% 64%; }
}

/* Une fois l'illustration Nuit chargée, le décor CSS/SVG existant
   (redondant : silhouettes, lac, constellation, fleurs lumineuses...)
   s'efface — secours automatique tant que l'image n'a pas chargé.
   .deco-night-1 (étoile filante) N'EST PAS masquée : elle vit hors
   #env-scene et continue d'apporter du mouvement par-dessus l'image. */
.env-theme.env-night.has-illustration .blob,
.env-theme.env-night.has-illustration .env-sun,
.env-theme.env-night.has-illustration .env-horizon,
.env-theme.env-night.has-illustration #env-scene{
  display:none;
}

.env-theme.env-fairy{
  --env-grad-1:#f0e6ff;
  --env-grad-2:#ffe9d6;
  --env-base:#fffaf3;
  --env-blob-1:#dcc3f8;
  --env-blob-2:#ffd2e6;
  --env-blob-3:#ffe0a3;
  --env-sun-color-1:#f6e3ff;
  --env-sun-color-2:transparent;
  --env-sun-top:6%;
  --env-sun-right:15%;
  --env-sun-size:200px;
  --env-sun-opacity:0.5;
  --env-horizon-color:#8a6bb0;
  --env-horizon-opacity:0.35;
  --env-horizon-height:150px;
  --env-horizon-clip:polygon(0% 100%, 0% 55%, 6% 55%, 6% 30%, 10% 30%, 10% 48%, 14% 48%, 14% 20%, 18% 20%, 18% 45%, 26% 45%, 26% 60%, 34% 60%, 34% 35%, 38% 35%, 38% 15%, 42% 15%, 42% 40%, 50% 40%, 50% 58%, 58% 58%, 58% 32%, 62% 32%, 62% 12%, 66% 12%, 66% 38%, 74% 38%, 74% 55%, 82% 55%, 82% 28%, 86% 28%, 86% 50%, 94% 50%, 94% 65%, 100% 65%, 100% 100%);
  --env-star-color:var(--gold-500);
  --env-petal-color:var(--pink-300);
  --env-illus-pos:50% 42%;
}
@media (max-width:640px){
  .env-theme.env-fairy{ --env-illus-pos:50% 40%; }
}
@media (orientation:landscape) and (max-height:500px){
  .env-theme.env-fairy{ --env-illus-pos:50% 66%; }
}

/* Une fois l'illustration Féerique chargée, le décor CSS/SVG existant
   (redondant : château, cascade, cristaux, arbre magique, chemin...)
   s'efface — secours automatique tant que l'image n'a pas chargé.
   Les stickers deco-fairy-1/2 sont déjà masqués en permanence ailleurs
   (remplacés par la scène, voir plus bas dans ce fichier). Seuls les
   papillons de la scène (.scene-butterfly, dans #env-scene) restent
   affichés : ce sont les "papillons" que l'analyse demandait de garder —
   masquer #env-scene en entier les aurait supprimés par erreur. */
.env-theme.env-fairy.has-illustration .blob,
.env-theme.env-fairy.has-illustration .env-sun,
.env-theme.env-fairy.has-illustration .env-horizon,
.env-theme.env-fairy.has-illustration #env-scene > *:not(.scene-butterfly){
  display:none;
}

/* --------------------------------------------------------------------------
   Décor spécifique par environnement — éléments toujours présents dans le
   DOM (léger : emoji + un point CSS pour l'étoile filante), seul
   l'affichage change via .env-theme.env-<clé>. Aucune création ni
   destruction de nœuds au changement d'univers.
   -------------------------------------------------------------------------- */

.env-scenery{
  position:absolute;
  inset:0;
  overflow:hidden;
  pointer-events:none;
}
.scenery-item{
  display:none;
  position:absolute;
  font-size:2.2rem;
  filter:drop-shadow(0 4px 6px rgba(74,52,82,0.15));
  opacity:0.85;
}

.deco-sakura-1{ top:10%; right:12%; animation:scenery-sway 5s ease-in-out infinite; }
.deco-sakura-2{ top:16%; left:8%; font-size:1.6rem; animation:scenery-sway 6.5s ease-in-out infinite 0.4s; }
.env-theme.env-sakura .deco-sakura-1,
.env-theme.env-sakura .deco-sakura-2{ display:block; }

.deco-forest-1{ bottom:16%; left:9%; animation:scenery-glow 3.4s ease-in-out infinite; }
.deco-forest-2{ bottom:22%; right:10%; font-size:1.7rem; animation:scenery-sway 5.5s ease-in-out infinite 0.3s; }
.env-theme.env-forest .deco-forest-1,
.env-theme.env-forest .deco-forest-2{ display:block; }

.deco-tropical-1{ bottom:8%; left:6%; font-size:3rem; }
.deco-tropical-2{ bottom:6%; right:8%; font-size:2.6rem; transform:scaleX(-1); }
.env-theme.env-tropical .deco-tropical-1,
.env-theme.env-tropical .deco-tropical-2{ display:block; }

.deco-snow-1{ bottom:14%; left:7%; font-size:2.6rem; }
.deco-snow-2{ bottom:12%; right:9%; font-size:2.2rem; }
.env-theme.env-snow .deco-snow-1,
.env-theme.env-snow .deco-snow-2{ display:block; }

.deco-night-1{
  top:18%; left:-10%;
  width:3px; height:3px;
  background:#fff;
  border-radius:50%;
  box-shadow:0 0 6px 1px #fff;
  animation:shooting-star 6s linear infinite 2s;
}
.env-theme.env-night .deco-night-1{ display:block; }

.deco-fairy-1{ top:8%; left:10%; font-size:2.4rem; animation:scenery-sway 6s ease-in-out infinite; }
.deco-fairy-2{ top:24%; right:14%; font-size:1.6rem; animation:scenery-flutter 3.2s ease-in-out infinite; }
.env-theme.env-fairy .deco-fairy-1,
.env-theme.env-fairy .deco-fairy-2{ display:block; }

@keyframes scenery-sway{
  0%,100%{ transform:rotate(-4deg); }
  50%{ transform:rotate(5deg); }
}
@keyframes scenery-glow{
  0%,100%{ opacity:0.6; filter:drop-shadow(0 0 3px rgba(255,233,163,0.4)); }
  50%{ opacity:1; filter:drop-shadow(0 0 9px rgba(255,233,163,0.8)); }
}
@keyframes scenery-flutter{
  0%,100%{ transform:translateY(0) rotate(-6deg); }
  50%{ transform:translateY(-8px) rotate(6deg); }
}
@keyframes shooting-star{
  0%{ transform:translate(0,0); opacity:0; }
  2%{ opacity:1; }
  10%{ transform:translate(46vw, 22vh); opacity:0; }
  100%{ transform:translate(46vw, 22vh); opacity:0; }
}

/* --------------------------------------------------------------------------
   SCÈNE 2D DÉTAILLÉE — pièces positionnées individuellement (arbres, pont,
   lanternes, sol...), injectées par environnement dans #env-scene (voir
   environments.js / applyGameConfig dans script.js). Vient compléter le
   ciel/soleil/horizon existant (--env-*), ne le remplace pas. Chaque pièce
   est un petit SVG autonome positionné en CSS, sans calcul d'aspect-ratio
   global — même logique déjà éprouvée que le décor emoji précédent.
   -------------------------------------------------------------------------- */

.env-scene{
  position:absolute;
  inset:0;
  overflow:hidden;
  pointer-events:none;
}
.scene-piece{
  position:absolute;
  overflow:visible;
}

/* ---- Sakura : cerisiers, pont, lanternes, sol fleuri ---- */

.scene-tree{ bottom:6%; width:34vw; max-width:180px; height:auto; }
.scene-tree-left{ left:-4%; }
.scene-tree-right{ right:-4%; transform:scaleX(-1); }

.tree-trunk{ fill:#7a5240; }
.tree-branch{ stroke:#7a5240; stroke-width:3; stroke-linecap:round; fill:none; }
.tree-canopy ellipse:nth-child(1){ fill:var(--pink-200); }
.tree-canopy ellipse:nth-child(2){ fill:var(--pink-300); }
.tree-canopy ellipse:nth-child(3){ fill:var(--pink-200); }
.tree-canopy ellipse:nth-child(4){ fill:#fff0f6; }
.tree-canopy ellipse:nth-child(5){ fill:#fff0f6; }
.tree-canopy ellipse:nth-child(6){ fill:var(--pink-300); }
.tree-canopy{
  transform-box:fill-box;
  transform-origin:50% 100%;
  animation:tree-sway 6.5s ease-in-out infinite;
}
.scene-tree-right .tree-canopy{ animation-duration:7.2s; animation-delay:0.6s; }
@keyframes tree-sway{
  0%,100%{ transform:rotate(-1.5deg); }
  50%{ transform:rotate(1.5deg); }
}

.scene-bridge{
  left:50%;
  bottom:1%;
  width:46vw;
  max-width:230px;
  transform:translateX(-50%);
}
.bridge-deck{ fill:#b8493f; }
.bridge-rail, .bridge-top-rail{ stroke:#8a352c; stroke-width:2.6; stroke-linecap:round; fill:none; }

.scene-lantern{ bottom:4%; width:9vw; max-width:42px; }
.scene-lantern-left{ left:24%; }
.scene-lantern-right{ right:24%; }
.lantern-post{ fill:#5c4636; }
.lantern-cap{ fill:#5c4636; }
.lantern-body{ fill:var(--gold-300); }
.lantern-glow{
  fill:#ffdca0;
  opacity:0.55;
  filter:blur(4px);
  animation:lantern-glow 3.2s ease-in-out infinite;
}
@keyframes lantern-glow{
  0%,100%{ opacity:0.4; }
  50%{ opacity:0.75; }
}

.scene-ground{
  position:absolute;
  left:0; right:0; bottom:0;
  height:9%;
  min-height:34px;
  background:linear-gradient(180deg, var(--pink-200), var(--pink-300) 70%);
  opacity:0.55;
  clip-path:polygon(0% 40%, 8% 20%, 18% 45%, 30% 15%, 42% 40%, 55% 10%, 68% 38%, 80% 18%, 92% 42%, 100% 22%, 100% 100%, 0% 100%);
}

.scene-stone{
  position:absolute;
  bottom:2%;
  border-radius:50% 50% 45% 45%;
  background:#c9b8c4;
  opacity:0.6;
}
.scene-stone-1{ left:14%; width:26px; height:14px; }
.scene-stone-2{ right:30%; width:20px; height:11px; }

.scene-flowers{ bottom:1%; width:7vw; max-width:32px; }
.scene-flowers-1{ left:8%; }
.scene-flowers-2{ right:12%; }
.flower-dot{ fill:var(--pink-400); }
.flower-center{ fill:var(--gold-500); }

/* Sakura : les anciens stickers emoji (lanterne/fleur) sont remplacés par
   la scène ci-dessus. */
.env-theme.env-sakura .deco-sakura-1,
.env-theme.env-sakura .deco-sakura-2{ display:none; }

/* Lueur générique (champignon, fenêtre, cristal...) — même mécanique que
   la lanterne de Sakura, seule la couleur change par variante. */
.scene-glow{
  opacity:0.5;
  filter:blur(4px);
  animation:lantern-glow 3.2s ease-in-out infinite;
}

/* ---- Forêt enchantée : grands arbres, fougères, champignons lumineux ---- */

.scene-lightbeam{
  top:0; left:30%;
  width:24%; height:58%;
  background:linear-gradient(200deg, rgba(255,244,200,0.35), transparent 70%);
  transform:skewX(-12deg);
  animation:lightbeam-pulse 5s ease-in-out infinite;
}
@keyframes lightbeam-pulse{
  0%,100%{ opacity:0.35; }
  50%{ opacity:0.65; }
}

.forest-tree{ bottom:4%; width:38vw; max-width:210px; height:auto; }
.forest-tree-left{ left:-6%; }
.forest-tree-right{ right:-6%; transform:scaleX(-1); }
.forest-trunk{ fill:#4a3324; }
.forest-branch{ stroke:#4a3324; stroke-width:4; stroke-linecap:round; fill:none; }
.forest-canopy ellipse:nth-child(1){ fill:#4f8058; }
.forest-canopy ellipse:nth-child(2){ fill:#2f5a3d; }
.forest-canopy ellipse:nth-child(3){ fill:#5a9066; }
.forest-canopy ellipse:nth-child(4){ fill:#3f6b4a; }
.forest-canopy{
  transform-box:fill-box;
  transform-origin:50% 100%;
  animation:tree-sway 8s ease-in-out infinite;
}
.forest-tree-right .forest-canopy{ animation-duration:8.8s; animation-delay:0.5s; }

.scene-fern{ bottom:2%; width:11vw; max-width:52px; }
.scene-fern-1{ left:22%; }
.scene-fern-2{ right:18%; }
.fern-blade{ stroke:#3f7a4d; stroke-width:3; stroke-linecap:round; fill:none; }

.scene-mushroom{ bottom:1%; width:6vw; max-width:30px; }
.scene-mushroom-1{ left:40%; }
.scene-mushroom-2{ right:38%; }
.mushroom-stem{ fill:#e8dcc8; }
.mushroom-cap{ fill:#c65b8a; }
.mushroom-glow{ fill:#ffb8de; }

.scene-ground-forest{ background:linear-gradient(180deg, #7fae7a, #4f8058 70%); opacity:0.55; }
.scene-stone-moss{ background:#8a9c7a; }

/* ---- Île tropicale : palmiers, mer, sable, coquillages ---- */

.scene-palm{ bottom:5%; width:28vw; max-width:170px; height:auto; }
.scene-palm-left{ left:-6%; }
.scene-palm-right{ right:-6%; transform:scaleX(-1); }
.palm-trunk{ stroke:#8a6a3f; stroke-width:9; stroke-linecap:round; fill:none; }
.palm-frond{ stroke:#2f9e78; stroke-width:7; stroke-linecap:round; fill:none; }
.palm-crown{
  transform-box:fill-box;
  transform-origin:50% 100%;
  animation:tree-sway 4.5s ease-in-out infinite;
}
.scene-palm-right .palm-crown{ animation-duration:5.1s; animation-delay:0.3s; }

.scene-sea{
  position:absolute;
  left:0; right:0; bottom:9%;
  height:8%; min-height:22px;
  background:linear-gradient(90deg, #8fd8c9, #5ec2ac, #8fd8c9);
  background-size:200% 100%;
  opacity:0.7;
  animation:sea-shimmer 6s linear infinite;
}
@keyframes sea-shimmer{
  0%{ background-position:0% 0%; }
  100%{ background-position:200% 0%; }
}

.scene-ground-sand{ background:linear-gradient(180deg, #ffe4b0, #f5c877 70%); opacity:0.7; }

.scene-shell{ bottom:1%; width:6vw; max-width:28px; }
.scene-shell-1{ left:30%; }
.scene-shell-2{ right:34%; }
.shell-shape{ fill:#ffd9c2; }
.scene-stone-sand{ background:#e8c9a0; }

.scene-boat{ top:14%; right:14%; width:14vw; max-width:64px; opacity:0.5; }
.boat-hull{ fill:#7a5a3f; }
.boat-mast{ stroke:#5c4030; stroke-width:1.5; }
.boat-sail{ fill:#fff8ec; opacity:0.9; }

.scene-hibiscus{ bottom:2%; width:7vw; max-width:32px; }
.scene-hibiscus-1{ left:16%; }
.scene-hibiscus-2{ right:8%; }
.hibiscus-petal{ fill:#ff5f7a; }
.hibiscus-center{ fill:var(--gold-500); }

/* ---- Monde enneigé : sapins, chalet, fumée, congères ---- */

.scene-pine{ bottom:5%; width:20vw; max-width:110px; height:auto; }
.scene-pine-left{ left:-2%; }
.scene-pine-right{ right:-2%; }
.pine-trunk{ fill:#5c4636; }
.pine-tier{ fill:#2f6b52; }
.pine-snow{ fill:#f5faff; opacity:0.9; }

.scene-chalet{ left:50%; bottom:3%; width:38vw; max-width:190px; transform:translateX(-50%); height:auto; }
.chalet-base{ fill:#7a5a3f; }
.chalet-roof{ fill:#5c4030; }
.chalet-snow-roof{ fill:#f5faff; }
.chalet-door{ fill:#4a3324; }
.chalet-window{ fill:#ffdca0; }
.chalet-window-glow{ fill:#ffdca0; }
.chalet-chimney{ fill:#5c4030; }
.chalet-smoke{
  fill:#eef2f5;
  opacity:0;
  animation:smoke-rise 3.6s ease-out infinite;
}
.chalet-smoke-2{ animation-delay:1.2s; }
@keyframes smoke-rise{
  0%{ opacity:0; transform:translateY(0) scale(0.6); }
  20%{ opacity:0.6; }
  100%{ opacity:0; transform:translateY(-18px) scale(1.3); }
}

.scene-ground-snow{ background:linear-gradient(180deg, #ffffff, #dce8f5 70%); opacity:0.75; }
.scene-drift{ background:#ffffff; opacity:0.7; }

.scene-snowman{ bottom:2%; right:18%; width:9vw; max-width:44px; }
.snowman-body{ fill:#f5faff; stroke:#dce8f5; stroke-width:1; }
.snowman-arm{ stroke:#7a5a3f; stroke-width:2; stroke-linecap:round; }
.snowman-eye{ fill:#2a2530; }
.snowman-nose{ fill:var(--gold-500); }

.scene-footprints{
  position:absolute;
  left:18%;
  bottom:3%;
  width:30%;
  height:14px;
  opacity:0.35;
  background-image:
    radial-gradient(ellipse 4px 7px at 0% 50%, #7a90b8 45%, transparent 46%),
    radial-gradient(ellipse 4px 7px at 22% 20%, #7a90b8 45%, transparent 46%),
    radial-gradient(ellipse 4px 7px at 44% 50%, #7a90b8 45%, transparent 46%),
    radial-gradient(ellipse 4px 7px at 66% 20%, #7a90b8 45%, transparent 46%),
    radial-gradient(ellipse 4px 7px at 88% 50%, #7a90b8 45%, transparent 46%);
  background-repeat:no-repeat;
}

/* ---- Nuit étoilée : silhouettes, petit lac, fleurs lumineuses ---- */

.night-silhouette{ bottom:5%; width:15vw; max-width:80px; height:auto; }
.night-silhouette-left{ left:6%; }
.night-silhouette-right{ right:8%; }
.night-tree{ fill:#241f3d; opacity:0.85; }

.scene-lake{
  position:absolute;
  left:20%; right:20%; bottom:2%;
  height:6%; min-height:18px;
  border-radius:50%;
  background:#2a2650;
  opacity:0.6;
  overflow:hidden;
}
.lake-glint{
  position:absolute;
  top:20%; left:38%;
  width:24%; height:40%;
  background:radial-gradient(circle, #e8e4ff, transparent 70%);
  opacity:0.5;
  animation:lake-glint 4s ease-in-out infinite;
}
@keyframes lake-glint{
  0%,100%{ opacity:0.35; }
  50%{ opacity:0.65; }
}

.scene-ground-night{ background:linear-gradient(180deg, #3a3564, #241f3d 70%); opacity:0.6; }

.scene-flowers-glow .flower-dot{ fill:#c9c3ff; }
.scene-flowers-glow .flower-center{ fill:#fff6d8; }
.scene-flowers-glow{ filter:drop-shadow(0 0 4px rgba(201,195,255,0.7)); }

.scene-constellation{
  position:absolute;
  top:14%;
  right:16%;
  width:70px;
  height:50px;
  opacity:0.7;
  background-image:
    radial-gradient(circle 1.6px at 10% 20%, #fff 90%, transparent),
    radial-gradient(circle 1.4px at 40% 10%, #fff 90%, transparent),
    radial-gradient(circle 1.8px at 65% 35%, #fff 90%, transparent),
    radial-gradient(circle 1.3px at 85% 15%, #fff 90%, transparent),
    radial-gradient(circle 1.5px at 30% 55%, #fff 90%, transparent);
  background-repeat:no-repeat;
  animation:lantern-glow 4.5s ease-in-out infinite;
}

/* ---- Royaume féerique : château, cascade, cristaux ---- */

.scene-castle{ left:50%; top:4%; width:54vw; max-width:260px; height:auto; transform:translateX(-50%); }
.castle-tower, .castle-wall{ fill:#c9b3e0; }
.castle-tower-main{ fill:#d9c3ee; }
.castle-roof{ fill:#8a6bb0; }
.castle-window{ fill:#ffe9a3; }
.castle-flagpole{ stroke:#8a6bb0; stroke-width:2; }
.castle-flag{ fill:#ff9ec7; }

.scene-cascade{
  position:absolute;
  right:14%; top:10%; bottom:8%;
  width:3%; min-width:10px;
  background:linear-gradient(180deg, #dcc3f8, #9fd8e8, #dcc3f8);
  background-size:100% 200%;
  opacity:0.55;
  border-radius:0 0 40% 40%;
  animation:cascade-flow 1.4s linear infinite;
}
@keyframes cascade-flow{
  0%{ background-position:0 0%; }
  100%{ background-position:0 200%; }
}

.scene-crystal{ bottom:2%; width:7vw; max-width:30px; }
.scene-crystal-1{ left:16%; }
.scene-crystal-2{ right:18%; }
.scene-crystal use{ fill:#c9a3f0; }
.crystal-glow{ fill:#e3c9ff; }

.scene-magic-tree{ bottom:3%; width:19vw; max-width:100px; height:auto; }
.scene-magic-tree-1{ left:6%; }
.magic-trunk{ fill:#8a6b50; }
.magic-canopy ellipse:nth-child(1){ fill:#f0d9ff; }
.magic-canopy ellipse:nth-child(2){ fill:#e3c9ff; }
.magic-canopy ellipse:nth-child(3){ fill:#f6e6ff; }

.scene-butterfly{
  width:7vw; max-width:32px;
  animation:scenery-flutter 3.2s ease-in-out infinite;
}
.scene-butterfly-1{ top:30%; left:60%; }
.scene-butterfly-2{ top:44%; left:20%; width:5vw; max-width:24px; animation-duration:3.8s; animation-delay:0.5s; }
.butterfly-wing{ fill:#ffb3d8; }
.butterfly-body{ stroke:#8a6bb0; stroke-width:2; }

.scene-path{
  position:absolute;
  left:50%;
  bottom:0;
  width:16%;
  height:26%;
  transform:translateX(-50%);
  background:linear-gradient(180deg, transparent, #f0e6ff 80%);
  clip-path:polygon(38% 0%, 62% 0%, 82% 100%, 18% 100%);
  opacity:0.5;
}

.scene-ground-fairy{ background:linear-gradient(180deg, #e3c9ff, #dcc3f8 70%); opacity:0.55; }

/* Stickers emoji devenus redondants, remplacés par les scènes ci-dessus. */
.env-theme.env-forest .deco-forest-1,
.env-theme.env-forest .deco-forest-2,
.env-theme.env-tropical .deco-tropical-1,
.env-theme.env-tropical .deco-tropical-2,
.env-theme.env-snow .deco-snow-1,
.env-theme.env-snow .deco-snow-2,
.env-theme.env-fairy .deco-fairy-1,
.env-theme.env-fairy .deco-fairy-2{ display:none; }

/* ==========================================================================
   BOUTON SON
   ========================================================================== */

#sound-toggle{
  position:fixed;
  top:max(14px, env(safe-area-inset-top));
  right:max(14px, env(safe-area-inset-right));
  z-index:40;
  width:48px;
  height:48px;
  border-radius:50%;
  background:var(--white);
  box-shadow:var(--shadow-soft);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  transition:transform 0.2s ease;
}
#sound-toggle:hover{ transform:scale(1.08); }
#sound-toggle:active{ transform:scale(0.94); }

/* Retour preview/demo (voir initModeBackButton, script.js) — même recette
   que #sound-toggle (pilule fixe) mais côté opposé, jamais affiché pour un
   vrai gift. */
#mode-back-btn{
  position:fixed;
  top:max(14px, env(safe-area-inset-top));
  left:max(14px, env(safe-area-inset-left));
  z-index:40;
  min-height:40px;
  padding:8px 16px;
  border-radius:999px;
  background:var(--white);
  box-shadow:var(--shadow-soft);
  font-family:var(--font-heading);
  font-weight:700;
  font-size:0.8rem;
  color:var(--ink-soft);
  transition:color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
#mode-back-btn:hover{ color:var(--pink-600); box-shadow:var(--shadow-pink); }
#mode-back-btn:active{ transform:scale(0.96); }
#mode-back-btn.hidden{ display:none; }
/* RTL (Phase C2) — #mode-back-btn est un élément de NAVIGATION (bouton
   retour), explicitement dans le périmètre "éléments purement UI" adaptable
   de cette passe : déplacé du coin opposé pour rester cohérent avec le sens
   de lecture RTL, comme .config-nav en Phase C1. Sa chaîne traduite
   (game.preview.backButton / game.demo.backButton, locales/ar.js) porte
   désormais une flèche → au lieu de ← pour la même raison — les deux
   corrections vont ensemble.
   #sound-toggle N'EST PAS un élément de navigation (contrôle audio, aucune
   direction de lecture) et n'est donc volontairement PAS "adapté RTL" en
   tant que tel : il est seulement déplacé au coin opposé, uniquement pour
   éviter une collision physique avec #mode-back-btn qui occupe désormais
   son coin d'origine. Aucun autre élément HUD/décor n'est touché. */
[dir="rtl"] #mode-back-btn{ left:auto; right:max(14px, env(safe-area-inset-right)); }
[dir="rtl"] #sound-toggle{ right:auto; left:max(14px, env(safe-area-inset-left)); }

@media (max-width:440px){
  #mode-back-btn{ min-height:34px; padding:6px 12px; font-size:0.72rem; }
}
/* GAME-19 — bouton compact (34 px) gardé tel quel visuellement, mais sa zone
   tactile est étendue à 46 px par un pseudo-élément transparent. */
#mode-back-btn::after{
  content:'';
  position:absolute;
  inset:-6px;
}

/* ==========================================================================
   SCÈNE PRINCIPALE
   ========================================================================== */

#stage{
  position:relative;
  z-index:10;
  width:100%;
  max-width:460px;
  min-height:100dvh;
  margin:0 auto;
  padding:56px 18px 32px;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
}

#stage-header{
  margin-bottom:6px;
}

/* Lisibilité titre/sous-titre d'intro (audit 2026-09) : sous 1000px,
   #stage n'a aucun fond propre (contrairement à ≥1000px, voir plus bas)
   — le texte reposait uniquement sur text-shadow, insuffisant sur les
   illustrations les plus chargées (fairy/sakura/tropical notamment).
   Réutilise exactement les tokens de .text-panel (même recette "verre"
   déjà utilisée pour dialogue/quiz/carte finale), sans en inventer de
   nouveaux. Scopé <1000px uniquement pour ne jamais superposer un second
   panneau au fond translucide desktop existant de #stage (voir media
   query min-width:1000px plus bas, INCHANGÉE). #game-title/#game-subtitle
   eux-mêmes ne sont pas touchés : couleurs, tailles, font-weight,
   text-shadow restent strictement identiques. */
@media (max-width:999px){
  #stage-header{
    background:var(--panel-bg);
    backdrop-filter:var(--panel-blur);
    -webkit-backdrop-filter:var(--panel-blur);
    border:var(--panel-border);
    box-shadow:var(--panel-shadow);
    border-radius:var(--radius-lg);
    padding:12px 16px;
  }
}

#game-title{
  font-size:clamp(1.5rem, 6vw, 2.1rem);
  font-weight:700;
  color:var(--pink-600);
  text-shadow:var(--text-shadow-soft);
  line-height:1.25;
}

.heart-accent{
  display:inline-block;
  animation:heartbeat 1.6s ease-in-out infinite;
}
@keyframes heartbeat{
  0%,100%{ transform:scale(1); }
  25%{ transform:scale(1.18); }
  40%{ transform:scale(1); }
}

#game-subtitle{
  margin-top:8px;
  font-size:1.02rem;
  color:var(--text-secondary);
  font-weight:600;
  text-shadow:var(--text-shadow-soft);
}

#hearts-counter{
  font-family:var(--font-heading);
  font-weight:600;
  background:var(--panel-bg);
  backdrop-filter:var(--panel-blur);
  -webkit-backdrop-filter:var(--panel-blur);
  border:var(--panel-border);
  color:var(--pink-600);
  padding:8px 18px;
  border-radius:999px;
  box-shadow:var(--panel-shadow);
  margin:12px 0;
  font-size:0.95rem;
}

/* ==========================================================================
   MILO
   ========================================================================== */

#milo-stage{
  position:relative;
  width:min(46vw, 210px);
  margin:10px 0 4px;
}

#milo-tap{
  display:block;
  width:100%;
  border-radius:50%;
  transform-origin:center bottom;
  animation:idle-breathe var(--idle-duration, 3.6s) ease-in-out infinite;
}
@keyframes idle-breathe{
  0%,100%{ transform:scale(1); }
  50%{ transform:scale(var(--idle-scale, 1.015)); }
}

#milo{
  width:100%;
  height:auto;
  overflow:visible;
  filter:drop-shadow(0 14px 14px rgba(74,52,82,0.18));
  transition:transform 0.15s ease;
}
#milo-tap:active #milo{ transform:scale(0.96); }

#milo-fx{
  position:absolute;
  inset:-20% -40%;
  pointer-events:none;
  z-index:5;
  overflow:visible;
}

.milo-shadow{ fill:#e3b3cf; opacity:0.4; }

.milo-tail{ stroke:var(--char-fur, var(--milo-black)); stroke-width:27; stroke-linecap:round; fill:none; }
.milo-tail-sheen{ stroke:var(--char-sheen, var(--milo-sheen)); stroke-width:7; stroke-linecap:round; fill:none; opacity:0.45; }
.milo-tail-group{
  transform-origin:var(--tail-origin, 175px 208px);
  animation:tail-wag var(--tail-duration, 2.6s) ease-in-out infinite;
}
@keyframes tail-wag{
  0%,100%{ transform:rotate(var(--tail-rot-a, -5deg)); }
  50%{ transform:rotate(var(--tail-rot-b, 9deg)); }
}

.milo-body{ fill:var(--char-fur, var(--milo-black)); }
.milo-body-sheen{ fill:var(--char-sheen, var(--milo-sheen)); opacity:0.3; }
.milo-paw{ fill:var(--char-fur, var(--milo-black)); }
.milo-paw-line{ stroke:var(--char-fur-deep, var(--milo-black-deep)); stroke-width:2; opacity:0.5; }

.milo-ear{ fill:var(--char-fur, var(--milo-black)); }
.milo-ear-inner{ fill:var(--char-ear-inner, var(--pink-200)); }

/* Oreilles animables indépendamment (voir animals.js). Selon l'animal,
   ear-l/ear-r porte soit directement la forme (chat : polygone sans
   transform SVG propre), soit un <g> qui l'enveloppe (lapin : l'ellipse a
   déjà sa propre inclinaison via l'attribut SVG transform, qu'on ne veut
   pas écraser — le <g> encaisse l'animation CSS pendant que l'ellipse
   garde sa forme statique). D'où le sélecteur simple .ear-l/.ear-r plutôt
   que .milo-ear.ear-l : il matche les deux cas sans distinction. Origine
   par animal via variables, repli = chat noir. */
.ear-l{ transform-origin:var(--ear-l-origin, 81px 76px); }
.ear-r{ transform-origin:var(--ear-r-origin, 158px 76px); }
.ear-l.twitching, .ear-r.twitching{ animation:ear-twitch 0.5s ease-in-out; }
@keyframes ear-twitch{
  0%,100%{ transform:rotate(0deg); }
  30%{ transform:rotate(-8deg); }
  60%{ transform:rotate(6deg); }
}
.ear-l.ears-down, .ear-r.ears-down{ animation:ears-down 0.6s ease-in-out; }
@keyframes ears-down{
  0%,100%{ transform:rotate(0deg); }
  30%,70%{ transform:rotate(14deg); }
}
/* Oreilles qui se redressent d'un coup (idle rare / réaction positive) —
   même principe que ears-down, rotation inverse. */
.ear-l.perking, .ear-r.perking{ animation:ears-perk 0.6s ease-in-out; }
@keyframes ears-perk{
  0%,100%{ transform:rotate(0deg); }
  30%,70%{ transform:rotate(-10deg); }
}

/* Tête + oreilles + visage : petit regard de côté / inclinaison, jamais
   animé par ailleurs (voir script.js Milo.startIdle) — aucun conflit avec
   #milo (saut/frisson/ronron) ni #milo-tap (respiration). */
.milo-head-group{ transform-origin:120px 113px; }
.milo-head-group.glance-side{ animation:glance-side 1.6s ease-in-out; }
@keyframes glance-side{
  0%,100%{ transform:rotate(0deg) translateX(0); }
  20%,70%{ transform:rotate(-3deg) translateX(-3px); }
}
.milo-head-group.head-tilt{ animation:head-tilt 1.4s ease-in-out; }
@keyframes head-tilt{
  0%,100%{ transform:rotate(0deg); }
  30%,70%{ transform:rotate(6deg); }
}

/* Petit mouvement de nez (lapin) — réutilisable par tout animal, le
   museau/nez (.milo-nose) fait partie du visage partagé (FACE_STATES_SVG,
   animals.js), identique pour tous. fill-box+center évite de dépendre des
   coordonnées locales du path, qui ne varient pas ici mais pourraient à
   l'avenir. */
.milo-nose{ transform-box:fill-box; transform-origin:center; }
.milo-nose.nose-twitch{ animation:nose-twitch 0.5s ease-in-out; }
@keyframes nose-twitch{
  0%,100%{ transform:scale(1); }
  30%,70%{ transform:scale(1.18, 0.85); }
}

/* Coup de queue plus vif, ponctuel : remplace temporairement tail-wag
   (classe plus spécifique) le temps de l'animation, puis revient d'elle-
   même à l'animation de base une fois la classe retirée par JS. */
.milo-tail-group.tail-flick{ animation:tail-flick 0.9s ease-in-out; }
@keyframes tail-flick{
  0%,100%{ transform:rotate(var(--tail-rot-a, -5deg)); }
  25%{ transform:rotate(calc(var(--tail-rot-b, 9deg) * 1.6)); }
  50%{ transform:rotate(calc(var(--tail-rot-a, -5deg) * 1.6)); }
  75%{ transform:rotate(calc(var(--tail-rot-b, 9deg) * 1.6)); }
}

/* Petit étirement (idle rare) — sur #milo comme jump/shiver/purring, donc
   un seul de ces quatre à la fois (JS ne les déclenche jamais ensemble). */
#milo.stretch{ animation:milo-stretch 0.9s ease-in-out; }
@keyframes milo-stretch{
  0%,100%{ transform:scale(1,1) translateY(0); }
  40%{ transform:scale(1.08,0.94) translateY(3px); }
  70%{ transform:scale(0.97,1.03) translateY(-1px); }
}

/* Petit bond silencieux (idle rare / réaction positive) — distinct du
   "vrai" saut (.jump, avec son et hauteur propre par animal) : plus
   discret, jamais les deux en même temps (voir script.js). */
#milo.hop{ animation:milo-hop 0.5s ease-in-out; }
@keyframes milo-hop{
  0%,100%{ transform:translateY(0); }
  40%{ transform:translateY(-9px); }
  70%{ transform:translateY(2px); }
}

.milo-head{ fill:var(--char-fur, var(--milo-black)); }
.milo-muzzle{ fill:var(--char-muzzle, var(--milo-muzzle)); }
.milo-blush{ fill:var(--pink-300); opacity:0.5; }
.milo-nose-cap{ fill:#3a2e2f; }
.milo-eye-patch{ fill:#2a2530; }

.milo-whiskers line{ stroke:var(--char-whisker, #f8f0f6); stroke-width:2; stroke-linecap:round; opacity:0.8; }

.eye-white{ fill:#fff6e9; }
.eye-pupil{ fill:#3a2e2f; }
.eye-pupil-small{ fill:#3a2e2f; }
.eye-shine{ fill:#ffffff; }
.eyelid{
  fill:var(--char-fur, var(--milo-black));
  transform-box:fill-box;
  transform-origin:center;
  transform:scaleY(0);
}
.milo-nose{ fill:var(--pink-300); }
.milo-mouth{ stroke:var(--milo-black-deep); stroke-width:2.4; fill:none; stroke-linecap:round; }

/* Palettes par animal — chaque entrée ne fixe que la couleur, jamais la
   forme (qui vient du SVG injecté par animals.js). Sans entrée, tout
   retombe sur les couleurs du chat noir (repli ci-dessus). */
.character[data-animal="blackCat"]{
  --char-fur:var(--milo-black);
  --char-fur-deep:var(--milo-black-deep);
  --char-sheen:var(--milo-sheen);
  --char-muzzle:var(--milo-muzzle);
  --char-whisker:#f8f0f6;
  --char-ear-inner:var(--pink-200);
}
.character[data-animal="rabbit"]{
  --char-fur:#fdf6f0;
  --char-fur-deep:#d8c3b0;
  --char-sheen:#ffffff;
  --char-muzzle:#fffaf5;
  --char-whisker:#c9b6a6;
  --char-ear-inner:var(--pink-200);
}
.character[data-animal="dog"]{
  --char-fur:#e8b579;
  --char-fur-deep:#b8894f;
  --char-sheen:#f5d9a8;
  --char-muzzle:#fff3e0;
  --char-whisker:#8a6b45;
  --char-ear-inner:#ffd9b3;
}
.character[data-animal="fox"]{
  --char-fur:#e8783c;
  --char-fur-deep:#b6541f;
  --char-sheen:#f4a06a;
  --char-muzzle:#fff6ec;
  --char-whisker:#5c3a1e;
  --char-ear-inner:#fff6ec;
  --char-tail-tip:#fff6ec;
}
.character[data-animal="panda"]{
  --char-fur:#ffffff;
  --char-fur-deep:#d8d8d8;
  --char-sheen:#f3f3f3;
  --char-muzzle:#ffffff;
}
.character[data-animal="bear"]{
  --char-fur:#a9744f;
  --char-fur-deep:#7c5236;
  --char-sheen:#c99872;
  --char-muzzle:#f3ddc0;
  --char-ear-inner:#f3ddc0;
}

/* Le panda a des oreilles/pattes noires (contrastant avec le corps blanc) */
.character[data-animal="panda"] .milo-ear,
.character[data-animal="panda"] .milo-paw{ fill:#2a2530; }

/* Panda et ourson : pas de moustaches visibles */
.character[data-animal="panda"] .milo-whiskers,
.character[data-animal="bear"] .milo-whiskers{ display:none; }

/* Bout de queue clair (renard) */
.tail-tip{ fill:var(--char-tail-tip, #fff6ec); }

/* Réglages d'animation par animal — paramètrent les animations partagées
   (respiration idle sur #milo-tap, saut et balancement de queue sur #milo)
   au lieu de dupliquer des jeux de keyframes. Posés sur #milo-stage (un
   ancêtre commun) pour que les variables cascadent aussi bien vers #milo-tap
   que vers #milo. Sans entrée, un animal utilise les réglages du chat noir
   (replis ci-dessus dans les keyframes). */
#milo-stage[data-animal="rabbit"]{
  --jump-height:-46px; --jump-duration:0.6s;
  /* Pas de queue qui remue chez Beauté (simple pompon, pas un vrai
     comportement de lapin) — amplitude nulle plutôt que de dupliquer un
     système d'animation séparé pour ce seul cas. */
  --tail-duration:1.1s; --tail-rot-a:0deg; --tail-rot-b:0deg;
  --idle-duration:2.6s; --idle-scale:1.02;
  --wrap-duration:0.28s; --wrap-amplitude:3deg;
  --ear-l-origin:83px 74px; --ear-r-origin:157px 74px;
}
#milo-stage[data-animal="dog"]{
  --jump-height:-34px; --jump-duration:0.55s;
  --tail-duration:0.7s; --tail-rot-a:-14deg; --tail-rot-b:14deg;
  --idle-duration:3.2s; --idle-scale:1.018;
  --wrap-duration:0.18s; --wrap-amplitude:4deg;
}
#milo-stage[data-animal="fox"]{
  --jump-height:-40px; --jump-duration:0.6s;
  --tail-duration:2.2s; --tail-rot-a:-6deg; --tail-rot-b:7deg; --tail-origin:168px 190px;
  --idle-duration:3.8s; --idle-scale:1.015;
  --wrap-duration:0.55s; --wrap-amplitude:1.5deg;
}
#milo-stage[data-animal="panda"]{
  --jump-height:-22px; --jump-duration:0.85s;
  --tail-duration:3.4s; --tail-rot-a:-3deg; --tail-rot-b:3deg;
  --idle-duration:4.4s; --idle-scale:1.02;
  --wrap-duration:0.7s; --wrap-amplitude:1deg;
}
#milo-stage[data-animal="bear"]{
  --jump-height:-26px; --jump-duration:0.8s;
  --tail-duration:3s; --tail-rot-a:-3deg; --tail-rot-b:3deg;
  --idle-duration:4.2s; --idle-scale:1.02;
  --wrap-duration:0.4s; --wrap-amplitude:2deg;
}

/* Clignement : déclenché en JS à intervalle aléatoire (voir Milo.startIdle,
   script.js) plutôt qu'en boucle CSS à durée fixe — organique, avec double
   clignement occasionnel. Un seul cycle court, la classe est retirée puis
   reposée par JS pour rejouer (même pattern que .jump/.shiver). */
.eyelid.blink-now{ animation:blink-once 0.22s ease-in-out; }
@keyframes blink-once{
  0%, 100%{ transform:scaleY(0); }
  45%{ transform:scaleY(1); }
}

.face{ display:none; }
#milo[data-face="normal"] .face-normal{ display:block; }
#milo[data-face="happy"] .face-happy{ display:block; }
#milo[data-face="shocked"] .face-shocked{ display:block; }
#milo[data-face="annoyed"] .face-annoyed{ display:block; }
#milo[data-face="closed"] .face-closed{ display:block; }
#milo[data-face="yawn"] .face-yawn{ display:block; }

.happy-eye{ stroke:var(--milo-black-deep); stroke-width:5; fill:none; stroke-linecap:round; }
.happy-mouth{ fill:var(--pink-300); }
.shocked-mouth{ fill:var(--milo-black-deep); }
.annoyed-eye{ stroke:var(--milo-black-deep); stroke-width:4.5; fill:none; stroke-linecap:round; }
.annoyed-mouth{ stroke:var(--milo-black-deep); stroke-width:3; fill:none; stroke-linecap:round; }
.closed-eye{ stroke:var(--milo-black-deep); stroke-width:4.5; fill:none; stroke-linecap:round; }
.closed-mouth{ stroke:var(--milo-black-deep); stroke-width:2.4; fill:none; stroke-linecap:round; }
.yawn-mouth{ fill:var(--milo-black-deep); }
.yawn-mouth-inner{ fill:var(--pink-300); }

/* Objet signature de l'animal (pelote/carotte/balle/plume/bambou/miel).
   Un seul groupe/animation partagés ; la forme et les couleurs viennent
   du SVG propre à chaque animal (animals.js). Tempo (durée/amplitude) réglé
   par animal via #milo-stage[data-animal] plus bas. */
.signature-wrap{ display:none; }
#milo.wrapped .signature-wrap{
  display:block;
  animation:signature-wiggle var(--wrap-duration, 0.35s) ease-in-out infinite alternate;
}
@keyframes signature-wiggle{
  0%{ transform:rotate(calc(-1 * var(--wrap-amplitude, 2deg))); }
  100%{ transform:rotate(var(--wrap-amplitude, 2deg)); }
}

/* Chat — pelote de laine */
.sig-yarn-1{ stroke:var(--lavender-300); stroke-width:7; stroke-linecap:round; fill:none; }
.sig-yarn-2{ stroke:var(--pink-300); stroke-width:7; stroke-linecap:round; fill:none; }
.sig-yarn-3{ stroke:var(--lavender-500); stroke-width:7; stroke-linecap:round; fill:none; }

/* Lapin — carotte */
.sig-carrot-body{ fill:#f0924a; }
.sig-carrot-leaf{ stroke:#4f8a4f; stroke-width:5; stroke-linecap:round; fill:none; }

/* Chien — balle */
.sig-ball{ fill:#f0d24a; }
.sig-ball-line{ stroke:#c9a12e; stroke-width:3; fill:none; }

/* Renard — plume */
.sig-feather{ fill:#c9a3f0; }
.sig-feather-quill{ stroke:#8a6bb0; stroke-width:2; }

/* Panda — bambou */
.sig-bamboo{ fill:#8fbf6a; }
.sig-bamboo-line{ stroke:#5a8a3f; stroke-width:3; }
.sig-bamboo-leaf{ stroke:#6fae4a; stroke-width:5; stroke-linecap:round; fill:none; }

/* Ourson — pot de miel */
.sig-honeypot{ fill:#e8a53f; }
.sig-honeypot-lid{ fill:#c97f2a; }
.sig-honeypot-drip{ fill:#f0b84f; }

#milo.jump{ animation:milo-jump var(--jump-duration, 0.65s) cubic-bezier(.34,1.56,.64,1); }
@keyframes milo-jump{
  0%{ transform:translateY(0) scale(1,1); }
  25%{ transform:translateY(4px) scale(1.06,0.92); }
  55%{ transform:translateY(var(--jump-height, -38px)) scale(0.96,1.06); }
  75%{ transform:translateY(0) scale(1.05,0.94); }
  100%{ transform:translateY(0) scale(1,1); }
}

#milo.shiver{ animation:milo-shiver 0.55s ease; }
@keyframes milo-shiver{
  0%,100%{ transform:rotate(0deg) translateX(0); }
  20%{ transform:rotate(-2.5deg) translateX(-3px); }
  40%{ transform:rotate(2.5deg) translateX(3px); }
  60%{ transform:rotate(-2deg) translateX(-2px); }
  80%{ transform:rotate(2deg) translateX(2px); }
}

#milo.purring{ animation:milo-purr 0.22s ease-in-out infinite; }
@keyframes milo-purr{
  0%,100%{ transform:translateY(0); }
  50%{ transform:translateY(-1.4px); }
}

/* ==========================================================================
   DIALOGUE
   ========================================================================== */

#dialogue-box{
  position:relative;
  width:100%;
  max-width:400px;
  background:var(--panel-bg);
  backdrop-filter:var(--panel-blur);
  -webkit-backdrop-filter:var(--panel-blur);
  border:var(--panel-border);
  border-radius:var(--radius-lg);
  padding:18px 22px 22px;
  margin:8px 0 16px;
  box-shadow:var(--panel-shadow);
  cursor:pointer;
}
#dialogue-box::before{
  content:"";
  position:absolute;
  top:-14px;
  left:50%;
  transform:translateX(-50%);
  border-left:12px solid transparent;
  border-right:12px solid transparent;
  border-bottom:14px solid var(--panel-bg);
}
.dialogue-speaker{
  display:block;
  font-family:var(--font-heading);
  font-weight:700;
  font-size:0.82rem;
  letter-spacing:0.02em;
  color:var(--pink-500);
  margin-bottom:2px;
}
#dialogue-text{
  font-size:1.06rem;
  font-weight:700;
  color:var(--text-primary);
  line-height:1.5;
  min-height:1.6em;
}
/* Petite transition entre deux répliques (showDialogue) — un simple creux
   d'opacité rejoué à chaque nouvelle ligne, en parallèle de la révélation
   progressive (jamais une attente séquentielle en plus). */
#dialogue-text.line-transition{ animation:line-fade-in 0.18s ease; }
@keyframes line-fade-in{
  from{ opacity:0.3; }
  to{ opacity:1; }
}
/* Narration (opts.variant:'narration', showDialogue) : légèrement plus
   douce, sans nom au-dessus — désactivé par défaut, n'affecte donc aucun
   appel existant tant qu'il n'est pas explicitement demandé. */
#dialogue-box.narration #dialogue-text{
  font-style:italic;
  font-weight:600;
  color:var(--text-secondary);
}
#dialogue-box.narration .dialogue-speaker{ display:none; }

.dialogue-next{
  display:block;
  text-align:center;
  color:var(--pink-400);
  font-size:1.2rem;
  margin-top:4px;
  animation:bounce-hint 1.3s ease-in-out infinite;
}
/* Indicateur "tu peux continuer" — visible seulement une fois la réplique
   entièrement révélée (voir showDialogue, .revealing posée/retirée par
   JS), jamais pendant l'apparition progressive ni en mode flash. */
#dialogue-box.flash-mode .dialogue-next,
#dialogue-box.revealing .dialogue-next{ display:none; }
#dialogue-box.flash-mode{ cursor:default; }
/* GAME-19 — réplique terminée mais bulle laissée affichée (question
   au-dessus des choix) : chevron masqué sans changer la hauteur de la bulle. */
#dialogue-box.settled{ cursor:default; }
#dialogue-box.settled .dialogue-next{ visibility:hidden; animation:none; }
@keyframes bounce-hint{
  0%,100%{ transform:translateY(0); opacity:0.6; }
  50%{ transform:translateY(4px); opacity:1; }
}

/* ==========================================================================
   ZONE INTERACTIVE — éléments génériques
   ========================================================================== */

#interactive-zone{
  width:100%;
  max-width:420px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  padding-bottom:24px;
}
/* Chaque nouveau contenu de phase (choix, objets, quiz, coffre...) apparaît
   en douceur au lieu de surgir brutalement — un seul point d'ancrage pour
   toutes les transitions de phase du jeu. */
#interactive-zone > *{
  animation:phase-in 0.35s ease forwards;
}
/* GAME-19 — marge gardée sous un élément ramené à l'écran par bringIntoView()
   (script.js) : le bouton câlin pulse et dépassait de 2 px du bas d'écran. */
#interactive-zone > *, #dialogue-box, .reveal-line, .hug-btn, .replay-link{
  scroll-margin:16px;
}
@keyframes phase-in{
  from{ opacity:0; transform:translateY(10px); }
  to{ opacity:1; transform:translateY(0); }
}

.choice-row{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  justify-content:center;
  width:100%;
}

.choice-btn{
  background:var(--panel-bg);
  backdrop-filter:var(--panel-blur);
  -webkit-backdrop-filter:var(--panel-blur);
  border:var(--panel-border);
  color:var(--pink-600);
  font-family:var(--font-heading);
  font-weight:600;
  font-size:1rem;
  padding:14px 22px;
  border-radius:999px;
  box-shadow:var(--panel-shadow);
  transition:transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height:48px;
}
.choice-btn:hover{ transform:translateY(-2px); box-shadow:var(--shadow-pink); }
.choice-btn:active{ transform:translateY(0) scale(0.97); background:var(--panel-bg-strong); }
.choice-btn.primary{
  background:linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color:var(--white);
}
.choice-btn.correct-flash{ animation:pop-correct 0.4s ease; }
.choice-btn.wrong-flash{ animation:shake-wrong 0.4s ease; }
.choice-btn:disabled{ opacity:0.55; cursor:default; }
.choice-btn:disabled:hover{ transform:none; box-shadow:var(--shadow-soft); }

@keyframes pop-correct{
  0%{ transform:scale(1); }
  50%{ transform:scale(1.12); }
  100%{ transform:scale(1); }
}
@keyframes shake-wrong{
  0%,100%{ transform:translateX(0); }
  25%{ transform:translateX(-6px); }
  75%{ transform:translateX(6px); }
}

.start-btn{
  font-size:1.15rem;
  padding:16px 34px;
  background:linear-gradient(135deg, var(--pink-400), var(--pink-600));
  color:var(--white);
  border-radius:999px;
  box-shadow:var(--shadow-pink);
  font-family:var(--font-heading);
  font-weight:700;
  animation:start-pulse 2.2s ease-in-out infinite;
}
@keyframes start-pulse{
  0%,100%{ transform:scale(1); }
  50%{ transform:scale(1.045); }
}

/* Objets à fouiller */
.treasure-objects{
  display:flex;
  gap:16px;
  justify-content:center;
  flex-wrap:wrap;
  width:100%;
}
.treasure-item{
  width:96px;
  height:96px;
  background:var(--panel-bg);
  backdrop-filter:var(--panel-blur);
  -webkit-backdrop-filter:var(--panel-blur);
  border:var(--panel-border);
  border-radius:var(--radius-md);
  box-shadow:var(--panel-shadow);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:2.4rem;
  transition:transform 0.18s ease;
  position:relative;
}
.treasure-item:hover{ transform:translateY(-3px) scale(1.04); }
.treasure-item:active{ transform:scale(0.95); }
.treasure-item.examined{
  opacity:0.55;
  pointer-events:none;
  animation:treasure-collected 0.4s ease;
}
@keyframes treasure-collected{
  0%{ transform:scale(1); }
  40%{ transform:scale(1.12); }
  100%{ transform:scale(1); }
}
.treasure-item.examined::after{
  content:"✓";
  position:absolute;
  top:-6px;
  right:-6px;
  width:24px;
  height:24px;
  background:var(--pink-500);
  color:var(--white);
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.85rem;
}
.treasure-item.shake{ animation:shake-wrong 0.4s ease; }

/* Quiz */
/* Panneau "verre" partagé — dialogue/quiz/objets/révélation du coffre.
   Un seul niveau d'intensité (voir --panel-*, :root) : pas de variante par
   environnement, le fond quasi-opaque suffit à porter le contraste. */
.text-panel{
  background:var(--panel-bg);
  backdrop-filter:var(--panel-blur);
  -webkit-backdrop-filter:var(--panel-blur);
  border:var(--panel-border);
  border-radius:var(--radius-lg);
  box-shadow:var(--panel-shadow);
  padding:16px 20px;
  width:100%;
  max-width:400px;
}

.quiz-question{
  font-family:var(--font-heading);
  font-size:1.2rem;
  font-weight:700;
  color:var(--text-primary);
  text-align:center;
  margin-bottom:4px;
}
.quiz-options{
  display:flex;
  flex-direction:column;
  gap:10px;
  width:100%;
}
.quiz-options .choice-btn{
  width:100%;
}

/* ==========================================================================
   MINI-JEU DES CŒURS (plein écran)
   ========================================================================== */

#hearts-layer{
  position:fixed;
  inset:0;
  z-index:20;
  overflow:hidden;
}

.floating-heart{
  position:absolute;
  width:56px;
  height:56px;
  color:var(--pink-500);
  filter:drop-shadow(0 4px 8px rgba(241,80,154,0.35));
  animation:heart-pop-in 0.35s ease, heart-bob 2.4s ease-in-out 0.35s infinite;
  transform-origin:center;
  display:flex;
  align-items:center;
  justify-content:center;
}

/* Hitbox commune (.floating-heart, 56x56, inchangée) + gabarit visuel
   commun (.collectible-visual, ici) — séparés pour que les corrections de
   scale par forme ci-dessous ne rentrent jamais en conflit avec les
   animations de mouvement/apparition/collecte, qui utilisent déjà
   transform sur .floating-heart (voir plus bas : heart-pop-in, heart-bob,
   heart-caught, heart-fade-out). Le cœur reste la référence : aucun
   scale ne lui est appliqué. */
.collectible-visual{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  transform-origin:center;
  /* Lisibilité sur tous les décors : halo sombre léger en plus de l'ombre
     rose déjà posée sur .floating-heart (inchangée) — fonctionne aussi bien
     sur SVG (fill:currentColor) que sur emoji (glyphe texte), sans changer
     le design ni épaissir le contour façon "cartoon". Deux drop-shadow
     empilés : un très serré pour un léger contour, un plus diffus pour un
     contraste doux même sur des fonds très clairs (neige, sakura). */
  filter:
    drop-shadow(0 1px 1.5px rgba(0,0,0,0.4))
    drop-shadow(0 0 4px rgba(0,0,0,0.22));
}
.collectible-visual svg{ width:100%; height:100%; fill:currentColor; }

/* Corrections par symbole SVG partagé (petal/star/crystal-shape, voir
   index.html <defs>) : un seul scale uniforme chacun, mesuré sur la
   bounding box réelle de leur path — heart-shape remplit déjà tout son
   viewBox (référence, aucune correction), les trois autres laissent une
   marge interne qui les fait paraître plus petits à taille de boîte
   égale. Un symbole peut être réutilisé par plusieurs objets (star-shape
   sert à star/starfish/snowflake) : la correction s'applique à tous
   identiquement, c'est la même forme. */
.collectible-visual.shape-star{ transform:scale(1.17); }
.collectible-visual.shape-crystal{ transform:scale(1.28); }
.collectible-visual.shape-petal{ transform:scale(1.4); }

/* Emoji : la police laisse une marge interne bien plus large qu'un SVG
   dessiné à la main, donc une taille de base nettement plus généreuse est
   nécessaire pour égaler l'encre du cœur — puis un ajustement individuel
   pour les glyphes particulièrement fins ou étirés (croissant de lune,
   comète à traîne...). */
.floating-heart.is-emoji .collectible-visual{
  font-size:44px;
  line-height:1;
}
.collectible-visual.glyph-moon{ font-size:52px; }
.collectible-visual.glyph-comet{ font-size:50px; }
.collectible-visual.glyph-acorn{ font-size:48px; }
.collectible-visual.glyph-mitten{ font-size:47px; }
.collectible-visual.glyph-shell{ font-size:47px; }
.collectible-visual.glyph-crown{ font-size:46px; }

.floating-heart.is-glow .collectible-visual{
  border-radius:50%;
  background:radial-gradient(circle, var(--glow-color, #ffe9a3) 0%, transparent 72%);
  box-shadow:0 0 12px var(--glow-color, #ffe9a3);
}

@keyframes heart-pop-in{
  0%{ transform:scale(0); opacity:0; }
  70%{ transform:scale(1.15); opacity:1; }
  100%{ transform:scale(1); opacity:1; }
}
@keyframes heart-bob{
  0%,100%{ transform:translateY(0) rotate(-4deg); }
  50%{ transform:translateY(-14px) rotate(4deg); }
}
.floating-heart.fade-out{
  animation:heart-fade-out 0.5s ease forwards;
}
@keyframes heart-fade-out{
  to{ transform:scale(0.6); opacity:0; }
}
.floating-heart.caught{
  animation:heart-caught 0.4s ease forwards;
  pointer-events:none;
}
@keyframes heart-caught{
  to{ transform:scale(1.7); opacity:0; }
}

/* ==========================================================================
   COFFRE
   ========================================================================== */

.chest-scene{
  position:relative;
  width:220px;
  height:190px;
  margin:10px auto 0;
  perspective:600px;
}
.chest-glow{
  position:absolute;
  inset:-40px;
  border-radius:50%;
  background:radial-gradient(circle, rgba(255,224,163,0.65) 0%, rgba(255,224,163,0) 70%);
  animation:glow-pulse 2.4s ease-in-out infinite;
}
@keyframes glow-pulse{
  0%,100%{ opacity:0.6; transform:scale(1); }
  50%{ opacity:1; transform:scale(1.12); }
}
.chest{
  position:absolute;
  inset:0;
  display:block;
}
.chest-base{
  position:absolute;
  bottom:0;
  left:8px;
  right:8px;
  height:110px;
  background:linear-gradient(180deg, var(--gold-300), var(--gold-500));
  border-radius:14px;
  box-shadow:var(--shadow-pink), inset 0 -8px 0 rgba(0,0,0,0.08);
  border:4px solid var(--cream);
}
.chest-lid{
  position:absolute;
  top:26px;
  left:0;
  right:0;
  height:64px;
  background:linear-gradient(180deg, var(--gold-500), var(--gold-300));
  border-radius:20px 20px 10px 10px;
  border:4px solid var(--cream);
  box-shadow:var(--shadow-soft);
  transform-origin:50% 100%;
  transition:transform 0.7s cubic-bezier(.4,0,.2,1);
  animation:chest-idle 2.6s ease-in-out infinite;
}
@keyframes chest-idle{
  0%,100%{ transform:rotate(0deg) translateY(0); }
  50%{ transform:rotate(-1.5deg) translateY(-2px); }
}
.chest-lock{
  position:absolute;
  top:66px;
  left:50%;
  transform:translateX(-50%);
  width:34px;
  height:34px;
  color:var(--pink-500);
  filter:drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}
.chest-lock svg{ width:100%; height:100%; fill:currentColor; }

.chest.open .chest-lid{
  animation:none;
  transform:rotate(-115deg) translate(-4px,-18px);
}
.chest.open .chest-lock{
  animation:lock-pop 0.4s ease forwards;
}
@keyframes lock-pop{
  to{ transform:translateX(-50%) scale(0); opacity:0; }
}
.chest.open .chest-glow{
  animation:chest-burst 0.9s ease forwards;
}
@keyframes chest-burst{
  0%{ opacity:0.7; transform:scale(1); }
  60%{ opacity:1; transform:scale(2.1); }
  100%{ opacity:0; transform:scale(2.6); }
}

/* ==========================================================================
   MESSAGE FINAL & CÂLIN
   ========================================================================== */

.final-message{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  text-align:center;
  /* GAME-19 — largeur fixée dès l'ouverture : le panneau s'élargissait à
     chaque ligne plus longue que les précédentes, ce qui décalait toutes les
     lignes déjà affichées (décalage de mise en page mesuré : CLS 0,11 à 0,20
     sur téléphone, au moment de la révélation). */
  width:100%;
}
.reveal-line{
  font-family:var(--font-heading);
  font-size:1.15rem;
  font-weight:600;
  color:var(--text-primary);
  opacity:0;
  transform:translateY(8px);
  transition:opacity 0.7s ease, transform 0.7s ease;
}
.reveal-line.show{ opacity:1; transform:translateY(0); }

.hug-btn{
  margin-top:10px;
  font-size:1.1rem;
  padding:16px 30px;
  background:linear-gradient(135deg, var(--pink-400), var(--pink-600));
  color:var(--white);
  border-radius:999px;
  box-shadow:var(--shadow-pink);
  font-family:var(--font-heading);
  font-weight:700;
  animation:start-pulse 2.2s ease-in-out infinite;
}

/* Carte du mot final — petite "lettre" cohérente avec le dialogue-box
   plutôt qu'une modale générique. Sélecteur renforcé (#interactive-zone >
   .final-card) pour dépasser volontairement la spécificité de la règle
   partagée #interactive-zone > * : anime différemment (léger scale) tout
   en restant protégée par sa propre valeur forwards, indépendamment de la
   règle partagée — défense en profondeur contre la même classe de bug. */
#interactive-zone > .final-card{
  animation:final-card-in 0.9s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes final-card-in{
  from{ opacity:0; transform:translateY(14px) scale(0.92); }
  to{ opacity:1; transform:translateY(0) scale(1); }
}
.final-card{
  width:100%;
  max-width:400px;
  box-sizing:border-box;
  background:var(--panel-bg-strong);
  backdrop-filter:var(--panel-blur-strong);
  -webkit-backdrop-filter:var(--panel-blur-strong);
  border:var(--panel-border-glow);
  border-radius:var(--radius-lg);
  padding:28px 24px 24px;
  margin:8px 0 4px;
  box-shadow:var(--shadow-pink), var(--panel-shadow);
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  /* Cliquable/tapable tant que non activée (role="button" tabindex="0"
     posés en JS, voir renderFinalCard) — même affordance que #dialogue-box. */
  cursor:pointer;
}
.final-card:focus-visible{
  outline:3px solid var(--pink-400);
  outline-offset:3px;
}
.final-card.activated{ cursor:default; }
/* Chevron "continuer" réutilisé de .dialogue-next : léger ajustement de
   couleur pour rester lisible sur le fond plus opaque de la carte finale
   (--panel-bg-strong) qu'elle a déjà par défaut. */
.final-card-next{ color:var(--pink-500); }
.final-card-icon{
  display:inline-block;
  font-size:2rem;
  animation:final-card-icon-pulse 1.8s ease-in-out infinite;
}
@keyframes final-card-icon-pulse{
  0%,100%{ transform:scale(1); }
  50%{ transform:scale(1.15); }
}
/* Photo souvenir optionnelle (Chantier 9C) — object-fit:contain (jamais
   cover) pour ne jamais rogner un visage/couple, quel que soit le ratio
   d'origine (portrait/paysage/carré). max-height borne la hauteur sans
   dépendre de la largeur de l'image ; width:auto laisse le navigateur
   respecter le ratio naturel dans cette limite. */
.final-card-photo{
  display:block;
  width:auto;
  max-width:100%;
  max-height:30vh;
  object-fit:contain;
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-soft);
}
.final-card-message{
  width:100%;
  box-sizing:border-box;
  font-family:var(--font-heading);
  font-size:clamp(1.02rem, 4.4vw, 1.3rem);
  font-weight:700;
  color:var(--pink-600);
  line-height:1.5;
  white-space:pre-wrap;
  overflow-wrap:break-word;
  word-break:break-word;
  max-height:38vh;
  overflow-y:auto;
  /* GAME-19 — les jambages de la police dépassaient d'1 px la boîte : une
     barre de défilement apparaissait sur un message court (ordinateur,
     Android). 2 px de marge interne absorbent ce dépassement. */
  padding-block:2px;
}
.final-card-signature{
  font-size:0.92rem;
  color:var(--ink-soft);
  font-weight:600;
  margin-top:2px;
}

.replay-link{
  /* GAME-19 — zone tactile portée à 44 px de haut (lien de 20 px mesuré) ;
     marge réduite d'autant : même position visuelle du texte. */
  margin-top:6px;
  min-height:44px;
  padding:12px 14px;
  font-size:0.85rem;
  color:var(--text-secondary);
  text-decoration:underline;
  text-shadow:var(--text-shadow-soft);
  opacity:0.7;
  background:none;
  border:none;
  cursor:pointer;
  font-family:inherit;
}
.replay-link:hover{ opacity:1; }

/* Écran de déblocage de l'aperçu limité (?preview=1 uniquement — voir
   showPreviewUnlockGate, script.js). Réutilise .text-panel (fond/ombre déjà
   posés en JS via className) et .choice-btn.primary / .replay-link pour les
   deux actions — seule la mise en page (empilement centré) est nouvelle. */
.preview-gate{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  text-align:center;
}
.preview-gate-title{
  font-family:var(--font-heading);
  font-size:1.15rem;
  font-weight:700;
  color:var(--pink-600);
  margin:0;
}
.preview-gate-text{
  font-size:0.92rem;
  color:var(--ink-soft);
  line-height:1.5;
  margin:0;
}
.preview-gate .choice-btn.primary{ margin-top:6px; }

/* --------------------------------------------------------------------------
   FINALE — intensification du décor au moment du mot personnel. Une seule
   classe (.finale-glow, posée sur <html> par playFinalEnvironmentEffect()
   dans script.js) ; chaque environnement réutilise ses propres éléments de
   décor déjà existants (pas de nouvel asset), seule leur intensité change.
   -------------------------------------------------------------------------- */

.env-theme.env-sakura.finale-glow .lantern-glow{ opacity:0.85; filter:blur(6px); }
.env-theme.env-sakura.finale-glow .env-sun{ opacity:0.78; }
/* Variante illustration : #env-scene (donc .lantern-glow) est masqué une
   fois .has-illustration actif — le final intensifie alors les lueurs
   .illus-glow repositionnées à la place. */
.env-theme.env-sakura.has-illustration.finale-glow .illus-glow-sakura-1,
.env-theme.env-sakura.has-illustration.finale-glow .illus-glow-sakura-2{
  width:44px; height:44px;
  filter:blur(8px);
  animation-duration:2s;
}

.env-theme.env-forest.finale-glow .mushroom-glow{ filter:drop-shadow(0 0 6px #ffb8de); }
.env-theme.env-forest.finale-glow .scene-lightbeam{ opacity:0.75; }
/* Variante illustration : #env-scene est masqué une fois .has-illustration
   actif — le final intensifie alors les lueurs .illus-glow à la place. */
.env-theme.env-forest.has-illustration.finale-glow .illus-glow-forest-1,
.env-theme.env-forest.has-illustration.finale-glow .illus-glow-forest-2{
  width:40px; height:40px;
  filter:blur(8px);
  animation-duration:2s;
}

.env-theme.env-tropical.finale-glow .env-sun{ opacity:0.85; }
.env-theme.env-tropical.finale-glow .scene-sea{ opacity:0.9; }
/* Variante illustration : .env-sun/#env-scene sont masqués une fois
   .has-illustration actif — le final intensifie alors le reflet chaud. */
.env-theme.env-tropical.has-illustration.finale-glow .illus-glow-tropical-1{
  width:74px; height:34px;
  filter:blur(8px);
  animation-duration:2s;
}

.env-theme.env-snow.finale-glow .chalet-window{ fill:#ffe9c2; }
.env-theme.env-snow.finale-glow .chalet-window-glow{ filter:drop-shadow(0 0 6px #ffdca0); }
/* Variante illustration : #env-scene (donc le chalet) est masqué une fois
   .has-illustration actif — le final intensifie alors les lueurs .illus-glow. */
.env-theme.env-snow.has-illustration.finale-glow .illus-glow-snow-1,
.env-theme.env-snow.has-illustration.finale-glow .illus-glow-snow-2{
  width:38px; height:38px;
  filter:blur(8px);
  animation-duration:2s;
}

.env-theme.env-night.finale-glow .scene-constellation{ opacity:1; filter:drop-shadow(0 0 4px rgba(255,255,255,0.8)); }
.env-theme.env-night.finale-glow .lake-glint{ opacity:0.8; }
/* Variante illustration : #env-scene (constellation/lac CSS) est masqué
   une fois .has-illustration actif — le final révèle alors une lueur
   discrète (reflet chaud sur l'eau) qui reste invisible tout le reste de
   la partie, pour ne pas surcharger un ciel déjà très étoilé. */
.env-theme.env-night.has-illustration.finale-glow .illus-glow-night-1{
  display:block;
}
.env-theme.env-night.finale-glow .deco-night-1{ animation-duration:3.5s; }
.env-theme.env-night.finale-glow .deco-night-1::after{
  content:"";
  position:absolute;
  top:40px; left:-60px;
  width:3px; height:3px;
  background:#fff;
  border-radius:50%;
  box-shadow:0 0 6px 1px #fff;
  animation:shooting-star 5s linear infinite 4s;
}

.env-theme.env-fairy.finale-glow .castle-window{ fill:#fff3c4; filter:drop-shadow(0 0 6px #ffe9a3); }
.env-theme.env-fairy.finale-glow .crystal-glow{ filter:drop-shadow(0 0 8px #e3c9ff); }
.env-theme.env-fairy.finale-glow .deco-fairy-2{ filter:drop-shadow(0 0 6px rgba(255,255,255,0.6)); }
/* Variante illustration : #env-scene (château/cristaux CSS) est masqué une
   fois .has-illustration actif — le final révèle alors une lueur discrète,
   normalement invisible pour ne pas surcharger la composition la plus
   chargée des six. .deco-fairy-2 (papillon) reste inchangée : hors
   #env-scene, son boost ci-dessus s'applique déjà correctement. */
.env-theme.env-fairy.has-illustration.finale-glow .illus-glow-fairy-1{
  display:block;
}

#app.bright-mode::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:2;
  background:radial-gradient(circle at 50% 30%, rgba(255,255,255,0.55), transparent 70%);
  pointer-events:none;
  animation:brighten-in 1.5s ease forwards;
}
@keyframes brighten-in{
  from{ opacity:0; }
  to{ opacity:1; }
}

/* ==========================================================================
   EASTER EGGS
   ========================================================================== */

#secret-cat{
  position:fixed;
  bottom:6%;
  left:-120px;
  z-index:30;
  width:90px;
  color:var(--lavender-500);
  opacity:0.9;
}
#secret-cat svg{ width:100%; height:auto; fill:currentColor; }
#secret-cat.crossing{
  animation:cat-cross 7s linear forwards;
}
@keyframes cat-cross{
  0%{ transform:translate(0,0); }
  50%{ transform:translate(60vw,-6px); }
  100%{ transform:translate(130vw,0); }
}
.secret-cat-tail{ fill:none; stroke:currentColor; stroke-width:6; stroke-linecap:round; }

/* ==========================================================================
   UTILITAIRES
   ========================================================================== */

.hidden{ display:none !important; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (min-width:600px){
  #stage{ padding-top:64px; }
  #milo-stage{ width:230px; }
  #game-title{ font-size:2.3rem; }
  .treasure-item{ width:108px; height:108px; font-size:2.7rem; }
}

@media (min-width:1000px){
  #app{
    background:
      radial-gradient(120% 80% at 15% 0%, var(--env-grad-1, var(--lavender-100)) 0%, transparent 55%),
      radial-gradient(120% 90% at 85% 10%, var(--env-grad-2, var(--pink-100)) 0%, transparent 55%),
      var(--env-base, var(--cream));
  }
  #stage{
    max-width:520px;
    margin-top:20px;
    margin-bottom:20px;
    border-radius:32px;
    background:rgba(255,255,255,0.35);
    box-shadow:0 30px 70px rgba(138,90,120,0.18);
    backdrop-filter:blur(6px);
  }
}

@media (max-width:360px){
  #game-title{ font-size:1.3rem; }
  #game-subtitle{ font-size:0.9rem; }
  .treasure-item{ width:84px; height:84px; font-size:2.1rem; }
}

@media (max-height:640px) and (orientation:portrait){
  #milo-stage{ width:26vw; min-width:120px; }
  #stage{ padding-top:44px; }
  .final-card-photo{ max-height:24vh; }
}

/* Téléphone en mode paysage : peu de hauteur disponible, on compacte
   l'en-tête/le personnage/le dialogue pour que tout reste visible sans
   avoir à défiler. */
@media (orientation:landscape) and (max-height:500px){
  #stage{ padding-top:16px; padding-bottom:16px; }
  #stage-header{ margin-bottom:2px; }
  #game-title{ font-size:1.1rem; }
  #game-subtitle{ font-size:0.85rem; margin-top:2px; }
  #milo-stage{ width:18vw; min-width:90px; margin:2px 0; }
  #dialogue-box{ padding:12px 16px 14px; margin:4px 0 8px; }
  #dialogue-text{ font-size:0.92rem; }
  .final-card{ padding:16px 16px 14px; gap:6px; }
  .final-card-icon{ font-size:1.5rem; }
  .final-card-photo{ max-height:18vh; }
  .final-card-message{ font-size:0.95rem; max-height:26vh; }
  .text-panel{ padding:12px 16px; }
  .quiz-question{ font-size:1.05rem; }

  /* Passe 5A (robustesse responsive) : reveal du coffre (.final-message,
     voir onChestClick()/revealLines() dans script.js). En paysage, le
     nombre de lignes (8 + 1-3 selon l'animal, voir revealReactionByAnimal)
     peut largement dépasser la hauteur disponible — jusqu'à ~436px de
     dépassement mesurés pour Lucky (11 lignes) à 844x390. Même principe
     que .final-card-message juste au-dessus (max-height + overflow-y:auto,
     déjà établi) : le bouton câlin reste ainsi TOUJOURS à une distance de
     défilement bornée et prévisible, jamais à 300-400px plus bas dans la
     page. gap et taille de ligne réduits en plus, pour limiter à quel
     point le défilement interne est sollicité. Portrait non concerné : ni
     max-height ni overflow-y n'existent en dehors de cette media query,
     donc le comportement actuel (défilement de page, déjà fonctionnel)
     reste strictement inchangé partout ailleurs. */
  .final-message{
    max-height:44vh;
    overflow-y:auto;
    gap:6px;
  }
  .reveal-line{ font-size:0.95rem; }
  .hug-btn{ margin-top:6px; }
}

/* ==========================================================================
   ÉCRANS DE CHARGEMENT / ERREUR CADEAU — voir gift-loader.js. Masqués par
   défaut (.hidden), affichés uniquement le temps de récupérer une config
   distante (?gift=XXXX) ; n'apparaissent jamais en mode dev/URL/défaut.
   Au-dessus de tout le reste (#hearts-layer inclus, z-index:20).
   ========================================================================== */
#gift-loading, #gift-error{
  position:fixed;
  inset:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    radial-gradient(120% 80% at 15% 0%, var(--lavender-100) 0%, transparent 55%),
    var(--cream);
}

.gift-status-card{
  max-width:360px;
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  text-align:center;
  padding:32px 26px;
}
.gift-status-card p{
  font-family:var(--font-heading);
  font-size:1.08rem;
  font-weight:700;
  color:var(--text-primary);
  line-height:1.5;
}
.gift-status-icon{
  display:inline-block;
  font-size:2.2rem;
  animation:gift-status-pulse 1.8s ease-in-out infinite;
}
@keyframes gift-status-pulse{
  0%,100%{ transform:scale(1); opacity:0.85; }
  50%{ transform:scale(1.12); opacity:1; }
}
#gift-error .gift-status-icon{ animation:none; }
#gift-error-retry{ margin-top:4px; }

/* Garde i18n (PASSE 3K, INDEX UNIQUEMENT — #app et #gift-loading n'existent
   que dans index.html) : classe posée par i18n-preboot.js pour un visiteur
   non-FR, ou par script.js (boot()) le temps de charger la langue d'un
   cadeau. visibility (jamais display:none) : aucune variation de layout au
   reveal, et rien de focusable pendant l'attente. Le loader cadeau reste
   visible (fond + cœur animé, visuel neutre) ; seul son texte attend de
   pouvoir être affiché dans la bonne langue. Retirée par script.js (boot())
   une fois la langue définitive appliquée — jamais avant. */
html.i18n-prepaint-pending #app,
html.i18n-prepaint-pending #gift-loading p{
  visibility:hidden;
}
/* Même garde tant que le loader cadeau (plein écran, opaque) est affiché :
   #app est de toute façon invisible dessous, mais sa mise à jour au reveal
   (contenu par défaut → contenu du cadeau, bascule ltr → rtl) était comptée
   comme layout shift. Sans :has() (navigateurs anciens) : comportement
   d'avant, rien de masqué. */
body:has(> #gift-loading:not(.hidden)) #app{
  visibility:hidden;
}

/* ==========================================================================
   ACCESSIBILITÉ — MOUVEMENT RÉDUIT
   ========================================================================== */

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:0.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:0.001ms !important;
  }
  .blob, .ambient-particle, .heart-accent, .start-btn, .hug-btn, .chest-lid, .floating-heart, #milo-tap, .scenery-item, .tree-canopy, .lantern-glow,
  .milo-tail-group, .milo-head-group, .ear-l, .ear-r, .milo-nose, .eyelid.blink-now, .gift-status-icon{
    animation:none !important;
  }
}

.svg-defs-hidden {
  position: absolute;
}

/* PRELAUNCH-15 — bandeau de pré-lancement (ventes non ouvertes). Bloc statique en tête de page :
   ne modifie ni la navigation (collante), ni les animations, ni le configurateur. */
.prelaunch-banner{
  position:relative;
  z-index:70;
  margin:0;
  padding:9px 16px;
  text-align:center;
  font-family:inherit;
  font-size:0.86rem;
  font-weight:700;
  line-height:1.4;
  color:#fff;
  background:#3b2450;
}

.prelaunch-banner a{ color:#fff; text-decoration:underline; }
.prelaunch-banner span[lang]{ font-weight:400; opacity:.85; }
