/* ==========================================================================
   CHRONICLES OF THE COSMIC DREAD — Feuille de style principale
   Thème : gothique victorien sombre / gaslight 1929 / chiaroscuro
   Aucune ressource externe (prévisualisation sandboxée sans réseau).
   ========================================================================== */

:root {
  /* Palette — issue de data/graphic_bible.json */
  --ink:        #0B0A0C;
  --soot:       #141217;
  --soot-2:     #1B181F;
  --abyss:      #1E2F2B;
  --sea-grey:   #3B5C5A;
  --brass:      #A8823F;
  --brass-lit:  #C9A24B;
  --blood:      #7A1F1F;
  --blood-lit:  #A03030;
  --gaslight:   #D9B36B;
  --parchment:  #E8DDC9;
  --parchment-dim: #B9AC93;
  --eldritch:   #5C8A72;

  /* Typographie (piles système — aucun webfont externe) */
  --f-display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --f-body:    Georgia, "Times New Roman", serif;
  --f-small:   "Gill Sans", "Segoe UI", Calibri, sans-serif;

  --hud-h: 58px;
  --rad: 4px;
  --shadow-deep: 0 18px 50px rgba(0,0,0,.75);
}

/* ---------- Base ------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Vignette globale + grain léger */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0,0,0,.55) 100%);
  mix-blend-mode: multiply;
}

/* ---------- Écrans ----------------------------------------------------- */
.screen { position: fixed; inset: 0; display: none; }
.screen.is-active { display: flex; flex-direction: column; }

/* ============ ÉCRAN TITRE ============================ */
.screen--title {
  align-items: center; justify-content: center; text-align: center;
  background:
    radial-gradient(90% 60% at 50% 108%, rgba(30,47,43,.85) 0%, transparent 60%),
    radial-gradient(70% 50% at 82% -8%, rgba(59,92,90,.28) 0%, transparent 60%),
    linear-gradient(180deg, #060507 0%, var(--ink) 45%, #0D0F0F 100%);
}
.screen--title.has-keyart::before {
  content: ""; position: absolute; inset: 0;
  background-image: url('../assets/images/ui_title_keyart.jpg');
  background-size: cover; background-position: center;
  opacity: .38; filter: saturate(.75) brightness(.6) contrast(1.05);
}
.title-aurora {
  position: absolute; inset: 0; opacity: .5; filter: blur(60px);
  background:
    radial-gradient(40% 25% at 25% 20%, rgba(92,138,114,.20), transparent 70%),
    radial-gradient(45% 30% at 78% 30%, rgba(59,92,90,.18), transparent 70%);
  animation: auroraDrift 26s ease-in-out infinite alternate;
}
@keyframes auroraDrift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2.5%, 2%, 0) scale(1.08); }
}
.title-fog, .title-bottom-fog {
  position: absolute; left: -10%; right: -10%; height: 28%; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(59,92,90,.10) 45%, transparent);
  filter: blur(14px);
}
.title-fog { top: 6%; animation: fogSlide 34s linear infinite alternate; }
.title-bottom-fog { bottom: 0; animation: fogSlide 41s linear infinite alternate-reverse; }
@keyframes fogSlide { from { transform: translateX(-3%); } to { transform: translateX(3%); } }

.title-inner { position: relative; z-index: 2; max-width: 760px; padding: 2rem; }
.title-sigil {
  width: 130px; height: 130px; margin: 0 auto .8rem; color: var(--brass);
  filter: drop-shadow(0 0 14px rgba(169,130,63,.35));
  animation: sigilPulse 7s ease-in-out infinite;
}
@keyframes sigilPulse {
  0%, 100% { opacity: .85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.025); }
}
.game-title {
  font-family: var(--f-display);
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
  letter-spacing: .14em; text-transform: uppercase;
  margin: 0 0 .35rem; color: var(--parchment);
  text-shadow: 0 2px 24px rgba(0,0,0,.9);
}
.game-subtitle {
  font-style: italic; color: var(--gaslight); letter-spacing: .06em;
  margin: 0 0 1.6rem; font-size: clamp(1rem, 2.2vw, 1.25rem);
}
.title-quote {
  margin: 0 auto 2.2rem; max-width: 56ch; color: var(--parchment-dim);
  font-style: italic; font-size: .95rem;
}
.title-quote cite { display: block; margin-top: .5rem; font-size: .8rem; color: var(--sea-grey); font-style: normal; letter-spacing: .08em; }
.title-menu { display: flex; flex-direction: column; gap: .7rem; width: min(340px, 80vw); margin: 0 auto; }
.title-footer {
  margin-top: 2.4rem; font-family: var(--f-small); font-size: .72rem;
  letter-spacing: .12em; text-transform: uppercase; color: rgba(185,172,147,.5);
}

