:root {
  --ink: #1d1712;
  --parchment: #f2e6cf;
  --parchment-dim: #d9c9ab;
  --gold: #d9a441;
  --gold-soft: #b8893a;
  --red: #8f2f2a;
  --panel: rgba(20, 16, 12, 0.72);
  --panel-line: rgba(217, 164, 65, 0.35);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d0f14;
  color: var(--parchment);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* Assombrissement léger des bords : rend l'image plus « cinéma ». */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 95% at 50% 45%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.42) 100%);
}

/* Éclair bleuté au moment de la bascule temporelle. */
#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 60%, rgba(210, 248, 255, 0.95), rgba(80, 190, 255, 0.35) 35%, rgba(10, 30, 60, 0) 70%);
  z-index: 5;
}

#flash.flash {
  animation: chrono-flash 0.85s ease-out;
}

@keyframes chrono-flash {
  0% { opacity: 0; }
  12% { opacity: 0.9; }
  100% { opacity: 0; }
}

#hud.visible { opacity: 1; }

.topbar {
  position: absolute;
  top: 22px;
  left: 26px;
  right: 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: rgba(20, 16, 12, 0.55);
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fbf1de;
}

.brand small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(242, 230, 207, 0.66);
}

.epoch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: rgba(20, 16, 12, 0.55);
  backdrop-filter: blur(6px);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f3e7d0;
  transition: color 0.5s ease, border-color 0.5s ease;
}

.epoch .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f0b45c;
  box-shadow: 0 0 12px #f0b45c;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.epoch.night { color: #c9dcff; border-color: rgba(120, 160, 220, 0.35); }
.epoch.night .dot { background: #7fb4ff; box-shadow: 0 0 12px #7fb4ff; }

.bottom {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 24px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.card {
  padding: 12px 16px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.card .label {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.card p {
  margin: 0;
  max-width: 46ch;
  font-size: 14px;
  line-height: 1.45;
  color: #f6ecd8;
}

.card.objective { max-width: 520px; }
.card.inventory { min-width: 150px; }
.card.inventory p { color: var(--gold); font-weight: 600; }

.card.counter { min-width: 96px; }
.card.counter p { color: #ffd45e; font-weight: 700; font-size: 18px; }
.card.counter.hidden { display: none; }

.hint {
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 16, 12, 0.45);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(242, 230, 207, 0.55);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hint.visible { opacity: 1; }

#prompt {
  position: absolute;
  left: 50%;
  bottom: 24%;
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border: 1px solid rgba(217, 164, 65, 0.45);
  border-radius: 10px;
  background: rgba(16, 12, 9, 0.72);
  backdrop-filter: blur(6px);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #fbf0d9;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

#prompt.visible { opacity: 1; transform: translate(-50%, 0); }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: rgba(251, 240, 217, 0.85);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.2s ease;
}

#crosshair.visible { opacity: 1; }

#toast {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, -8px);
  max-width: min(620px, 84vw);
  padding: 12px 20px;
  border: 1px solid rgba(217, 164, 65, 0.45);
  border-radius: 12px;
  background: rgba(24, 17, 11, 0.86);
  font-size: 14px;
  letter-spacing: 0.02em;
  text-align: center;
  color: #fbefd7;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Écran titre ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(40, 27, 14, 0.55), rgba(5, 6, 10, 0.92)),
    rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(7px);
  z-index: 20;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panel {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(26px, 4vw, 46px);
  border: 1px solid rgba(217, 164, 65, 0.28);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(39, 29, 20, 0.94), rgba(18, 14, 11, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 236, 200, 0.06);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold);
}

.panel h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(42px, 7vw, 74px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #fbf1de;
  text-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.panel h1 span { color: var(--gold); }

.lead {
  margin: 18px 0 26px;
  max-width: 56ch;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(242, 230, 207, 0.78);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0 0 30px;
  padding: 0;
  list-style: none;
}

.controls li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  font-size: 13px;
  color: rgba(242, 230, 207, 0.82);
}

.keys { display: flex; gap: 4px; min-width: 116px; }

kbd {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid rgba(242, 230, 207, 0.22);
  border-bottom-color: rgba(242, 230, 207, 0.12);
  border-radius: 6px;
  background: rgba(255, 246, 228, 0.07);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #f4e8d1;
}

#play {
  width: 100%;
  padding: 15px 22px;
  border: 1px solid rgba(255, 214, 140, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, #e0b055, #b5852f);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #241808;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

#play:hover { transform: translateY(-1px); filter: brightness(1.06); }
#play:active { transform: translateY(1px); }

.note {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(242, 230, 207, 0.48);
}

.note kbd { padding: 2px 6px; font-size: 10px; }

@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  .bottom { left: 14px; right: 14px; bottom: 14px; flex-wrap: wrap; }
  .card.objective { max-width: none; flex: 1 1 100%; }
  .card.inventory { flex: 1 1 auto; }
  .hint { display: none; }
  .topbar { left: 14px; right: 14px; top: 14px; }
  .brand small { display: none; }
  .epoch { padding: 7px 11px; font-size: 10px; }
}

/* ---------- Habillage rétro (pixel) ---------- */

:root {
  --mono: "Consolas", "Lucida Console", "Courier New", ui-monospace, monospace;
}

#hud,
.panel,
.card,
.epoch,
.brand .mark,
.brand strong,
.brand small,
#prompt,
#toast,
#hint,
kbd,
#play,
.eyebrow,
.card .label,
.lead,
.note,
.controls li,
.panel h1 {
  font-family: var(--mono);
  border-radius: 0;
  backdrop-filter: none;
}

.brand strong,
.panel h1,
.eyebrow,
.card .label,
kbd,
#play {
  letter-spacing: 0.14em;
}

.card,
.epoch,
.brand .mark,
#prompt,
#toast,
.panel {
  border-width: 2px;
}

.card,
#prompt,
#toast {
  background: rgba(10, 9, 12, 0.84);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55);
}

