/* ==========================================================================
   LE ROYAUME DES MOTS — ambiance parchemin, or et velours royal.
   ========================================================================== */
:root {
  --ink: #2B1B10;
  --ink-soft: #5A4330;
  --parch: #F7EBCB;
  --parch-2: #EBD6A6;
  --parch-edge: #B98A4B;
  --gold: #E7B416;
  --gold-d: #9C6F0E;
  --royal: #2B1B3D;
  --royal-2: #1A1026;
  --red: #B3122E;
  --green: #2E8B3E;
  --green-l: #DDF2D4;
  --red-l: #FBDCD8;
  --blue: #1F55B3;
  --purple: #7A3FB0;
  --shadow: 0 6px 0 rgba(43, 27, 16, .18), 0 12px 30px rgba(0, 0, 0, .25);
  --radius: 18px;
  --title: 'MedievalSharp', 'Cinzel', serif;
  --serif: 'Cinzel', serif;
  --body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #46295F 0%, var(--royal) 45%, var(--royal-2) 100%);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font-family: inherit; color: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen {
  position: relative;
  min-height: 100vh;
  padding: 12px 16px 96px;
  max-width: 1100px;
  margin: 0 auto;
  animation: screenIn .35s ease;
}
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } }

.scene-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.scene-bg .scene-svg { width: 100%; height: 100%; display: block; }
.scene-bg.dim::after { content: ''; position: absolute; inset: 0; background: rgba(26, 16, 38, .45); }

