/* ============================================================
   ELIAV SE CASSE LE POIGNET — style DS/PS1 rétro
   ============================================================ */
:root {
  --bg: #14092e;
  --bg2: #241245;
  --box: #1b1464;
  --box-edge: #f8f4e8;
  --gold: #ffcc33;
  --red: #ff4757;
  --cyan: #3de1ff;
  --green: #52ff7a;
  --purple: #b06cff;
  --text: #f8f4e8;
  --px: "Press Start 2P", monospace;
  --vt: "VT323", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--vt);
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse at 50% -20%, #3a1d6e 0%, transparent 60%),
    repeating-linear-gradient(45deg, #180b36 0 24px, #14092e 24px 48px);
}

/* --- CRT overlay --- */
#crt {
  pointer-events: none;
  position: fixed; inset: 0; z-index: 999;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#crt::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,10,.55) 100%);
}

/* --- stage / screens --- */
#stage {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.screen {
  display: none;
  width: min(100vw, 1024px);
  height: min(100vh, 768px);
  max-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
}
.screen.active { display: flex; animation: screenIn .35s steps(6); }
@keyframes screenIn {
  from { transform: scale(.92); opacity: 0; filter: brightness(3); }
  to   { transform: scale(1); opacity: 1; filter: brightness(1); }
}

/* --- boutons pixel --- */
.px-btn {
  font-family: var(--px);
  font-size: 14px;
  color: var(--text);
  background: var(--box);
  border: 3px solid var(--box-edge);
  box-shadow: 0 4px 0 #000, inset 0 0 0 2px #000;
  padding: 12px 20px;
  cursor: pointer;
  text-transform: uppercase;
  image-rendering: pixelated;
  transition: transform .05s steps(2);
}
.px-btn:hover { background: #2a1f8a; transform: translateY(-2px); }
.px-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000, inset 0 0 0 2px #000; }
.px-btn.big { font-size: 18px; padding: 16px 28px; }
.px-btn.tiny { font-size: 9px; padding: 6px 10px; }

.blink { animation: blink 1s steps(2) infinite; }
.blink-slow { animation: blink 2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ============ ÉCRAN TITRE ============ */
#screen-title { text-align: center; }
.title-bg {
  position: absolute; inset: 0;
  background: url("../assets/img/cover.webp") center/cover no-repeat;
  filter: brightness(.45) saturate(1.3) contrast(1.1);
  image-rendering: pixelated;
}
.title-inner { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.title-sub {
  font-family: var(--px); font-size: 11px; color: var(--cyan);
  text-shadow: 2px 2px 0 #000;
}
.game-title {
  font-family: var(--px);
  line-height: 1.35;
  display: flex; flex-direction: column; gap: 6px;
  text-shadow: 4px 4px 0 #000, 8px 8px 0 rgba(255,71,87,.35);
}
.game-title .t1 { font-size: clamp(34px, 7vw, 64px); color: var(--gold); animation: bounce 1.6s ease-in-out infinite; }
.game-title .t2 { font-size: clamp(18px, 3.5vw, 30px); color: var(--text); }
.game-title .t3 { font-size: clamp(26px, 5.5vw, 48px); color: var(--red); animation: bounce 1.6s .2s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.title-bone { font-size: 42px; animation: spin 4s linear infinite; filter: drop-shadow(3px 3px 0 #000); }
@keyframes spin { to { transform: rotate(360deg); } }
.title-footnote { font-size: 16px; color: #bfa8ff; text-shadow: 1px 1px 0 #000; }

/* ============ SÉLECTION D'ÉPISODE ============ */
.screen-title {
  font-family: var(--px); font-size: clamp(14px, 2.6vw, 22px);
  color: var(--gold); text-shadow: 3px 3px 0 #000;
  margin-bottom: 26px;
}
#chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 900px;
}
.chap {
  border: 3px solid var(--box-edge);
  box-shadow: 0 5px 0 #000, inset 0 0 0 2px #000;
  background: var(--box);
  padding: 14px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .06s steps(2);
}
.chap:hover:not(.locked) { transform: translateY(-3px); background: #2a1f8a; }
.chap .chap-num { font-family: var(--px); font-size: 10px; color: var(--cyan); }
.chap .chap-title { font-family: var(--px); font-size: 13px; color: var(--gold); line-height: 1.5; }
.chap .chap-state { font-size: 18px; }
.chap.done .chap-state { color: var(--green); }
.chap.locked { filter: grayscale(1) brightness(.5); cursor: not-allowed; }
.chap.locked .chap-title::after { content: " 🔒"; }
.hint { margin-top: 22px; font-size: 19px; color: #bfa8ff; text-shadow: 1px 1px 0 #000; }

/* ============ VISUAL NOVEL ============ */
#screen-novel { justify-content: flex-start; gap: 8px; padding: 10px; }
#vn-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  font-family: var(--px); font-size: 11px; color: var(--cyan);
  text-shadow: 2px 2px 0 #000;
}
#vn-scene {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 4px solid var(--box-edge);
  box-shadow: 0 0 0 3px #000, 0 8px 0 rgba(0,0,0,.6);
  background: #000;
  overflow: hidden;
}
#vn-image {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s steps(4);
}
#vn-image.swap { opacity: 0; }
#vn-bust {
  position: absolute; bottom: 0; right: 2%;
  height: 82%;
  max-width: 45%;
  object-fit: contain; object-position: bottom;
  filter: drop-shadow(4px 4px 0 rgba(0,0,0,.65));
  transition: transform .12s steps(3), opacity .12s steps(3);
  transform-origin: bottom center;
}
#vn-bust.hidden { opacity: 0; transform: translateY(20px); }
#vn-bust.pop { animation: bustPop .18s steps(3); }
@keyframes bustPop { from { transform: scale(.9) translateY(14px); } to { transform: scale(1) translateY(0); } }

#vn-box {
  position: relative;
  width: 100%;
  min-height: 132px;
  background: linear-gradient(180deg, #221a7a, var(--box));
  border: 4px solid var(--box-edge);
  box-shadow: 0 0 0 3px #000, inset 0 0 0 2px #000, 0 6px 0 rgba(0,0,0,.6);
  padding: 20px 22px 14px;
  cursor: pointer;
}
#vn-nameplate {
  position: absolute; top: -18px; left: 14px;
  font-family: var(--px); font-size: 11px;
  background: var(--red);
  color: #fff;
  border: 3px solid var(--box-edge);
  box-shadow: 2px 2px 0 #000;
  padding: 6px 12px;
  display: none;
}
#vn-nameplate.narrator { background: #4a3b9e; color: var(--gold); }
#vn-text {
  font-family: var(--vt);
  font-size: clamp(20px, 2.6vw, 27px);
  line-height: 1.25;
  min-height: 64px;
  text-shadow: 1px 1px 0 #000;
}
#vn-text b { color: var(--gold); }
#vn-text i { color: var(--cyan); }
#vn-text .tbc {
  font-family: var(--px); font-size: 26px; color: var(--red);
  text-shadow: 3px 3px 0 #000;
  display: inline-block; animation: bounce 1s ease-in-out infinite;
}
#vn-next {
  position: absolute; bottom: 6px; right: 14px;
  font-size: 20px; color: var(--gold);
}
#vn-next.hidden { display: none; }