.panel {
  background: rgba(10, 9, 12, 0.94);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.7);
}

.overlay {
  backdrop-filter: none;
  background: rgba(5, 5, 9, 0.92);
}

#play {
  border-width: 2px;
  background: #d9a441;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.6);
  transform: none;
  transition: none;
}

#play:hover { background: #e8b657; transform: none; }
#play:active { background: #b5852f; transform: none; }

kbd {
  border-radius: 0;
  border-width: 2px;
  background: rgba(255, 246, 228, 0.06);
}

.brand .mark { border-radius: 0; }

/* Fines lignes horizontales : petit effet écran cathodique. */
#scanlines {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0,
    rgba(0, 0, 0, 0.55) 1px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0) 3px
  );
}

#scene { image-rendering: pixelated; }

/* ---------- Machine temporelle : menu ---------- */

.menu-overlay { z-index: 30; }

.time-panel { width: min(640px, 100%); }

.destination-btn {
  width: 100%;
  margin: 22px 0 8px;
  padding: 20px 24px;
  border: 2px solid rgba(217, 164, 65, 0.65);
  border-radius: 0;
  background: rgba(18, 14, 10, 0.92);
  color: #f6ecd8;
  font-family: var(--mono);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 0 24px rgba(217, 164, 65, 0.06);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.destination-btn:hover,
.destination-btn:focus-visible {
  background: rgba(217, 164, 65, 0.18);
  box-shadow: inset 0 0 30px rgba(217, 164, 65, 0.14), 0 0 24px rgba(217, 164, 65, 0.12);
  outline: none;
}

.destination-btn.terminal {
  border-color: #63ff9a;
  background: linear-gradient(180deg, #b8ffd2, #63ff9a);
  color: #02110a;
  box-shadow: 0 0 30px rgba(99, 255, 154, 0.35);
}

.destination-btn.terminal:hover,
.destination-btn.terminal:focus-visible {
  background: linear-gradient(180deg, #dcffe9, #8affb0);
  box-shadow: 0 0 42px rgba(99, 255, 154, 0.55);
}

.destination-btn:disabled,
.destination-btn:disabled:hover {
  border-color: rgba(242, 230, 207, 0.18);
  background: rgba(10, 9, 12, 0.7);
  color: rgba(242, 230, 207, 0.38);
  box-shadow: none;
  cursor: not-allowed;
}

.time-panel h2 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f6ecd8;
}

.menu-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: rgba(242, 230, 207, 0.6);
}

.dest-list {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.dest {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 14px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(217, 164, 65, 0.28);
  background: rgba(255, 246, 228, 0.035);
  color: inherit;
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
}

.dest:hover,
.dest.selected {
  border-color: rgba(217, 164, 65, 0.9);
  background: rgba(217, 164, 65, 0.12);
}

.dest.current { border-color: rgba(110, 205, 255, 0.55); }

.dest-date {
  grid-column: 1;
  font-size: 20px;
  letter-spacing: 0.12em;
  color: #f8eedb;
}

.dest-place {
  grid-column: 1;
  font-size: 12px;
  color: rgba(242, 230, 207, 0.6);
}

.dest-tag {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--gold);
}

.menu-hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(242, 230, 207, 0.45);
}

