:root {
  --nuit: #0D1219;
  --brume: #1E2A33;
  --cuivre: #B8893E;
  --cuivre-clair: #F0D38C;
  --parchemin: #E8DCC0;
  --cendre: #8FA0AD;
  --lanterne: #FFB454;
  --phosphore: #7CE38B;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--nuit);
  color: var(--parchemin);
  font-family: Georgia, 'Times New Roman', serif;
}

#app canvas { display: block; width: 100%; height: 100%; }

/* Vignette et grain de nuit : cadres le tableau sans étouffer les lanternes. */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(5,8,11,0) 42%, rgba(5,8,11,0.26) 74%, rgba(5,8,11,0.6) 100%),
    linear-gradient(180deg, rgba(5,8,11,0.22), transparent 16%, transparent 84%, rgba(5,8,11,0.2));
}
#vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
  opacity: 0.5;
}

/* Passage de la Porte des Âges : un voile de brume chaude recouvre la rue,
   puis se lève en révélant le tableau suivant. */
#vignette::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at 50% 58%, rgba(249,226,198,0.66) 0%, rgba(214,184,151,0.48) 46%, rgba(186,170,154,0.26) 72%, rgba(30,42,51,0) 100%),
    linear-gradient(180deg, rgba(255,238,214,0.1) 0%, rgba(40,30,24,0.35) 100%);
}
body.era-reveal #vignette::before {
  animation: ls7h-mist-reveal 2.8s ease-out forwards;
}
@keyframes ls7h-mist-reveal {
  0% { opacity: 0.88; }
  40% { opacity: 0.68; }
  100% { opacity: 0; }
}

/* Tableau II : l'aube réchauffe les bords, sans éteindre les pierres. */
body.era-aube {
  --cuivre: #C99A5E;
  --cuivre-clair: #F4D9A6;
  --parchemin: #F3E4C8;
  --cendre: #C7AE93;
  --lanterne: #FFCF9A;
}
body.era-aube #vignette {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(80,42,24,0) 46%, rgba(80,42,24,0.18) 76%, rgba(30,16,10,0.42) 100%),
    linear-gradient(180deg, rgba(255,186,122,0.08), transparent 18%, transparent 82%, rgba(40,24,16,0.14));
}
body.era-aube .kicker { color: #E8B36B; }
body.era-aube #game .crt-frame {
  background: linear-gradient(180deg, #3A2A20, #1E1712);
  border-color: #7B5A33;
}

/* Tableau III : matin clair du Roi-Soleil. */
body.era-soleil {
  --cuivre: #D6B46A;
  --cuivre-clair: #FBEBC2;
  --parchemin: #FAF0D8;
  --cendre: #D6C9AF;
  --lanterne: #FFE6B0;
}
body.era-soleil #vignette {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(20,30,40,0) 48%, rgba(20,30,40,0.10) 78%, rgba(10,16,24,0.30) 100%),
    linear-gradient(180deg, rgba(255,236,180,0.10), transparent 20%, transparent 82%, rgba(20,26,30,0.12));
}
body.era-soleil .kicker { color: #F0C878; }
body.era-soleil #game .crt-frame {
  background: linear-gradient(180deg, #3A3226, #1E1A14);
  border-color: #8A6B3B;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  padding: 18px 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.kicker {
  margin: 0 0 6px;
  color: var(--cuivre);
  font-size: 10px;
  letter-spacing: 4px;
}
.hud-era h1 {
  margin: 0;
  font-size: clamp(18px, 2.6vw, 30px);
  font-weight: 400;
  letter-spacing: 1px;
}
.sub { margin: 4px 0 0; color: var(--cendre); font-size: 12px; font-style: italic; }
.hud-right { text-align: right; }
.seals {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid rgba(184,137,62,0.6);
  background: rgba(13,18,25,0.55);
  color: var(--cuivre-clair);
  font-size: 12px;
  letter-spacing: 2px;
}
.mode-badge {
  display: flex;
  width: max-content;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px auto;
  padding: 5px 12px;
  border: 1px solid rgba(184,137,62,0.35);
  background: rgba(13,18,25,0.5);
  color: var(--parchemin);
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 2px;
}
.mode-badge[hidden] { display: none; }
.mode-badge-label { color: var(--cendre); }
.mode-badge.mode-exploratoire #mode-badge-value { color: var(--phosphore); }
.seals-label { color: var(--cendre); font-size: 10px; }
.help { margin: 10px 0 0; color: var(--cendre); font-size: 11px; opacity: 0.8; }

/* ---------- Choix du mode à l'entrée ---------- */
#mode-select {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 5vh 4vw;
  z-index: 40;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(184,137,62,0.12), transparent 58%),
    radial-gradient(circle at 50% 45%, rgba(27,39,51,0.84) 0%, rgba(7,11,15,0.95) 78%);
  backdrop-filter: blur(4px);
}
#mode-select[hidden] { display: none; }
.mode-select-card {
  width: min(92vw, 820px);
  padding: clamp(22px, 4vw, 40px);
  border: 1px solid rgba(184,137,62,0.55);
  background: rgba(10,14,19,0.88);
  box-shadow: 0 32px 100px rgba(0,0,0,0.75), 0 0 0 1px rgba(0,0,0,0.4);
  text-align: center;
}
.mode-select-kicker {
  margin: 0 0 10px;
  color: var(--cuivre);
  font-size: 10px;
  letter-spacing: 5px;
}
.mode-select-card h2 {
  margin: 0;
  font-size: clamp(26px, 4.4vw, 44px);
  font-weight: 400;
  letter-spacing: 1px;
}
.mode-select-sub {
  margin: 12px auto 28px;
  max-width: 560px;
  color: var(--cendre);
  font-style: italic;
  font-size: 13px;
  line-height: 1.6;
}
.mode-select-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: left;
}
.mode-select-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 22px;
  background: rgba(13,18,25,0.55);
  border: 1px solid rgba(184,137,62,0.45);
  color: var(--parchemin);
  font-family: Georgia, 'Times New Roman', serif;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.mode-select-option:hover,