.shake { animation: shake .4s steps(8); }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-8px,4px); } 40% { transform: translate(7px,-5px); }
  60% { transform: translate(-6px,-3px); } 80% { transform: translate(5px,4px); }
}

/* ============ INTRO DE JEU ============ */
.gi-card {
  max-width: 640px;
  background: var(--box);
  border: 4px solid var(--box-edge);
  box-shadow: 0 0 0 3px #000, 0 10px 0 rgba(0,0,0,.6);
  padding: 34px;
  text-align: center;
  display: flex; flex-direction: column; gap: 20px; align-items: center;
}
.gi-label { font-family: var(--px); font-size: 12px; color: var(--cyan); animation: blink 1.4s steps(2) infinite; }
#gi-title { font-family: var(--px); font-size: clamp(18px, 3.4vw, 30px); color: var(--gold); text-shadow: 3px 3px 0 #000; line-height: 1.4; }
#gi-text { font-size: 23px; line-height: 1.3; }

/* ============ GÉNÉRIQUE DE FIN ============ */
#screen-credits {
  justify-content: center;
  background: #000;
  width: 100vw; height: 100vh; max-height: 100vh;
}
#credits-viewport {
  position: absolute; inset: 0;
  overflow: hidden;
}
#credits-roll {
  position: absolute;
  left: 0; width: 100%;
  text-align: center;
  will-change: transform;
}
#credits-roll .c-role {
  font-family: var(--px);
  font-size: clamp(9px, 1.6vw, 13px);
  color: var(--cyan);
  margin-top: 34px;
  text-shadow: 2px 2px 0 #000;
}
#credits-roll .c-name {
  font-family: var(--px);
  font-size: clamp(14px, 2.6vw, 22px);
  color: var(--gold);
  margin-top: 10px;
  text-shadow: 3px 3px 0 #000;
}
#credits-roll .c-big {
  font-family: var(--px);
  font-size: clamp(20px, 4vw, 34px);
  color: var(--red);
  margin-top: 70px;
  text-shadow: 4px 4px 0 #000;
  line-height: 1.5;
}
#credits-roll .c-img {
  width: min(420px, 70%);
  margin-top: 60px;
  border: 4px solid var(--box-edge);
  box-shadow: 0 0 0 3px #000;
}
#credits-roll .c-cap {
  font-family: var(--vt);
  font-size: clamp(18px, 2.2vw, 24px);
  font-style: italic;
  color: #f8f4e8;
  margin: 14px auto 26px;
  max-width: min(480px, 80%);
  line-height: 1.2;
  text-shadow: 1px 1px 0 #000;
}
#credits-roll .c-small {
  font-family: var(--vt);
  font-size: 20px;
  color: #bfa8ff;
  margin-top: 26px;
}
#credits-end {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 30px;
  align-items: center; justify-content: center;
  background: #000;
}
#credits-end[hidden] { display: none; }
.ce-title {
  font-family: var(--px);
  font-size: clamp(22px, 4.5vw, 40px);
  color: var(--gold);
  text-shadow: 4px 4px 0 #000, 8px 8px 0 rgba(255,71,87,.35);
  animation: bounce 1.6s ease-in-out infinite;
}
#btn-credits-skip {
  position: absolute; bottom: 14px; right: 14px; z-index: 5;
  opacity: .7;
}

/* ============ JEU ============ */
#screen-game { justify-content: flex-start; gap: 8px; padding: 10px; }
#game-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  font-family: var(--px); font-size: 11px; color: var(--gold); text-shadow: 2px 2px 0 #000;
}
#game-wrap {
  width: 100%;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
#game-canvas {
  width: 100%;
  max-width: 960px;
  max-height: 100%;
  aspect-ratio: 16/9;
  image-rendering: pixelated;
  border: 4px solid var(--box-edge);
  box-shadow: 0 0 0 3px #000, 0 8px 0 rgba(0,0,0,.6);
  background: #000;
}
#game-msg {
  min-height: 30px;
  font-size: 21px; color: #bfa8ff; text-shadow: 1px 1px 0 #000;
  text-align: center;
}

@media (max-width: 700px) {
  #vn-bust { height: 60%; }
  .px-btn.big { font-size: 13px; }
}