/* ---------- Boutons ---------- */
.btn {
  border: 0; cursor: pointer; border-radius: 14px;
  padding: 12px 20px; font-weight: 800; font-size: 1rem;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.primary {
  background: linear-gradient(180deg, #F7D25A, var(--gold) 55%, #C99414);
  color: #3A2604; box-shadow: 0 4px 0 var(--gold-d), 0 8px 16px rgba(0, 0, 0, .25);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.primary:disabled { filter: grayscale(.8) brightness(.9); opacity: .6; cursor: default; }
.btn.ghost { background: rgba(255, 250, 235, .9); color: var(--ink); box-shadow: 0 3px 0 rgba(43, 27, 16, .25); }
.btn.ghost:disabled { opacity: .55; cursor: default; }
.btn.big { font-size: 1.15rem; padding: 15px 26px; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--red); }
.icon-btn {
  border: 0; background: rgba(255, 250, 235, .9); border-radius: 12px; cursor: pointer;
  width: 42px; height: 42px; font-size: 1.2rem; box-shadow: 0 3px 0 rgba(43, 27, 16, .25); flex: none;
}
.icon-btn.mini { width: 32px; height: 32px; font-size: .95rem; }
.pill {
  background: rgba(255, 250, 235, .95); border-radius: 999px; padding: 7px 12px;
  font-weight: 800; box-shadow: 0 3px 0 rgba(43, 27, 16, .2); white-space: nowrap;
}
.row { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--ink-soft); font-size: .92rem; margin: 4px 0 10px; }
.hint.center { text-align: center; color: #F7EBCB; }

/* ---------- Parchemin ---------- */
.panel.parchment {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, .55), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(185, 138, 75, .25), transparent 60%),
    linear-gradient(180deg, var(--parch), var(--parch-2));
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: inset 0 0 0 2px rgba(185, 138, 75, .55), inset 0 0 40px rgba(156, 111, 14, .2), var(--shadow);
  max-width: 760px;
  margin: 16px auto;
}
.h-title {
  font-family: var(--title); font-weight: 400; text-align: center;
  font-size: clamp(1.5rem, 5vw, 2.1rem); margin: 4px 0 12px; color: var(--ink); letter-spacing: .02em;
}
.h-title small { display: block; font-family: var(--body); font-size: .9rem; font-weight: 800; opacity: .8; letter-spacing: .1em; text-transform: uppercase; }
.h-title.light { color: #FFF7DE; text-shadow: 0 3px 0 rgba(0, 0, 0, .4), 0 0 18px rgba(0, 0, 0, .5); }

/* ---------- Écran titre ---------- */
.back-link {
  display: inline-block; color: #FFF7DE; text-decoration: none; font-weight: 800;
  background: rgba(26, 16, 38, .5); padding: 6px 12px; border-radius: 999px; font-size: .9rem;
}
.top-right { position: absolute; top: 12px; right: 16px; }
.title-wrap { text-align: center; padding-top: 7vh; color: #FFF7DE; }
.eyebrow { letter-spacing: .25em; text-transform: uppercase; font-size: .8rem; opacity: .9; text-shadow: 0 2px 4px rgba(0, 0, 0, .5); color: #3A2604; }
.logo { font-family: var(--title); font-weight: 400; margin: 6px 0 14px; line-height: 1; color: #FFE08A; }
.logo span {
  display: block; font-size: clamp(1.8rem, 6vw, 2.8rem);
  text-shadow: 2px 0 0 #5B2E06, -2px 0 0 #5B2E06, 0 2px 0 #5B2E06, 0 -2px 0 #5B2E06, 0 5px 0 #5B2E06, 0 8px 16px rgba(0, 0, 0, .45);
}
.logo .big {
  font-size: clamp(3.2rem, 13vw, 6.2rem); color: #FFD54A;
  text-shadow: 3px 0 0 #5B2E06, -3px 0 0 #5B2E06, 0 3px 0 #5B2E06, 0 -3px 0 #5B2E06, 2px 2px 0 #5B2E06, -2px -2px 0 #5B2E06, 2px -2px 0 #5B2E06, -2px 2px 0 #5B2E06, 0 8px 0 #5B2E06, 0 12px 24px rgba(0, 0, 0, .5);
  animation: logoGlow 3s ease-in-out infinite;
}
@keyframes logoGlow { 50% { color: #FFEFA0; } }
.tagline {
  max-width: 520px; margin: 0 auto 26px; font-size: 1.05rem; color: #2B1B10;
  background: rgba(255, 247, 222, .85); padding: 10px 16px; border-radius: 14px;
}
.title-btns { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.welcome { margin: 4px 0; background: rgba(26, 16, 38, .55); padding: 6px 14px; border-radius: 999px; }
.tiny { font-size: .8rem; margin-top: 30px; color: #2B1B10; opacity: .8; }

/* ---------- Histoire ---------- */
.story { display: flex; flex-direction: column; padding-bottom: 20px; }
.story-art {
  position: relative; border-radius: var(--radius); overflow: hidden; height: min(48vh, 420px);
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(231, 180, 22, .6); margin-top: 8px;
}
.story-art .scene-svg { width: 100%; height: 100%; display: block; }
.sa-layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4vw; }
.sa-layer.row { align-items: flex-end; padding-bottom: 8%; }
.sa { font-size: 3rem; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
.sa.xl { font-size: clamp(5rem, 18vw, 9rem); }
.sa.big { font-size: clamp(3.5rem, 12vw, 6rem); }
.sa.g { font-size: clamp(2.6rem, 9vw, 4.5rem); animation: bob 2.4s ease-in-out infinite; }
.sa.a1 { position: absolute; top: 14%; left: 18%; animation: bob 3s ease-in-out infinite; }
.sa.a2 { position: absolute; bottom: 16%; right: 18%; animation: bob 3.4s ease-in-out infinite reverse; }
.sa-mage { width: clamp(140px, 30vw, 230px); }
.float { animation: bob 3s ease-in-out infinite; }
.flash { animation: flash 1.2s steps(2) infinite; }
.spin { animation: spin 3s linear infinite; }
.cursed { filter: drop-shadow(0 0 12px #B04DFF) drop-shadow(0 0 4px #5B1E8A) hue-rotate(-30deg) saturate(1.3); }
@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes flash { 50% { opacity: .2; } }
@keyframes spin { to { transform: rotate(360deg); } }
.story-box {
  position: relative; margin: -30px auto 0; width: min(94%, 760px);
  background: linear-gradient(180deg, var(--parch), var(--parch-2)); border-radius: var(--radius);
  padding: 22px 20px 16px 20px; box-shadow: var(--shadow), inset 0 0 0 2px rgba(185, 138, 75, .55);
}
.narrator {
  position: absolute; top: -28px; left: 16px; font-size: 2.4rem; background: var(--parch);
  border-radius: 50%; width: 58px; height: 58px; display: grid; place-items: center;
  box-shadow: 0 0 0 3px var(--gold), var(--shadow);
}
.story-text { font-size: 1.15rem; line-height: 1.55; margin: 14px 0 12px; min-height: 4.6em; }
.story-text.appear { animation: textIn .5s ease; }
@keyframes textIn { from { opacity: 0; transform: translateY(6px); } }
.story-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.dots { margin-right: auto; display: flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(43, 27, 16, .2); }
.dots i.on { background: var(--gold); box-shadow: 0 0 0 2px var(--gold-d); }
.skip { position: fixed; top: 12px; right: 16px; }

/* ---------- Création du héros ---------- */
.create .field { display: block; margin: 12px 0; }
.create .field > span, .bm-title { display: block; font-family: var(--serif); font-weight: 800; margin-bottom: 6px; }
.create input {
  width: 100%; font: inherit; font-size: 1.15rem; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--parch-edge); background: #FFFBEF;
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; border: 2px solid var(--parch-edge); background: #FFFBEF; border-radius: 12px; padding: 10px;
  font-weight: 800; cursor: pointer; min-width: 90px;
}
.seg.small button { padding: 6px 8px; font-size: .88rem; min-width: 60px; }
.seg button.on { background: var(--royal); color: #FFE79A; border-color: var(--royal); }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.av { font-size: 2rem; width: 58px; height: 58px; border-radius: 14px; border: 2px solid var(--parch-edge); background: #FFFBEF; cursor: pointer; }
.av.on { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold); transform: scale(1.08); }
.blason-maker { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: start; margin: 16px 0; }
.bm-preview .blason { width: 150px; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); }
.bm-row { display: grid; grid-template-columns: 82px 1fr; gap: 8px; align-items: center; margin: 8px 0; }
.bm-row > span { font-size: .85rem; font-weight: 800; color: var(--ink-soft); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 32px; height: 32px; border-radius: 8px; background: var(--c); border: 2px solid rgba(0, 0, 0, .3); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 3px var(--gold); transform: scale(1.12); }
.emblems { display: flex; gap: 4px; flex-wrap: wrap; }
.emblems button { font-size: 1.4rem; width: 40px; height: 40px; border-radius: 10px; border: 2px solid transparent; background: #FFFBEF; cursor: pointer; }
.emblems button.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.bm-heraldry { font-size: .9rem; color: var(--ink-soft); margin: 10px 0 0; }
.create > .btn { display: flex; margin: 14px auto 0; }
@media (max-width: 560px) {
  .blason-maker { grid-template-columns: 1fr; }
  .bm-preview { display: flex; justify-content: center; }
  .bm-preview .blason { width: 120px; }
}

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.hud-hero {
  display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer; text-align: left;
  background: rgba(255, 250, 235, .95); border-radius: 999px; padding: 4px 14px 4px 6px; box-shadow: 0 3px 0 rgba(43, 27, 16, .2);
  min-width: 0;
}
.hud-blason .blason { width: 34px; display: block; }
.hud-id { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.hud-id b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.hud-id small { font-size: .75rem; color: var(--gold-d); font-weight: 800; }
.hud-res { display: flex; align-items: center; gap: 6px; }
@media (max-width: 420px) { .hud-res .pill:first-child { display: none; } }

/* ---------- Carte ---------- */
.map-wrap { overflow: hidden; border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 4px #8A5A2E, 0 0 0 7px var(--gold); margin: 6px 4px; }
.map { position: relative; aspect-ratio: 10 / 7; min-width: 0; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-svg .fog { transition: opacity 2.2s ease; animation: fogDrift 6s ease-in-out infinite; }
.map-svg .fog.clearing { opacity: 0; }
@keyframes fogDrift { 50% { transform: translateX(6px); } }
.map-svg .smoke { animation: smoke 4s ease-in-out infinite; }
@keyframes smoke { 50% { transform: translateY(-4px); opacity: .3; } }
.map-svg .bolt { animation: flash 2.5s steps(2) infinite; }
.map-svg .glow, .castle-svg .glow, .mage-svg .orb { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .55; } }
.map-svg .serpent { animation: bob 4s ease-in-out infinite; }
.flag { transform-box: fill-box; transform-origin: left center; animation: flag 1.6s ease-in-out infinite; }
@keyframes flag { 50% { transform: scaleX(.82) skewY(4deg); } }
.marker {
  position: absolute; transform: translate(-50%, -30%); border: 0; cursor: pointer;
  background: linear-gradient(180deg, #FFF7DE, #F0DDB0); border-radius: 12px; padding: 5px 10px;
  box-shadow: 0 0 0 2px var(--rc, var(--purple)), 0 4px 10px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; max-width: 34%;
  transition: transform .15s ease;
}
.marker:hover { transform: translate(-50%, -30%) scale(1.06); }
.m-name { font-family: var(--title); font-size: clamp(.68rem, 1.8vw, 1.02rem); color: var(--ink); white-space: nowrap; }
.m-sub { font-size: clamp(.55rem, 1.3vw, .78rem); color: var(--ink-soft); font-weight: 800; white-space: nowrap; }
.marker.freed { box-shadow: 0 0 0 3px var(--rc, var(--gold)), 0 0 18px rgba(255, 215, 90, .7); }
.marker.final { --rc: #5B2A86; background: linear-gradient(180deg, #E9D8FF, #C7A8EE); }
.marker.final.locked { filter: grayscale(.5); }
.marker.final.freed { background: linear-gradient(180deg, #FFF3B8, #F2C232); }

.bottom-nav {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 6px; padding: 6px; border-radius: 20px; width: min(96vw, 620px);
  background: linear-gradient(180deg, #4A2E1A, #2E1C0E); box-shadow: 0 0 0 2px var(--gold), 0 8px 24px rgba(0, 0, 0, .5);
}
.bottom-nav button {
  position: relative; flex: 1; border: 0; border-radius: 14px; cursor: pointer; padding: 6px 4px;
  background: rgba(255, 247, 222, .1); color: #FFE79A; font-size: 1.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottom-nav button span { font-size: .72rem; font-weight: 800; color: #FFF7DE; }
.bottom-nav button:hover { background: rgba(255, 247, 222, .2); }
.badge {
  position: absolute; top: 2px; right: 10px; background: var(--red); color: #fff; font-style: normal;
  font-size: .7rem; font-weight: 900; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
}
.glow-btn { animation: navGlow 1.6s ease-in-out infinite; }
@keyframes navGlow { 50% { background: rgba(255, 215, 90, .3); } }

/* ---------- Région ---------- */
.region-head { display: flex; align-items: center; gap: 10px; }
.region-head .h-title { flex: 1; margin-right: 60px; }
.mentor-card { display: flex; gap: 14px; align-items: flex-start; max-width: 760px; margin: 8px auto 16px; }
.mentor-face {
  position: relative; flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  font-size: 3rem; background: radial-gradient(circle at 35% 30%, #FFF7DE, #E8CF95);
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 7px #6B4E2E, var(--shadow);
}
.mentor-face i { position: absolute; bottom: -4px; right: -6px; font-size: 1.5rem; font-style: normal; }
.bubble {
  position: relative; flex: 1; background: #FFFBEF; border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow);
}
.bubble::before { content: ''; position: absolute; left: -10px; top: 26px; border: 10px solid transparent; border-left: 0; border-right-color: #FFFBEF; }
.bubble b { font-family: var(--serif); }
.bubble p { margin: 6px 0 0; line-height: 1.45; }
.bubble .speak-bubble { position: absolute; right: 8px; bottom: 8px; }
.path {
  display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; position: relative; padding: 4px 0;
}
.path::before {
  content: ''; position: absolute; left: 50%; top: 20px; bottom: 20px; width: 6px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(255, 247, 222, .8) 0 12px, transparent 12px 22px); z-index: 0;
}
.node {
  position: relative; z-index: 1; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px;
  border: 0; cursor: pointer; text-align: left; border-radius: 18px; padding: 10px 14px;
  background: linear-gradient(180deg, #FFF7DE, #F0DDB0); box-shadow: var(--shadow);
  width: 86%; transition: transform .15s ease;
}
.node:nth-child(odd) { align-self: flex-start; }
.node:nth-child(even) { align-self: flex-end; }
.node:hover:not(.locked) { transform: scale(1.03); }
.n-num {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-family: var(--title); font-size: 1.5rem;
  background: var(--rc); color: #fff; box-shadow: 0 0 0 3px #FFF7DE, 0 0 0 5px var(--rc);
}
.n-title { font-family: var(--serif); font-weight: 800; font-size: 1rem; }
.n-stars { font-size: 1.2rem; white-space: nowrap; }
.st { color: rgba(43, 27, 16, .2); }
.st.on { color: var(--gold); text-shadow: 0 1px 0 var(--gold-d); }
.node.locked { filter: grayscale(.8); opacity: .75; cursor: not-allowed; }
.node.current { box-shadow: var(--shadow), 0 0 0 3px var(--gold); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: var(--shadow), 0 0 0 6px rgba(231, 180, 22, .55); } }
.node.boss { width: 100%; align-self: center; background: linear-gradient(180deg, #E9D8FF, #BFA0E6); }
.node.boss.done { background: linear-gradient(180deg, #FFF3B8, #F2C232); }
.node.boss .n-num { background: #2B1B3D; font-size: 1.9rem; font-family: inherit; }
.node.boss .n-stars { font-size: .9rem; font-weight: 800; }
@media (max-width: 560px) { .node { width: 100%; grid-template-columns: 48px 1fr; } .n-stars { grid-column: 2; } .n-num { width: 44px; height: 44px; } }

/* ---------- Leçon ---------- */
.lesson-kicker { text-align: center; margin: 0; font-weight: 800; color: var(--rc, var(--gold-d)); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.lesson-body { line-height: 1.6; font-size: 1.05rem; }
.lesson-body ul { padding-left: 20px; }
.lesson-body li { margin: 4px 0; }
.lesson-body b { color: #7A2410; }
.conj-table { border-collapse: collapse; margin: 10px auto; background: #FFFBEF; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 2px var(--parch-edge); font-size: .98rem; }
.conj-table td { padding: 6px 12px; border-bottom: 1px solid var(--parch-2); }
.conj-table tr:first-child td { font-weight: 800; background: var(--parch-2); }
.lesson-tip { display: flex; gap: 12px; align-items: center; background: #FFFBEF; border-radius: 14px; padding: 10px 14px; margin-top: 12px; border-left: 5px solid var(--gold); }
.lesson-tip p { margin: 0; }
.mentor-mini { font-size: 2.2rem; }
.new-page { text-align: center; color: var(--purple); font-weight: 800; animation: bob 2s ease-in-out infinite; }
.final-mage { width: 160px; margin: 0 auto; }

/* ---------- Session d'épreuves ---------- */
.play-top { display: flex; align-items: center; gap: 8px; max-width: 760px; margin: 0 auto; }
.play-title { flex: 1; text-align: center; color: #FFF7DE; line-height: 1.15; text-shadow: 0 2px 4px rgba(0, 0, 0, .6); }
.play-title b { display: block; font-family: var(--title); font-weight: 400; font-size: 1.3rem; }
.play-title small { font-weight: 800; opacity: .9; }
.torches { display: flex; justify-content: center; gap: 6px; margin: 12px auto 6px; max-width: 760px; flex-wrap: wrap; }
.torches i {
  width: 26px; height: 32px; border-radius: 8px 8px 4px 4px; background: rgba(255, 247, 222, .2);
  position: relative; box-shadow: inset 0 -8px 0 rgba(90, 60, 30, .8);
}
.torches i.lit { background: radial-gradient(circle at 50% 40%, #FFF3B8, #F2A51A 60%, #C2410C); box-shadow: inset 0 -8px 0 #5B3A1E, 0 0 14px rgba(255, 170, 40, .9); animation: torch 1s ease-in-out infinite; }
.torches i.dim { background: rgba(120, 120, 140, .5); }
@keyframes torch { 50% { box-shadow: inset 0 -8px 0 #5B3A1E, 0 0 6px rgba(255, 170, 40, .6); } }
.combo { text-align: center; color: #FFD54A; font-family: var(--title); font-size: 1.2rem; text-shadow: 0 2px 0 #7A2410, 0 0 12px rgba(255, 120, 0, .8); }
.combo.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } }
.q-host { max-width: 760px; margin: 0 auto; }

/* ---------- Carte de question ---------- */
.qcard {
  background: linear-gradient(180deg, var(--parch), var(--parch-2)); border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: inset 0 0 0 2px rgba(185, 138, 75, .55), var(--shadow); animation: cardIn .35s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.passage { background: #FFFBEF; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; border: 2px solid var(--parch-edge); }
.passage summary { cursor: pointer; font-family: var(--serif); font-weight: 800; }
.passage-text { white-space: pre-line; line-height: 1.6; font-size: 1.04rem; margin-top: 6px; }
.q-head { display: flex; align-items: flex-start; gap: 10px; }
.q-prompt { flex: 1; margin: 2px 0 8px; font-size: 1.12rem; font-weight: 800; line-height: 1.4; }
.q-prompt b { color: #7A2410; }
.q-sentence {
  font-size: clamp(1.15rem, 3.6vw, 1.45rem); background: #FFFBEF; border-radius: 12px; padding: 12px 16px; margin: 4px 0 14px;
  line-height: 1.5; text-align: center; border: 2px dashed rgba(185, 138, 75, .6);
}
.q-sentence:empty { display: none; }
.hl { background: linear-gradient(180deg, transparent 55%, rgba(231, 180, 22, .55) 55%); padding: 0 2px; color: #4A1C08; }
.blank {
  display: inline-block; min-width: 3.2em; border-bottom: 3px solid var(--gold-d); color: var(--gold-d);
  text-align: center; font-weight: 800; padding: 0 4px; animation: blink 1.4s ease-in-out infinite;
}
.blank.filled { animation: none; color: var(--green); border-color: var(--green); }
@keyframes blink { 50% { opacity: .45; } }
.q-actions { display: flex; justify-content: center; margin-top: 14px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.long { grid-template-columns: 1fr; }
.choice {
  display: flex; align-items: center; gap: 10px; text-align: left; border: 0; cursor: pointer; border-radius: 14px;
  padding: 12px 14px; background: #FFFBEF; font-size: 1.08rem; font-weight: 700;
  box-shadow: 0 0 0 2px var(--parch-edge), 0 4px 0 rgba(43, 27, 16, .2); transition: transform .1s ease;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); }
.choice .key {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem;
  background: var(--parch-2); color: var(--ink-soft); font-weight: 900;
}
.choice.picked { box-shadow: 0 0 0 3px var(--royal), 0 4px 0 rgba(43, 27, 16, .2); background: #F1E6FF; }
.choice.picked .key { background: var(--royal); color: #FFE79A; }
.choice.right { background: var(--green-l); box-shadow: 0 0 0 3px var(--green); }
.choice.right .key { background: var(--green); color: #fff; }
.choice.wrong { background: var(--red-l); box-shadow: 0 0 0 3px var(--red); }
.choice:disabled { cursor: default; }
@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } }

.tap-line { font-size: clamp(1.15rem, 3.8vw, 1.45rem); line-height: 2.3; text-align: center; background: #FFFBEF; border-radius: 12px; padding: 10px; }
.tok {
  border: 0; background: rgba(185, 138, 75, .18); border-radius: 8px; padding: 2px 6px; font-size: inherit; font-weight: 700;
  cursor: pointer; box-shadow: 0 2px 0 rgba(43, 27, 16, .2);
}
.tok.picked { background: var(--royal); color: #FFE79A; }
.tok.right { background: var(--green); color: #fff; }
.tok.missed { background: transparent; box-shadow: 0 0 0 3px var(--green); }
.tok.wrong { background: var(--red); color: #fff; text-decoration: line-through; }
.tok:disabled { cursor: default; }
.punct { font-weight: 700; }

.sort-pool, .order-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 48px; padding: 8px; border-radius: 12px; background: rgba(255, 251, 239, .6); }
.chip {
  border: 0; background: #FFFBEF; border-radius: 10px; padding: 8px 12px; font-size: 1.05rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 0 0 2px var(--parch-edge), 0 3px 0 rgba(43, 27, 16, .25);
}
.chip.sel { background: var(--royal); color: #FFE79A; transform: translateY(-3px); }
.chip.right { background: var(--green-l); box-shadow: 0 0 0 2px var(--green); }
.chip.wrong { background: var(--red-l); box-shadow: 0 0 0 2px var(--red); }
.chip small { color: var(--red); font-size: .78rem; }
.sort-bins { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.bin {
  border-radius: 14px; background: linear-gradient(180deg, #8A5A2E, #6B4022); padding: 6px; cursor: pointer; min-height: 96px;
  box-shadow: 0 0 0 2px #3E2A1E, inset 0 0 0 3px rgba(231, 180, 22, .5);
}
.bin-lid { color: #FFE79A; font-family: var(--serif); font-weight: 800; text-align: center; padding: 4px; }
.bin-in { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 6px; min-height: 52px; background: rgba(0, 0, 0, .2); border-radius: 10px; }
.bin:hover { box-shadow: 0 0 0 2px #3E2A1E, inset 0 0 0 3px var(--gold), 0 0 14px rgba(231, 180, 22, .6); }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.match-grid .col { display: flex; flex-direction: column; gap: 8px; }
.mitem {
  border: 0; background: #FFFBEF; border-radius: 12px; padding: 12px; font-size: 1.05rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 0 0 2px var(--parch-edge), 0 3px 0 rgba(43, 27, 16, .2); position: relative;
}
.mitem.sel { box-shadow: 0 0 0 3px var(--royal); background: #F1E6FF; }
.mitem.c1 { background: #FFE1A8; box-shadow: 0 0 0 3px #D98E04; }
.mitem.c2 { background: #CFE5FF; box-shadow: 0 0 0 3px #1F55B3; }
.mitem.c3 { background: #E5D4FF; box-shadow: 0 0 0 3px #7A3FB0; }
.mitem.c4 { background: #FFD3E0; box-shadow: 0 0 0 3px #C2185B; }
.mitem.c5 { background: #D3F5EC; box-shadow: 0 0 0 3px #00897B; }
.mitem.right { background: var(--green-l) !important; box-shadow: 0 0 0 3px var(--green) !important; }
.mitem.wrong { background: var(--red-l) !important; box-shadow: 0 0 0 3px var(--red) !important; }

.order-line {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 56px; padding: 10px; margin-bottom: 10px;
  border-radius: 12px; background: #FFFBEF; border: 2px dashed var(--parch-edge);
}
.order-line.empty::before { content: 'Ta réponse apparaîtra ici…'; color: var(--ink-soft); opacity: .6; align-self: center; }
.order-line.vertical, .order-pool.vertical { flex-direction: column; align-items: stretch; }
.order-pool.vertical .chip, .order-line.vertical .chip { text-align: left; display: flex; gap: 8px; align-items: center; }
.piece .num:empty { display: none; }
.piece .num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #3A2604; display: grid; place-items: center; font-size: .8rem; }
.solution { background: var(--green-l); border-radius: 10px; padding: 8px 14px; font-weight: 800; color: #1F5E2A; }
ol.solution { padding-left: 34px; }

.type-box { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.type-input {
  width: min(100%, 420px); font: inherit; font-size: 1.4rem; text-align: center; padding: 12px; border-radius: 12px;
  border: 3px solid var(--parch-edge); background: #FFFBEF;
}
.type-input.right { border-color: var(--green); background: var(--green-l); }
.type-input.wrong { border-color: var(--red); background: var(--red-l); }
.accents { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.acc { width: 40px; height: 40px; border-radius: 10px; border: 0; background: #FFFBEF; font-size: 1.2rem; font-weight: 800; cursor: pointer; box-shadow: 0 0 0 2px var(--parch-edge), 0 3px 0 rgba(43, 27, 16, .2); }

.q-feedback { margin-top: 14px; border-radius: 14px; padding: 12px 14px; animation: cardIn .3s ease; }
.q-feedback.good { background: var(--green-l); box-shadow: 0 0 0 2px var(--green); }
.q-feedback.bad { background: #FFF1D6; box-shadow: 0 0 0 2px #D98E04; }
.fb-row { display: flex; gap: 12px; align-items: flex-start; }
.fb-mentor { flex: none; font-size: 2.3rem; width: 56px; height: 56px; display: grid; place-items: center; background: #FFFBEF; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold); }
.fb-title { margin: 0 0 4px; font-family: var(--serif); font-weight: 800; font-size: 1.1rem; }
.fb-explain { margin: 0; line-height: 1.5; }
.fb-explain b { color: #7A2410; }
.q-feedback .continue { display: flex; margin: 12px auto 0; }
.speak-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: #FFFBEF; cursor: pointer; font-size: 1.1rem; box-shadow: 0 0 0 2px var(--parch-edge); flex: none; }

/* ---------- Résultats ---------- */
.result { text-align: center; }
.big-stars { font-size: clamp(3rem, 12vw, 4.6rem); display: flex; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.bst { color: rgba(43, 27, 16, .18); }
.bst.on { color: var(--gold); text-shadow: 0 3px 0 var(--gold-d), 0 0 18px rgba(255, 215, 90, .8); animation: starIn .6s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes starIn { from { transform: scale(0) rotate(-60deg); opacity: 0; } }
.result-stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.result-stats div { background: #FFFBEF; border-radius: 12px; padding: 8px 14px; min-width: 96px; box-shadow: 0 0 0 2px var(--parch-edge); }
.result-stats b { display: block; font-size: 1.3rem; }
.result-stats small { color: var(--ink-soft); }
.rank-up { font-size: 1.2rem; color: var(--purple); animation: pop .6s ease 1.4s both; }
.unlock-note { font-weight: 800; color: #5B2A86; }
.big-emoji { font-size: 4rem; margin: 6px 0; }

/* ---------- Combat ---------- */
.arena { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; max-width: 760px; margin: 8px auto 10px; min-height: 190px; }
.boss-side { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.boss { font-size: clamp(5rem, 20vw, 8rem); line-height: 1; transition: filter .8s ease; }
.boss span { display: inline-block; animation: bob 2.6s ease-in-out infinite; }
.boss.mage { width: clamp(130px, 32vw, 190px); }
.boss.cursed { filter: drop-shadow(0 0 18px #B04DFF) drop-shadow(0 0 6px #5B1E8A); }
.boss.freed { filter: drop-shadow(0 0 20px rgba(255, 220, 120, .95)); }
.boss.freed span { animation: happy .8s ease-in-out infinite; }
@keyframes happy { 50% { transform: translateY(-14px) rotate(-6deg); } }
.boss.hit { animation: hit .45s ease; }
@keyframes hit { 20% { transform: translateX(-12px) rotate(-6deg); filter: brightness(2.5); } 50% { transform: translateX(10px); } }
.boss-bubble {
  background: #FFFBEF; border-radius: 14px; padding: 8px 12px; font-weight: 800; max-width: 340px; text-align: center;
  box-shadow: var(--shadow); margin-bottom: 8px; position: relative; font-size: .95rem; min-height: 1em;
}
.boss-bubble:empty { visibility: hidden; }
.boss-bubble::after { content: ''; position: absolute; bottom: -9px; left: 50%; border: 9px solid transparent; border-bottom: 0; border-top-color: #FFFBEF; transform: translateX(-50%); }
.boss-bubble.pop { animation: pop .4s ease; }
.hpbar { position: relative; width: min(280px, 90%); height: 22px; border-radius: 999px; background: rgba(0, 0, 0, .45); box-shadow: 0 0 0 2px var(--gold); margin-top: 6px; overflow: hidden; }
.hpbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #7A1FB0, #C77DFF); transition: width .5s ease; border-radius: 999px; }
.hpbar span { position: relative; display: block; text-align: center; color: #fff; font-weight: 900; font-size: .85rem; line-height: 22px; text-shadow: 0 1px 2px #000; }
.hero-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero-face { position: relative; font-size: clamp(3.2rem, 12vw, 4.4rem); line-height: 1; }
.mini-blason { position: absolute; right: -14px; bottom: -6px; width: 30px; }
.mini-blason .blason { width: 100%; display: block; }
.hearts { display: flex; gap: 2px; font-style: normal; }
.hearts i { font-style: normal; font-size: 1.25rem; }
.hearts i.lost { opacity: .5; }
.battle-intro { text-align: center; }

/* ---------- Domaine ---------- */
.sub-head { display: flex; align-items: center; gap: 10px; }
.sub-head .h-title { flex: 1; color: #FFF7DE; margin-right: 70px; text-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.castle-view { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow), 0 0 0 4px #8A5A2E, 0 0 0 7px var(--gold); margin: 8px 4px; }
.castle-view.built { animation: built .7s ease; }
@keyframes built { 30% { transform: scale(1.015); filter: brightness(1.25); } }
.castle-svg { width: 100%; display: block; }
.castle-svg .cloud { animation: drift 30s linear infinite alternate; }
.castle-svg .cloud.slow { animation-duration: 45s; }
@keyframes drift { to { transform: translateX(120px); } }
.castle-svg .mill-blades { animation: spin 6s linear infinite; }
.castle-svg .flame { transform-box: fill-box; transform-origin: bottom center; animation: flame .5s ease-in-out infinite alternate; }
@keyframes flame { to { transform: scaleY(1.15) scaleX(.9); } }
.castle-svg .smoke-puff { animation: puff 3s ease-out infinite; }
@keyframes puff { to { transform: translateY(-30px) scale(1.8); opacity: 0; } }
.castle-svg .pet-dragon { animation: fly 8s ease-in-out infinite; }
@keyframes fly { 25% { transform: translate(-120px, 20px); } 50% { transform: translate(-260px, -10px); } 75% { transform: translate(-120px, 30px); } }
.castle-svg .unicorn, .castle-svg .friend, .castle-svg .hero-stand { animation: bob 3s ease-in-out infinite; }
.castle-svg .friend:nth-of-type(2n) { animation-delay: -1.2s; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; margin-top: 10px; }
.shop-item {
  display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, var(--parch), var(--parch-2));
  border-radius: 14px; padding: 10px 12px; box-shadow: inset 0 0 0 2px rgba(185, 138, 75, .55), 0 4px 0 rgba(0, 0, 0, .2);
}
.shop-item.owned { opacity: .8; }
.si-icon { font-size: 2rem; }
.si-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.si-txt small { color: var(--ink-soft); font-weight: 600; }
.si-done { color: var(--green); font-weight: 900; white-space: nowrap; }

/* ---------- Grimoire ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; max-width: 760px; margin: 8px auto 0; }
.tab {
  flex: 1; border: 0; cursor: pointer; border-radius: 12px 12px 0 0; padding: 8px 10px; white-space: nowrap;
  background: rgba(255, 247, 222, .6); font-weight: 800;
}
.tab.on { background: var(--parch); box-shadow: inset 0 -4px 0 var(--rc); }
.grimoire { margin-top: 0; border-top-left-radius: 0; }
.grimoire h3 { font-family: var(--title); font-weight: 400; font-size: 1.5rem; text-align: center; margin: 0 0 10px; color: var(--rc); }
.pages { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.pages li {
  display: flex; align-items: center; gap: 12px; background: #FFFBEF; border-radius: 12px; padding: 10px 12px; cursor: pointer;
  box-shadow: 0 0 0 2px var(--parch-edge);
}
.pages li:hover:not(.locked) { box-shadow: 0 0 0 3px var(--gold); }
.pages li.locked { opacity: .55; cursor: not-allowed; }
.pg-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--royal); color: #FFE79A; font-family: var(--title); flex: none; }
.pg-title { flex: 1; font-weight: 800; display: flex; flex-direction: column; }
.pg-title small { font-weight: 600; color: var(--ink-soft); }
.mastery { position: relative; width: 80px; height: 18px; border-radius: 999px; background: var(--parch-2); overflow: hidden; flex: none; }
.mastery i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #E9A23B, var(--green)); }
.mastery b { position: relative; display: block; text-align: center; font-size: .72rem; line-height: 18px; }

/* ---------- Quête du jour / Tournoi ---------- */
.owl-talk { display: flex; gap: 12px; align-items: flex-start; }
.owl-talk span { font-size: 3rem; }
.owl-talk p { margin: 0; line-height: 1.5; font-size: 1.05rem; }
.streak, .record { text-align: center; font-size: 1.15rem; }
.daily-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.daily-list li { background: #FFFBEF; border-radius: 10px; padding: 8px 12px; box-shadow: 0 0 0 2px var(--parch-edge); }
.joust { display: flex; justify-content: center; gap: 16px; align-items: center; margin: 10px 0; font-size: 1.4rem; color: #FFF7DE; }
.joust .score { background: rgba(26, 16, 38, .6); padding: 4px 14px; border-radius: 999px; }
.lances i { font-style: normal; }
.lances i.lost { opacity: .25; filter: grayscale(1); }

/* ---------- Modale, toast, réglages ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(15, 8, 24, .6); display: grid; place-items: center; padding: 16px; animation: screenIn .2s ease; }
.modal { background: linear-gradient(180deg, var(--parch), var(--parch-2)); border-radius: var(--radius); padding: 20px; width: min(100%, 420px); box-shadow: var(--shadow), inset 0 0 0 2px rgba(185, 138, 75, .55); }
.modal-text { font-size: 1.1rem; text-align: center; margin: 0; line-height: 1.45; }
.settings { display: flex; flex-direction: column; gap: 10px; }
.set-hero { display: flex; gap: 12px; align-items: center; }
.set-hero .blason { width: 60px; }
.set-hero div { display: flex; flex-direction: column; }
.set-hero small { color: var(--ink-soft); }
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 200; background: var(--royal); color: #FFE79A;
  padding: 10px 18px; border-radius: 14px; font-weight: 800; box-shadow: 0 0 0 2px var(--gold), var(--shadow);
  animation: toastIn .3s ease; transition: opacity .4s ease, transform .4s ease; text-align: center; max-width: 92vw;
}
.toast.out { opacity: 0; transform: translate(-50%, -10px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -14px); } }

/* ---------- Effets ---------- */
.fx-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 150; }
.coin {
  display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -.14em;
  background: radial-gradient(circle at 35% 30%, #FFF6C2 0 18%, #F7CC3A 40%, #C98E0E 75%, #8A5C06 100%);
  box-shadow: inset 0 0 0 .09em #A87410, 0 1px 0 rgba(0, 0, 0, .25);
}
.fly-coin { position: fixed; z-index: 160; pointer-events: none; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF6C2 0 18%, #F7CC3A 40%, #C98E0E 75%, #8A5C06 100%); box-shadow: inset 0 0 0 2px #A87410, 0 2px 6px rgba(0, 0, 0, .35); }
.float-text {
  position: fixed; z-index: 160; pointer-events: none; transform: translateX(-50%); font-family: var(--title);
  font-size: 2rem; color: #fff; text-shadow: 0 3px 0 #7A2410, 0 0 10px rgba(0, 0, 0, .6); animation: floatUp 1.3s ease-out forwards; white-space: nowrap;
}
.float-text.crit { color: #FFD54A; font-size: 1.7rem; }
.float-text.hurt { color: #FF8A8A; }
@keyframes floatUp { to { transform: translate(-50%, -80px); opacity: 0; } }
.shake { animation: shake .4s ease; }
.shake-big { animation: shake .55s ease; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

.scene-svg .twinkle { animation: glow 2.4s ease-in-out infinite; }
.scene-svg .ember { animation: ember 4s linear infinite; }
@keyframes ember { to { transform: translateY(-260px); opacity: 0; } }
.scene-svg .firefly { animation: firefly 4s ease-in-out infinite; }
@keyframes firefly { 50% { transform: translate(14px, -18px); opacity: .2; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .screen { padding: 10px 12px 96px; }
  .panel.parchment { padding: 18px 14px; }
  .qcard { padding: 14px 12px; }
  .region-head .h-title, .sub-head .h-title { margin-right: 0; font-size: 1.35rem; }
  .mentor-face { width: 64px; height: 64px; font-size: 2.2rem; }
  .sort-bins { grid-template-columns: 1fr 1fr; gap: 8px; }
  .match-grid { gap: 8px; }
  .mitem { padding: 10px 6px; font-size: .95rem; }
}
