/* ═══════════════════════════════════════════════════════════
   L'ANNIVERSAIRE ENCHANTÉ – Feuille de styles complète
   Mobile-first · Palette parcheminée & dorée
═══════════════════════════════════════════════════════════ */

/* ── Variables globales ─────────────────────────────────── */
:root {
  /* Couleurs globales */
  --gold:          #C9A84C;
  --gold-light:    #F0D078;
  --gold-dim:      #8B6914;
  --gold-glow:     #FFD70040;
  --parchment:     #FDF6E3;
  --parchment-2:   #F5E8C8;
  --ink:           #2C1810;
  --ink-soft:      #4A2F24;
  --cream:         #FAF3DF;

  /* Thème chapitre 1 – Bibliothèque */
  --ch1-bg:        #120806;
  --ch1-surface:   #1F0E08;
  --ch1-accent:    #8B1A1A;
  --ch1-text:      #E8D5B0;
  --ch1-highlight: #C9A84C;

  /* Thème chapitre 2 – Théâtre */
  --ch2-bg:        #0A0407;
  --ch2-surface:   #160A10;
  --ch2-accent:    #7B0E24;
  --ch2-text:      #F0D8C8;
  --ch2-spot:      #FFD700;

  /* Thème chapitre 3 – Atelier (nuit, chandelles) */
  --ch3-bg:        #100A04;
  --ch3-surface:   #1E1208;
  --ch3-text:      #E8C890;

  /* Thème chapitre 4 – Lac */
  --ch4-bg:        #081420;
  --ch4-surface:   #0D1E30;
  --ch4-water:     #1565C0;
  --ch4-mist:      #B0D4E8;
  --ch4-text:      #CFE8F8;

  /* Thème chapitre 5 – Tour */
  --ch5-bg:        #08061A;
  --ch5-surface:   #10082A;
  --ch5-accent:    #6C3483;
  --ch5-cyber:     #00BCD4;
  --ch5-text:      #D8C8F8;

  /* Typographie */
  --font-display: 'Cinzel', 'Georgia', serif;
  --font-body:    'Cormorant Garamond', 'Georgia', serif;
  --font-ui:      'Jost', 'Arial', sans-serif;

  /* Tailles */
  --touch:        48px;
  --radius:       14px;
  --radius-lg:    22px;
  --radius-xl:    32px;

  /* Transitions */
  --ease-magic:   cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #08060E;
  color: var(--parchment);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ── Système d'écrans ───────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Overlay de transition ──────────────────────────────── */
#transition-overlay {
  position: fixed;
  inset: 0;
  background: #08060E;
  opacity: 0;
  pointer-events: none;
  z-index: 900;
  transition: opacity 0.3s ease;
}
#transition-overlay.active { opacity: 1; pointer-events: all; }

/* ── Scroll interne ─────────────────────────────────────── */
.chapter-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2rem;
}