/* ---------- Cinématique de voyage ---------- */

.travel {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--mono);
  background: radial-gradient(circle at 50% 50%, rgba(40, 100, 140, 0.35), rgba(2, 5, 9, 0.92));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.travel.active { opacity: 1; visibility: visible; }

.travel-inner { padding: 24px; }

.travel-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #63dcff;
}

#travel-date {
  margin: 10px 0 6px;
  font-family: var(--mono);
  font-size: clamp(32px, 7vw, 68px);
  letter-spacing: 0.08em;
  color: #eaf9ff;
  text-shadow: 0 0 26px rgba(90, 210, 255, 0.55);
}

.travel-place {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: rgba(230, 245, 255, 0.7);
}

.travel-track {
  width: min(430px, 72vw);
  height: 8px;
  margin: 20px auto 12px;
  border: 2px solid rgba(120, 220, 255, 0.5);
}

#travel-bar {
  display: block;
  width: 0;
  height: 100%;
  background: #63dcff;
  box-shadow: 0 0 14px #63dcff;
}

.travel-status {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(200, 235, 255, 0.75);
}

.epoch.future {
  color: #c6e8ff;
  border-color: rgba(110, 190, 255, 0.45);
}

.epoch.future .dot {
  background: #6fb7ff;
  box-shadow: 0 0 12px #6fb7ff;
}

/* ---------- Machine temporelle : formulaire ---------- */

.date-form {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
  margin: 18px 0 6px;
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.date-field input,
.date-field select {
  padding: 11px 12px;
  border: 2px solid rgba(217, 164, 65, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: #f8eedb;
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.08em;
  outline: none;
}

.date-field input:focus,
.date-field select:focus {
  border-color: rgba(217, 164, 65, 0.9);
}

.date-submit {
  grid-column: 1 / -1;
  padding: 13px 18px;
  border: 2px solid rgba(255, 214, 140, 0.45);
  background: linear-gradient(180deg, #e0b055, #b5852f);
  color: #241808;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
}

.date-submit:hover { filter: brightness(1.06); }

.menu-error {
  min-height: 20px;
  margin: 0 0 4px;
  font-size: 12px;
  color: #ff9a8a;
}

.menu-hint {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(242, 230, 207, 0.5);
}

.home-btn {
  margin-top: 12px;
  padding: 10px 14px;
  border: 2px solid rgba(110, 190, 255, 0.4);
  background: rgba(40, 80, 120, 0.25);
  color: #cfeeff;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

#home-btn.hidden { display: none; }

.terminal-btn {
  border-color: rgba(99, 255, 154, 0.55);
  background: rgba(30, 100, 70, 0.3);
  color: #d9ffe8;
}

.terminal-btn.hidden { display: none; }

/* ---------- Dialogue ---------- */

.dialogue {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 0 5vw 8vh;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 45%);
  font-family: var(--mono);
  pointer-events: auto;
}

#dialogue.hidden { display: none; }

.dialogue-box {
  width: min(760px, 92vw);
  padding: 16px 20px 12px;
  border: 2px solid var(--panel-line);
  background: rgba(10, 9, 12, 0.92);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.55);
}

.dialogue-speaker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold);
}

.dialogue-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: #f6ecd8;
}

