/* Académie de Sorcellerie de Brumelune — thème "nuit étoilée et parchemins" */
:root {
  --nuit: #120c2c;
  --nuit-2: #1d1446;
  --violet: #2c1f5e;
  --violet-clair: #4b3a8f;
  --or: #f3c25a;
  --or-clair: #ffe39a;
  --or-fonce: #b9821f;
  --parchemin: #f6e8c8;
  --parchemin-2: #e8cf9f;
  --encre: #3b2914;
  --encre-douce: #6b5232;
  --texte: #f4eeff;
  --texte-doux: #c7bce6;
  --rouge: #ff5a6e;
  --vert: #43d39e;
  --rayon: 16px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, #3a2a7a 0%, var(--nuit-2) 40%, var(--nuit) 100%) fixed;
  background-color: var(--nuit);
  color: var(--texte);
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.fond-etoiles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 72%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 34%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 58%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 26%, #d8c8ff 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 88%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 54% 92%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 94% 80%, #ffe9b0 50%, transparent 51%);
  animation: scintille 6s ease-in-out infinite alternate;
  opacity: 0.8;
}

@keyframes scintille { from { opacity: 0.45; } to { opacity: 0.9; } }

main#ecran {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--haut) + 20px) 16px calc(var(--bas) + 40px);
}

body.avec-barre main#ecran { padding-top: calc(var(--haut) + 74px); }

h1, h2, h3 { font-family: 'Cinzel', serif; font-weight: 700; margin: 0 0 0.5em; line-height: 1.2; }
h2 { font-size: 1.45rem; color: var(--or); text-shadow: 0 2px 12px rgba(243, 194, 90, 0.35); }
h3 { font-size: 1.12rem; }
p { margin: 0 0 0.8em; }
strong { font-weight: 800; }

.accroche { font-size: 1.15rem; font-weight: 700; text-align: center; color: var(--or-clair); }
.petit { font-size: 0.88rem; opacity: 0.85; }

/* ---------- Boutons ---------- */
.btn {
  display: block;
  width: 100%;
  margin: 14px 0 0;
  padding: 15px 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--or-clair), var(--or) 45%, var(--or-fonce));
  color: #2a1a05;
  font: 800 1.05rem 'Nunito', sans-serif;
  box-shadow: 0 6px 18px rgba(243, 194, 90, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-grand { padding: 18px; font-size: 1.15rem; }
.btn-sec {
  background: rgba(255, 255, 255, 0.08);
  color: var(--texte);
  border: 1.5px solid rgba(243, 194, 90, 0.5);
  box-shadow: none;
}
.lien {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: 0;
  color: var(--encre-douce);
  font: 700 0.92rem 'Nunito', sans-serif;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Animations communes ---------- */
.ecran { animation: apparait 0.45s ease both; }
@keyframes apparait { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.secoue { animation: secoue 0.5s ease; }
@keyframes secoue {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-1deg); }
  40% { transform: translateX(8px) rotate(1deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.etincelle {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: etincelle 1s ease-out forwards;
  text-shadow: 0 0 8px currentColor;
}
@keyframes etincelle {
  from { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(120deg); }
}

/* ---------- Barre du haut ---------- */
#barre {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--haut) + 8px) 12px 8px;
  background: rgba(18, 12, 44, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(243, 194, 90, 0.35);
}
#barre[hidden] { display: none; }
.sablier {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 700 1.1rem 'Cinzel', serif;
  color: var(--or-clair);
  min-width: 92px;
}
.sablier-icone { display: inline-block; animation: sablier 4s ease-in-out infinite; }
@keyframes sablier { 0%, 80% { transform: rotate(0); } 90%, 100% { transform: rotate(180deg); } }
.sablier.urgent { color: var(--rouge); animation: pulse 1s infinite; }
.sablier.bonus { color: #8ff0c2; }
@keyframes pulse { 50% { opacity: 0.55; } }
.sacoche { flex: 1; display: flex; justify-content: center; gap: 3px; }
.sacoche span { font-size: 1.15rem; filter: grayscale(1); opacity: 0.25; transition: all 0.6s; }
.sacoche span.obtenu { filter: none; opacity: 1; transform: scale(1.1); }
.badge-role {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--c, var(--or));
  background: rgba(255, 255, 255, 0.06);
  color: var(--texte);
  font: 800 0.92rem 'Nunito', sans-serif;
  cursor: pointer;
}

#connexion {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--bas) + 12px);
  z-index: 60;
  padding: 12px 16px;
  border-radius: 14px;
  background: #5b1f3a;
  border: 1px solid var(--rouge);
  text-align: center;
  font-weight: 800;
  animation: pulse 1.4s infinite;
}
#connexion[hidden] { display: none; }

/* ---------- Écrans d'accueil ---------- */
.ecran-centre { text-align: center; padding-top: 30vh; }
.boule-attente { font-size: 4rem; animation: flotte 2.4s ease-in-out infinite; }
@keyframes flotte { 50% { transform: translateY(-10px); } }

.ecran-choix { text-align: center; }
.titre-academie {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.55rem;
  color: var(--or);
  text-shadow: 0 2px 18px rgba(243, 194, 90, 0.45);
  margin: 10px 0 26px;
}
.titre-academie span { display: block; font-size: 2.2rem; margin-top: 4px; }
.choix-roles { display: grid; gap: 14px; margin-top: 18px; }
.carte-role {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--rayon);
  border: 1.5px solid rgba(243, 194, 90, 0.45);
  background: linear-gradient(135deg, rgba(75, 58, 143, 0.55), rgba(29, 20, 70, 0.75));
  color: var(--texte);
  text-align: left;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
}
.carte-role:active { transform: scale(0.98); }
.carte-role .initiale {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--or-clair), var(--or-fonce));
  color: #2a1a05;
  font: 700 1.6rem 'Cinzel Decorative', serif;
}
.carte-role .nom { font: 700 1.45rem 'Cinzel', serif; flex: 1; }
.carte-role .statut { font-size: 0.8rem; color: var(--texte-doux); }