/* ---------- Boutons ---------------------------------------------------- */
.btn {
  position: relative; padding: .72rem 1.4rem;
  background: linear-gradient(180deg, var(--soot-2), var(--soot));
  color: var(--parchment);
  border: 1px solid rgba(168,130,63,.45);
  border-radius: var(--rad);
  font-family: var(--f-display); letter-spacing: .12em; text-transform: uppercase;
  font-size: .85rem;
  transition: all .22s ease;
}
.btn:hover:not(:disabled) {
  border-color: var(--brass-lit); color: var(--gaslight);
  box-shadow: 0 0 18px rgba(201,162,75,.22), inset 0 0 12px rgba(201,162,75,.06);
  transform: translateY(-1px);
}
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn--primary { border-color: var(--brass); background: linear-gradient(180deg, #241F16, #171310); }
.btn--ghost { background: transparent; border-style: dashed; }
.btn--small { padding: .4rem .9rem; font-size: .75rem; }
.btn--danger { border-color: var(--blood); color: #E0B0A0; }
.btn--danger:hover:not(:disabled) { border-color: var(--blood-lit); color: #F0CCC0; box-shadow: 0 0 16px rgba(160,48,48,.3); }

.icon-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  background: transparent; border: 1px solid rgba(168,130,63,.35);
  color: var(--parchment); border-radius: var(--rad);
  padding: .34rem .6rem; font-family: var(--f-small); font-size: .75rem;
  letter-spacing: .06em; transition: all .18s ease;
}
.icon-btn:hover { border-color: var(--brass-lit); color: var(--gaslight); }
.icon { width: 16px; height: 16px; }
.icon-btn--lang { font-weight: 700; letter-spacing: .12em; min-width: 44px; justify-content: center; }

/* ============ ÉCRAN JEU ============================== */
.screen--game { display: none; }
.screen--game.is-active { display: flex; }

/* ---------- HUD -------------------------------------------------------- */
.hud {
  height: var(--hud-h); flex: 0 0 var(--hud-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 .9rem;
  background: linear-gradient(180deg, #17141A 0%, #0F0D12 100%);
  border-bottom: 1px solid rgba(168,130,63,.4);
  box-shadow: 0 6px 24px rgba(0,0,0,.6); z-index: 20; position: relative;
}
.hud-block--id { display: flex; flex-direction: column; min-width: 150px; }
.hud-player { font-family: var(--f-display); font-size: .95rem; color: var(--gaslight); letter-spacing: .05em; }
.hud-location { font-size: .72rem; color: var(--sea-grey); font-style: italic; letter-spacing: .06em; }
.hud-block--meters { display: flex; gap: 1rem; flex: 1; justify-content: center; flex-wrap: wrap; }
.hud-block--actions { display: flex; gap: .45rem; align-items: center; }
.icon-btn-label { display: none; }
@media (min-width: 1100px) { .icon-btn-label { display: inline; } }

.meter { display: flex; align-items: center; gap: .5rem; min-width: 170px; }
.meter-label {
  font-family: var(--f-small); font-size: .62rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--parchment-dim); width: 4.2em; text-align: right;
}
.meter--ap .meter-label { width: auto; }
.meter-track {
  position: relative; flex: 1; height: 9px; min-width: 80px; max-width: 180px;
  background: #050405; border: 1px solid rgba(168,130,63,.3); border-radius: 5px; overflow: hidden;
}
.meter-fill {
  position: absolute; inset: 0; width: 100%; transform-origin: left;
  background: linear-gradient(90deg, var(--sea-grey), var(--eldritch));
  transition: width .5s cubic-bezier(.6,0,.2,1);
}
.meter--hp .meter-fill  { background: linear-gradient(90deg, #6E3B2A, var(--gaslight)); }
.meter--san .meter-fill { background: linear-gradient(90deg, var(--abyss), var(--eldritch)); }
.meter--ap .meter-fill  { background: linear-gradient(90deg, var(--brass), var(--brass-lit)); }
.meter-value { font-family: var(--f-small); font-size: .72rem; color: var(--parchment); width: 2.4em; }
.meter--san.is-warning .meter-fill { animation: sanFlicker 2.2s infinite; }
@keyframes sanFlicker { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Layout jeu ------------------------------------------------- */
.game-layout {
  flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}
.stage { display: flex; flex-direction: column; min-height: 0; }

.scene-visual {
  position: relative; flex: 1; margin: 0; overflow: hidden;
  border-bottom: 1px solid rgba(168,130,63,.35);
  background: #050505;
}
.scene-visual__image {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transition: transform 8s ease, filter 2s ease;
  transform: scale(1.02);
}
.scene-visual.is-fading .scene-visual__image { opacity: 0; }

/* Fonds procéduraux de substitution (en attendant les JPG générés — STATE_4+) */
.scene-visual__image { background-image: radial-gradient(120% 90% at 50% 0%, rgba(59,92,90,.15), transparent 60%); }
.bg-arkham    .scene-visual__image { background-image:
  linear-gradient(180deg, rgba(6,6,9,0) 0%, rgba(6,6,9,.25) 100%),
  radial-gradient(60% 40% at 70% 12%, rgba(217,179,107,.10), transparent 60%),
  radial-gradient(120% 100% at 50% 110%, #101417 0%, #07080A 55%, #050405 100%); }
.bg-innsmouth .scene-visual__image { background-image:
  radial-gradient(70% 45% at 50% 100%, rgba(30,47,43,.75), transparent 70%),
  linear-gradient(180deg, #06090A 0%, #0B1213 60%, #0E1B19 100%); }
.bg-library   .scene-visual__image { background-image:
  radial-gradient(45% 60% at 50% 30%, rgba(217,179,107,.14), transparent 65%),
  linear-gradient(180deg, #0B0906 0%, #14100A 60%, #090705 100%); }
.bg-asylum    .scene-visual__image { background-image:
  linear-gradient(90deg, transparent 48%, rgba(217,179,107,.05) 50%, transparent 52%),
  linear-gradient(180deg, #0A0B0C 0%, #121316 100%); }
.bg-dreams    .scene-visual__image { background-image:
  radial-gradient(80% 60% at 30% 20%, rgba(92,138,114,.22), transparent 60%),
  radial-gradient(60% 50% at 75% 70%, rgba(59,92,90,.25), transparent 60%),
  linear-gradient(180deg, #070910, #0D1218); }
.bg-rlyeh     .scene-visual__image { background-image:
  radial-gradient(90% 60% at 50% 115%, rgba(30,80,60,.55), transparent 65%),
  linear-gradient(180deg, #050A08 0%, #0A1A14 100%); }
.bg-dunwich   .scene-visual__image { background-image:
  radial-gradient(70% 50% at 50% 100%, rgba(38,42,32,.7), transparent 70%),
  radial-gradient(45% 35% at 80% 15%, rgba(92,138,114,.12), transparent 65%),
  linear-gradient(180deg, #08090A 0%, #12150F 60%, #0A0D08 100%); }
.bg-beach     .scene-visual__image { background-image:
  radial-gradient(80% 45% at 50% 100%, rgba(30,47,43,.6), transparent 70%),
  radial-gradient(40% 30% at 65% 10%, rgba(217,179,107,.08), transparent 60%),
  linear-gradient(180deg, #070809 0%, #0C1214 65%, #122220 100%); }
.bg-witch     .scene-visual__image { background-image:
  radial-gradient(50% 65% at 55% 30%, rgba(217,179,107,.13), transparent 60%),
  linear-gradient(115deg, transparent 48%, rgba(59,92,90,.10) 50%, transparent 52%),
  linear-gradient(180deg, #0B0805 0%, #171009 55%, #0A0705 100%); }

/* ---------- Écrans de fin (5 fins distinctes) ---------- */
.overlay-ending {
  position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(100% 90% at 50% 55%, rgba(9,7,11,.90), rgba(3,2,4,.99));
  animation: modalIn .5s ease;
}
.end-box {
  width: min(640px, 92vw); text-align: center; padding: 3rem 2.2rem 2.2rem;
  border: 1px solid rgba(168,130,63,.55); border-radius: 6px;
  background: linear-gradient(180deg, #161319, #0C0A0D);
  box-shadow: var(--shadow-deep), inset 0 0 60px rgba(0,0,0,.5);
}
.end-badge {
  font-family: var(--f-small); font-size: .65rem; letter-spacing: .3em;
  color: var(--brass-lit); opacity: .85; margin-bottom: 1.2rem;
}
.end-box h2 {
  font-family: var(--f-display); font-size: 1.7rem; letter-spacing: .18em; text-transform: uppercase;
  margin: 0 0 1rem; color: var(--parchment); text-shadow: 0 2px 30px rgba(0,0,0,.9);
}
.end-box p { font-style: italic; color: var(--parchment-dim); margin: 0 0 2rem; line-height: 1.7; }
.overlay-ending--sceau .end-box { border-color: var(--brass); }
.overlay-ending--deep .end-box { border-color: var(--sea-grey); box-shadow: var(--shadow-deep), inset 0 0 60px rgba(30,47,43,.35); }
.overlay-ending--sand .end-box { border-color: #B98A52; box-shadow: var(--shadow-deep), inset 0 0 60px rgba(185,138,82,.12); }
.overlay-ending--reve .end-box { border-color: var(--eldritch); box-shadow: var(--shadow-deep), inset 0 0 60px rgba(92,138,114,.14); }
.overlay-ending--folie .end-box { border-color: var(--blood-lit); box-shadow: var(--shadow-deep), inset 0 0 60px rgba(122,31,31,.18); }

.scene-visual__grain {
  position: absolute; inset: -50%; pointer-events: none; opacity: .05;
  background-image: repeating-conic-gradient(#fff 0 .00003turn, #000 .00003turn .00006turn);
  background-size: 260px 260px; animation: grainShift 1.1s steps(4) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0,0); } 25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); } 75% { transform: translate(2%, 2%); } 100% { transform: translate(0,0); }
}
.scene-visual__vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(115% 100% at 50% 45%, transparent 52%, rgba(0,0,0,.72) 100%);
}
.scene-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: .5rem 1rem;
  font-family: var(--f-small); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(232,221,201,.55); background: linear-gradient(0deg, rgba(0,0,0,.6), transparent);
}

/* Distorsions liées à la Santé Mentale (charte : graphic_bible.json) */
body.sanity-70 .scene-visual__image { filter: saturate(.85) contrast(1.05); animation: chromaDrift 9s ease-in-out infinite alternate; }
@keyframes chromaDrift { from { transform: scale(1.02) rotate(-.25deg); } to { transform: scale(1.035) rotate(.25deg); } }
body.sanity-40 .scene-visual__image { filter: saturate(.7) contrast(1.12) hue-rotate(-8deg); animation: chromaPulse 4.5s ease-in-out infinite; }
@keyframes chromaPulse {
  0%,100% { transform: scale(1.02); } 30% { transform: scale(1.045) skewX(.4deg); } 60% { transform: scale(1.03) skewX(-.4deg); }
}
body.sanity-15 .scene-visual__image { filter: saturate(.5) contrast(1.25) hue-rotate(-18deg); animation: madPulse 2.6s ease-in-out infinite; }
body.sanity-15 .scene-visual::before {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: .10;
  background: repeating-linear-gradient(115deg, transparent 0 34px, rgba(122,31,31,.6) 34px 35px);
  mix-blend-mode: screen; animation: ghostScroll 3s linear infinite;
}
@keyframes madPulse { 0%,100% { transform: scale(1.02); filter: saturate(.5) contrast(1.25); } 50% { transform: scale(1.06) rotate(.5deg); filter: saturate(.4) contrast(1.4) hue-rotate(12deg); } }
@keyframes ghostScroll { from { background-position: 0 0; } to { background-position: 68px 0; } }
body.sanity-40 .hud, body.sanity-15 .hud { animation: hudShiver 5s infinite; }
body.sanity-15 .hud { animation-duration: 2.4s; }
@keyframes hudShiver { 0%, 96%, 100% { transform: translateX(0); } 97% { transform: translateX(-2px); } 98.5% { transform: translateX(2px); } }

/* ---------- Barre audio ------------------------------------------------ */
.audio-bar {
  flex: 0 0 30px; display: flex; align-items: center; gap: .55rem;
  padding: 0 .9rem; background: #0D0B0F;
  font-family: var(--f-small); font-size: .72rem; letter-spacing: .08em;
  color: var(--parchment-dim); border-bottom: 1px solid rgba(168,130,63,.25);
}
.audio-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3A383E; transition: all .3s;
}
.audio-dot.is-playing { background: var(--eldritch); box-shadow: 0 0 8px var(--eldritch); animation: dotPulse 1.4s infinite; }
@keyframes dotPulse { 50% { opacity: .4; } }
.audio-toggle { margin-left: auto; background: none; border: none; color: var(--sea-grey); font-size: .7rem; letter-spacing: .1em; text-decoration: underline; }
.audio-toggle:hover { color: var(--gaslight); }

/* ---------- Panneau de dialogue ---------------------------------------- */
.dialogue-panel {
  flex: 0 0 auto; max-height: 44%;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 0; background: linear-gradient(180deg, #121016, #0B0A0C);
  border-top: 1px solid rgba(168,130,63,.35);
  min-height: 168px;
}
.dialogue-text {
  padding: 1.1rem 1.3rem; overflow-y: auto;
  font-size: 1.02rem; line-height: 1.7; color: var(--parchment);
  border-right: 1px solid rgba(168,130,63,.18);
}
.dialogue-text p { margin: 0 0 .8em; }
.dialogue-text p:last-child { margin-bottom: 0; }
.dialogue-text .speaker {
  display: block; font-family: var(--f-small); font-size: .68rem;
  letter-spacing: .2em; text-transform: uppercase; color: var(--gaslight);
  margin-bottom: .4em;
}
.dialogue-text .dropcap::first-letter {
  initial-letter: 2;
  font-size: 2.6em; float: left; line-height: .8; padding: .06em .12em 0 0;
  color: var(--brass-lit); font-family: var(--f-display);
}
.dialogue-choices {
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .5rem;
  overflow-y: auto; justify-content: center;
}
.choice-btn {
  position: relative; text-align: left; width: 100%;
  padding: .62rem .9rem .62rem 1rem;
  background: linear-gradient(90deg, rgba(27,24,31,.9), rgba(20,18,23,.65));
  border: 1px solid rgba(168,130,63,.28); border-left: 3px solid var(--brass);
  border-radius: 2px var(--rad) var(--rad) 2px;
  color: var(--parchment); font-size: .92rem; line-height: 1.45;
  transition: all .16s ease;
}
.choice-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, rgba(38,32,26,.95), rgba(24,21,27,.8));
  border-color: var(--brass-lit); border-left-color: var(--gaslight);
  transform: translateX(3px);
}
.choice-btn:disabled { opacity: .35; cursor: not-allowed; }
.choice-btn .choice-key {
  display: inline-block; margin-right: .55em; color: var(--brass-lit);
  font-family: var(--f-small); font-size: .72rem; letter-spacing: .1em;
}
.choice-btn .choice-impact {
  position: absolute; right: .7rem; top: .5rem;
  font-family: var(--f-small); font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; padding: .1em .45em; border-radius: 3px;
  border: 1px solid currentColor; opacity: .85;
}
.choice-impact--san-down { color: var(--blood-lit); }
.choice-impact--san-up   { color: var(--eldritch); }
.choice-impact--story    { color: var(--gaslight); }
.choice-btn.is-madness {
  border-left-color: var(--blood); font-style: italic;
  background: linear-gradient(90deg, rgba(40,16,16,.92), rgba(24,14,16,.7));
}
.choice-btn.is-madness .choice-key { color: var(--blood-lit); }
.choice-btn.is-madness::after {
  content: "✦"; position: absolute; right: .75rem; bottom: .45rem; color: var(--blood-lit); opacity: .7;
}

/* ---------- Interface de combat (STATE_2) ------------------------------ */
.combat-ui {
  position: absolute; inset: var(--hud-h) 0 0 0; z-index: 15;
  display: flex; flex-direction: column; gap: 0;
  background: rgba(6,5,8,.96); backdrop-filter: blur(3px);
}
.combat-arena {
  flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 1rem; padding: 1.2rem 1.5rem; align-items: center;
  border-bottom: 1px solid rgba(122,31,31,.5);
  background: linear-gradient(180deg, rgba(122,31,31,.08), transparent);
}
.combatant { border: 1px solid rgba(168,130,63,.3); border-radius: var(--rad); padding: .8rem 1rem; background: rgba(20,18,23,.8); }
.combatant--enemy { border-color: rgba(122,31,31,.55); }
.combatant-name { font-family: var(--f-display); letter-spacing: .1em; color: var(--gaslight); margin-bottom: .5rem; }
.combatant--enemy .combatant-name { color: var(--blood-lit); }
.combatant-intent { margin-top: .4rem; font-size: .78rem; color: var(--parchment-dim); font-style: italic; }
.combat-vs { font-size: 1.6rem; color: var(--blood); opacity: .8; }
.combat-actions {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: .5rem;
  padding: .9rem 1.5rem; border-bottom: 1px solid rgba(168,130,63,.2);
}
.combat-log {
  flex: 1 1 auto; overflow-y: auto; padding: .9rem 1.5rem;
  font-size: .88rem; color: var(--parchment-dim); line-height: 1.6;
}
.combat-log .log-turn { color: var(--sea-grey); font-family: var(--f-small); font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; margin: .4rem 0 .2rem; }
.combat-log .log-hit { color: #D8A47F; }
.combat-log .log-miss { color: var(--sea-grey); font-style: italic; }
.combat-log .log-san { color: #8FB5A0; }
.combat-log .log-death { color: var(--blood-lit); font-weight: bold; }

/* ---------- Modales ----------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,4,7,.78); backdrop-filter: blur(4px);
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  width: min(860px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #17141B, #100E13);
  border: 1px solid rgba(168,130,63,.5); border-radius: 6px;
  box-shadow: var(--shadow-deep), inset 0 0 60px rgba(0,0,0,.5);
  animation: boxIn .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes boxIn { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.1rem; border-bottom: 1px solid rgba(168,130,63,.35);
}
.modal-head h2 {
  margin: 0; font-family: var(--f-display); font-size: 1.05rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--gaslight);
}
.modal-sub { font-family: var(--f-small); font-size: .72rem; color: var(--parchment-dim); }
.modal-close { margin-left: auto; border: none; font-size: 1rem; color: var(--parchment-dim); }
.modal-close:hover { color: var(--blood-lit); }
.modal-body { padding: 1.1rem; overflow-y: auto; flex: 1; }
.modal-foot { padding: .7rem 1.1rem; border-top: 1px solid rgba(168,130,63,.25); display: flex; gap: .5rem; align-items: center; }

/* Inventaire */
.inv-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 1rem; }
.inventory-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; align-content: start;
}
.inv-slot {
  aspect-ratio: 1; border: 1px solid rgba(168,130,63,.25); border-radius: var(--rad);
  background:
    linear-gradient(180deg, rgba(27,24,31,.6), rgba(16,14,19,.9));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; padding: .35rem; cursor: pointer; transition: all .15s ease; position: relative;
}
.inv-slot:hover:not(.is-empty) { border-color: var(--brass-lit); box-shadow: 0 0 12px rgba(201,162,75,.18); }
.inv-slot.is-empty { opacity: .28; cursor: default; border-style: dashed; }
.inv-slot.is-selected { border-color: var(--gaslight); box-shadow: 0 0 0 1px var(--gaslight), 0 0 16px rgba(217,179,107,.25); }
.inv-slot.is-combine-source { border-color: var(--eldritch); box-shadow: 0 0 0 1px var(--eldritch); }
.inv-slot-rune { font-size: 1.5rem; line-height: 1; color: var(--brass-lit); text-shadow: 0 0 10px rgba(201,162,75,.4); }
.inv-slot-name {
  font-family: var(--f-small); font-size: .6rem; text-align: center; line-height: 1.25;
  letter-spacing: .03em; color: var(--parchment-dim); max-width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.inv-slot-qty {
  position: absolute; top: 3px; right: 6px; font-family: var(--f-small);
  font-size: .6rem; color: var(--gaslight);
}
.inventory-detail {
  border: 1px solid rgba(168,130,63,.22); border-radius: var(--rad);
  padding: .9rem; min-height: 160px; font-size: .9rem; color: var(--parchment-dim);
  background: rgba(11,10,12,.55);
}
.inv-hint { font-style: italic; margin: 0 0 .8rem; }
.inv-hint--combine { font-size: .76rem; color: var(--sea-grey); }
.inv-detail-name { font-family: var(--f-display); color: var(--gaslight); letter-spacing: .08em; margin: 0 0 .5rem; font-size: 1rem; }
.inv-detail-desc { font-size: .88rem; line-height: 1.55; }
.inv-combine-status { margin-left: auto; font-family: var(--f-small); font-size: .7rem; letter-spacing: .08em; color: var(--eldritch); }

/* Inspection */
.modal-box--inspect { width: min(920px, 94vw); }
.inspect-body { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 58%); gap: 1.2rem; }
.inspect-visual {
  margin: 0; aspect-ratio: 1; border-radius: var(--rad); overflow: hidden;
  border: 1px solid rgba(168,130,63,.4); position: relative;
  background:
    radial-gradient(70% 70% at 50% 45%, rgba(217,179,107,.08), transparent 70%),
    linear-gradient(180deg, #100E12, #070608);
  display: flex; align-items: center; justify-content: center;
  background-size: cover; background-position: center;
}
.inspect-visual .inspect-rune { font-size: 5rem; color: var(--brass); text-shadow: 0 0 30px rgba(201,162,75,.5); opacity: .9; }
.inspect-visual::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(100% 100% at 50% 45%, transparent 60%, rgba(0,0,0,.6) 100%);
}
.inspect-desc { font-size: .95rem; line-height: 1.65; }
.inspect-lore {
  margin: .9rem 0; padding: .8rem .9rem; border-left: 3px solid var(--abyss);
  background: rgba(30,47,43,.18); font-size: .85rem; font-style: italic; color: var(--parchment-dim);
}
.inspect-effects { font-family: var(--f-small); font-size: .75rem; letter-spacing: .05em; color: var(--eldritch); }
.inspect-effects span { display: inline-block; margin-right: .8em; padding: .15em .5em; border: 1px solid rgba(92,138,114,.4); border-radius: 3px; }

/* ---------- Toast -------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 70; padding: .6rem 1.3rem;
  background: rgba(20,17,24,.95); border: 1px solid var(--brass);
  border-radius: var(--rad); color: var(--parchment);
  font-family: var(--f-small); font-size: .8rem; letter-spacing: .08em;
  box-shadow: var(--shadow-deep); animation: toastIn .25s ease;
}
.toast--blood { border-color: var(--blood-lit); color: #E8C4B8; }
.toast--mint { border-color: var(--eldritch); color: #CFE8DA; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Divers ------------------------------------------------------- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: #0D0B0F; }
::-webkit-scrollbar-thumb { background: #2A2531; border-radius: 5px; border: 2px solid #0D0B0F; }
::-webkit-scrollbar-thumb:hover { background: var(--brass); }
::selection { background: rgba(169,130,63,.45); color: #fff; }

@media (max-width: 900px) {
  .dialogue-panel { grid-template-columns: 1fr; max-height: 56%; }
  .dialogue-text { border-right: none; border-bottom: 1px solid rgba(168,130,63,.18); }
  .hud-block--meters { display: none; }
  .inv-body, .inspect-body { grid-template-columns: 1fr; }
}

/* Accessibilité mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   ÉTAT 2 — Extensions : phobies, combat, hantise typographique, game over
   ========================================================================== */
.screen--game { position: relative; }

/* Chips de phobies dans le HUD */
.hud-phobias { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .15rem; }
.phobia-chip {
  font-family: var(--f-small); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase;
  color: #C98F8F; border: 1px solid rgba(122,31,31,.65); border-radius: 3px;
  padding: .05em .4em; cursor: help; background: rgba(122,31,31,.12);
}

/* Combat — barre d'actions & rangée de sorts */
.combat-actions { align-content: flex-start; }
.btn--cbt { border-left: 3px solid var(--blood); }
.btn--cbt:hover:not(:disabled) { border-left-color: var(--blood-lit); }
.btn--spell { border-left: 3px solid var(--eldritch); font-style: italic; }
.btn--spell:hover:not(:disabled) { border-left-color: #8FB5A0; box-shadow: 0 0 14px rgba(92,138,114,.25); }
.cbt-cost {
  display: inline-block; margin-left: .45rem; font-family: var(--f-small);
  font-size: .6rem; letter-spacing: .08em; color: var(--parchment-dim);
  border: 1px solid rgba(168,130,63,.35); border-radius: 3px; padding: .05em .4em;
}
.cbt-spellrow {
  flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .5rem;
  padding-top: .55rem; margin-top: .55rem;
  border-top: 1px dashed rgba(92,138,114,.35);
}
body.is-combat .dialogue-panel, body.is-combat .stage { filter: brightness(.55) saturate(.6); }
body.is-combat .stage { pointer-events: none; }

/* Hantise typographique (SAN<40) */
.haunt-line {
  display: block; margin: .7em 0 0; font-style: italic; letter-spacing: .09em;
  color: #8E4B45; opacity: .75; font-size: .9em;
  animation: hauntFlicker 3.4s ease-in-out infinite;
  text-shadow: 0 0 8px rgba(122,31,31,.35);
}
@keyframes hauntFlicker {
  0%, 100% { opacity: .75; } 42% { opacity: .75; }
  45% { opacity: .15; } 47% { opacity: .8; } 49% { opacity: .28; } 55% { opacity: .75; }
}

/* Écran de fin (défaite / folie) */
.overlay-gameover {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(90% 80% at 50% 50%, rgba(20,8,10,.92), rgba(4,3,5,.98));
  animation: modalIn .4s ease;
}
.og-box {
  width: min(560px, 90vw); text-align: center; padding: 2.4rem 2rem;
  border: 1px solid rgba(122,31,31,.6); border-radius: 6px;
  background: linear-gradient(180deg, #171016, #0C090C);
  box-shadow: var(--shadow-deep), inset 0 0 40px rgba(122,31,31,.08);
}
.og-box h2 {
  font-family: var(--f-display); color: var(--blood-lit); letter-spacing: .12em;
  text-transform: uppercase; font-size: 1.3rem; margin: 0 0 1rem;
}
.og-box p { color: var(--parchment-dim); font-style: italic; line-height: 1.7; margin: 0 0 1.8rem; }

/* Visuel d'inspection quand un JPG HD est disponible */
.inspect-visual.has-image { background-size: cover; background-position: center; }

/* Badge « Équipé » dans l'inventaire */
.inv-slot-qty {
  font-size: .58rem; letter-spacing: .08em; color: var(--eldritch);
  border: 1px solid rgba(92,138,114,.5); border-radius: 3px; padding: 0 .35em;
}

/* ==========================================================================
   CODEX DU MYTHE + BADGES DE FINS (Enrichissement — Vague 1)
   ========================================================================== */

.modal-box--codex { width: min(1060px, 94vw); height: min(720px, 90vh); }

.codex-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 18px 0; border-bottom: 1px solid rgba(168,130,63,.25);
}
.codex-tab {
  background: none; border: 1px solid rgba(168,130,63,.25); border-bottom: none;
  color: var(--parchment-dim); font-family: var(--f-small); font-size: 13px;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 8px 14px 7px; border-radius: var(--rad) var(--rad) 0 0; cursor: pointer;
}
.codex-tab:hover { color: var(--gaslight); }
.codex-tab.is-active {
  color: var(--gaslight); background: rgba(168,130,63,.12);
  box-shadow: inset 0 -2px 0 var(--brass);
}
.codex-tab-count { opacity: .65; font-size: 11px; margin-left: 4px; }

.codex-body {
  display: grid; grid-template-columns: 280px 1fr; gap: 0;
  flex: 1; min-height: 0;
}

.codex-list {
  list-style: none; margin: 0; padding: 10px;
  overflow-y: auto; border-right: 1px solid rgba(168,130,63,.2);
}
.codex-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 10px; border-radius: var(--rad); cursor: pointer;
  font-family: var(--f-body); font-size: 14px; color: var(--parchment);
  border-left: 2px solid transparent;
}
.codex-item:hover { background: rgba(216,179,107,.07); }
.codex-item.is-active { background: rgba(168,130,63,.14); border-left-color: var(--brass); }
.codex-item.is-locked { opacity: .38; cursor: default; font-style: italic; }
.codex-item-rune { color: var(--brass); min-width: 18px; text-align: center; }

.codex-detail { overflow-y: auto; padding: 18px 26px 26px; }
.codex-fig {
  height: 190px; margin: 0 0 14px; border-radius: var(--rad);
  background-size: cover; background-position: center 30%;
  border: 1px solid rgba(168,130,63,.3);
  box-shadow: var(--shadow-deep), inset 0 0 60px rgba(0,0,0,.55);
}
.codex-name {
  font-family: var(--f-display); color: var(--gaslight);
  font-size: 26px; margin: 0 0 2px; letter-spacing: .02em;
}
.codex-sub { color: var(--parchment-dim); font-style: italic; margin: 2px 0 8px; }
.codex-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 12px;
  font-family: var(--f-small); font-size: 12px; color: var(--parchment-dim);
  text-transform: uppercase; letter-spacing: .05em;
}
.codex-original { color: var(--eldritch); }
.codex-desc { font-family: var(--f-body); line-height: 1.62; font-size: 15.5px; }
.codex-desc p { margin: 0 0 10px; }
.codex-quote {
  margin: 14px 0; padding: 12px 16px;
  border-left: 3px solid var(--blood-lit);
  background: rgba(122,31,31,.12);
  font-style: italic; color: var(--parchment);
}
.codex-row { font-size: 14px; line-height: 1.55; color: var(--parchment-dim); }
.codex-row .codex-label,
.codex-quote .codex-label {
  display: block; font-family: var(--f-small); font-size: 11px;
  text-transform: uppercase; letter-spacing: .14em; color: var(--brass-lit);
  margin-bottom: 4px; font-style: normal;
}
.codex-conn {
  display: inline-block; margin: 2px 6px 2px 0; padding: 2px 10px;
  border: 1px solid rgba(92,138,114,.5); border-radius: 999px;
  color: var(--eldritch); font-size: 12.5px; font-family: var(--f-small);
}
@media (max-width: 820px) {
  .codex-body { grid-template-columns: 1fr; }
  .codex-list { max-height: 180px; border-right: none; border-bottom: 1px solid rgba(168,130,63,.2); }
}

/* ---- Badges de fins sur l'écran titre ---- */
.ending-badges {
  display: flex; gap: 14px; justify-content: center; align-items: flex-end;
  margin-top: 26px; min-height: 64px;
}
.end-badge-slot {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 88px; opacity: .35; filter: grayscale(1);
  transition: opacity .4s, filter .4s, transform .3s;
}
.end-badge-slot .eb-sigil {
  font-size: 30px; line-height: 1; color: var(--parchment-dim);
  text-shadow: 0 0 14px rgba(0,0,0,.8);
}
.end-badge-slot .eb-name {
  font-family: var(--f-small); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--parchment-dim); text-align: center;
}
.end-badge-slot.is-unlocked { opacity: 1; filter: none; transform: translateY(-2px); }
.end-badge-slot.is-unlocked.eb--sceau .eb-sigil { color: var(--brass-lit); text-shadow: 0 0 18px rgba(201,162,75,.6); }
.end-badge-slot.is-unlocked.eb--deep  .eb-sigil { color: var(--sea-grey);   text-shadow: 0 0 18px rgba(59,92,90,.9); }
.end-badge-slot.is-unlocked.eb--sand  .eb-sigil { color: var(--gaslight);   text-shadow: 0 0 18px rgba(217,179,107,.55); }
.end-badge-slot.is-unlocked.eb--reve  .eb-sigil { color: #9a86c8;           text-shadow: 0 0 18px rgba(154,134,200,.6); }
.end-badge-slot.is-unlocked.eb--folie .eb-sigil { color: var(--blood-lit);  text-shadow: 0 0 18px rgba(160,48,48,.7); }
.eb-title {
  width: 100%; text-align: center; margin-bottom: 2px;
  font-family: var(--f-small); font-size: 10px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--brass);
}

.ending-badges { flex-wrap: wrap; }