.dialogue-advance {
  margin: 10px 0 0;
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(242, 230, 207, 0.45);
}

/* ---------- Fenêtres document ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 29;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 4, 8, 0.78);
  font-family: var(--mono);
}

#modal.hidden { display: none; }

.modal-panel {
  width: min(620px, 94vw);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  border: 2px solid var(--panel-line);
  background: rgba(10, 9, 12, 0.96);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.6);
}

.modal-panel h3 {
  margin: 0 0 14px;
  font-size: 22px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f6ecd8;
}

.modal-text {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(246, 236, 216, 0.82);
}

.photo-img {
  display: block;
  width: min(320px, 80%);
  margin: 0 auto 16px;
  border: 8px solid #f2ead8;
  image-rendering: pixelated;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}


/* Écran blanc du saut temporel (au-dessus de la cinématique). */
#travel-flash {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}

#travel-flash.on {
  animation: travel-flash 0.85s ease-out;
}

@keyframes travel-flash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  32% { opacity: 1; }
  100% { opacity: 0; }
}

.keypad-display {
  margin: 8px 0 10px;
  padding: 14px 10px;
  border: 2px solid rgba(99, 220, 255, 0.55);
  background: rgba(4, 18, 26, 0.9);
  color: #b6f4ff;
  font-family: var(--mono);
  font-size: 34px;
  letter-spacing: 0.35em;
  text-align: center;
  text-shadow: 0 0 18px rgba(90, 210, 255, 0.55);
}

.keypad-display.long {
  font-size: 22px;
  letter-spacing: 0.12em;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.keypad-key {
  padding: 12px;
  border: 2px solid rgba(217, 164, 65, 0.35);
  background: rgba(255, 246, 228, 0.05);
  color: #f6ecd8;
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.keypad-key:hover {
  border-color: rgba(217, 164, 65, 0.9);
  background: rgba(217, 164, 65, 0.15);
}

.keypad-key.ok {
  background: #d9a441;
  color: #1d1712;
  font-weight: 700;
}

.keypad-key.clear {
  color: #ff9a8a;
}

/* La zone de texte des fenêtres document reste lisible. */
.modal-panel .menu-error {
  min-height: 18px;
}

/* ---------- Écran de fin ---------- */

.ending {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(80% 70% at 50% 42%, rgba(30, 90, 58, 0.35), rgba(2, 6, 5, 0.96) 70%),
    #020605;
  color: #d9ffe8;
  overflow-y: auto;
}

.ending.hidden { display: none; }

.ending-panel {
  width: min(640px, 100%);
  padding: 38px 42px 34px;
  border: 1px solid rgba(99, 255, 154, 0.45);
  border-radius: 4px;
  background: rgba(3, 14, 10, 0.86);
  box-shadow: 0 0 80px rgba(99, 255, 154, 0.16), inset 0 0 40px rgba(99, 255, 154, 0.05);
  text-align: center;
}

.ending-eyebrow {
  margin: 0;
  color: #63ff9a;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.ending-number {
  margin: 4px 0 2px;
  color: #63ff9a;
  font-family: var(--mono);
  font-size: clamp(86px, 18vw, 154px);
  line-height: 1;
  text-shadow: 0 0 34px rgba(99, 255, 154, 0.55);
}

.ending-panel h1 {
  margin: 2px 0 16px;
  color: #f2fff6;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 4vw, 34px);
  letter-spacing: 0.04em;
}

.ending-text {
  max-width: 470px;
  margin: 0 auto 14px;
  color: #a8d8bc;
  line-height: 1.6;
  font-size: 15px;
}

.ending-stats {
  margin: 0 0 22px;
  color: #ffd45e;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ending-credits {
  margin: 0 auto 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(99, 255, 154, 0.2);
  color: #7fae92;
  font-size: 12px;
  line-height: 1.8;
}

.ending-credits p { margin: 0; }

.ending-panel button {
  padding: 13px 26px;
  border: 1px solid rgba(99, 255, 154, 0.6);
  border-radius: 3px;
  background: #63ff9a;
  color: #02110a;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.ending-panel button:hover {
  background: #b6ffd2;
}

/* ---------- Menu principal ---------- */

body:not(.game-started) #scene,
body:not(.game-started) #vignette,
body:not(.game-started) #scanlines,
body:not(.game-started) #flash {
  visibility: hidden;
  opacity: 0;
}

body.game-started #scene {
  visibility: visible;
  opacity: 1;
  cursor: none;
}