.ecran-intro { text-align: center; }
.hibou-postal { font-size: 4.5rem; margin-top: 3vh; animation: arriveHibou 1.4s ease-out both, flotte 3s 1.4s ease-in-out infinite; }
@keyframes arriveHibou { from { transform: translate(-60vw, -20vh) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.enveloppe {
  position: relative;
  display: block;
  width: 250px;
  height: 160px;
  margin: 24px auto 12px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(160deg, #f2deb2, #dcbd83);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  overflow: hidden;
  animation: flotte 2.6s ease-in-out infinite;
}
.enveloppe-rabat {
  position: absolute;
  inset: 0 0 auto;
  height: 95px;
  background: linear-gradient(180deg, #e9cf98, #d4b273);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.enveloppe-sceau { position: absolute; left: 50%; top: 62px; width: 64px; transform: translateX(-50%); }
.sceau { width: 100%; height: auto; display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }

.parchemin {
  background: linear-gradient(170deg, var(--parchemin), var(--parchemin-2));
  color: var(--encre);
  border-radius: var(--rayon);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(150, 100, 40, 0.25);
  border: 1px solid #c9a46a;
}
.parchemin h2, .parchemin h3 { color: #5a3410; text-shadow: none; }

.lettre { padding: 22px 20px; text-align: left; font-size: 1rem; }
.lettre-entete { text-align: center; border-bottom: 1px solid #c9a46a; margin-bottom: 14px; padding-bottom: 10px; }
.lettre-blason { font-size: 2.2rem; }
.lettre-entete h2 { font-size: 1.15rem; margin: 4px 0; }
.lettre-directeur { font-size: 0.8rem; color: var(--encre-douce); margin: 0; }
.signature { text-align: right; font-family: 'Cinzel', serif; font-weight: 700; margin-top: 16px; }
.signature em, .signature small { font-family: 'Nunito', sans-serif; font-weight: 500; font-size: 0.8rem; }
.ps { font-size: 0.85rem; font-style: italic; color: var(--encre-douce); }

.scene-chapeau { padding-top: 2vh; }
.chapeau { width: 200px; height: auto; display: block; margin: 0 auto 10px; transform-origin: 50% 90%; }
.chapeau.reflechit { animation: reflechit 1.6s ease-in-out infinite; }
@keyframes reflechit { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) scaleY(1.04); } }
.chapeau.crie { animation: crie 0.6s ease 2; }
@keyframes crie { 50% { transform: scale(1.15) translateY(-10px); } }
.chapeau-texte { min-height: 5.5em; font-size: 1.12rem; font-style: italic; color: var(--or-clair); }
.chapeau-verdict { animation: apparait 0.6s ease both; }
.verdict-annonce { font-size: 1.1rem; margin: 0; }
.verdict-titre {
  font: 700 1.9rem 'Cinzel Decorative', serif;
  color: var(--c);
  text-shadow: 0 0 22px var(--c);
  margin: 6px 0 10px;
  animation: grandit 0.7s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes grandit { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
.verdict-desc { color: var(--texte-doux); }

.ecran-salle { text-align: center; }
.bougies { font-size: 2.6rem; display: flex; justify-content: center; gap: 28px; margin: 10px 0; }
.bougies span { animation: flamme 1.6s ease-in-out infinite; }
.bougies span:nth-child(2) { animation-delay: 0.4s; }
.bougies span:nth-child(3) { animation-delay: 0.9s; }
@keyframes flamme { 50% { transform: scale(1.08) rotate(2deg); filter: brightness(1.3); } }
.liste-apprentis { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; text-align: left; }
.liste-apprentis li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 5px solid var(--c);
}
.liste-apprentis li.ok { background: rgba(67, 211, 158, 0.12); }
.liste-apprentis .embleme { font-size: 1.6rem; }
.liste-apprentis small { color: var(--texte-doux); }

.ecran-mission { text-align: center; }
.alerte-hibou { font-weight: 800; color: var(--or-clair); animation: pulse 1.5s infinite; }
.crapaud-geant { font-size: 5rem; animation: saute 0.9s ease-in-out infinite; margin: 6px 0; }
@keyframes saute { 0%, 100% { transform: translateY(0) scaleY(1); } 40% { transform: translateY(-16px) scaleY(1.05); } 60% { transform: translateY(0) scaleY(0.92); } }
.mission-texte { padding: 18px; text-align: left; }
.mission-texte p { opacity: 0; animation: apparait 0.7s ease forwards; }
.mission-action .btn { opacity: 0; animation: apparait 0.6s ease forwards; }

/* ---------- Étapes ---------- */
.etape-entete { text-align: center; margin-bottom: 12px; }
.etape-num {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(243, 194, 90, 0.15);
  border: 1px solid rgba(243, 194, 90, 0.5);
  color: var(--or-clair);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.bulle-crapaud { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.bulle-crapaud .crapaud { flex: none; font-size: 2.6rem; line-height: 1; animation: saute 2.4s ease-in-out infinite; }
.bulle-crapaud p {
  position: relative;
  margin: 0;
  padding: 12px 14px;
  border-radius: 4px 16px 16px 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.98rem;
}

.carte {
  padding: 18px 16px;
  margin-bottom: 16px;
  border-radius: var(--rayon);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.carte.parchemin { background: linear-gradient(170deg, var(--parchemin), var(--parchemin-2)); border-color: #c9a46a; }

.devinette {
  margin: 12px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--or-fonce);
  border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.45);
  font-size: 1.08rem;
  font-weight: 700;
  font-style: italic;
}

/* Runes */
.message-runes { display: flex; flex-wrap: wrap; gap: 14px 18px; justify-content: center; margin: 14px 0; }
.mot-runes { display: flex; gap: 3px; }
.case-rune { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #3a1f6b; }
.case-rune input {
  width: 30px;
  height: 34px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid #b08a52;
  border-radius: 4px 4px 0 0;
  background: rgba(255, 255, 255, 0.55);
  color: var(--encre);
  font: 800 16px 'Nunito', sans-serif;
  text-align: center;
  text-transform: uppercase;
}
.case-rune input:focus { outline: 2px solid var(--or-fonce); }
.cle-runes { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; padding: 10px; }
.cle-case {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  color: #3a1f6b;
}
.cle-case span { font: 800 1.05rem 'Nunito', sans-serif; color: var(--encre); }

/* Encre invisible */
.zone-grattage { position: relative; border-radius: 12px; overflow: hidden; }
.voile-grattage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; transition: opacity 0.7s; cursor: crosshair; }
.voile-grattage.disparait { opacity: 0; pointer-events: none; }
.zone-secret { margin: 12px 0; min-height: 120px; display: grid; place-items: center; }
.secret { margin: 0; padding: 16px; text-align: center; font-size: 1.1rem; }
.secret .rouge { color: #d4142e; }

/* Hibou */
.hibou h3 { color: var(--or-clair); }
.hibou-photo { overflow: hidden; border-radius: 14px; aspect-ratio: 1 / 1; background: #000; border: 3px solid var(--or); }
.hibou-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 1.2s ease; }
.rebus { font-size: 2.5rem; text-align: center; letter-spacing: 0.05em; padding: 10px 0; }

/* Champ de réponse */
.champ-magique { margin: 4px 0 16px; }
.champ-magique label { display: block; font-weight: 800; margin-bottom: 6px; color: var(--or-clair); }
.carte.parchemin .champ-magique label { color: #5a3410; }
.champ-ligne { display: flex; flex-direction: column; gap: 0; }
.champ-magique input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 2px solid var(--or);
  background: #fffaf0;
  color: var(--encre);
  font: 800 18px 'Nunito', sans-serif;
  letter-spacing: 0.04em;
}
.champ-magique input:focus { outline: none; box-shadow: 0 0 0 4px rgba(243, 194, 90, 0.35); }

/* Fées */
.danse-num { text-align: center; font-weight: 800; color: #5a3410; margin: 6px 0 12px; }
.fees { display: grid; gap: 14px; }
.fees.quatre { grid-template-columns: 1fr 1fr; }
.fees.deux { grid-template-columns: 1fr 1fr; }
.fee {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.25);
  background: radial-gradient(circle at 40% 35%, #fff 0%, var(--c) 45%, #1b1030 100%);
  background: radial-gradient(circle at 40% 35%, #fff 0%, var(--c) 45%, color-mix(in srgb, var(--c) 55%, #000) 100%);
  opacity: 0.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: 'Nunito', sans-serif;
  color: #1b1030;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
}
.fees.deux .fee { opacity: 0.8; }
.fee .fee-perso { font-size: 2.4rem; }
.fee small { font-weight: 800; font-size: 0.95rem; }
.fee.allumee { opacity: 1; transform: scale(1.1); box-shadow: 0 0 40px 10px var(--c); }
.fee:active { transform: scale(1.05); }
.progression { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.progression span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #8a6a3a; }
.progression span.pleine { background: var(--or-fonce); box-shadow: 0 0 8px var(--or); }

/* Mandragore */
.mandragore-carte { text-align: center; }
.mandragore {
  position: relative;
  font-size: 4.5rem;
  background: none;
  border: 0;
  cursor: pointer;
  line-height: 1;
  padding: 10px;
}
.cri { min-height: 1.4em; font-weight: 800; color: #9c1c2b; }

/* Ciel */
.ciel-carte { background: #070518; border-color: rgba(243, 194, 90, 0.4); }
.ciel-carte h3 { color: var(--or-clair); }
.ciel { width: 100%; height: auto; display: block; background: radial-gradient(ellipse at 50% 30%, #1a1442, #070518); border-radius: 12px; }
.ciel .traits line { stroke: rgba(200, 210, 255, 0.45); stroke-width: 1.6; }
.ciel .etoile { fill: #fff; filter: drop-shadow(0 0 4px #fff); }
.ciel .etoile.rouge { fill: #ff4d5e; filter: drop-shadow(0 0 5px #ff4d5e); }

/* Cadenas */
.ordre-cadenas { font-size: 1.1rem; font-weight: 800; margin: 8px 0 0; padding-left: 26px; }
.ordre-cadenas li { margin: 4px 0; }
.cadenas { margin: 4px auto 16px; max-width: 320px; }
.cadenas-anse {
  width: 140px;
  height: 70px;
  margin: 0 auto -10px;
  border: 16px solid #9a9aa8;
  border-bottom: 0;
  border-radius: 70px 70px 0 0;
}
.cadenas-corps {
  padding: 18px 16px;
  border-radius: 20px;
  background: linear-gradient(160deg, #e6b94c, #a87418);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.roues { display: flex; justify-content: center; gap: 10px; }
.roue { display: flex; flex-direction: column; align-items: center; background: #2a1d0a; border-radius: 12px; padding: 4px; }
.roue-btn {
  width: 52px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--or-clair);
  font-size: 1.2rem;
  cursor: pointer;
}
.roue-chiffre { font: 700 2rem 'Cinzel', serif; color: #fff; min-width: 40px; text-align: center; }

/* Dragon */
.dragon-carte { text-align: center; }
.dragon { font-size: 4.5rem; line-height: 1; animation: flotte 3s ease-in-out infinite; }
.dragon-carte .devinette { text-align: left; }
.bravo { font-weight: 800; color: #1c7a4f; font-size: 1.05rem; }
.statut-dragon { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.pastille {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--c);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  font-size: 0.92rem;
}
.pastille.ok { background: rgba(67, 211, 158, 0.18); }

/* Chaudron */
.zone-chaudron { position: relative; text-align: center; margin: 4px 0 14px; }
.zone-chaudron .chaudron {
  width: 240px;
  max-width: 72%;
  margin: 0 auto;
  filter: hue-rotate(var(--teinte, 0deg)) drop-shadow(0 0 18px rgba(255, 255, 255, 0.18));
  transition: filter 0.8s;
}
.zone-chaudron.fume .chaudron { animation: pschit 0.9s ease; }
@keyframes pschit { 30% { filter: hue-rotate(var(--teinte, 0deg)) grayscale(1) brightness(1.7); transform: scale(1.06); } }
.zone-chaudron.remuable { cursor: pointer; }
.zone-chaudron.tourne .chaudron { animation: tourne 0.25s ease; }
@keyframes tourne { 33% { transform: rotate(-4deg); } 66% { transform: rotate(4deg); } }
.verses { display: flex; justify-content: center; gap: 6px; min-height: 1.6em; font-size: 1.4rem; }
.verses span { animation: grandit 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
.recette ul { list-style: none; padding: 0; margin: 8px 0; }
.recette li { padding: 8px 10px; margin: 6px 0; border-radius: 10px; background: rgba(255, 255, 255, 0.5); font-size: 1.02rem; }
.mes-ingredients h3 { color: var(--or-clair); }
.boutons-ingredients { display: grid; gap: 10px; }
.btn-ingredient {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--or);
  background: linear-gradient(135deg, rgba(75, 58, 143, 0.7), rgba(29, 20, 70, 0.9));
  color: var(--texte);
  font: 800 1.02rem 'Nunito', sans-serif;
  text-align: left;
  cursor: pointer;
}
.btn-ingredient .emoji { font-size: 1.8rem; }
.btn-ingredient:disabled { opacity: 0.35; border-color: transparent; }

.barres { margin-top: 14px; display: grid; gap: 8px; }
.barre-remue span { font-weight: 800; font-size: 0.92rem; }
.jauge { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.15); overflow: hidden; }
.jauge div { height: 100%; background: var(--c); border-radius: 999px; transition: width 0.3s; }

/* Formule */
.morceau-formule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
  padding: 16px;
  border-radius: 14px;
  background: #2a1d4f;
  color: #fff;
}
.morceau-formule .rang {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--or);
  color: #2a1a05;
  font: 700 1.6rem 'Cinzel', serif;
}
.morceau-formule .mot { font: 700 1.35rem 'Cinzel', serif; color: var(--or-clair); letter-spacing: 0.04em; }
.btn-micro.ecoute { animation: pulse 1s infinite; background: linear-gradient(180deg, #ff9aa8, var(--rouge)); }
.transcription { text-align: center; font-style: italic; margin-top: 10px; min-height: 1.4em; }

/* Boule de cristal */
.cristal {
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: var(--rayon);
  background: rgba(120, 90, 220, 0.14);
  border: 1px dashed rgba(178, 141, 255, 0.6);
  transition: box-shadow 0.4s;
}
.cristal.brille { box-shadow: 0 0 30px 6px rgba(178, 141, 255, 0.6); }
.cristal-titre { font: 700 1rem 'Cinzel', serif; color: #d8c8ff; display: flex; align-items: center; gap: 8px; }
.cristal-titre .boule { font-size: 1.4rem; animation: flotte 3s ease-in-out infinite; }
.cristal-liste { margin: 10px 0 0; padding-left: 22px; }
.cristal-liste li { margin: 6px 0; }
.cristal-liste:empty { display: none; }
.cristal-action { margin-top: 8px; }
.cristal-attente { font-size: 0.9rem; color: var(--texte-doux); }
.btn-cristal { background: linear-gradient(180deg, #d9c9ff, #a98bff 45%, #7a5ce0); box-shadow: 0 6px 18px rgba(150, 110, 255, 0.35); }

/* ---------- Fin ---------- */
.ecran-fin { text-align: center; }
.transformation { font-size: 6rem; margin: 2vh 0 6px; }
.transformation .perso { display: inline-block; }
.perso.tremble { animation: tremble 0.12s linear infinite; }
@keyframes tremble { 25% { transform: translate(-4px, 2px) rotate(-6deg); } 75% { transform: translate(4px, -2px) rotate(6deg); } }
.fin-titre { min-height: 1.5em; }
.fin-suite { text-align: left; animation: apparait 0.8s ease both; }
.flash { position: fixed; inset: 0; z-index: 90; background: #fff; pointer-events: none; animation: flash 0.9s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.vue-diplome {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow-y: auto;
  padding: calc(var(--haut) + 16px) 16px calc(var(--bas) + 20px);
  background: var(--nuit);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
}
.vue-diplome.visible { opacity: 1; }
.diplome {
  max-width: 480px;
  margin: 0 auto;
  padding: 26px 20px 20px;
  background: linear-gradient(170deg, #fbf1d6, #ecd3a0);
  color: var(--encre);
  border-radius: 6px;
  border: 10px double #a8792a;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}
.diplome h2 { font-family: 'Cinzel Decorative', serif; color: #6b3a0c; text-shadow: none; font-size: 1.35rem; }
.diplome-ecole { font: 700 0.85rem 'Cinzel', serif; letter-spacing: 0.06em; color: var(--encre-douce); }
.diplome-nom { font: 700 2.6rem 'Cinzel Decorative', serif; color: #4a2a8a; margin: 4px 0; }
.diplome-role { font-weight: 800; font-size: 1.1rem; }
.diplome-temps { font-weight: 800; color: #6b3a0c; }
.diplome-date { font-style: italic; }
.diplome-bas { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.diplome-bas .signature { text-align: left; margin: 0; font-size: 0.95rem; }
.diplome-bas .sceau { width: 80px; flex: none; }

/* ---------- Fenêtres ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 5, 24, 0.82);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.35s;
}
.overlay.visible { opacity: 1; }
.overlay-boite {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
  border-radius: 22px;
  background: linear-gradient(170deg, #2e2166, #1a1240);
  border: 1.5px solid rgba(243, 194, 90, 0.6);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(243, 194, 90, 0.15);
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.35s cubic-bezier(.2, 1.4, .4, 1);
}
.overlay.visible .overlay-boite { transform: none; }
.overlay-recit { color: var(--texte-doux); }
.ingredient-gros { font-size: 5.5rem; animation: tournoie 1.6s ease-out both; filter: drop-shadow(0 0 24px rgba(255, 230, 150, 0.8)); }
@keyframes tournoie { from { transform: scale(0) rotate(-540deg); } to { transform: none; } }
.message-mj {
  margin: 10px 0;
  padding: 16px;
  border-radius: 12px;
  background: var(--parchemin);
  color: var(--encre);
  font-size: 1.12rem;
  font-weight: 700;
}
.menu .btn { margin-top: 10px; }

#toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(var(--haut) + 70px);
  z-index: 85;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: #2e2166;
  border: 1.5px solid var(--or);
  color: var(--texte);
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: apparait 0.3s ease both;
  transition: opacity 0.5s, transform 0.5s;
}
.toast.erreur { border-color: var(--rouge); background: #4a1730; }
.toast.succes { border-color: var(--vert); background: #133c33; }
.toast.part { opacity: 0; transform: translateY(-10px); }

/* ---------- Illustrations ---------- */
.illu { display: block; max-width: 100%; height: auto; -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
.emoji-secours { display: inline-block; }
.mini, .badge-embleme, .hibou-titre, .mini-embleme { display: inline-block; vertical-align: middle; object-fit: contain; }
.mini { width: 28px; height: 28px; }
.badge-embleme { width: 26px; height: 26px; }
.hibou-titre { width: 36px; height: 36px; }
.mini-embleme { width: 36px; height: 36px; }

/* Le château occupe le haut de l'écran ; le titre se pose sur la brume sombre du bas de l'image. */
.ecran-choix { --largeur: min(100vw, 520px); }
.vitrail-chateau { position: relative; margin: calc(-1 * (var(--haut) + 20px)) -16px 0; }
.vitrail-chateau .chateau {
  width: 100%;
  -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent);
  mask-image: linear-gradient(to bottom, #000 82%, transparent);
}
.vitrail-chateau .emoji-secours { font-size: 4.2rem; margin-top: calc(var(--haut) + 5vh); }
.vitrail-chateau:has(img) + .titre-academie { margin-top: calc(var(--largeur) * -0.83); }
.ecran-choix .titre-academie, .ecran-choix .accroche, .ecran-choix .choix-roles { position: relative; }

.hibou-postal .illu { width: 150px; margin: 0 auto; }
.lettre-blason .illu { width: 92px; margin: 0 auto; }
.scene-chapeau .chapeau { width: 230px; }
.verdict-embleme { width: 140px; margin: 8px auto 0; animation: grandit 0.7s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 0 18px rgba(255, 230, 150, 0.45)); }
.crapaud-geant .illu { width: 200px; margin: 0 auto; }
.bulle-crapaud .crapaud .illu { width: 66px; }
.sacoche span .illu { width: 26px; height: 26px; object-fit: contain; }
.ingredient-gros .illu { width: 160px; margin: 0 auto; }
.overlay-message .hibou-postal .illu { width: 120px; }
.fee .fee-perso { display: block; width: 58%; }
.mandragore .illu { width: 180px; }
.dragon .illu { width: 200px; margin: 0 auto; }
.verses span .illu { width: 34px; height: 34px; object-fit: contain; }
.btn-ingredient .emoji .illu { width: 46px; height: 46px; object-fit: contain; }
.transformation .perso .illu { width: 230px; margin: 0 auto; }
.diplome-blason { width: 96px; margin: 0 auto 6px; }

/* ---------- Acte 2 ---------- */
.btn-rond {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, var(--or-clair), var(--or-fonce));
  color: #2a1a05;
  font: 800 1.6rem 'Nunito', sans-serif;
  cursor: pointer;
}
.btn-rond:active { transform: scale(0.94); }

/* Labyrinthe */
.grille-laby {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin: 10px 0 8px;
  padding: 6px;
  border-radius: 12px;
  background: #241a3f;
}
.grille-laby .case {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.3rem;
  line-height: 1;
}
.grille-laby .case.trace { background: rgba(243, 194, 90, 0.22); }
.grille-laby .case.mur { background: linear-gradient(160deg, #9a9aab, #55556a); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.4); }
.grille-laby .case.piege { background: rgba(255, 90, 110, 0.35); }
.grille-laby .case.cle { background: rgba(255, 215, 100, 0.4); }
.grille-laby .case .illu { width: 92%; height: 92%; object-fit: contain; }
.grille-laby .case.plumeau { background: rgba(120, 220, 255, 0.35); box-shadow: 0 0 12px rgba(120, 220, 255, 0.8); }
.laby-infos { text-align: center; font-weight: 800; margin: 0; }
.pave-fleches {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}
.fleche {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--or-clair), var(--or) 45%, var(--or-fonce));
  color: #2a1a05;
  font-size: 1.7rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.fleche:active { transform: scale(0.93); }
.fleche.haut { grid-column: 2; grid-row: 1; }
.fleche.gauche { grid-column: 1; grid-row: 2; }
.fleche.droite { grid-column: 3; grid-row: 2; }
.fleche.bas { grid-column: 2; grid-row: 3; }

/* Fioles */
.etagere {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin: 14px 0 10px;
  padding: 10px 6px 14px;
  border-bottom: 10px solid #7a4a1e;
  border-radius: 4px;
}
.fiole {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.fiole:active { transform: scale(0.94); }
.fiole-bouchon { width: 14px; height: 9px; border-radius: 3px; background: #8b5a2b; }
.fiole-verre {
  position: relative;
  width: 100%;
  max-width: 40px;
  height: 74px;
  overflow: hidden;
  border: 2px solid rgba(60, 40, 20, 0.6);
  border-radius: 6px 6px 18px 18px;
  background: rgba(255, 255, 255, 0.55);
}
.fiole-liquide { position: absolute; left: 0; right: 0; bottom: 0; height: var(--niveau); background: var(--couleur); }
.fiole-etiquette {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 2px;
  border-radius: 4px;
  background: #fbf1d6;
  font-size: 15px;
  line-height: 1.2;
}
.fiole-num { margin-top: 4px; font-weight: 800; color: #5a3410; }
.indices-secrets { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.5); }
.indices-secrets ul { margin: 6px 0 0; padding-left: 20px; }
.indices-secrets li { margin: 4px 0; font-weight: 700; }
.fioles-carte { position: relative; }
.sommeil {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 6, 30, 0.97);
  color: var(--texte);
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}
.sommeil .zzz { font-size: 5rem; animation: flotte 2s ease-in-out infinite; }

/* Parchemin déchiré */
.compteur-morceaux { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }
.morceaux { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px; font-size: 1.4rem; }
.morceaux span { filter: grayscale(1); opacity: 0.3; }
.morceaux span.trouve { filter: none; opacity: 1; }
.morceaux strong { width: 100%; text-align: center; font-size: 1.1rem; }
.dragon-souvenir { width: 120px; margin: 0 auto 8px; }
.reglage-decalage { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 10px 0; font-size: 1.15rem; font-weight: 800; }
.valeur-decalage { font-size: 1.6rem; color: #6b3a0c; }
.roue-lettres { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.paire {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}
.paire small { font-size: 0.75rem; color: #8a6a3a; font-weight: 700; }
.paire strong { font: 700 1.25rem 'Cinzel', serif; color: #3a1f6b; }

/* Gardien */
.gardien-carte { text-align: center; }
.gardien-image { width: 190px; margin: 0 auto; }
.questions-gardien { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.questions-gardien .pastille { color: var(--encre); background: rgba(255, 255, 255, 0.5); }

/* Sort de l'unisson */
.unisson-carte { text-align: center; }
.manche-unisson { font-weight: 800; }
.rune-unisson {
  width: 190px;
  height: 190px;
  margin: 10px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 4px solid var(--c);
  background: radial-gradient(circle, #3a2a7a, #160f33);
  box-shadow: 0 0 30px var(--c);
  cursor: pointer;
  touch-action: manipulation;
}
.rune-unisson .illu { width: 70%; }
.rune-unisson.appui { animation: appui 0.4s ease; }
@keyframes appui { 40% { transform: scale(0.9); box-shadow: 0 0 60px 20px var(--c); } }
.appuis-unisson { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.appuis-unisson .pastille { color: var(--encre); background: rgba(255, 255, 255, 0.5); }

/* Entracte et fin */
.ecran-entracte { text-align: center; }
.ecran-entracte .fin-suite { text-align: left; }
.pie-surprise .illu { width: 170px; margin: 0 auto; animation: arriveHibou 1.2s ease-out both; }
.grimoire-ouvert .illu { width: 220px; margin: 2vh auto 6px; filter: drop-shadow(0 0 30px rgba(255, 220, 120, 0.7)); animation: grandit 1s cubic-bezier(.2, 1.6, .4, 1) both; }
.ecran-fin { text-align: center; }
.ecran-fin .bulle-crapaud, .ecran-fin .carte { text-align: left; }
.fin-recit { color: var(--texte-doux); font-style: italic; }
.sceau-mini { font-size: 1.15rem; }

/* Effets spéciaux du narrateur */
.effet-eclair { position: fixed; inset: 0; z-index: 95; pointer-events: none; background: #fff; animation: eclair 1.4s linear forwards; }
@keyframes eclair { 0% { opacity: 0.95; } 10% { opacity: 0; } 18% { opacity: 0.8; } 30%, 100% { opacity: 0; } }
.effet-bougies {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #000;
  animation: bougies 8s ease forwards;
}
.effet-bougies-texte { color: #c9bde8; text-align: center; font-size: 1.3rem; font-weight: 800; line-height: 1.6; }
.effet-bougies-texte small { font-weight: 600; }
@keyframes bougies { 0% { opacity: 0; } 5%, 85% { opacity: 1; } 100% { opacity: 0; } }
.effet-apparition { position: fixed; left: 50%; bottom: 0; z-index: 95; width: 220px; pointer-events: none; animation: apparition 2.6s ease forwards; }
@keyframes apparition { 0% { transform: translate(-50%, 100%); } 25%, 75% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, 100%); } }
.effet-vol { position: fixed; top: 30%; left: 0; z-index: 95; width: 160px; pointer-events: none; animation: vol 3.2s ease-in-out forwards; }
.effet-gong { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; pointer-events: none; animation: gong-fin 2.6s ease forwards; }
.effet-gong > * { grid-area: 1 / 1; }
.effet-gong .cloche { font-size: 7rem; transform-origin: 50% 8%; animation: balance 0.45s ease-in-out 5 alternate; filter: drop-shadow(0 0 30px rgba(255, 215, 100, 0.9)); }
.effet-gong .onde { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--or); opacity: 0; animation: onde 1.8s ease-out forwards; }
.effet-gong .onde:nth-child(2) { animation-delay: 0.3s; }
.effet-gong .onde:nth-child(3) { animation-delay: 0.6s; }
@keyframes balance { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes onde { 0% { transform: scale(0.4); opacity: 0.9; } 100% { transform: scale(4); opacity: 0; } }
@keyframes gong-fin { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes vol {
  0% { transform: translate(-200px, 40px) rotate(-10deg); }
  50% { transform: translate(calc(50vw - 80px), -30px) rotate(8deg); }
  100% { transform: translate(110vw, 20px) rotate(-6deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
