/*
 * Merveillia 2 — feuille de style de l'interface (menus, dialogues, énigmes, espace adulte).
 * Version 0.6.0 — 22/11/2026
 * Le monde lui-même est dessiné par PixiJS dans #monde ; tout le reste est en HTML/CSS
 * pour rester lisible et accessible.
 */

/* ---------- Polices (copiées dans fonts/, licence OFL) ---------- */
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-ext-500-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("../fonts/nunito-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("../fonts/nunito-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Palette commune (planche de style) ---------- */
:root {
  --nuit: #1E2A4A; --mer: #2E4372; --lueur: #FFC857; --miel: #FFE3A3; --creme: #FFF6E5;
  --menthe: #7FD1B9; --menthe-s: #4FA893; --peche: #FFAD8A; --lavande: #B49FDC; --brume: #9AA6B8; --encre: #2B2440;
  --titre: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --texte: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --ombre: 0 4px 0 rgba(43, 36, 64, .25);
  --sur-haut: env(safe-area-inset-top, 0px);
  --sur-bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--nuit); color: var(--encre);
  font-family: var(--texte); font-size: 20px; line-height: 1.45; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.cache { display: none !important; }

#monde { position: fixed; inset: 0; }
#monde canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- Boutons ---------- */
.btn { font-family: var(--titre); font-weight: 500; font-size: 22px; border: none; border-radius: 999px;
  padding: 14px 28px; min-height: 60px; background: var(--lueur); color: var(--encre); box-shadow: 0 4px 0 #D9A23A;
  transition: transform .12s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #D9A23A; }
.btn.doux { background: var(--menthe); box-shadow: 0 4px 0 var(--menthe-s); }
.btn.clair { background: var(--creme); box-shadow: 0 4px 0 #D8CDB8; }
.btn:focus-visible, .rond:focus-visible, .choix:focus-visible { outline: 4px solid var(--lavande); outline-offset: 3px; }
.rond { width: 68px; height: 68px; border-radius: 50%; border: 3px solid var(--encre); display: grid; place-items: center;
  background: var(--lueur); box-shadow: var(--ombre); padding: 0; }
.rond svg { width: 40px; height: 40px; }
.rond.doux { background: var(--menthe); }
.rond.clair { background: var(--creme); }

/* ---------- Écrans plein écran (accueil, création, intro, pause) ---------- */
#ecran:empty { display: none; }
#ecran { position: fixed; inset: 0; z-index: 30; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 60% 25%, var(--mer), var(--nuit) 75%); color: var(--creme); }
.titre-jeu { font-family: var(--titre); font-weight: 600; font-size: clamp(44px, 10vw, 84px); margin: 0; text-align: center; line-height: 1.1; }
.titre-jeu .e { color: var(--lueur); }
.titre-jeu .deux { display: inline-block; width: 1.15em; height: 1.15em; line-height: 1.15em; text-align: center; margin-left: .15em;
  border-radius: 50%; background: var(--lueur); color: var(--nuit); font-size: .5em; vertical-align: .45em; }
.sous-titre { text-align: center; font-size: 22px; opacity: .9; margin: 4px 0 0; }
.accueil { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 30px 16px calc(30px + var(--sur-bas)); }
.accueil .troupe { display: flex; align-items: flex-end; gap: 4px; }
.accueil .troupe { max-width: 100%; }
.accueil .troupe svg { display: block; max-width: 19vw; height: auto; }
.carte-profil { background: var(--creme); color: var(--encre); border: none; border-radius: 28px; padding: 14px 26px 14px 14px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.25); font-family: var(--titre); font-size: 26px; }
.carte-profil .portrait { width: 76px; height: 76px; border-radius: 50%; background: var(--mer); overflow: hidden; display: grid; place-items: center; }
.porte-adulte { position: fixed; left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(12px + var(--sur-bas)); width: 54px; height: 54px; border-radius: 50%; border: none;
  background: rgba(255,246,229,.12); display: grid; place-items: center; }
.porte-adulte svg { width: 28px; height: 28px; opacity: .7; }
.porte-adulte .anneau { position: absolute; inset: -4px; border-radius: 50%; border: 4px solid var(--lueur); clip-path: inset(0 100% 0 0); }
.porte-adulte.appui .anneau { transition: clip-path 1.8s linear; clip-path: inset(0 0 0 0); }

/* Intro et pause : grande image + texte */
.recit { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px calc(24px + var(--sur-bas)); text-align: center; }
.recit .illus { width: min(560px, 92vw); }
.recit .illus svg { width: 100%; height: auto; display: block; border-radius: 26px; }
.recit p { max-width: 640px; font-size: 22px; margin: 0; }

/* ---------- Création du personnage (le miroir) ---------- */
.creation { min-height: 100%; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 1.3fr); gap: 18px; padding: 20px 16px calc(20px + var(--sur-bas)); align-items: center; max-width: 1100px; margin: 0 auto; }
@media (max-width: 760px) { .creation { grid-template-columns: 1fr; } }
.miroir { background: radial-gradient(ellipse at 50% 40%, #3B5A8C, #22305A); border: 10px solid #C9A45B; border-radius: 48% 48% 30px 30px / 38% 38% 30px 30px;
  padding: 26px 10px 16px; display: flex; justify-content: center; align-items: flex-end; gap: 6px; min-height: 340px; box-shadow: 0 0 0 4px var(--encre), 0 10px 30px rgba(0,0,0,.4); }
.miroir .perso-grand { width: min(230px, 48vw); }
.miroir .perso-lumi { width: min(130px, 28vw); }
.panneau-choix { background: var(--creme); color: var(--encre); border-radius: 26px; padding: 16px 18px; }
.panneau-choix h2 { font-family: var(--titre); font-weight: 600; margin: 0 0 6px; font-size: 28px; }
.onglets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.onglet { border: 3px solid var(--encre); background: #fff; border-radius: 999px; padding: 6px 16px; font-family: var(--titre); font-size: 19px; }
.onglet[aria-selected="true"] { background: var(--lueur); }
.groupe-choix { margin: 8px 0 12px; }
.groupe-choix h3 { font-family: var(--titre); font-weight: 500; font-size: 20px; margin: 0 0 6px; }
.pastilles { display: flex; flex-wrap: wrap; gap: 10px; }
.pastille { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--encre); padding: 0; position: relative; }
.pastille[aria-pressed="true"]::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 4px solid var(--lavande); }
.pastille.forme { background: #fff; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 18px; }
.pastille.forme svg { width: 62px; height: 62px; }
.pastille.forme[aria-pressed="true"]::after { border-radius: 24px; }
.champ-nom { font-family: var(--titre); font-size: 24px; border: 3px solid var(--encre); border-radius: 16px; padding: 10px 14px; width: 100%; max-width: 360px; -webkit-user-select: text; user-select: text; }
.actions-creation { display: flex; gap: 12px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }

/* ---------- HUD (la troupe, le carnet, la lanterne-portail) ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud .troupe-hud { position: absolute; top: calc(10px + var(--sur-haut)); left: calc(10px + env(safe-area-inset-left, 0px)); display: flex; gap: 8px; pointer-events: auto; }
#hud .portrait { width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--encre); background: var(--creme); overflow: hidden; display: grid; place-items: center; box-shadow: var(--ombre); }
#hud .portrait svg { width: 120%; height: 120%; margin-top: 20%; }
#hud .boutons-hud { position: absolute; top: calc(10px + var(--sur-haut)); right: calc(10px + env(safe-area-inset-right, 0px)); display: flex; gap: 10px; pointer-events: auto; }
#hud .notif { position: absolute; top: calc(84px + var(--sur-haut)); left: 50%; transform: translateX(-50%); background: var(--creme); border: 3px solid var(--encre); border-radius: 20px;
  padding: 8px 18px; font-family: var(--titre); font-size: 20px; box-shadow: var(--ombre); white-space: nowrap; }

/* ---------- Dialogues ---------- */
#dialogue { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sur-bas)); width: min(860px, calc(100vw - 24px)); z-index: 20;
  background: var(--creme); border: 4px solid var(--encre); border-radius: 28px; padding: 14px 18px 14px 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
#dialogue .portrait-dia { flex: none; width: 96px; height: 96px; border-radius: 50%; background: var(--mer); border: 3px solid var(--encre); overflow: hidden; display: grid; place-items: center; }
#dialogue .portrait-dia svg { width: 118%; height: 118%; margin-top: 22%; }
/* Le personnage qui parle bouge un peu (rebond et léger balancement) */
@keyframes parle { 0%, 100% { transform: translateY(0) rotate(0deg); } 25% { transform: translateY(-4px) rotate(-3deg); } 50% { transform: translateY(0) rotate(0deg); } 75% { transform: translateY(-3px) rotate(3deg); } }
.parle svg { animation: parle .6s ease-in-out infinite; transform-origin: 50% 80%; }
#dialogue .portrait-dia { border-width: 4px; }
#jeu .bulle-aide .mini svg { animation: parle .6s ease-in-out 5; transform-origin: 50% 80%; }
#dialogue .contenu { flex: 1; min-width: 0; }
#dialogue .nom { font-family: var(--titre); font-weight: 600; font-size: 20px; }
#dialogue .texte { font-size: 21px; margin: 2px 0 0; }
#dialogue .suite { flex: none; align-self: flex-end; }
#dialogue .options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Énigmes (vue rapprochée) ---------- */
#jeu { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; color: var(--creme);
  background: radial-gradient(ellipse at 50% 30%, #2E4A5E, #15202F 80%); }
#jeu .barre-jeu { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(10px + var(--sur-haut)) 12px 6px; }
#jeu .consigne { flex: 1; text-align: center; font-family: var(--titre); font-size: clamp(20px, 3.2vw, 28px); padding: 0 8px; min-height: 2.6em; display: grid; place-items: center; }
#jeu .scene-jeu { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 10px; }
#jeu .scene-jeu > svg { width: 100%; height: 100%; max-height: 100%; touch-action: none; }
#jeu .bas-jeu { display: flex; align-items: flex-end; justify-content: center; gap: 14px; padding: 6px 12px calc(14px + var(--sur-bas)); flex-wrap: wrap; min-height: 96px; }
#jeu .aide-perso { position: absolute; left: 10px; bottom: 8px; display: flex; align-items: flex-end; gap: 6px; pointer-events: none; }
#jeu .aide-perso svg { width: 90px; height: auto; }
#jeu .bulle-aide { position: absolute; left: 50%; transform: translateX(-50%); top: 6px; max-width: min(620px, 90%); background: var(--creme); color: var(--encre); border: 3px solid var(--encre);
  border-radius: 22px; padding: 10px 16px; font-size: 20px; box-shadow: var(--ombre); display: flex; gap: 10px; align-items: center; z-index: 2; }
#jeu .bulle-aide .mini { flex: none; width: 54px; height: 54px; border-radius: 50%; background: var(--mer); overflow: hidden; display: grid; place-items: center; }
#jeu .bulle-aide .mini svg { width: 118%; height: 118%; margin-top: 22%; }
.choix { font-family: var(--titre); font-weight: 600; font-size: 34px; min-width: 104px; min-height: 84px; border-radius: 26px; border: 4px solid var(--encre);
  background: var(--creme); color: var(--encre); box-shadow: 0 5px 0 rgba(0,0,0,.3); padding: 6px 18px; transition: transform .12s; }
.choix:active { transform: translateY(3px); }
.choix.choisi { background: var(--lueur); }
.choix.pas-encore { opacity: .5; }

/* ---------- Carnet ---------- */
.carnet { min-height: 100%; padding: calc(16px + var(--sur-haut)) 16px calc(24px + var(--sur-bas)); max-width: 980px; margin: 0 auto; }
.carnet header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.carnet h1 { font-family: var(--titre); font-weight: 600; font-size: 34px; margin: 0; }
.carnet .pages { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 14px; }
.carnet .page { background: var(--creme); color: var(--encre); border-radius: 24px; padding: 14px 16px; }
.carnet .page h2 { font-family: var(--titre); font-weight: 600; font-size: 24px; margin: 0 0 8px; }
.carnet .element { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.carnet .element .icone { flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--mer); display: grid; place-items: center; overflow: hidden; }
.carnet .element .icone svg { width: 118%; height: 118%; margin-top: 22%; }
.carnet .vide { opacity: .6; font-style: italic; }
.carnet .carte-ile { width: 100%; border-radius: 18px; display: block; }

/* ---------- Espace adulte ---------- */
.adulte { min-height: 100%; background: #F4F1EA; color: #222; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; padding: calc(16px + var(--sur-haut)) 16px 40px; -webkit-user-select: text; user-select: text; }
.adulte .cadre { max-width: 1000px; margin: 0 auto; }
.adulte h1 { font-size: 26px; margin: 0 0 4px; } .adulte h2 { font-size: 20px; margin: 26px 0 8px; }
.adulte .carte { background: #fff; border-radius: 14px; padding: 14px 16px; margin: 12px 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.adulte button { font-size: 16px; padding: 10px 16px; border-radius: 10px; border: 1px solid #bbb; background: #fff; margin: 4px 6px 4px 0; }
.adulte button.principal { background: #2E4372; color: #fff; border-color: #2E4372; }
.adulte button.danger { border-color: #A0522D; color: #A0522D; }
.adulte table.grille { border-collapse: collapse; font-size: 13px; }
.adulte table.grille th, .adulte table.grille td { width: 38px; height: 34px; text-align: center; border: 1px solid #ddd; padding: 0; }
.adulte table.grille th { background: #F0EDE6; }
.adulte .e0 { background: #fff; color: #bbb; } .adulte .e1 { background: #EEF3FB; } .adulte .e2 { background: #DCE8F8; }
.adulte .e3 { background: #CFE7DA; } .adulte .e4 { background: #B4DEC4; } .adulte .e5 { background: #8FCDA8; } .adulte .e6 { background: #5DB487; color: #fff; }
.adulte .legende span { display: inline-block; margin: 3px 10px 3px 0; }
.adulte .legende i { display: inline-block; width: 26px; height: 18px; border: 1px solid #ccc; vertical-align: middle; margin-right: 4px; text-align: center; font-style: normal; font-size: 12px; }
.adulte label { display: block; margin: 8px 0; }
.adulte input[type=range] { width: 220px; vertical-align: middle; }
.adulte .question { max-width: 420px; margin: 18vh auto 0; text-align: center; }
.adulte .question input { font-size: 22px; width: 140px; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid #aaa; }

/* ---------- Voile de transition ---------- */
#voile { position: fixed; inset: 0; z-index: 40; background: var(--nuit); opacity: 0; pointer-events: none; }

/* Moins d'animations (réglage adulte ou préférence de l'appareil) */
body.calme *, body.calme *::before, body.calme *::after { transition-duration: .01s !important; animation-duration: .01s !important; }