body.game-started #travel {
  cursor: none;
}

#scene {
  transition: opacity 0.8s ease;
}

#start.menu-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: #02070f;
  color: #dff8ff;
  font-family: var(--mono);
}

#start.menu-screen.hidden { display: none; }

.menu-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(0, 145, 255, 0.42), transparent 56%),
    radial-gradient(ellipse at 88% 80%, rgba(0, 80, 255, 0.28), transparent 48%),
    radial-gradient(ellipse at 12% 78%, rgba(0, 225, 255, 0.16), transparent 48%),
    linear-gradient(180deg, #041b42 0%, #03102a 48%, #01050d 100%);
}

.menu-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(120, 230, 255, 0.035) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
  opacity: 0.55;
}

.menu-bg::after {
  content: "";
  position: absolute;
  inset: -10%;
  background: radial-gradient(circle at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.menu-stars {
  position: absolute;
  inset: -20%;
  background-image:
    radial-gradient(circle, rgba(190, 250, 255, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(60, 180, 255, 0.7) 0 1.4px, transparent 2px),
    radial-gradient(circle, rgba(210, 255, 255, 0.4) 0 1px, transparent 1.4px);
  background-size: 140px 140px, 230px 230px, 360px 360px;
  background-position: 0 0, 40px 80px, 120px 30px;
  animation: menu-stars-drift 38s linear infinite;
  opacity: 0.62;
}

.menu-grid {
  position: absolute;
  left: -30%;
  right: -30%;
  bottom: -17%;
  height: 68%;
  background-image:
    linear-gradient(rgba(65, 220, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 220, 255, 0.18) 1px, transparent 1px);
  background-size: 68px 68px;
  transform: perspective(430px) rotateX(63deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 12%, transparent 86%);
  -webkit-mask-image: linear-gradient(to top, #000 12%, transparent 86%);
  animation: menu-grid-move 7s linear infinite;
  opacity: 0.55;
}

.menu-42 {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  color: rgba(0, 155, 255, 0.055);
  font-size: min(46vw, 560px);
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 0.8;
  text-shadow: 0 0 90px rgba(0, 170, 255, 0.18);
  animation: menu-42-pulse 6s ease-in-out infinite;
  pointer-events: none;
}

.menu-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(65, 210, 255, 0.16);
  border-radius: 50%;
  pointer-events: none;
}

.menu-orbit::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8ff7ff;
  box-shadow: 0 0 12px #43d8ff, 0 0 30px rgba(40, 200, 255, 0.6);
}

.orbit-a {
  width: 62vmin;
  height: 62vmin;
  margin: -31vmin 0 0 -31vmin;
  animation: menu-orbit-spin 24s linear infinite;
  opacity: 0.7;
}

.orbit-b {
  width: 92vmin;
  height: 92vmin;
  margin: -46vmin 0 0 -46vmin;
  border-color: rgba(65, 210, 255, 0.08);
  animation: menu-orbit-spin 38s linear infinite reverse;
}

.orbit-c {
  width: 126vmin;
  height: 126vmin;
  margin: -63vmin 0 0 -63vmin;
  border-color: rgba(65, 210, 255, 0.045);
  animation: menu-orbit-spin 52s linear infinite;
}

.menu-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -22%;
  height: 18%;
  background: linear-gradient(to bottom, transparent, rgba(95, 235, 255, 0.16), transparent);
  filter: blur(2px);
  animation: menu-scan 6s linear infinite;
  pointer-events: none;
}

.menu-stage {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: min(760px, 94vw);
  text-align: center;
  animation: menu-stage-in 0.7s ease-out both;
}

.menu-stage.hidden,
.menu-credits.hidden {
  display: none;
}

.menu-kicker {
  margin: 0 0 22px;
  color: #7feaff;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(70, 220, 255, 0.45);
}

.game-title {
  position: relative;
  margin: 0;
  color: #eaffff;
  font-family: var(--mono);
  font-size: clamp(42px, 8.5vw, 112px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-shadow:
    0 0 12px rgba(150, 245, 255, 0.95),
    0 0 34px rgba(0, 175, 255, 0.55),
    0 0 80px rgba(0, 90, 255, 0.35);
}

.game-title::before,
.game-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
}

.game-title::before {
  color: #44e5ff;
  transform: translate(2px, -1px);
  clip-path: inset(0 0 54% 0);
  animation: menu-glitch-a 3.2s infinite linear alternate;
}

.game-title::after {
  color: #8c5dff;
  transform: translate(-2px, 1px);
  clip-path: inset(55% 0 0 0);
  animation: menu-glitch-b 2.6s infinite linear alternate;
}

.menu-tagline {
  margin: 24px 0 30px;
  color: #8c5dff;
  font-size: clamp(12px, 1.7vw, 15px);
  line-height: 1.8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(140, 93, 255, 0.35);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.menu-btn {
  min-width: 210px;
  padding: 15px 26px;
  border: 1px solid rgba(80, 225, 255, 0.55);
  border-radius: 2px;
  background: rgba(3, 28, 48, 0.72);
  color: #c9f7ff;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    inset 0 0 20px rgba(0, 160, 255, 0.06),
    0 0 18px rgba(0, 120, 255, 0.12);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background: rgba(0, 145, 255, 0.28);
  box-shadow:
    inset 0 0 24px rgba(0, 180, 255, 0.15),
    0 0 30px rgba(0, 190, 255, 0.3);
  transform: translateY(-2px);
  outline: none;
}

.menu-actions #play {
  width: auto;
  padding: 15px 30px;
  border-radius: 0;
  font-size: 15px;
  border-color: #99faff;
  background: linear-gradient(180deg, #8cf8ff, #1b9ee0);
  color: #02111c;
  font-weight: 700;
  box-shadow:
    0 0 0 3px rgba(0, 90, 140, 0.25),
    0 0 30px rgba(50, 220, 255, 0.42);
  transform: none;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.menu-actions #play:hover,
.menu-actions #play:focus-visible {
  background: linear-gradient(180deg, #c6ffff, #39c5ff);
  box-shadow:
    0 0 0 3px rgba(0, 120, 180, 0.3),
    0 0 42px rgba(70, 235, 255, 0.6);
  transform: translateY(-2px);
}

.insert-coin {
  position: relative;
  width: min(390px, 82vw);
  margin: 10px 0 18px;
  padding: 28px 24px 20px;
  border: 2px solid rgba(120, 245, 255, 0.85);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 190, 255, 0.22), transparent 68%),
    rgba(2, 22, 38, 0.82);
  color: #eaffff;
  font-family: var(--mono);
  font-size: clamp(22px, 4.4vw, 38px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(3% 0, 97% 0, 100% 12%, 100% 88%, 97% 100%, 3% 100%, 0 88%, 0 12%);
  box-shadow:
    0 0 0 6px rgba(0, 100, 170, 0.09),
    0 0 36px rgba(0, 190, 255, 0.3),
    inset 0 0 30px rgba(0, 190, 255, 0.1);
  animation: menu-coin-pulse 2.4s ease-in-out infinite;
}

.insert-coin::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  width: 48px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #02070c;
  box-shadow: inset 0 0 5px #000, 0 0 9px rgba(80, 230, 255, 0.45);
}

.insert-coin span {
  display: block;
  text-shadow: 0 0 12px rgba(140, 245, 255, 0.85), 0 0 30px rgba(0, 160, 255, 0.55);
}

.insert-coin small {
  display: block;
  margin-top: 8px;
  color: #78cfe6;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.34em;
}

.insert-coin:hover,
.insert-coin:focus-visible {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(80, 235, 255, 0.34), transparent 70%),
    rgba(3, 40, 62, 0.9);
  box-shadow:
    0 0 0 6px rgba(0, 160, 255, 0.15),
    0 0 55px rgba(60, 225, 255, 0.5),
    inset 0 0 38px rgba(0, 210, 255, 0.16);
  outline: none;
}

