/* ==========================================================
   The Story of Wanou — Obsidienne moderne
   ========================================================== */
:root {
  --bg: #0a080d;
  --page: #141019;
  --page-2: #191420;
  --ink: #d8cfc2;
  --ink-dim: #9b8fa3;
  --gold: #c9a35a;
  --gold-soft: rgba(201, 163, 90, 0.35);
  --blood: #a03040;
  --line: rgba(201, 163, 90, 0.18);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse 120% 90% at 50% 10%, #171221 0%, var(--bg) 60%, #060509 100%);
  font-family: 'EB Garamond', serif;
  color: var(--ink);
  overflow: hidden;
}
#embers { position: fixed; inset: 0; pointer-events: none; z-index: 1; }

/* ---------- Écrans ---------- */
.screen { position: fixed; inset: 0; z-index: 5; display: none; }
.screen.active { display: block; animation: screenIn .7s ease both; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================
   ACCUEIL
   ========================================================== */
#screen-accueil { display: none; }
#screen-accueil.active { display: grid; place-items: center; }
.accueil-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: .55; }
.accueil-veil {
  position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 30%, rgba(10,8,13,.88) 100%);
}
.accueil-inner { text-align: center; animation: fadeUp 1.2s ease both; }
.accueil-kicker {
  font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: 6px;
  text-transform: uppercase; color: var(--ink-dim);
}
.accueil-title {
  font-family: 'Cinzel', serif; font-weight: 500; font-size: clamp(40px, 6vw, 68px);
  color: #efe7d8; margin: 14px 0 4px;
  text-shadow: 0 4px 40px rgba(201,163,90,.25);
}
.accueil-sub {
  font-style: italic; font-size: 19px; color: var(--gold); margin-bottom: 8px;
}
.accueil-rule {
  width: 220px; height: 1px; margin: 26px auto;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  position: relative;
}
.accueil-rule::after {
  content: '◆'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: var(--gold); font-size: 9px; background: transparent;
}
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu button {
  font-family: 'Cinzel', serif; font-size: 17px; letter-spacing: 3px;
  background: none; border: none; color: var(--ink);
  padding: 11px; cursor: pointer;
  transition: all .3s cubic-bezier(.2,.7,.2,1);
  position: relative;
}
.menu button:hover { color: var(--gold); letter-spacing: 5px; text-shadow: 0 0 24px var(--gold-soft); }
.menu button:disabled { color: rgba(155,143,163,.35); cursor: not-allowed; }
.menu button:disabled:hover { letter-spacing: 3px; text-shadow: none; }
.menu button.editor-entry { font-size: 13px; color: var(--ink-dim); margin-top: 14px; }
#btn-quitter { display: none; }
body.desktop #btn-quitter { display: block; }
.menu button.editor-entry:hover { color: var(--gold); }
.accueil-version {
  position: absolute; bottom: 18px; right: 24px;
  font-family: 'Inter', sans-serif; font-size: 10.5px; letter-spacing: 1.5px; color: rgba(155,143,163,.5);
}
.accueil-account {
  position: absolute; top: 20px; right: 24px; z-index: 4;
  display: flex; align-items: center; gap: 12px;
  font-family: 'Inter', sans-serif; font-size: 12px; color: var(--ink-dim);
}
.accueil-account button {
  background: rgba(20,16,25,.7); border: 1px solid var(--line); color: var(--gold);
  font-family: 'Inter', sans-serif; font-size: 12px; padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: border-color .2s;
}
.accueil-account button:hover { border-color: var(--gold-soft); }