.mode-select-option:focus-visible {
  outline: none;
  border-color: var(--cuivre-clair);
  background: rgba(184,137,62,0.14);
  transform: translateY(-2px);
}
.mode-select-option-kicker {
  color: var(--cuivre);
  font-family: 'Courier New', monospace;
  font-size: 9px;
  letter-spacing: 3px;
}
.mode-select-option strong {
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 400;
  letter-spacing: 1px;
}
.mode-select-option-text {
  flex: 1;
  color: var(--cendre);
  font-size: 12px;
  line-height: 1.55;
}
.mode-select-option-cta {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(184,137,62,0.25);
  color: var(--cuivre-clair);
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 2px;
}
.mode-select-option-cta::after { content: " ▸"; }
.mode-select-option:hover .mode-select-option-cta::after { content: " →"; }
.mode-select-foot {
  margin: 22px 0 0;
  color: var(--cendre);
  font-size: 10px;
  letter-spacing: 1px;
  opacity: 0.7;
}
@media (max-width: 640px) {
  .mode-select-options { grid-template-columns: 1fr; }
  .mode-select-card { padding: 22px; }
}

/* ---------- Prompt ---------- */
#prompt {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(10,14,19,0.78);
  border: 1px solid rgba(184,137,62,0.55);
  border-radius: 3px;
  font-size: 14px;
  color: var(--parchemin);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 5;
}
#prompt[hidden], #toast[hidden], #game[hidden], #banner[hidden] { display: none; }
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  background: linear-gradient(180deg, #D8AB5B, #966C2C);
  border: 1px solid #5C4218;
  border-radius: 3px;
  color: #24180F;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 0 #5C4218;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 620px;
  padding: 18px 26px;
  background: rgba(10,14,19,0.92);
  border: 1px solid rgba(184,137,62,0.6);
  border-radius: 3px;
  color: var(--parchemin);
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  z-index: 8;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
#toast .accent { color: var(--cuivre-clair); }

/* ---------- Fondu ---------- */
#fade {
  position: fixed;
  inset: 0;
  background: #05080B;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  z-index: 10;
}
#fade.on { opacity: 1; }

/* ---------- Jeu plein écran ---------- */
#game {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #17232E 0%, #070B0F 70%);
  z-index: 20;
}
.crt-frame {
  width: min(94vw, 980px, calc((100vh - 96px) * 4 / 3));
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #31261B, #1A150F);
  border: 3px solid #5C4218;
  box-shadow: 0 0 0 2px #0D1219, 0 30px 90px rgba(0,0,0,0.8);
}
.crt-head, .crt-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  color: var(--cuivre-clair);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 2px;
}
.crt-head { margin-bottom: 10px; opacity: 0.75; }
.crt-foot { margin-top: 10px; opacity: 0.75; font-size: 10px; }
.crt-actions { display: flex; gap: 8px; pointer-events: auto; }
.crt-frame button[hidden] { display: none; }
.crt-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #020604;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 42px rgba(0,0,0,0.9), 0 0 24px rgba(124,227,139,0.14);
}
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.crt-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.30) 0, rgba(0,0,0,0.30) 1px, transparent 1px, transparent 3px),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
  mix-blend-mode: multiply;
}
.crt-frame button {
  pointer-events: auto;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid rgba(184,137,62,0.7);
  color: var(--cuivre-clair);
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
}
.crt-frame button:hover { background: rgba(184,137,62,0.2); }

/* ---------- Bannière d'époque ---------- */
#banner {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 45%, #223140 0%, #070B0F 75%);
  z-index: 25;
  padding: 24px;
}
.banner-kicker { color: var(--cuivre); font-size: 11px; letter-spacing: 5px; margin: 0 0 10px; }
#banner h2 { margin: 0; font-size: clamp(34px, 7vw, 64px); font-weight: 400; letter-spacing: 1px; }
.banner-sub { color: var(--cendre); font-style: italic; margin: 14px 0 32px; }
#banner button {
  padding: 11px 22px;
  background: transparent;
  border: 1px solid rgba(184,137,62,0.7);
  color: var(--cuivre-clair);
  letter-spacing: 2px;
  font-family: Georgia, serif;
  font-size: 12px;
  cursor: pointer;
}
#banner button:hover { background: rgba(184,137,62,0.15); }

/* ---------- Zoom sur la plaque de cuivre ---------- */
#plaque-zoom {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 5vh 4vw;
  background: rgba(8, 6, 4, 0.72);
  z-index: 30;
}
#plaque-zoom[hidden] { display: none; }
.plaque-zoom-card {
  width: min(92vw, 900px);
  padding: 18px;
  background: linear-gradient(180deg, #3a2a1e, #17110c);
  border: 2px solid rgba(184, 137, 62, 0.75);
  border-radius: 10px;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.8), 0 0 0 2px #0d1219;
}
.plaque-zoom-kicker {
  margin: 0 0 12px;
  color: #e8b36b;
  font-size: 10px;
  letter-spacing: 4px;
  text-align: center;
}
#plaque-zoom-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 32px rgba(255, 207, 154, 0.18);
  background: #24180f;
}
.plaque-zoom-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  color: var(--cuivre-clair);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 1px;
}
#plaque-zoom-label {
  color: var(--parchemin);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
}
#plaque-zoom-close {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid rgba(184, 137, 62, 0.7);
  color: var(--cuivre-clair);
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
}
#plaque-zoom-close:hover { background: rgba(184, 137, 62, 0.18); }