.loading-rings {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 12px;
}

.loading-rings i {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(70, 220, 255, 0.55);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 16px rgba(0, 180, 255, 0.15);
}

.loading-rings i:nth-child(1) {
  width: 100%;
  height: 100%;
  border-top-color: #b8ffff;
  animation: menu-orbit-spin 2.4s linear infinite;
}

.loading-rings i:nth-child(2) {
  width: 72%;
  height: 72%;
  border-right-color: #45d8ff;
  animation: menu-orbit-spin 1.8s linear infinite reverse;
}

.loading-rings i:nth-child(3) {
  width: 40%;
  height: 40%;
  border-bottom-color: #8c5dff;
  animation: menu-orbit-spin 1.2s linear infinite;
}

.loading-status {
  margin: 20px 0 12px;
  color: #8fdcf1;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.loading-bar {
  width: min(480px, 82vw);
  height: 12px;
  margin: 0 auto;
  padding: 2px;
  border: 1px solid rgba(80, 225, 255, 0.5);
  background: rgba(0, 10, 18, 0.8);
  box-shadow: 0 0 22px rgba(0, 170, 255, 0.16);
}

.loading-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #046f9e, #48e5ff 65%, #d1ffff);
  box-shadow: 0 0 16px rgba(70, 230, 255, 0.8);
}

