/* Escape Rooms: shared styles for the lobby and the game shell. */

:root {
  --bg: #0b0d12;
  --panel: #151926;
  --panel-2: #1b2030;
  --line: #262d3f;
  --text: #eae4d6;
  --dim: #a49c8c;
  --faint: #6f6a60;
  --accent: #d9a24b;
  --accent-strong: #f0be6a;
  --danger: #c94f4f;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: Consolas, 'Cascadia Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 50% -10%, #141a2a 0%, var(--bg) 70%);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Lobby page: ambient video (or still image fallback) under a heavy dark scrim.
   Layering: body image (-3 effectively) < .lobby-video (-2) < ::before scrim (-1). */
body.lobby {
  background: var(--bg) url('../assets/lobby-bg.webp') center top / cover no-repeat fixed;
}
body.lobby::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(11, 13, 18, 0.55) 0%, rgba(11, 13, 18, 0.78) 60%, rgba(11, 13, 18, 0.9) 100%);
  pointer-events: none;
}

/* capture mode: bare canvas at native size for the AI map pipeline */
body.capture #hud,
body.capture #inv-bar,
body.capture #toasts,
body.capture #intro,
body.capture #win,
body.capture #overlay { display: none !important; }
body.capture #stage { padding: 0; display: block; }
body.capture #game { border-radius: 0; border: none; box-shadow: none; }
.lobby-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  pointer-events: none;
}