/* ═══════════════════════════════════════════════════════════
   OVERLAY FRAGMENT DÉCOUVERT
═══════════════════════════════════════════════════════════ */
.fragment-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.4s ease;
}
.fragment-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.fragment-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}
.fragment-overlay-card {
  position: relative;
  background: linear-gradient(145deg, #1A0E04, #2C1A08);
  border: 2px solid var(--gold);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem 2.5rem 2rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 0 60px var(--gold-glow), 0 20px 60px rgba(0,0,0,0.6);
  animation: overlayCard 0.5s var(--ease-magic) forwards;
  overflow: visible;
}
@keyframes overlayCard {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.fragment-glyph {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  animation: floatGlyph 2s ease-in-out infinite;
}
@keyframes floatGlyph {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.fragment-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.fragment-name {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 1rem;
}
.fragment-text {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--parchment-2);
  font-style: italic;
  margin-bottom: 1.8rem;
}
.fragment-continue-btn {
  width: 100%;
}

/* Photo de Manon — figure entière, fond transparent, côté droit */
.fragment-manon-photo {
  position: absolute;
  right: -14px;
  bottom: -6px;
  height: 88%;
  max-height: 310px;
  min-height: 180px;
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  filter:
    drop-shadow(-6px 0 18px rgba(201,168,76,0.35))
    drop-shadow(0 -4px 12px rgba(201,168,76,0.15));
  animation: manonReveal 0.65s 0.55s cubic-bezier(0.34,1.56,0.64,1) both;
  z-index: 3;
}
@keyframes manonReveal {
  from { opacity: 0; transform: translateX(18px) translateY(10px); }
  to   { opacity: 1; transform: translateX(0)    translateY(0);    }
}
.fragment-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN ACCUEIL
═══════════════════════════════════════════════════════════ */
#screen-home {
  background: radial-gradient(ellipse at 30% 20%, #1A0A30 0%, #08060E 60%);
  align-items: center;
  justify-content: center;
  text-align: center;
}
.home-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.star-particle {
  position: absolute;
  color: var(--gold-light);
  opacity: 0;
  animation: starFloat linear infinite;
  user-select: none;
}
@keyframes starFloat {
  0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.4; }
  100% { opacity: 0; transform: translateY(-120px) rotate(360deg); }
}
.home-content {
  position: relative;
  z-index: 1;
  padding: 2rem 2rem 1rem;
  max-width: 480px;
  width: 100%;
}
.home-wand {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  display: block;
  animation: wandPulse 3s ease-in-out infinite;
}
@keyframes wandPulse {
  0%, 100% { transform: scale(1) rotate(-5deg); filter: drop-shadow(0 0 8px var(--gold)); }
  50%       { transform: scale(1.1) rotate(5deg); filter: drop-shadow(0 0 20px var(--gold-light)); }
}
.game-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 700;
  color: var(--parchment);
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-shadow: 0 0 40px var(--gold-glow);
  margin-bottom: 0.8rem;
}
.title-accent {
  color: var(--gold-light);
  display: block;
}
.game-subtitle {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--gold);
  font-style: italic;
  margin-bottom: 2.5rem;
  opacity: 0.9;
}
.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
}
.home-scroll-hint {
  position: absolute;
  bottom: 1.5rem;
  letter-spacing: 0.5em;
  color: var(--gold);
  opacity: 0.4;
  font-size: 0.75rem;
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN CARTE
═══════════════════════════════════════════════════════════ */
#screen-map {
  background:
    radial-gradient(ellipse at 80% 10%, #2C1A0820 0%, transparent 50%),
    radial-gradient(ellipse at 10% 90%, #1A0A3020 0%, transparent 50%),
    linear-gradient(160deg, #12090A 0%, #0E0E1A 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem 0.6rem;
  border-bottom: 1px solid #ffffff14;
  flex-shrink: 0;
}
.map-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold-light);
  letter-spacing: 0.04em;
}
.fragment-counter {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
}
#fragment-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-light);
}
.counter-sep { font-size: 0.9rem; color: #ffffff40; margin: 0 2px; }
.counter-label { font-size: 0.75rem; color: #ffffff50; margin-left: 4px; text-transform: uppercase; letter-spacing: 0.1em; }

.fragments-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  flex-shrink: 0;
}
.fragment-orb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1A1020;
  border: 2px solid #ffffff20;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  filter: grayscale(1) opacity(0.35);
  transition: all 0.5s var(--ease-magic);
}
.fragment-orb.collected {
  filter: grayscale(0) opacity(1);
  border-color: var(--gold);
  box-shadow: 0 0 16px var(--gold-glow);
  animation: orbPulse 2s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { box-shadow: 0 0 12px var(--gold-glow); }
  50%       { box-shadow: 0 0 24px var(--gold), 0 0 40px var(--gold-glow); }
}

.map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 0.9rem;
  padding: 0.8rem 1.2rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-content: start;
}
.portal-btn {
  position: relative;
  min-height: var(--touch);
  padding: 1.2rem 0.8rem;
  background: linear-gradient(145deg, #1A1020, #120C1C);
  border: 1.5px solid #ffffff18;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  transition: transform 0.2s var(--ease-magic), border-color 0.3s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.portal-btn:active { transform: scale(0.96); }
.portal-btn.completed {
  border-color: var(--gold);
  background: linear-gradient(145deg, #1E1428, #160F20);
  box-shadow: 0 0 20px var(--gold-glow);
}
.portal-center {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
}
.portal-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, var(--gold-glow), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}
.portal-btn.completed .portal-glow { opacity: 1; }
.portal-btn:active .portal-glow { opacity: 1; }
.portal-icon { font-size: 2rem; line-height: 1; }
.portal-name {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--parchment-2);
  text-align: center;
  line-height: 1.3;
}
.portal-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gold);
  color: #1A0A04;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-ui);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-finale {
  grid-column: 1 / -1;
  margin-top: 0.4rem;
  margin-bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));

  font-family: var(--font-display);
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold), var(--gold-light));
  color: #1A0A04;
  border: none;
  border-radius: var(--radius-lg);
  padding: 1rem 2.5rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 30px rgba(201,168,76,0.4);
  animation: finaleBtnGlow 2.5s ease-in-out infinite;
  min-height: var(--touch);
}
@keyframes finaleBtnGlow {
  0%, 100% { box-shadow: 0 4px 30px rgba(201,168,76,0.4); }
  50%       { box-shadow: 0 4px 50px rgba(240,208,120,0.7); }
}