.loading-percent {
  margin: 10px 0 0;
  color: #7feaff;
  font-size: 12px;
  letter-spacing: 0.18em;
}

.menu-credits {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 5, 12, 0.82);
  backdrop-filter: blur(5px);
}

.credits-card {
  width: min(560px, 92vw);
  padding: 34px;
  border: 1px solid rgba(80, 225, 255, 0.4);
  background: rgba(2, 16, 28, 0.94);
  box-shadow: 0 0 50px rgba(0, 140, 255, 0.18);
  text-align: center;
}

.credits-card h2 {
  margin: 0 0 18px;
  color: #eaffff;
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: 0.14em;
}

.credits-card p {
  margin: 10px 0;
  color: #9fd9ed;
  font-size: 12px;
  line-height: 1.8;
}

@keyframes menu-stars-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-140px, 80px, 0); }
}

@keyframes menu-grid-move {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 68px, 68px 0; }
}

@keyframes menu-scan {
  from { transform: translateY(-20vh); }
  to { transform: translateY(125vh); }
}

@keyframes menu-orbit-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes menu-42-pulse {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

@keyframes menu-coin-pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(0, 100, 170, 0.09), 0 0 30px rgba(0, 190, 255, 0.24), inset 0 0 30px rgba(0, 190, 255, 0.1); }
  50% { box-shadow: 0 0 0 8px rgba(0, 130, 220, 0.14), 0 0 54px rgba(0, 210, 255, 0.44), inset 0 0 38px rgba(0, 210, 255, 0.16); }
}

@keyframes menu-stage-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes menu-glitch-a {
  0%, 82%, 100% { transform: translate(2px, -1px); }
  84% { transform: translate(-3px, 1px); }
  86% { transform: translate(2px, -1px); }
  88% { transform: translate(3px, 0); }
}

@keyframes menu-glitch-b {
  0%, 78%, 100% { transform: translate(-2px, 1px); }
  80% { transform: translate(3px, -1px); }
  82% { transform: translate(-2px, 1px); }
  84% { transform: translate(1px, 1px); }
}

@media (max-width: 640px) {
  .menu-actions { flex-direction: column; width: 100%; }
  .menu-actions .menu-btn { width: 100%; }
  .menu-42 { font-size: 80vw; }
}

/* ---------- Refonte pixel / warp 2001 ---------- */

#start.menu-screen {
  background: #000;
}

#start[data-stage="insert"] .menu-bg,
#start[data-stage="loading"] .menu-bg {
  opacity: 0;
  visibility: hidden;
}