/* ---------- CODEX / CARTE ---------- */
#screen-codex { background: radial-gradient(ellipse 100% 80% at 50% 10%, #171221 0%, var(--bg) 70%); }
#screen-codex.active { display: block; }
.codex-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 24px 40px 32px; }
.codex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.codex-head h1 { font-family: 'Cinzel', serif; font-weight: 500; font-size: 30px; color: #efe7d8; }
.codex-close { background: none; border: 1px solid var(--line); border-radius: 50%; width: 40px; height: 40px; cursor: pointer; color: var(--ink-dim); display: grid; place-items: center; transition: all .2s; }
.codex-close:hover { border-color: var(--gold-soft); color: var(--gold); }
.codex-close svg { width: 18px; height: 18px; stroke: currentColor; }
.codex-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.codex-tab { font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: 1px; background: none; border: 1px solid var(--line); color: var(--ink-dim); padding: 9px 20px; border-radius: 999px; cursor: pointer; transition: all .25s; }
.codex-tab:hover { color: var(--ink); border-color: var(--gold-soft); }
.codex-tab.active { color: var(--gold); border-color: var(--gold-soft); background: rgba(201,163,90,.08); }
.codex-body { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; gap: 30px; min-height: 0; }
.codex-map { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #0d0a12; display: grid; place-items: center; }
.codex-map img { width: 100%; height: 100%; object-fit: contain; display: none; }
.codex-map img.loaded { display: block; }
.codex-map-hint { position: absolute; font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink-dim); text-align: center; padding: 20px; }
.codex-map-hint code { color: var(--gold); background: rgba(201,163,90,.1); padding: 2px 8px; border-radius: 4px; }
.codex-map-pin { position: absolute; transform: translate(-50%,-50%); z-index: 2; }
.codex-map-pin .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--blood); border: 2px solid #efe7d8; box-shadow: 0 0 12px var(--blood); cursor: pointer; }
.codex-map-pin .label { position: absolute; left: 16px; top: -4px; white-space: nowrap; font-family: 'Cinzel', serif; font-size: 12px; color: #efe7d8; text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity .2s; pointer-events: none; }
.codex-map-pin:hover .label { opacity: 1; }
.codex-content { overflow-y: auto; padding-right: 10px; }
.codex-content::-webkit-scrollbar { width: 5px; }
.codex-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.codex-content h2 { font-family: 'Cinzel', serif; font-weight: 500; font-size: 22px; color: var(--gold); margin-bottom: 16px; }
.codex-section { margin-bottom: 22px; }
.codex-section h3 { font-family: 'Cinzel', serif; font-size: 16px; color: #efe7d8; margin-bottom: 6px; }
.codex-section p { font-size: 15.5px; line-height: 1.7; color: var(--ink); }

/* ---------- Overlay / Auth ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(6,5,9,.8); backdrop-filter: blur(4px); }
.overlay.show { display: flex; }
.auth-card { width: 360px; background: linear-gradient(160deg, var(--page-2), var(--page)); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.auth-tab { flex: 1; background: none; border: none; color: var(--ink-dim); font-family: 'Cinzel', serif; font-size: 14px; padding: 10px; cursor: pointer; border-bottom: 2px solid transparent; transition: all .2s; }
.auth-tab.active { color: var(--gold); border-bottom-color: var(--gold-soft); }
.auth-fields { display: flex; flex-direction: column; gap: 12px; }
.auth-fields input { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--ink); font-family: 'EB Garamond', serif; font-size: 15px; }
.auth-fields input:focus { outline: none; border-color: var(--gold-soft); }
.auth-error { font-family: 'Inter', sans-serif; font-size: 12.5px; color: #d97c8a; min-height: 16px; }
.auth-submit { background: rgba(201,163,90,.12); border: 1px solid var(--gold-soft); color: var(--gold); font-family: 'Cinzel', serif; font-size: 15px; letter-spacing: 1px; padding: 12px; border-radius: 10px; cursor: pointer; transition: all .2s; }
.auth-submit:hover { background: rgba(201,163,90,.2); }
.auth-cancel { width: 100%; margin-top: 12px; background: none; border: none; color: var(--ink-dim); font-family: 'Inter', sans-serif; font-size: 12px; cursor: pointer; }
.auth-cancel:hover { color: var(--ink); }

/* ==========================================================
   CINÉMATIQUE plein écran (événement clé, façon visual novel)
   ========================================================== */
#screen-cinematic { background: #060509; }
#screen-cinematic.active { display: block; }
#cine-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: saturate(.9) contrast(1.05) brightness(.9);
  animation: cineZoom 14s ease-out both;
}
@keyframes cineZoom { from { transform: scale(1.08); } to { transform: scale(1); } }
.cine-tint { position: absolute; inset: 0; background: rgba(20,12,30,.28); mix-blend-mode: multiply; }
.cine-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
.cine-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 90% 80% at 50% 35%, transparent 40%, rgba(6,5,9,.85) 100%),
              linear-gradient(180deg, transparent 45%, rgba(6,5,9,.95) 100%);
}
.cine-content {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 0 8vw 8vh; text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.cine-kicker {
  font-family: 'Inter', sans-serif; font-size: 12px; letter-spacing: 5px;
  text-transform: uppercase; color: var(--gold);
  animation: fadeUp 1s ease both .3s;
}
.cine-title {
  font-family: 'Cinzel', serif; font-weight: 500; font-size: clamp(30px, 4.5vw, 52px);
  color: #efe7d8; margin: 12px 0 18px; text-shadow: 0 4px 40px rgba(0,0,0,.9);
  animation: fadeUp 1.1s ease both .5s;
}
.cine-text {
  max-width: 680px; font-size: 19px; line-height: 1.7; color: var(--ink);
  font-style: italic; text-shadow: 0 2px 20px rgba(0,0,0,.9);
  animation: fadeUp 1.2s ease both .8s;
}
.cine-continue {
  margin-top: 32px; background: none; border: 1px solid var(--gold-soft);
  color: var(--gold); font-family: 'Cinzel', serif; font-size: 15px; letter-spacing: 2px;
  padding: 12px 32px; border-radius: 999px; cursor: pointer;
  transition: all .3s; animation: fadeUp 1.3s ease both 1.4s;
}
.cine-continue span { transition: transform .3s; display: inline-block; }
.cine-continue:hover { background: rgba(201,163,90,.1); border-color: var(--gold); letter-spacing: 3px; }
.cine-continue:hover span { transform: translateX(4px); }

/* ==========================================================
   HUD (en jeu)
   ========================================================== */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
}
.hud-left { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--gold-soft);
  background: linear-gradient(145deg, #241c2e, #120e18);
  display: grid; place-items: center;
  font-family: 'Cinzel', serif; color: var(--gold); font-size: 15px;
}
.hud-name { font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: 2px; color: var(--ink); }
.hud-sub { font-family: 'Inter', sans-serif; font-size: 10.5px; letter-spacing: 1.5px; color: var(--ink-dim); text-transform: uppercase; margin-top: 2px; }
.hud-right { display: flex; gap: 10px; }
.stat-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(20, 16, 25, 0.75); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  font-family: 'Inter', sans-serif; font-size: 12px; color: var(--ink-dim);
  transition: border-color .25s;
}
.stat-pill:hover { border-color: var(--gold-soft); }
.stat-pill b { color: var(--gold); font-weight: 500; }
.stat-pill.bump b { animation: statBump .6s ease; }
@keyframes statBump { 30% { transform: scale(1.5); color: #efe7d8; } }
.stat-pill svg { width: 13px; height: 13px; stroke: var(--gold); opacity: .8; }

/* ==========================================================
   LIVRE (en jeu)
   ========================================================== */
.book-wrap {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 72px 44px 52px;
}
.book {
  width: min(1180px, 100%); height: min(660px, 100%);
  display: grid; grid-template-columns: 1fr 1fr;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 40px 90px rgba(0,0,0,.65), 0 0 0 1px var(--line), 0 0 120px rgba(201,163,90,.05);
  position: relative;
  animation: bookIn 1s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes bookIn { from { opacity: 0; transform: translateY(24px) scale(.985); } to { opacity: 1; transform: none; } }
.spine {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; z-index: 4;
  background: linear-gradient(180deg, transparent, var(--gold-soft) 20%, var(--gold-soft) 80%, transparent);
}
.spine::before {
  content: ''; position: absolute; left: -30px; right: -30px; top: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.5) 50%, transparent);
}

/* ---------- Page gauche : image ---------- */
.page-left { position: relative; background: #0d0a12; overflow: hidden; }
.page-left .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.page-left .veil {
  position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(200deg, transparent 40%, rgba(10,8,13,.75) 100%),
              radial-gradient(ellipse 140% 100% at 50% 0%, transparent 55%, rgba(10,8,13,.55) 100%);
}
/* Grain + teinte : fond toute image IA dans l'ambiance Obsidienne */
.page-left .grain {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
.page-left .tint {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgba(20, 12, 30, 0.32); mix-blend-mode: multiply;
}
.page-left .art { filter: saturate(.92) contrast(1.04) brightness(.94); }
.art.hidden { display: none !important; }
.chapter-tag { position: absolute; left: 36px; bottom: 30px; right: 36px; z-index: 3; }
.chapter-num {
  font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: 4px;
  color: var(--gold); text-transform: uppercase;
  display: flex; align-items: center; gap: 12px;
}
.chapter-num::before { content: ''; width: 34px; height: 1px; background: var(--gold-soft); flex-shrink: 0; }
.chapter-name {
  font-family: 'Cinzel', serif; font-size: 28px; font-weight: 500;
  color: #efe7d8; margin-top: 8px; text-shadow: 0 2px 18px rgba(0,0,0,.8);
}
.progress { position: absolute; top: 28px; left: 36px; display: flex; gap: 8px; z-index: 3; }
.progress span { width: 26px; height: 2px; background: rgba(216,207,194,.18); border-radius: 2px; }
.progress span.done { background: var(--gold); }
.progress span.cur { background: var(--gold); box-shadow: 0 0 8px var(--gold-soft); }

/* ---------- Page droite : récit ---------- */
.page-right {
  background: linear-gradient(160deg, var(--page-2) 0%, var(--page) 55%, #100c16 100%);
  padding: 36px 46px 30px;
  display: flex; flex-direction: column;
  position: relative;
}
.scene-kicker {
  font-family: 'Inter', sans-serif; font-size: 10.5px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--ink-dim);
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.scene-kicker .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--blood); box-shadow: 0 0 8px var(--blood); flex-shrink: 0; }
.narrative { font-size: 16.5px; line-height: 1.7; color: var(--ink); flex: 1; overflow-y: auto; padding-right: 8px; }
.narrative::-webkit-scrollbar { width: 4px; }
.narrative::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.narrative p { margin-bottom: 1em; animation: fadeUp .8s ease both; }
.narrative p:nth-child(2) { animation-delay: .25s; }
.narrative p:nth-child(3) { animation-delay: .5s; }
.narrative p:nth-child(4) { animation-delay: .75s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.narrative .speech { color: #e8ddc9; font-style: italic; }

/* ---------- Choix ---------- */
.choices { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.choice {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 16px; border-radius: 12px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(216,207,194,.09);
  cursor: pointer;
  font-size: 15.5px; color: var(--ink);
  font-family: 'EB Garamond', serif;
  text-align: left; width: 100%;
  transition: all .28s cubic-bezier(.2,.7,.2,1);
  animation: fadeUp .7s ease both; animation-delay: .7s;
}
.choice:nth-child(2) { animation-delay: .82s; }
.choice:nth-child(3) { animation-delay: .94s; }
.choice:nth-child(4) { animation-delay: 1.06s; }
.choice:hover {
  background: rgba(201,163,90,.06);
  border-color: var(--gold-soft);
  transform: translateX(6px);
  box-shadow: -6px 0 0 -3px var(--gold);
}
.choice > span:first-child { flex: 1; min-width: 55%; }
.choice .fx-group { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.choice .fx {
  font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: rgba(201,163,90,.1); color: var(--gold);
  border: 1px solid rgba(201,163,90,.2);
}
.choice .fx.neg { background: rgba(160,48,64,.1); color: #d97c8a; border-color: rgba(160,48,64,.25); }
.choice .fx.req { background: rgba(160,48,64,.12); color: #d97c8a; border-color: rgba(160,48,64,.3); }
.choice.locked { opacity: .45; cursor: not-allowed; }
.choice.locked:hover { transform: none; box-shadow: none; background: rgba(255,255,255,.025); border-color: rgba(216,207,194,.09); }
.choice.locked .lock { margin-right: 8px; opacity: .7; }

/* ---------- Barre bas ---------- */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 26px; padding: 14px;
  font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--ink-dim);
}
.bottom-bar button {
  background: none; border: none; cursor: pointer; font: inherit; color: inherit;
  letter-spacing: inherit; text-transform: inherit;
  transition: color .2s; display: flex; align-items: center; gap: 7px;
}
.bottom-bar button:hover { color: var(--gold); }
.bottom-bar svg { width: 14px; height: 14px; stroke: currentColor; }
.bottom-bar .edit-btn { color: rgba(155,143,163,.55); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 50; padding: 10px 22px; border-radius: 999px;
  background: rgba(20,16,25,.92); border: 1px solid var(--gold-soft);
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--gold);
  opacity: 0; pointer-events: none; transition: all .4s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