/* ═══════════════════════════════════════════════════════════
   HEADER COMMUN AUX CHAPITRES
═══════════════════════════════════════════════════════════ */
.chapter-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid #ffffff14;
  flex-shrink: 0;
  z-index: 10;
}
.btn-back {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--gold);
  background: transparent;
  border: 1.5px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  min-height: var(--touch);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.btn-back:active { background: var(--gold); color: #1A0A04; }
.chapter-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--gold-light);
  letter-spacing: 0.03em;
  line-height: 1.3;
}
.chapter-content {
  padding: 1.2rem 1.2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ═══════════════════════════════════════════════════════════
   COMPOSANTS PARTAGÉS
═══════════════════════════════════════════════════════════ */

/* Boutons */
.btn-primary {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #8B6914, var(--gold), #E8C060);
  color: #1A0A04;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.85rem 2rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  min-height: var(--touch);
  box-shadow: 0 4px 20px rgba(201,168,76,0.35);
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(201,168,76,0.3);
}
.btn-large { padding: 1rem 2.5rem; font-size: 1.1rem; min-width: 220px; }

.btn-secondary {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.8rem;
  cursor: pointer;
  min-height: var(--touch);
  transition: background 0.2s, color 0.2s;
}
.btn-secondary:active { background: var(--gold); color: #1A0A04; }

.btn-ghost {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  background: transparent;
  color: #ffffff40;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  text-decoration: underline;
  min-height: var(--touch);
}

/* Textes narratifs */
.narrative-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
}
.intro-text {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.65;
  opacity: 0.9;
  margin-bottom: 0.8rem;
}
.riddle-box {
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid;
}
.riddle-text {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.6;
}
.riddle-question {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.8rem;
}

/* Feedback */
.feedback-box {
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.5;
  min-height: 3rem;
  transition: all 0.3s ease;
}
.feedback-box.success { background: #0D2B1A; border: 1px solid #27AE60; color: #80E8A0; }
.feedback-box.error   { background: #2B0D0D; border: 1px solid #E74C3C; color: #F8A0A0; }
.feedback-box.info    { background: #0D1A2B; border: 1px solid #2980B9; color: #80C8F8; }
.feedback-box.empty   { border: 1px solid transparent; }

/* Hint */
.hint-box {
  background: rgba(201,168,76,0.08);
  border: 1px dashed var(--gold-dim);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--gold);
  line-height: 1.5;
}

/* Écran chapitre déjà résolu */
.solved-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem 1rem;
}
.solved-icon { font-size: 4rem; animation: floatGlyph 2s ease-in-out infinite; }
.solved-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-light);
}
.solved-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  opacity: 0.8;
  line-height: 1.6;
}