.menu-bg {
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

.menu-warp {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* Le bouton est une image pixel art : aucun lissage, aucun arrondi. */
.insert-coin {
  width: min(420px, 82vw);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  clip-path: none;
  animation: none;
  line-height: 0;
  cursor: pointer;
}

.insert-coin::before {
  display: none;
}

.insert-coin canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: brightness(1);
  transition: filter 0.1s steps(2, end);
}

.insert-coin:hover canvas,
.insert-coin:focus-visible canvas {
  filter: brightness(1.18);
}

.insert-coin:hover,
.insert-coin:focus-visible {
  background: transparent;
  box-shadow: none;
  outline: none;
}

.insert-coin:focus-visible {
  outline: 4px solid rgba(120, 245, 255, 0.45);
  outline-offset: 6px;
}

/* Barre de chargement 8 bits, sans texte ni nom du jeu. */
.loading-bar {
  width: min(520px, 82vw);
  height: 28px;
  margin: 0;
  padding: 4px;
  border: 4px solid #6ff7ff;
  background: #000;
  box-shadow:
    0 0 0 4px #001722,
        9px 9px 0 #001018,
    inset 0 0 0 2px #002d3a;
}

.loading-bar span {
  display: block;
  width: 0;
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      #eaffff 0 9px,
      #3fd7ff 9px 18px,
      #0a7fb8 18px 20px
    );
  box-shadow: inset 0 -4px 0 rgba(0, 35, 55, 0.55);
  transition: width 0.08s linear;
}

.menu-whiteout {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}

.menu-whiteout.active {
  pointer-events: auto;
  animation: menu-whiteout 1.35s ease-out forwards;
}

@keyframes menu-whiteout {
  0% { opacity: 0; }
  7% { opacity: 1; }
  48% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Menu de pause ---------- */

.pause-screen {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 6, 13, 0.82);
  backdrop-filter: blur(4px);
  font-family: var(--mono);
}

.pause-screen.hidden { display: none; }

.pause-panel {
  width: min(500px, 92vw);
  padding: 32px;
  border: 2px solid rgba(80, 225, 255, 0.55);
  background: rgba(2, 14, 25, 0.96);
  box-shadow:
    0 0 0 4px rgba(0, 35, 55, 0.55),
    0 0 50px rgba(0, 160, 255, 0.18),
    inset 0 0 30px rgba(0, 130, 220, 0.08);
  text-align: center;
}

.pause-kicker {
  margin: 0 0 8px;
  color: #6fe7ff;
  font-size: 10px;
  letter-spacing: 0.3em;
}

.pause-panel h2 {
  margin: 0 0 26px;
  color: #eaffff;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-shadow: 0 0 18px rgba(70, 220, 255, 0.5);
}

.volume-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 48px;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
  color: #a9dceb;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.volume-row input[type="range"] {
  width: 100%;
  height: 10px;
  padding: 0;
  border: 1px solid #236e86;
  border-radius: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background: #061923;
  cursor: pointer;
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 20px;
  border: 2px solid #001018;
  border-radius: 0;
  background: #70f5ff;
  box-shadow: 0 0 12px rgba(60, 220, 255, 0.5);
  appearance: none;
  -webkit-appearance: none;
}

.volume-row input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 18px;
  border: 2px solid #001018;
  border-radius: 0;
  background: #70f5ff;
  box-shadow: 0 0 12px rgba(60, 220, 255, 0.5);
}

.volume-value {
  color: #6fe7ff;
  font-size: 11px;
  text-align: right;
}

.pause-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px 18px;
  border: 2px solid #72eaff;
  border-radius: 0;
  background: rgba(25, 175, 220, 0.22);
  color: #eaffff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
}

.pause-btn:hover,
.pause-btn:focus-visible {
  background: rgba(55, 215, 255, 0.35);
  box-shadow: 0 0 24px rgba(40, 210, 255, 0.3);
  outline: none;
}

.pause-btn.secondary {
  margin-top: 10px;
  border-color: rgba(255, 150, 140, 0.45);
  background: rgba(90, 30, 35, 0.24);
  color: #ffd8d2;
  font-size: 11px;
}

.pause-btn.secondary:hover,
.pause-btn.secondary:focus-visible {
  background: rgba(150, 50, 50, 0.35);
  box-shadow: 0 0 24px rgba(255, 100, 90, 0.2);
}

.pause-hint {
  margin: 14px 0 0;
  color: rgba(150, 210, 230, 0.45);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