/* room intro/victory art: video loop over the still, still over nothing */
.intro-art { position: relative; overflow: hidden; }
.intro-art-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .lobby-video, .intro-art-video { display: none; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--accent); color: #201607; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { background: #3a3f52; color: #777; cursor: default; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--dim); }
.btn-ghost:hover { color: var(--text); border-color: #3a4258; }

/* ---------- lobby ---------- */

.hub { max-width: 1080px; margin: 0 auto; padding: 64px 24px 48px; }

.hub-head { text-align: center; margin-bottom: 44px; }
.hub-head h1 {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  margin: 0 0 10px;
  text-shadow: 0 0 44px rgba(217, 162, 75, 0.28), 0 2px 4px rgba(0, 0, 0, 0.6);
}
.hub-head p { color: var(--dim); font-size: 1.05rem; margin: 0; }

.room-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
@media (max-width: 900px) { .room-grid { grid-template-columns: 1fr; } }

.room-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.room-card:hover {
  transform: translateY(-4px);
  border-color: rgba(217, 162, 75, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.card-scene {
  height: 150px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -46px 60px rgba(0, 0, 0, 0.55), inset 0 12px 40px rgba(0, 0, 0, 0.25);
}
.emblem {
  font-size: 62px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  transition: transform 0.25s ease;
}
.room-card:hover .emblem { transform: scale(1.12) rotate(-3deg); }
.scene-study { background: radial-gradient(140% 120% at 30% 0%, #4a3115 0%, #2b1d10 55%, #1a1209 100%); }
.scene-lab { background: radial-gradient(140% 120% at 70% 0%, #123a42 0%, #0d2229 55%, #0a161b 100%); }
.scene-crypt { background: radial-gradient(140% 120% at 50% 0%, #23301f 0%, #151d13 55%, #0d120c 100%); }
.scene-vault { background: radial-gradient(140% 120% at 50% 0%, #3a2f1a 0%, #241d10 55%, #14100a 100%); }
.scene-undertow { background: radial-gradient(140% 120% at 50% 100%, #10405a 0%, #0a2637 55%, #061320 100%); }

/* AI key art on top of the gradient fallbacks. If a webp is missing, the
   gradient above still renders. Rooms with art hide their emoji emblem. */
.scene-study,
.scene-lab,
.scene-crypt,
.scene-vault,
.scene-undertow {
  background-size: cover;
  background-position: center;
}
.scene-study {
  background-image: linear-gradient(180deg, rgba(11, 13, 18, 0) 45%, rgba(11, 13, 18, 0.5) 100%), url('../assets/cards/study.webp');
}
.scene-lab {
  background-image: linear-gradient(180deg, rgba(11, 13, 18, 0) 45%, rgba(11, 13, 18, 0.5) 100%), url('../assets/cards/lab.webp');
}
.scene-crypt {
  background-image: linear-gradient(180deg, rgba(11, 13, 18, 0) 45%, rgba(11, 13, 18, 0.5) 100%), url('../assets/cards/crypt.webp');
}
.scene-vault {
  background-image: linear-gradient(180deg, rgba(11, 13, 18, 0) 45%, rgba(11, 13, 18, 0.5) 100%), url('../assets/cards/vault.webp');
}
.scene-undertow {
  background-image: linear-gradient(180deg, rgba(11, 13, 18, 0) 45%, rgba(11, 13, 18, 0.5) 100%), url('../assets/cards/undertow.webp');
}
.scene-study .emblem,
.scene-lab .emblem,
.scene-crypt .emblem,
.scene-vault .emblem,
.scene-undertow .emblem { display: none; }

.scene-greenhouse {
  background: linear-gradient(180deg, rgba(8, 16, 10, 0.04) 42%, rgba(8, 16, 10, 0.62) 100%), url('../assets/cards/greenhouse.webp') center / cover no-repeat, radial-gradient(140% 120% at 50% 0%, #1e3a26 0%, #14231a 58%, #0a120d 100%);
}
.scene-greenhouse .emblem { display: none; }

.scene-observatory {
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.04) 42%, rgba(6, 10, 20, 0.62) 100%), url('../assets/cards/observatory.webp') center / cover no-repeat, radial-gradient(140% 120% at 50% 0%, #273b58 0%, #171d2c 58%, #090d16 100%);
}

.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-top h2 { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; margin: 0; color: var(--text); }
.difficulty {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.card-desc { color: var(--dim); font-size: 0.92rem; line-height: 1.55; margin: 0; flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--dim); }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 14px; height: 5px; border-radius: 3px; background: #2a3145; }
.pips i.on { background: var(--accent); }
.best.has-best { color: var(--accent); }

.hub-note { text-align: center; color: var(--faint); margin-top: 36px; font-size: 0.85rem; }

/* featured game-mode card */
.featured-card {
  display: block;
  text-decoration: none;
  background:
    linear-gradient(100deg, rgba(11, 13, 18, 0.92) 30%, rgba(11, 13, 18, 0.45) 70%),
    url('../assets/cards/descent.webp') center / cover no-repeat,
    radial-gradient(120% 160% at 85% 20%, #3a2917 0%, #1a1410 55%, #0d0b09 100%);
  border: 1px solid rgba(217, 162, 75, 0.4);
  border-radius: 18px;
  padding: 34px 38px;
  margin-bottom: 40px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.featured-card:hover {
  transform: translateY(-3px);
  border-color: rgba(217, 162, 75, 0.8);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55), 0 0 60px rgba(217, 162, 75, 0.12);
}
.featured-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 8px;
}
.featured-card h2 {
  font-family: var(--serif);
  font-size: 2.2rem;
  letter-spacing: 0.14em;
  margin: 0 0 10px;
  color: var(--text);
  text-shadow: 0 0 30px rgba(217, 162, 75, 0.3);
}
.featured-desc { color: var(--dim); line-height: 1.6; margin: 0 0 18px; max-width: 560px; }

/* ---------- character creator ---------- */

.creator {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 26px;
  margin-bottom: 34px;
}
@media (max-width: 640px) { .creator { flex-direction: column; } }
.creator-preview {
  background: radial-gradient(80% 80% at 50% 35%, #1d2333 0%, #12161f 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 4px;
  overflow: hidden;
}
.creator-preview img {
  display: block;
  width: 168px;
  height: 210px;
  object-fit: cover;
  object-position: top center;
  border-radius: 11px;
}
.hero-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-card {
  width: 92px;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.hero-card:hover { transform: translateY(-2px); border-color: #3a4258; }
.hero-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(217, 162, 75, 0.35); }
.hero-thumb {
  display: block;
  height: 96px;
  background-size: cover;
  background-position: top center;
}
.hero-name {
  display: block;
  text-align: center;
  font-size: 0.68rem;
  padding: 5px 4px;
  color: var(--dim);
  font-family: var(--sans);
}
.hero-card.sel .hero-name { color: var(--accent); }
.hero-blurb { color: var(--faint); font-style: italic; font-size: 0.85rem; margin: 0; min-height: 1.2em; }
.creator-controls { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.creator-controls h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 0; }
.creator-name { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--dim); max-width: 240px; }
.creator-name input {
  background: #0d101a;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  outline: none;
}
.creator-name input:focus { border-color: var(--accent); }

/* ---------- game shell ---------- */

body.game-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

#hud {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.7);
  backdrop-filter: blur(8px);
}
.hud-mid { flex: 1; min-width: 0; text-align: center; }
#hud-room { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin: 0; }
#objective { margin: 2px 0 0; font-size: 0.82rem; color: var(--dim); }
#objective.flash { animation: obj-flash 1.2s ease; }
@keyframes obj-flash { 30% { color: var(--accent-strong); } }
.hud-right { display: flex; align-items: center; gap: 12px; }
.timer { font-family: var(--mono); font-size: 1.05rem; min-width: 58px; text-align: right; }

#stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  user-select: none;
  -webkit-user-select: none;
}
#game {
  display: block;
  border-radius: 12px;
  border: 1px solid #202636;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 110px rgba(217, 162, 75, 0.06);
  background: #000;
}

#inv-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.7);
  min-height: 62px;
}
.inv-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--faint); }
#inv { display: flex; gap: 8px; }
.inv-item {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 21px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.inv-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.inv-empty { color: #565349; font-style: italic; font-size: 0.85rem; }

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: rgba(21, 25, 38, 0.95);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease;
  max-width: 480px;
  text-align: center;
}
.toast.gone { opacity: 0; transform: translateY(6px); transition: all 0.4s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- overlays and modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.78);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.overlay.hidden { display: none; }

.modal-card {
  background: var(--panel);
  border: 1px solid #2c3450;
  border-radius: 16px;
  padding: 26px 28px;
  width: min(430px, 92vw);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* ---------- the book: every in-room interaction is a two-page spread ---------- */

#modal-card.book {
  background: url('../assets/ui/book.webp') center / 100% 100% no-repeat;
  width: min(94vw, 1100px);
  aspect-ratio: 1.79;
  max-height: 88vh;
  padding: 0;
  border: none;
  border-radius: 10px;
  box-shadow: 0 46px 110px rgba(0, 0, 0, 0.78);
  position: relative;
  animation: book-in 0.35s ease;
}
@keyframes book-in {
  from { opacity: 0; transform: scale(0.92) translateY(14px); }
}
.book-page { position: absolute; top: 17%; bottom: 15%; }
.book-left {
  left: 19.5%;
  width: 25.5%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.book-right {
  left: 52.5%;
  width: 27.5%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 90, 44, 0.5) transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.book-plate {
  flex: 1;
  min-height: 0;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(90, 68, 40, 0.55);
  box-shadow: 0 3px 12px rgba(60, 40, 20, 0.35);
}
.book-plate.sepia { filter: sepia(0.7) contrast(0.95) brightness(1.06); }
.book-plate.empty { background: rgba(120, 95, 60, 0.12); border-style: dashed; }
.book-caption {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  color: #6a5136;
  margin: 0;
  font-size: 0.95rem;
}

/* ink-on-parchment restyle of everything on the right page */
.book .modal-title { color: #3a2a16; font-size: 1.45rem; }
.book .modal-text, .book .modal-note { color: #5c4730; }
.book .clue-body {
  background: rgba(122, 90, 44, 0.1);
  border-color: rgba(122, 90, 44, 0.4);
  color: #4a3823;
}
.book .clue-body b { color: #7a4d14; }
.book .clue-body i { color: #6a563c; }
.book .runes { color: #7a4d14; }
.book .keypad-display { background: rgba(48, 34, 17, 0.92); border-color: #8a744f; }
.book .key { background: #e2d2ae; color: #3a2a16; border-color: #b5a075; }
.book .key:hover { border-color: #7a4d14; }
.book .key-ok { background: #7a4d14; color: #f2e6c8; }
.book .key-c { color: #8a3324; }
.book .dial-value { background: rgba(48, 34, 17, 0.92); border-color: #8a744f; }
.book .dial-btn { background: #e2d2ae; color: #5c4730; border-color: #b5a075; }
.book .dial-btn:hover { color: #3a2a16; border-color: #7a4d14; }
.book .switch-toggle { background: #d9c8a4; border-color: #b5a075; }
.book .switch-toggle::after { background: #8a744f; }
.book .switch-toggle.on::after { background: #7a4d14; }
.book .switch-label { color: #5c4730; }
.book .hint-item {
  background: rgba(122, 90, 44, 0.12);
  border-left-color: #7a4d14;
  color: #4a3823;
}
.book .btn-ghost { border-color: #b5a075; color: #6a5136; }
.book .btn-ghost:hover { color: #3a2a16; border-color: #7a4d14; }
.book .term-input { background: #0d101a; }

@media (max-width: 780px), (max-height: 520px) {
  #modal-card.book {
    aspect-ratio: auto;
    background: #eadfc0;
    padding: 22px;
    border-radius: 14px;
    max-height: 92vh;
    overflow-y: auto;
  }
  .book-page { position: static; width: auto; }
  .book-left { display: none; }
}
.modal-title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 0 0 12px; }
.modal-text, .modal-note { color: var(--dim); line-height: 1.6; margin: 0 0 18px; }
.shake { animation: shake 0.35s ease; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.clue-body {
  color: var(--text);
  line-height: 1.7;
  margin: 0 0 18px;
  background: rgba(217, 162, 75, 0.07);
  border: 1px solid rgba(217, 162, 75, 0.25);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.98rem;
}
.clue-body b { color: var(--accent-strong); }
.clue-body i { color: var(--dim); }
.runes {
  font-family: 'Segoe UI Historic', 'Segoe UI Symbol', serif;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  color: var(--accent-strong);
}

/* keypad */
.keypad-display {
  font-family: var(--mono);
  font-size: 1.7rem;
  letter-spacing: 0.4em;
  text-align: center;
  background: #0d101a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
  color: var(--accent-strong);
  min-height: 54px;
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  height: 52px;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.key:hover { border-color: var(--accent); }
.key:active { transform: scale(0.96); }
.key-ok { background: var(--accent); color: #201607; }
.key-c { color: var(--danger); }

/* dials */
.dials-row { display: flex; justify-content: center; gap: 16px; margin: 6px 0 18px; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dial-value {
  width: 52px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-family: 'Segoe UI Historic', var(--mono);
  background: #0d101a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-strong);
}
.dial-btn {
  width: 52px;
  padding: 4px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 8px;
  cursor: pointer;
}
.dial-btn:hover { color: var(--text); border-color: var(--accent); }

/* switches */
.switch-row { display: flex; justify-content: center; gap: 20px; margin: 8px 0 20px; }
.switch { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.switch-label { font-family: var(--mono); color: var(--dim); font-size: 0.85rem; }
.switch-toggle {
  position: relative;
  width: 34px;
  height: 60px;
  background: #0d101a;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
.switch-toggle::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 22px;
  bottom: 4px;
  background: #4a5163;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.switch-toggle.on::after { bottom: 32px; background: var(--accent); }

/* terminal */
.term-screen {
  background: #06110a;
  border: 1px solid #1c3a26;
  border-radius: 10px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: #55c96c;
  min-height: 150px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.term-line { margin: 2px 0; }
.term-echo { color: #2e7a41; }
.term-bad { color: #d66a5a; }
.term-good { color: #8ce08a; font-weight: 700; }
.term-input-row { display: flex; gap: 8px; }
.term-input {
  flex: 1;
  background: #0d101a;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--text);
  font-family: var(--mono);
  outline: none;
}
.term-input:focus { border-color: var(--accent); }

/* hints */
.hint-list { margin-bottom: 16px; }
.hint-item {
  color: var(--text);
  background: rgba(217, 162, 75, 0.07);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  margin: 0 0 8px;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* intro and win cards */
.intro-art {
  height: 150px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 -30px 40px rgba(0, 0, 0, 0.5), 0 6px 24px rgba(0, 0, 0, 0.45);
  margin-bottom: 20px;
}
.end-card {
  background: var(--panel);
  border: 1px solid #2c3450;
  border-radius: 18px;
  padding: 40px 44px;
  text-align: center;
  max-width: 460px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: card-in 0.3s ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.end-eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--dim); margin: 0 0 10px; }
.end-title { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; margin: 0 0 8px; }
.end-tagline { color: var(--dim); line-height: 1.6; margin: 0 0 14px; }
.end-controls { color: var(--faint); font-size: 0.83rem; margin: 0 0 22px; }
.end-best { color: var(--accent); font-size: 0.85rem; margin: 0 0 18px; }
.end-stats { display: flex; justify-content: center; gap: 30px; margin: 18px 0 26px; }
.end-num { font-family: var(--mono); font-size: 1.5rem; color: var(--accent-strong); }
.end-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--dim); margin-top: 4px; }
.end-actions { display: flex; justify-content: center; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* (vault card scene now defined with the other art scenes near the top) */

/* tutorial isle replay link (Claude, 2026-07-18) */
.featured-alt { text-align: right; margin: -30px 4px 34px; font-size: 0.82rem; }
.featured-alt a { color: var(--faint); text-decoration: none; border-bottom: 1px dotted rgba(217, 162, 75, 0.4); }
.featured-alt a:hover { color: var(--accent); }

/* The Archive: escape rooms demoted to a collapsed shelf (Claude, 2026-07-18) */
.archive { margin-top: 8px; }
.archive summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 14px 4px;
  border-top: 1px solid rgba(38, 45, 63, 0.7);
  border-bottom: 1px solid rgba(38, 45, 63, 0.7);
  transition: color 0.2s ease;
}
.archive summary::-webkit-details-marker { display: none; }
.archive summary::before { content: '▸ '; color: var(--accent); }
.archive[open] summary::before { content: '▾ '; }
.archive summary:hover { color: var(--dim); }
.archive[open] summary { margin-bottom: 22px; }

/* Descent death overlay (Claude, 2026-07-18) */
.quest-death {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 45%, rgba(70, 10, 10, 0.4) 0%, rgba(5, 4, 6, 0.97) 68%);
  opacity: 0;
  transition: opacity 1s ease;
}
.quest-death.on { opacity: 1; }
.quest-death-card { text-align: center; padding: 30px; }
.qd-eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--danger);
  margin: 0 0 10px;
}
.quest-death-card h2 {
  font-family: var(--serif);
  font-size: 2.6rem;
  letter-spacing: 0.06em;
  color: #e4d9c2;
  text-shadow: 0 0 44px rgba(200, 40, 40, 0.4);
  margin: 0 0 12px;
}
.qd-sub { color: var(--dim); margin: 0 0 26px; }

/* ---------- phone landscape support (Claude, 2026-07-18) ---------- */

/* touch hardening: no double-tap zoom on the canvas, no tap flash, no
   accidental selection or callouts while dodging wraiths */
#game { touch-action: manipulation; }
body.game-page { -webkit-tap-highlight-color: transparent; }
body.game-page .btn, .inv-item, .key, .dial-btn, .switch-toggle { touch-action: manipulation; }

/* notched phones in landscape: keep HUD and pockets out of the sensor areas */
#hud { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
#inv-bar { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }

/* compact shell on short screens (landscape phones): every vertical pixel
   goes to the canvas */
@media (max-height: 520px) {
  #hud { padding-top: 4px; padding-bottom: 4px; gap: 10px; }
  #hud-room { font-size: 0.95rem; }
  #objective { font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hud .btn { padding: 5px 12px; font-size: 0.78rem; }
  .timer { font-size: 0.85rem; min-width: 44px; }
  #stage { padding: 6px; }
  #game { border-radius: 8px; }
  #inv-bar { min-height: 34px; padding-top: 4px; padding-bottom: 4px; }
  .inv-item { width: 30px; height: 30px; font-size: 15px; }
  #toasts { bottom: 46px; }
  .toast { padding: 7px 14px; font-size: 0.8rem; }
  .end-card { max-height: 92vh; overflow-y: auto; }
}

/* portrait on a touch phone: ask for the turn instead of serving a clipped map */
#rotate-note { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 840px) {
  #rotate-note {
    display: grid;
    place-items: center;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(7, 8, 12, 0.97);
    text-align: center;
    padding: 30px;
  }
}
#rotate-note span { font-size: 46px; display: block; margin-bottom: 14px; }
#rotate-note p { color: var(--dim); font-family: var(--serif); font-size: 1.15rem; line-height: 1.7; margin: 0; }

/* living featured card: ambient video under the scrim (Claude, 2026-07-18) */
.featured-card { position: relative; overflow: hidden; }
.featured-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}
.featured-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(11, 13, 18, 0.92) 30%, rgba(11, 13, 18, 0.4) 70%);
  z-index: 1;
  pointer-events: none;
}
.featured-body { position: relative; z-index: 2; }
@media (prefers-reduced-motion: reduce) { .featured-video { display: none; } }

/* descend transition: the gate swallows the screen (Claude, 2026-07-18) */
/* ---------- the Ledger of Legends overlay (all pages) ---------- */

.legends-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 4, 6, 0.84);
}
.legends-overlay.on { display: flex; }
.legends-card {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  background: #12141c;
  border: 1px solid rgba(217, 162, 75, 0.4);
  border-radius: 14px;
  padding: 24px 24px 18px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.65);
}
.legends-card h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}
.legends-sub {
  margin: 0 0 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--faint);
}
.legends-rows {
  list-style: none;
  counter-reset: legend;
  margin: 0;
  padding: 0;
}
.legends-rows li {
  counter-increment: legend;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 2px;
  border-top: 1px solid rgba(217, 162, 75, 0.14);
  font-size: 0.9rem;
}
.legends-rows li::before {
  content: counter(legend);
  min-width: 1.6em;
  font-family: var(--serif);
  color: var(--faint);
  text-align: right;
}
.legends-rows li:nth-child(-n+3)::before { color: var(--accent); }
.legends-rows b {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
}
.legends-score {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.legends-detail {
  font-size: 0.76rem;
  color: var(--faint);
  white-space: nowrap;
}
.legends-state {
  margin: 12px 0 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--faint);
}
.legends-close {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 11px 18px;
  font: inherit;
  font-size: 0.9rem;
  color: #14100a;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .legends-detail { display: none; }
}

.floor-fade {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #050406;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.floor-fade.on { opacity: 1; }
.floor-fade-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 24px;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  opacity: 0;
  transition: opacity 0.45s ease 0.25s;
}
.floor-fade.on .floor-fade-label { opacity: 1; }
.floor-fade-label b {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #e8ddc8;
}
.floor-fade-label span {
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232, 221, 200, 0.55);
}

/* lifetime progress on the featured card (Claude, 2026-07-18) */
.featured-progress {
  display: none;
  margin: 12px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--faint);
}

/* the ledger of the fallen (Claude, 2026-07-18) */
.qd-ledger {
  display: inline-block;
  text-align: left;
  margin: 0 0 16px;
  min-width: 250px;
}
.qd-ledger div {
  display: flex;
  justify-content: space-between;
  gap: 26px;
  padding: 5px 2px;
  border-bottom: 1px solid rgba(180, 60, 60, 0.16);
  font-size: 0.88rem;
  color: var(--dim);
}
.qd-ledger b { color: #e4d9c2; font-weight: 600; }

/* death-screen action row (Claude, 2026-07-18) */
.qd-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