/* Animations utilitaires */
@keyframes shake {
  0%  { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100%{ transform: translateX(0); }
}
.shake { animation: shake 0.4s ease forwards !important; }

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.pop-in { animation: popIn 0.35s var(--ease-magic) forwards; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   CHAPITRE 1 – BIBLIOTHÈQUE
═══════════════════════════════════════════════════════════ */
#screen-ch1 {
  background:
    radial-gradient(ellipse at 50% 0%, #4A1A0830 0%, transparent 60%),
    linear-gradient(180deg, var(--ch1-bg) 0%, #1A0C06 100%);
}
.ch1-theme .chapter-header { background: rgba(18, 8, 6, 0.9); }
.ch1-theme .narrative-box { border-color: var(--gold-dim); color: var(--ch1-text); }
.ch1-theme .riddle-box { background: rgba(139,26,26,0.12); border-color: var(--ch1-accent); color: var(--ch1-text); }
.ch1-theme .riddle-question { color: var(--gold); }

.books-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
.book-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius);
  transition: transform 0.2s var(--ease-magic);
  min-height: var(--touch);
}
.book-btn:active { transform: scale(0.95); }
.book-cover {
  border-radius: var(--radius);
  padding: 1.1rem 0.8rem;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.4;
  font-style: italic;
  border: 2px solid;
  transition: box-shadow 0.2s, transform 0.2s;
}
.book-a { background: linear-gradient(145deg, #1A0A08, #2C1010); border-color: #5C2020; color: #C89898; }
.book-b { background: linear-gradient(145deg, #0A1208, #121E0C); border-color: #2C4A20; color: #98B888; }
.book-c { background: linear-gradient(145deg, #0A100F, #122018); border-color: #204A3C; color: var(--gold); }
.book-d { background: linear-gradient(145deg, #0E0C1A, #18142A); border-color: #30285A; color: #B8A8E8; }
.book-btn:active .book-cover { box-shadow: 0 0 20px var(--gold-glow); }

/* ═══════════════════════════════════════════════════════════
   CHAPITRE 2 – THÉÂTRE
═══════════════════════════════════════════════════════════ */
#screen-ch2 {
  background:
    radial-gradient(ellipse at 50% -20%, #7B0E2420 0%, transparent 50%),
    linear-gradient(180deg, var(--ch2-bg) 0%, #100610 100%);
}
.ch2-theme .chapter-header { background: rgba(10,4,7,0.9); }
.ch2-theme .narrative-box { border-color: #7B0E2440; color: var(--ch2-text); }
.ch2-theme .riddle-box { background: rgba(123,14,36,0.10); border-color: var(--ch2-accent); color: var(--ch2-text); }
.ch2-theme .riddle-question { color: var(--ch2-spot); }

.spotlight {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 300px;
  background: radial-gradient(ellipse at top, rgba(255,215,0,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.matching-game {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.match-column h3 {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
  text-align: center;
}
.match-item, .match-role {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.8rem 0.5rem;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ch2-text);
  line-height: 1.3;
  text-align: center;
  min-height: var(--touch);
  transition: all 0.2s ease;
}
.match-item { font-size: 0.82rem; }
.match-emoji { font-size: 1.6rem; line-height: 1; }
.match-role { font-size: 0.8rem; }
.match-item.selected, .match-role.selected {
  border-color: var(--gold);
  background: rgba(201,168,76,0.12);
  color: var(--gold-light);
}
.match-item.matched, .match-role.matched {
  border-color: #27AE60;
  background: rgba(39,174,96,0.12);
  color: #80E8A0;
  cursor: default;
}
.match-item:disabled, .match-role:disabled {
  cursor: default;
}
.match-item:not(:disabled):active, .match-role:not(:disabled):active {
  transform: scale(0.96);
  border-color: var(--gold);
}

/* ═══════════════════════════════════════════════════════════
   CHAPITRE 3 – ATELIER
═══════════════════════════════════════════════════════════ */
#screen-ch3 {
  background: radial-gradient(ellipse at 50% 0%, #2A1A08 0%, var(--ch3-bg) 60%);
}
.ch3-theme .chapter-header {
  background: rgba(16, 10, 4, 0.95);
  border-bottom-color: #6A4A1880;
}
.ch3-theme .chapter-title { color: var(--gold); }
.ch3-theme .btn-back { color: var(--gold-light); border-color: #6A4A1880; }
.ch3-theme .btn-back:active { background: rgba(201,168,76,0.15); color: var(--gold); }
.ch3-theme .narrative-box { background: rgba(201,168,76,0.05); border-color: #7A5C2860; color: var(--ch3-text); }
.ch3-theme .riddle-box { background: rgba(201,168,76,0.07); border-color: var(--gold-dim); color: var(--ch3-text); }
.ch3-theme .riddle-text { color: var(--ch3-text); }
.ch3-theme .riddle-question { color: var(--gold-light); }
.ch3-theme .feedback-box.success { background: #0B2616; border-color: #2E9456; color: #78D898; }
.ch3-theme .feedback-box.error   { background: #2A0B10; border-color: #C0392B; color: #F09090; }
.ch3-theme .hint-box { background: rgba(201,168,76,0.08); border-color: #7A5C2850; color: var(--ch3-text); }
.ch3-theme .btn-secondary { color: var(--gold-light); border-color: #6A4A1880; }
.ch3-theme .ch-title-icon { color: var(--gold-dim); }

.canvas-frame {
  background: #1A1008;
  border: 2px solid #7A5C28;
  border-radius: var(--radius);
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.4);
  overflow: hidden;
}
.painting-slots {
  display: flex;
  height: 80px;
}
.paint-slot {
  flex: 1;
  background: #221608;
  transition: background 0.5s ease, transform 0.3s var(--ease-magic);
  border-right: 1px solid rgba(255,255,255,0.06);
}
.paint-slot:last-child { border-right: none; }
.paint-slot.filled { transform: scaleY(1.05); }
.painting-slots.complete { border-radius: var(--radius); overflow: hidden; }

.color-palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}
.color-orb {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: transform 0.2s var(--ease-magic), opacity 0.3s, filter 0.3s;
  padding: 0.5rem;
}
.color-orb:active { transform: scale(0.93); }
.color-orb.used { opacity: 0.35; transform: scale(0.88); pointer-events: none; }
.color-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  letter-spacing: 0.03em;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   CHAPITRE 4 – LAC / KAYAK
═══════════════════════════════════════════════════════════ */
#screen-ch4 {
  background: linear-gradient(180deg, var(--ch4-bg) 0%, #0A1020 100%);
}
.ch4-theme .chapter-header { background: rgba(8,20,32,0.9); border-bottom-color: #1E4D7B40; }
.ch4-theme .narrative-box { border-color: #1E4D7B60; color: var(--ch4-text); }
.ch4-theme .riddle-box { background: rgba(21,101,192,0.08); border-color: #1565C040; color: var(--ch4-mist); }

.kayak-ui {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem 0.5rem;
}
.lives-display { display: flex; gap: 0.3rem; font-size: 1.3rem; }
.timer-display {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ch4-mist);
}
#kayak-timer { font-size: 1.4rem; color: var(--gold-light); }

.canvas-wrapper {
  display: flex;
  justify-content: center;
}
#kayak-canvas {
  border-radius: var(--radius);
  display: block;
  touch-action: none;
}

.kayak-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0.5rem 0;
  gap: 1rem;
}
.btn-control {
  flex: 1;
  min-height: 64px;
  font-size: 1.8rem;
  background: rgba(21,101,192,0.25);
  border: 2px solid rgba(21,101,192,0.5);
  border-radius: var(--radius-lg);
  color: var(--ch4-mist);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
  touch-action: manipulation;
}
.btn-control:active { background: rgba(21,101,192,0.5); }

/* ═══════════════════════════════════════════════════════════
   CHAPITRE 5 – TOUR DES MAGES
═══════════════════════════════════════════════════════════ */
#screen-ch5 {
  background:
    radial-gradient(ellipse at 60% 0%, #6C348310 0%, transparent 50%),
    radial-gradient(ellipse at 30% 100%, #00BCD410 0%, transparent 50%),
    linear-gradient(180deg, var(--ch5-bg) 0%, #060412 100%);
}
.ch5-theme .chapter-header { background: rgba(8,6,26,0.9); border-bottom-color: #6C348330; }
.ch5-theme .narrative-box { border-color: #6C348340; color: var(--ch5-text); }
.ch5-theme .riddle-box { background: rgba(108,52,131,0.10); border-color: var(--ch5-accent); color: var(--ch5-text); }
.ch5-theme .riddle-question { color: var(--ch5-cyber); }

.digital-runes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.5rem;
  opacity: 0.25;
  pointer-events: none;
}
.rune {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--ch5-cyber);
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--ch5-cyber);
  border-radius: 4px;
  animation: runeFloat 3s ease-in-out infinite;
}
@keyframes runeFloat {
  0%, 100% { opacity: 0.5; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(-4px); }
}

.seo-options {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.seo-card {
  width: 100%;
  background: rgba(108,52,131,0.10);
  border: 1.5px solid rgba(108,52,131,0.35);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  min-height: var(--touch);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.seo-card:active { transform: scale(0.98); border-color: var(--ch5-cyber); background: rgba(0,188,212,0.08); }
.seo-card.correct {
  border-color: #27AE60;
  background: rgba(39,174,96,0.10);
}
.seo-card.wrong {
  border-color: #E74C3C;
  background: rgba(231,76,60,0.08);
  opacity: 0.7;
}
.seo-keyword {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ch5-cyber);
  letter-spacing: 0.02em;
}
.seo-note {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.seo-stats { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.stat-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: rgba(216,200,248,0.7);
  width: 110px;
  flex-shrink: 0;
}
.stat-crystals {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--gold);
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN FINALE
═══════════════════════════════════════════════════════════ */
#screen-finale {
  background:
    radial-gradient(ellipse at 50% 0%, #2C1A0830 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, #1A0A3020 0%, transparent 60%),
    linear-gradient(160deg, #0E0A04 0%, #0E0E1A 100%);
}
.finale-hero {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid #ffffff14;
}
.finale-emoji { font-size: 4rem; margin-bottom: 1rem; display: block; animation: floatGlyph 2s ease-in-out infinite; }
.finale-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  color: var(--gold-light);
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-shadow: 0 0 40px var(--gold-glow);
}
.finale-fragments-row {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1.2rem;
}
.finale-frag {
  font-size: 1.8rem;
  animation: floatGlyph 2s ease-in-out infinite;
}
.finale-frag:nth-child(1) { animation-delay: 0s; }
.finale-frag:nth-child(2) { animation-delay: 0.2s; }
.finale-frag:nth-child(3) { animation-delay: 0.4s; }
.finale-frag:nth-child(4) { animation-delay: 0.6s; }
.finale-frag:nth-child(5) { animation-delay: 0.8s; }

.finale-message {
  padding: 1.5rem 1.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.finale-message p {
  font-family: var(--font-body);
  font-size: 1.2rem;
  line-height: 1.75;
  color: var(--parchment-2);
}
.finale-message p:first-child {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-light);
}
.finale-message p:last-child {
  font-style: italic;
  white-space: pre-line;
}
.finale-photo-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 1.5rem 0;
}
.finale-photo {
  max-width: min(320px, 85vw);
  width: 100%;
  height: auto;
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 40px rgba(201,168,76,0.35), 0 2px 12px rgba(0,0,0,0.5);
  filter: drop-shadow(0 0 18px rgba(201,168,76,0.25));
  animation: photoReveal 0.7s 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes photoReveal {
  from { opacity:0; transform:scale(0.88) translateY(16px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}

.finale-actions {
  padding: 1.5rem;
  display: flex;
  justify-content: center;
}

/* Confettis */
.confetti-piece {
  position: fixed;
  z-index: 850;
  pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE FINE-TUNING
═══════════════════════════════════════════════════════════ */
@media (min-width: 420px) {
  .books-grid { grid-template-columns: 1fr 1fr; }
  .color-palette { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 680px) {
  .home-wand { font-size: 2.5rem; margin-bottom: 0.5rem; }
  .game-title { font-size: 1.8rem; }
  .game-subtitle { margin-bottom: 1.5rem; }
}
@media (min-width: 600px) {
  .map-grid { max-width: 500px; margin: 0 auto; }
  .chapter-content { max-width: 520px; margin: 0 auto; }
  .kayak-controls { max-width: 420px; margin: 0 auto; }
}

/* ═══════════════════════════════════════════════════════════
   NOUVEAUX COMPOSANTS v2
═══════════════════════════════════════════════════════════ */

/* ── Horloge sur la carte ──────────────────────────────── */
.map-header { position: relative; }
#map-clock {
  position: absolute;
  bottom: -1.6rem;
  right: 1.2rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.05em;
}

/* ── Portail verrouillé ────────────────────────────────── */
.portal-btn.portal-locked {
  opacity: 0.55;
  border-color: rgba(255,255,255,0.08);
}
.portal-lock-info {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  text-align: center;
  line-height: 1.4;
  margin-top: 0.3rem;
}

/* ── Match column layout ───────────────────────────────── */
.match-column {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.match-column h3 {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 0.2rem;
}

/* ── Indicateur de rounds HP ───────────────────────────── */
.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.6rem 0.2rem;
}
.round-dots { display: flex; gap: 0.5rem; align-items: center; }
.round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.2);
  transition: all 0.3s ease;
}
.round-dot.done {
  background: var(--gold-dim);
  border-color: var(--gold);
}
.round-dot.active {
  background: var(--gold);
  border-color: var(--gold-light);
  box-shadow: 0 0 8px var(--gold-glow);
  transform: scale(1.2);
}
.round-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── CH2 layout élargi (5 descriptions + 10 propositions) ─ */
.matching-game.ch2-wide { align-items: flex-start; }
.ch2-right-col {
  max-height: 460px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.ch2-right-col::-webkit-scrollbar { width: 4px; }
.ch2-right-col::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

/* Items gauche : label avec étoiles de difficulté */
.ch2-item-diff { align-items: flex-start !important; gap: 0.5rem; }
.match-label-wrap { display: flex; flex-direction: column; gap: 0.15rem; text-align: left; }
.match-stars { font-size: 0.6rem; opacity: 0.75; letter-spacing: 0.01em; }

/* Propositions droite : compactes pour tenir dans la colonne */
.ch2-role-compact {
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  min-height: 44px;
  line-height: 1.3;
}
/* Intrus : visuellement neutres (ne trahissent pas leur nature) */
.ch2-role-intruder { border-color: rgba(255,255,255,0.06); opacity: 0.88; }

/* ── CH2 redesign : questions séquentielles ───────────────── */
.ch2-item-hero {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}
.ch2-hero-emoji {
  font-size: 2.4rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 0.1rem;
}
.ch2-hero-hint {
  font-family: var(--font-body);
  font-size: 1rem;
  font-style: italic;
  color: var(--parchment-2);
  line-height: 1.55;
  text-align: left;
  margin: 0;
}

/* Grille 2×2 de propositions */
.ch2-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.8rem;
}
.ch2-option-btn {
  padding: 0.75rem 0.6rem;
  min-height: 60px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(201,168,76,0.2);
  border-radius: 12px;
  color: var(--parchment-2);
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.ch2-option-btn:hover:not(:disabled) {
  border-color: rgba(201,168,76,0.55);
  background: rgba(255,255,255,0.08);
}
.ch2-option-btn.correct {
  border-color: #4CAF50;
  background: rgba(76,175,80,0.15);
  color: #A5D6A7;
}
.ch2-option-btn.wrong {
  border-color: #E57373;
  background: rgba(229,115,115,0.12);
}
.ch2-option-btn.shake { animation: shake 0.4s; }

/* ── CH3 Atelier — composants multi-rounds ─────────────── */

/* Round 2 : grille de mélange de couleurs */
.ch3-mix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.ch3-mix-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 0.5rem;
  min-height: 82px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(201,168,76,0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  font-family: var(--font-body);
}
.ch3-mix-option:hover { border-color: rgba(201,168,76,0.5); background: rgba(255,255,255,0.08); }
.ch3-mix-option.shake { animation: shake 0.4s; }
.mix-dots { display: flex; align-items: center; gap: 0.25rem; }
.mix-dot-circle { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.3); }
.mix-plus-sign, .mix-eq-sign { font-size: 1rem; color: rgba(255,255,255,0.5); }
.mix-result-emoji { font-size: 1.3rem; }
.mix-label { font-size: 0.78rem; color: rgba(255,255,255,0.7); text-align: center; }

/* Round 3 : choix de peintre */
.ch3-painter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.ch3-painter-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.85rem 0.5rem;
  min-height: 86px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(201,168,76,0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.ch3-painter-option:hover { border-color: rgba(201,168,76,0.5); background: rgba(255,255,255,0.08); }
.ch3-painter-option.shake { animation: shake 0.4s; }
.painter-emoji { font-size: 1.6rem; }
.painter-name { font-family: var(--font-display); font-size: 0.75rem; color: #E8D8B0; text-align: center; line-height: 1.3; }
.painter-period { font-family: var(--font-ui); font-size: 0.65rem; color: rgba(255,255,255,0.4); }

/* Round 4 : couleur cible affichée */
.comp-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 0.7rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ch3-text);
}
.comp-swatch {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ── CH5 Tour des Mages — cartes techniques (sans stats) ── */
.seo-card-technical { min-height: 52px; }
.seo-card-technical .seo-keyword { font-size: 0.85rem; }
.seo-card-technical .seo-note { font-size: 0.72rem; }

/* ═══════════════════════════════════════════════════════════
   SPLASH SCREEN
═══════════════════════════════════════════════════════════ */
#splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse at 35% 25%, #1A0A30 0%, #08060E 65%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.55s ease;
}
#splash-overlay.fade-out { opacity: 0; pointer-events: none; }
#splash-overlay.gone     { display: none; }

.splash-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.splash-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}
.splash-wand {
  width: 72px;
  height: 72px;
  color: var(--gold);
  margin-bottom: 1.2rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
  animation: wandPulse 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(201,168,76,0.5));
}
.splash-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 700;
  color: var(--parchment);
  line-height: 1.2;
  letter-spacing: 0.04em;
  margin-bottom: 2rem;
}
.splash-title span { color: var(--gold-light); display: block; }
.splash-ring {
  width: 44px;
  height: 44px;
  border: 2.5px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto;
  animation: splashSpin 0.85s linear infinite;
}
@keyframes splashSpin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   BOUTON MUTE FLOTTANT
═══════════════════════════════════════════════════════════ */
.mute-btn {
  position: fixed;
  bottom: max(1.4rem, env(safe-area-inset-bottom, 1rem));
  right: 1.2rem;
  z-index: 500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(8, 6, 14, 0.88);
  border: 1.5px solid rgba(201,168,76,0.45);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.25s, opacity 0.25s, transform 0.15s;
  padding: 0;
}
.mute-btn svg { width: 18px; height: 18px; }
.mute-btn:active { transform: scale(0.92); }
.mute-btn.muted {
  opacity: 0.55;
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.45);
}

/* ═══════════════════════════════════════════════════════════
   ICÔNES SVG GLOBALES
═══════════════════════════════════════════════════════════ */
.home-wand-svg {
  width: 64px;
  height: 64px;
  color: var(--gold);
  display: block;
  filter: drop-shadow(0 0 10px rgba(201,168,76,0.4));
}
.btn-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 0.3em;
  flex-shrink: 0;
}
.ch-title-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 0.4em;
  color: var(--gold);
  flex-shrink: 0;
}
.ch3-theme .ch-title-icon { color: var(--ink-soft); }

/* Fragment orb SVG */
.fragment-orb { color: rgba(255,255,255,0.4); }
.fragment-orb svg { width: 22px; height: 22px; }
.fragment-orb.collected { color: var(--gold-light); }

/* Finale star */
.btn-finale-star {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 0.3em;
}

/* ═══════════════════════════════════════════════════════════
   CARTE AVENTURE – MAP REDESIGN
═══════════════════════════════════════════════════════════ */
.map-adventure {
  position: relative;
  flex: 1;
  min-height: 0;
  max-height: clamp(300px, 68vh, 580px);
  margin: 0.4rem 0.8rem 0;
  overflow: visible;
}

/* SVG du sentier */
.map-trail-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.trail-base {
  fill: none;
  stroke: rgba(201,168,76,0.12);
  stroke-width: 1.2;
  stroke-dasharray: 4 6;
  stroke-linecap: round;
}
.trail-seg {
  fill: none;
  stroke: rgba(201,168,76,0.15);
  stroke-width: 1.4;
  stroke-linecap: round;
  transition: stroke 0.7s ease, stroke-width 0.5s ease, filter 0.7s ease;
}
.trail-seg.done {
  stroke: var(--gold);
  stroke-width: 2.2;
  filter: drop-shadow(0 0 4px rgba(201,168,76,0.55));
}
.trail-node {
  fill: rgba(201,168,76,0.25);
  stroke: rgba(201,168,76,0.4);
  stroke-width: 0.8;
  transition: fill 0.5s ease;
}

/* Portails sur la carte */
.portal-node {
  position: absolute;
  left: var(--px);
  top: var(--py);
  transform: translate(-50%, -50%);
  width: 86px;
  background: linear-gradient(145deg, #1C1228, #130C1E);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem 0.65rem;
  overflow: hidden;
  transition: transform 0.2s var(--ease-magic), border-color 0.3s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.portal-node:active { transform: translate(-50%, -50%) scale(0.94); }
.portal-node.completed {
  border-color: var(--gold);
  background: linear-gradient(145deg, #201530, #160F24);
  box-shadow: 0 0 22px rgba(201,168,76,0.30);
}
.portal-node .portal-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(201,168,76,0.12), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}
.portal-node.completed .portal-glow,
.portal-node:active .portal-glow { opacity: 1; }

.portal-svg {
  width: 34px;
  height: 34px;
  color: var(--gold-dim);
  transition: color 0.4s ease, filter 0.4s ease;
  flex-shrink: 0;
}
.portal-node.completed .portal-svg {
  color: var(--gold-light);
  filter: drop-shadow(0 0 6px rgba(240,208,120,0.4));
}
.portal-node .portal-name {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.65);
  text-align: center;
  line-height: 1.3;
  transition: color 0.4s;
}
.portal-node.completed .portal-name { color: var(--parchment-2); }

/* Réutilise .portal-badge depuis le CSS existant */
.portal-node .portal-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--gold);
  color: #1A0A04;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Portail verrouillé */
.portal-node.portal-locked {
  opacity: 0.5;
  border-color: rgba(255,255,255,0.06);
}
.portal-lock-info {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
  line-height: 1.4;
  margin-top: 0.2rem;
}

/* Zone finale */
.map-finale-area {
  display: flex;
  justify-content: center;
  padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom, 0.5rem));
  flex-shrink: 0;
}
.btn-finale {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 1rem;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold), var(--gold-light));
  color: #1A0A04;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.9rem 2rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 30px rgba(201,168,76,0.4);
  animation: finaleBtnGlow 2.5s ease-in-out infinite;
  min-height: var(--touch);
}

/* ═══════════════════════════════════════════════════════════
   MICRO-INTERACTIONS – RIPPLE / GLOW
═══════════════════════════════════════════════════════════ */
.btn-primary, .btn-secondary, .book-btn,
.ch2-option-btn, .seo-card, .color-orb, .ch3-mix-option, .ch3-painter-option {
  position: relative;
  overflow: hidden;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(201,168,76,0.28);
  transform: scale(0);
  animation: rippleAnim 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* Glow au press des boutons primaires */
.btn-primary:active {
  box-shadow: 0 0 24px rgba(201,168,76,0.55);
}

/* ═══════════════════════════════════════════════════════════
   TRANSITIONS THÉMATIQUES (overlay doré)
═══════════════════════════════════════════════════════════ */
#transition-overlay {
  background: radial-gradient(ellipse at center, #2C1A08 0%, #08060E 70%);
}
#transition-overlay.active { opacity: 1; pointer-events: all; }

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITÉ – prefers-reduced-motion
═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .splash-ring { animation: none; border-top-color: var(--gold); }
  .ripple { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   COHÉRENCE COULEURS FEEDBACK (alignées palette dorée)
═══════════════════════════════════════════════════════════ */
.feedback-box.success { background: #0B2616; border: 1px solid #2E9456; color: #78D898; }
.feedback-box.error   { background: #2A0B10; border: 1px solid #C0392B; color: #F09090; }
.feedback-box.info    { background: #0A1828; border: 1px solid #2471A3; color: #78B4E8; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE AJUSTEMENTS CARTE
═══════════════════════════════════════════════════════════ */
@media (max-height: 620px) {
  .portal-node { width: 74px; padding: 0.5rem 0.35rem; }
  .portal-svg { width: 28px; height: 28px; }
  .portal-node .portal-name { font-size: 0.65rem; }
}
@media (min-width: 480px) {
  .portal-node { width: 100px; }
  .portal-svg { width: 40px; height: 40px; }
}
@media (min-width: 600px) {
  .map-adventure { max-width: 480px; margin-left: auto; margin-right: auto; }
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN GATE – Question de portail (cadenas)
═══════════════════════════════════════════════════════════ */
#screen-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.gate-scroll {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100%;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

.gate-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .85rem;
  width: 100%;
  max-width: 420px;
  padding: 1.8rem 1.4rem 2rem;
  background: rgba(14, 9, 4, .92);
  border: 1.5px solid var(--gold);
  border-radius: 22px;
  box-shadow: 0 0 50px rgba(201, 168, 76, .18), inset 0 0 30px rgba(201, 168, 76, .04);
}

.gate-lock-icon {
  font-size: 3.8rem;
  line-height: 1;
  filter: drop-shadow(0 0 14px rgba(201, 168, 76, .6));
  animation: gatePulse 2.4s ease-in-out infinite;
  transition: filter .4s;
}

@keyframes gatePulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.1); opacity: .8; }
}

.gate-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: .08em;
  text-align: center;
  margin: 0;
}

.gate-chapter-name {
  font-family: var(--font-body);
  font-size: .82rem;
  color: var(--gold-light);
  opacity: .65;
  text-align: center;
  margin: -.2rem 0 0;
}

.gate-divider {
  width: 60%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(201,168,76,.4), transparent);
  margin: .1rem 0;
}

.gate-question-box {
  background: rgba(201, 168, 76, .06);
  border: 1px solid rgba(201, 168, 76, .28);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  width: 100%;
  box-sizing: border-box;
}

.gate-question {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.65;
  margin: 0;
  font-style: italic;
}

.gate-input-area {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  width: 100%;
}

.gate-input {
  width: 100%;
  padding: .75rem 1rem;
  background: rgba(255, 255, 255, .05);
  border: 1.5px solid rgba(201, 168, 76, .35);
  border-radius: 10px;
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}

.gate-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, .15);
}

.gate-hint-btn {
  background: none;
  border: 1px dashed rgba(201, 168, 76, .35);
  border-radius: 8px;
  color: rgba(201, 168, 76, .6);
  font-family: var(--font-body);
  font-size: .875rem;
  padding: .55rem 1.1rem;
  cursor: pointer;
  transition: all .2s;
}

.gate-hint-btn:hover, .gate-hint-btn:focus {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 168, 76, .05);
}

.gate-hint-box {
  background: rgba(201, 168, 76, .07);
  border: 1px solid rgba(201, 168, 76, .22);
  border-radius: 12px;
  padding: .9rem 1.1rem;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: .875rem;
  color: var(--gold-light);
  line-height: 1.65;
}

.gate-hint-box p { margin: 0 0 .35rem; }
.gate-hint-box p:last-child { margin-bottom: 0; }

.gate-hint-label {
  font-weight: 600;
  color: var(--gold);
  font-style: normal !important;
  margin-bottom: .6rem !important;
}

.gate-hint-phrase {
  font-style: italic;
  color: rgba(240, 220, 180, .75);
  padding-left: .75rem;
  border-left: 2px solid rgba(201, 168, 76, .35);
}

.gate-back-btn {
  font-size: .82rem;
  opacity: .6;
  padding: .4rem .8rem;
}

.gate-back-btn:hover { opacity: 1; }

.gate-submit { width: 100%; }

/* Vignettage subtil sur les écrans sombres */
.screen::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  z-index: 0;
}
#screen-ch3.screen::after { background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.45) 100%); }
.screen > * { position: relative; z-index: 1; }
