/* Layout: a full-screen candlelit stage (16:9) between a slim HUD and the inventory shelf.
   One deliberate dark look for every theme. */
:root {
  --night: #090b0a;
  --wall: #141c18;
  --panel: #17130f;
  --line: #3a2d1f;
  --brass: #b8925a;
  --candle: #f3c870;
  --bone: #e9dfc8;
  --muted: #a39a88;
  --ghost: #cfe6df;
  --blood: #8c2a2f;
  --paper: #e4d9bf;
  --paper-ink: #2b2219;

  --f-display: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --f-whisper: "IM Fell English", Georgia, serif;
  --f-body: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-type: "Special Elite", "Courier New", monospace;
  --f-hand: "La Belle Aurore", "Segoe Script", cursive;

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--bone);
  font-family: var(--f-body);
  font-size: 18px;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 8px;
  gap: 8px;
  background: radial-gradient(ellipse at 50% 40%, #121815 0%, var(--night) 70%);
}

/* HUD */
#hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hud-place { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.hud-brand { font-family: var(--f-display); color: var(--brass); letter-spacing: 0.08em; font-size: 15px; }
.hud-room { font-family: var(--f-whisper); font-style: italic; color: var(--muted); }
.hud-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pieces { display: flex; align-items: center; gap: 6px; color: var(--paper); font-variant-numeric: tabular-nums; }
.pieces svg { width: 18px; height: 18px; color: var(--paper); opacity: 0.85; }
.candle { display: flex; align-items: center; gap: 8px; }
.candle-stick { position: relative; width: 10px; height: 28px; display: flex; flex-direction: column; justify-content: flex-end; }
.candle-wax { width: 10px; height: 100%; background: linear-gradient(90deg, #d9cdb2, #f1e8d4, #cbbd9f); border-radius: 2px 2px 1px 1px; transition: height 1s linear; }
.candle-flame { position: absolute; left: 50%; width: 6px; height: 10px; margin-left: -3px; border-radius: 50% 50% 45% 45%; background: radial-gradient(circle at 50% 70%, #fff6d6, var(--candle) 55%, rgba(243, 200, 112, 0) 75%); animation: flame 1.6s ease-in-out infinite; }
.hud-time { font-variant-numeric: tabular-nums; min-width: 4.2em; font-size: 17px; }
.hud-time.over { color: #e0646a; }
@keyframes flame { 0%, 100% { transform: scale(1) translateY(0); } 40% { transform: scale(0.85, 1.15) translateY(-1px); } 70% { transform: scale(1.1, 0.9); } }

.tool-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--bone);
  font-size: 16px;
  transition: border-color 0.2s, background 0.2s;
}
.tool-btn:hover { border-color: var(--brass); background: rgba(184, 146, 90, 0.08); }
.icon-btn { padding: 6px 8px; display: inline-grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] { border-color: var(--brass); }
#btn-sound[aria-pressed="false"] #sound-waves { opacity: 0.15; }

.cta {
  background: linear-gradient(180deg, #3a2a18, #251a0f);
  border: 1px solid var(--brass);
  color: var(--candle);
  font-family: var(--f-display);
  letter-spacing: 0.08em;
  font-size: 20px;
  padding: 10px 28px;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(243, 200, 112, 0.12);
}
.cta:hover { box-shadow: 0 0 32px rgba(243, 200, 112, 0.25); }
.cta:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* Stage */
#stage-wrap { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; position: relative; }
.stage {
  position: relative;
  width: min(100cqw, 100cqh * 16 / 9);
  aspect-ratio: 16 / 9;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #241c13;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
  container-type: inline-size;
  background: #0b0f0d;
}
#scene-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; pointer-events: none; }
#decals, #hotspots { position: absolute; inset: 0; }
#decals > * { position: absolute; pointer-events: none; }
#light {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 40% 58%, rgba(255, 190, 100, 0.10), rgba(0, 0, 0, 0) 55%);
  animation: flicker 5s infinite;
  mix-blend-mode: screen;
}
#light.dim { animation: dim 1.4s ease-in-out; }
@keyframes flicker { 0%, 100% { opacity: 1; } 12% { opacity: 0.75; } 14% { opacity: 1; } 47% { opacity: 0.85; } 52% { opacity: 1; } 80% { opacity: 0.9; } }
@keyframes dim { 0% { opacity: 1; filter: none; } 30% { opacity: 0.2; } 60% { opacity: 1.4; } 100% { opacity: 1; } }

.hotspot {
  position: absolute;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.hotspot:hover, .hotspot:focus-visible { background: rgba(243, 200, 112, 0.06); box-shadow: inset 0 0 30px rgba(243, 200, 112, 0.12); }
.hotspot .hs-label {
  position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  white-space: nowrap; pointer-events: none;
  font-family: var(--f-whisper); font-style: italic; font-size: clamp(12px, 1.4cqw, 18px);
  color: var(--bone); background: rgba(9, 11, 10, 0.8); padding: 2px 8px; border-radius: 3px;
  opacity: 0; transition: opacity 0.2s;
}
.hotspot.label-inside .hs-label { bottom: auto; top: 6px; }
.hotspot:hover .hs-label, .hotspot:focus-visible .hs-label { opacity: 1; }
.stage.highlight .hotspot { border: 1px dashed rgba(243, 200, 112, 0.6); }
.stage.highlight .hotspot .hs-label { opacity: 1; }

#whisper {
  position: absolute; left: 50%; top: 6%; transform: translateX(-50%);
  width: min(80%, 900px); margin: 0; text-align: center; pointer-events: none;
  font-family: var(--f-whisper); font-style: italic; font-size: clamp(15px, 2.1cqw, 30px);
  color: var(--ghost); text-shadow: 0 0 12px rgba(160, 220, 205, 0.6), 0 0 2px #000;
  opacity: 0; transition: opacity 1.2s ease;
}
#whisper.show { opacity: 1; }
#whisper.narration { color: var(--bone); text-shadow: 0 0 2px #000, 0 0 10px #000; font-style: normal; }

/* Close-up views */
#closeup { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(3, 4, 4, 0.72); z-index: 5; animation: fade-in 0.25s ease; }
.closeup-card {
  width: 88%; height: 88%;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1a1611, #110e0b);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0, 0, 0, 0.7);
  font-size: clamp(13px, 1.55cqw, 20px);
}
/* AI art: a carved mahogany frame with a gilded lip around every close-up, on dark damask velvet.
   The frame's corners are kept whole (slice 94 of 768 px) and its plain sides stretch to fit. */
.closeup-card {
  --frame: clamp(16px, 2.6cqw, 34px);
  border: var(--frame) solid #2a1810;
  border-image: url("../tex/closeup-frame.png") 94 / var(--frame) stretch;
  background:
    linear-gradient(180deg, rgba(26, 22, 17, 0.35), rgba(17, 14, 11, 0.55)),
    url("../tex/closeup-velvet.jpg") 0 0 / 256px 256px repeat,
    #160f0c;
  box-shadow: 0 0 0 1px #000, 0 20px 60px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(0, 0, 0, 0.6);
}
.closeup-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 1.4cqw 2cqw; border-bottom: 1px solid var(--line); }
.closeup-head h2 { margin: 0; font-family: var(--f-display); font-weight: normal; color: var(--brass); letter-spacing: 0.06em; font-size: clamp(16px, 2.2cqw, 28px); text-wrap: balance; }
.closeup-body { flex: 1; min-height: 0; overflow: auto; padding: 2cqw; display: flex; gap: 2.5cqw; align-items: safe center; justify-content: safe center; }
.closeup-body .doc-col { display: flex; flex-direction: column; align-items: center; gap: 1em; }
@media (max-width: 600px) { .closeup-body { flex-direction: column; } }
.closeup-body p { margin: 0 0 0.7em; line-height: 1.45; }
.closeup-body .col { flex: 1; min-width: 0; }
.closeup-body .narrow { max-width: 34em; }
.closeup-body .muted { color: var(--muted); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.closeup-actions { display: flex; gap: 10px; align-items: center; flex: none; }
#closeup-actions { display: contents; }
.take-btn { font-size: 16px; padding: 6px 16px; }
.found-list { display: flex; gap: 1.4cqw; flex-wrap: wrap; }
.found {
  display: flex; flex-direction: column; align-items: center; gap: 0.4em;
  background: rgba(233, 223, 200, 0.05); border: 1px dashed var(--brass); border-radius: 6px;
  padding: 1cqw 1.4cqw; cursor: pointer; color: var(--bone); font-size: 0.95em;
}
.found:hover { background: rgba(243, 200, 112, 0.1); }
.found svg { width: 5cqw; height: 5cqw; min-width: 36px; min-height: 36px; }

/* Paper documents: AI-made blank papers (tex/paper-letter.jpg, tex/paper-newsprint.jpg) stretched to fit; the text is
   the game's own. The gradient underneath shows until the picture has loaded. */
.paper {
  background: url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, radial-gradient(ellipse at 30% 20%, #efe6cf, var(--paper) 60%, #cdbf9f);
  color: var(--paper-ink);
  padding: 2cqw 2.4cqw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  max-width: 100%;
}
.newspaper { font-family: Georgia, "Times New Roman", serif; width: 100%; max-width: 44em; }
.paper.newspaper { background: url("../tex/paper-newsprint.jpg") center / 100% 100% no-repeat, #d8ceb2; }
.newspaper .masthead { font-family: var(--f-display); text-align: center; font-size: 2em; letter-spacing: 0.04em; border-bottom: 3px double var(--paper-ink); padding-bottom: 0.15em; margin-bottom: 0.2em; }
.newspaper .dateline { display: flex; justify-content: space-between; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--paper-ink); padding-bottom: 0.3em; margin-bottom: 0.6em; }
.newspaper h3 { font-family: var(--f-whisper); font-size: 1.7em; line-height: 1.05; margin: 0.1em 0 0.15em; text-align: center; text-wrap: balance; }
.newspaper .deck { text-align: center; font-style: italic; margin-bottom: 0.7em; }
.newspaper .cols { columns: 2 14em; column-gap: 1.6em; font-size: 0.92em; text-align: justify; hyphens: auto; }
.newspaper .cols p { margin: 0 0 0.6em; line-height: 1.38; }
.typed { font-family: var(--f-type); }
.hand { font-family: var(--f-hand); font-size: 1.15em; line-height: 1.7; }
.card-doc { width: 22em; text-align: center; }
.card-doc .big { font-family: var(--f-display); font-size: 1.6em; letter-spacing: 0.05em; }
.receipt { width: 18em; font-family: var(--f-type); font-size: 0.9em; }
.receipt .row { display: flex; justify-content: space-between; gap: 1em; border-bottom: 1px dotted #8a7a5e; padding: 0.25em 0; }

.book { display: flex; width: 100%; max-width: 46em; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); }
.book .page { flex: 1; min-width: 0; padding: 2cqw; background: var(--paper); color: var(--paper-ink); }
.book .page { background: url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, var(--paper); }
.book .page.left { background: linear-gradient(90deg, rgba(0, 0, 0, 0) 85%, rgba(110, 80, 40, 0.4)), url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, #e9dfc7; }
.book .page.right { background: linear-gradient(90deg, rgba(110, 80, 40, 0.4), rgba(0, 0, 0, 0) 15%), url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, #e6dbc2; }
.book .page.torn { background: linear-gradient(90deg, #c5b690, #1a1611 18%); color: var(--muted); display: flex; align-items: center; }
.book h4 { margin: 0 0 0.6em; font-family: var(--f-display); font-weight: normal; letter-spacing: 0.05em; border-bottom: 1px solid #8a7a5e; }
.book .entry { font-family: var(--f-hand); font-size: 1.05em; margin-bottom: 0.5em; line-height: 1.4; }
.book .entry small { font-family: var(--f-body); font-size: 0.75em; color: #6a5a44; display: block; }

.scrap {
  width: 16em; padding: 1.4em 1.6em;
  clip-path: polygon(4% 8%, 22% 0, 40% 6%, 63% 1%, 84% 7%, 100% 3%, 95% 30%, 100% 55%, 93% 80%, 97% 100%, 70% 94%, 46% 100%, 25% 93%, 0 98%, 5% 70%, 0 44%);
}

/* Clock */
.clock-wrap { display: flex; gap: 3cqw; align-items: center; justify-content: center; }
.clock-face { width: min(30cqw, 320px); aspect-ratio: 1; flex: none; }
.clock-controls { display: grid; gap: 1em; min-width: 0; max-width: 24em; }
@media (max-width: 600px) { .clock-wrap { flex-direction: column; } }
.dial-row { display: flex; align-items: center; gap: 0.6em; }
.dial-row .lbl { width: 7em; color: var(--muted); }
.dial-row .val { min-width: 2.4em; text-align: center; font-variant-numeric: tabular-nums; font-size: 1.2em; }
.round-btn { width: 2.4em; height: 2.4em; border-radius: 50%; border: 1px solid var(--brass); background: #1f1810; color: var(--candle); cursor: pointer; font-size: 1em; display: grid; place-items: center; touch-action: manipulation; }
.round-btn:hover { background: #2b2116; }
.clock-trunk { width: min(16cqw, 140px); }

/* Coats and lock */
.coats { display: flex; gap: 2cqw; align-items: flex-end; justify-content: center; }
.coat-btn { background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer; padding: 0.5em; display: flex; flex-direction: column; align-items: center; gap: 0.3em; color: var(--muted); }
.coat-btn:hover { border-color: var(--line); color: var(--bone); }
.coat-btn svg { width: min(16cqw, 150px); height: auto; }
.lining { width: min(26cqw, 240px); aspect-ratio: 3 / 4; border-radius: 40% 40% 8px 8px / 20% 20% 8px 8px; display: grid; place-items: center; box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6); }
.lining svg { width: 45%; height: auto; color: #d9d2c0; filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6)); }

.lock-plate { background: url("../tex/brass-plate.jpg") center / 100% 100% no-repeat, linear-gradient(135deg, #7a5a2c, #c49a55 45%, #6a4c24); padding: 1.6em 2em; border-radius: 10px; box-shadow: inset 0 0 0 2px #3a2812, 0 10px 40px rgba(0, 0, 0, 0.7); display: grid; gap: 1em; justify-items: center; }
.lock-plate.shake { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.lock-dial { display: flex; align-items: center; gap: 0.6em; }
.lock-window { width: 4.2em; height: 4.2em; border-radius: 50%; background: #1c140b; display: grid; place-items: center; box-shadow: inset 0 3px 10px #000; }
.lock-window svg { width: 60%; height: 60%; color: #e6d3a6; }
.lock-dial .round-btn { width: 2em; height: 2em; font-size: 0.85em; }

/* Inventory */
#inventory { display: flex; align-items: center; gap: 12px; min-height: 64px; border-top: 1px solid #1f1912; padding-top: 6px; }
.inv-label { font-family: var(--f-display); color: var(--muted); letter-spacing: 0.08em; font-size: 14px; }
.inv-slots { display: flex; gap: 8px; overflow-x: auto; min-width: 0; padding-bottom: 2px; }
.inv-item {
  flex: none; width: 56px; height: 56px; border-radius: 6px;
  border: 1px solid var(--line); background: #15110d; cursor: pointer; padding: 6px;
  display: grid; place-items: center; position: relative;
}
.inv-item:hover { border-color: var(--brass); }
.inv-item svg { width: 100%; height: 100%; }
/* Painted item pictures (art/inv/): dark backgrounds, so they fill the slot edge to edge */
.item-art { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; pointer-events: none; user-select: none; }
.inv-item:has(.item-art) { padding: 0; overflow: hidden; }
.found .item-art { width: 5cqw; height: 5cqw; min-width: 36px; min-height: 36px; }
.pinned .item-art { width: 2.6em; height: 2.6em; flex: none; }
.inv-item.new { animation: glow-new 1.8s ease 2; }
@keyframes glow-new { 50% { box-shadow: 0 0 18px rgba(243, 200, 112, 0.6); border-color: var(--candle); } }
.inv-empty { color: #5e574b; font-style: italic; }

/* Overlays and screens */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); z-index: 20; padding: 16px; }
.panel { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); padding: 24px; box-shadow: 0 20px 60px #000; }
.panel h2 { margin: 0; font-family: var(--f-display); font-weight: normal; color: var(--ghost); letter-spacing: 0.05em; }
.panel-sub { color: var(--muted); margin: 4px 0 16px; }
/* Eleanor whispering out of the mist (AI art); it fades into the panel under the hints */
#hint-panel .panel {
  position: relative; overflow: hidden; padding-top: clamp(28px, 9vw, 56px); min-height: min(320px, 70vh);
  background:
    linear-gradient(to right, rgba(23, 19, 15, 0.82) 0%, rgba(23, 19, 15, 0.45) 45%, rgba(23, 19, 15, 0) 70%),
    linear-gradient(to bottom, rgba(23, 19, 15, 0) 30%, var(--panel) 92%),
    url("../art/hint-eleanor.jpg") center top / 100% auto no-repeat,
    var(--panel);
  border-color: #2d3b37;
}
#hint-panel .hint-list, #hint-panel .panel-sub { max-width: 72%; }
#hint-panel .panel-actions { position: relative; }
@media (max-width: 520px) { #hint-panel .hint-list, #hint-panel .panel-sub { max-width: none; } }
.hint-list { margin: 0 0 20px; padding-left: 1.4em; display: grid; gap: 10px; }
.hint-list li { font-family: var(--f-whisper); font-style: italic; color: var(--ghost); line-height: 1.4; }
.hint-list .none { list-style: none; margin-left: -1.4em; color: var(--muted); }
.panel-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.panel-actions .cta { font-size: 17px; padding: 8px 20px; }

.screen { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; align-content: center; gap: 28px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 24px; background: radial-gradient(ellipse at 50% 35%, #18211c 0%, var(--night) 65%); overflow-y: auto; }
.title-block { max-width: 40em; text-align: center; display: grid; gap: 18px; justify-items: center; }
.eyebrow { margin: 0; font-family: var(--f-display); color: var(--brass); letter-spacing: 0.18em; font-size: 15px; }
.screen h1 { margin: 0; font-family: var(--f-whisper); font-weight: normal; font-size: clamp(40px, 7vw, 84px); line-height: 1; color: var(--bone); text-shadow: 0 0 30px rgba(243, 200, 112, 0.18); text-wrap: balance; }
.tagline { margin: 0; font-size: 21px; line-height: 1.5; color: var(--muted); max-width: 32em; text-wrap: balance; }
.title-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.fineprint { margin: 0; font-size: 15px; color: #6f685b; }
/* The text intro: each line's picture (stills from the intro video) fades in behind it, with a slow push in */
.intro-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; overflow: hidden; transition: opacity 1.6s ease; }
.intro-bg::before { content: ""; position: absolute; inset: 0; background: var(--pic) center / cover no-repeat; animation: intro-push 14s ease-out both; }
.intro-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(5, 7, 6, 0.3), rgba(5, 7, 6, 0.72) 80%); }
.intro-bg.show { opacity: 1; }
@keyframes intro-push { from { transform: scale(1.02); } to { transform: scale(1.1); } }
#screen-intro > :not(.intro-bg) { position: relative; z-index: 1; }
.intro-lines p { text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9); }
.intro-lines { max-width: 34em; display: grid; gap: 18px; text-align: center; min-height: 12em; align-content: center; }
.intro-lines p { margin: 0; font-size: clamp(20px, 2.6vw, 28px); line-height: 1.45; opacity: 0; transition: opacity 1.4s ease; }
.intro-lines p.show { opacity: 1; }
.intro-lines p.ghost { font-family: var(--f-whisper); font-style: italic; color: var(--ghost); text-shadow: 0 0 14px rgba(160, 220, 205, 0.5); }
.stats { display: grid; grid-template-columns: auto auto; gap: 6px 24px; margin: 8px 0 0; font-size: 19px; }
.stats dt { color: var(--muted); text-align: right; }
.stats dd { margin: 0; text-align: left; font-variant-numeric: tabular-nums; }

.rotate-note { display: none; position: absolute; bottom: 4px; margin: 0; font-size: 14px; color: var(--muted); }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate-note { display: block; }
  .hud-brand { display: none; }
  .closeup-card { width: 96%; height: 94%; }
}

/* Phones held sideways: compact bars, and close-ups use the whole screen instead of the small stage */
@media (max-height: 520px) {
  #app { padding-block: 4px; gap: 4px; }
  .tool-btn { padding: 4px 10px; font-size: 15px; }
  .icon-btn { padding: 4px 6px; }
  #inventory { min-height: 46px; padding-top: 4px; }
  .inv-item { width: 42px; height: 42px; padding: 4px; }
  #closeup {
    position: fixed; z-index: 15;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .closeup-card { width: 100%; height: 100%; font-size: 15px; --frame: 12px; }
  .closeup-head { padding: 8px 16px; }
  .closeup-head h2 { font-size: 19px; }
  .closeup-body { padding: 12px 16px; gap: 20px; }
  .clock-face { width: min(55vh, 240px); }
  .lining { width: min(45vh, 200px); }
  .coat-btn svg { width: min(32vh, 120px); }
  .found svg, .found .item-art { width: 40px; height: 40px; }
  #whisper { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  #light, .candle-flame, .inv-item.new { animation: none; }
  #whisper, .intro-lines p { transition: none; }
  .intro-bg { transition: none; }
  .intro-bg::before { animation: none; }
}

/* ---------- 3D room ---------- */
.stage.is-3d { width: 100%; height: 100%; aspect-ratio: auto; background: #020303; }
.stage.is-3d #scene-art, .stage.is-3d #decals, .stage.is-3d #light { display: none; }
#world { position: absolute; inset: 0; }
#world canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#world.hovering canvas { cursor: pointer; }
#world.dragging canvas { cursor: grabbing; }
.stage:not(.is-3d) #world { display: none; }

/* The keyboard list of objects in the room. It must never cover the 3D view: only a focused button takes clicks. */
.room-list { position: absolute; inset: auto auto auto auto; left: 12px; top: 12px; right: auto; bottom: auto; width: auto; height: auto; display: flex; flex-wrap: wrap; gap: 6px; max-width: 70%; z-index: 3; pointer-events: none; }
.room-list button:focus-visible { pointer-events: auto; }
.room-list button { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.room-list button:focus-visible { position: static; width: auto; height: auto; clip: auto; overflow: visible; background: rgba(9, 11, 10, 0.9); border: 1px solid var(--brass); border-radius: 4px; padding: 4px 12px; font-family: var(--f-whisper); font-style: italic; }

#look-label, #world-labels .wl {
  position: absolute; pointer-events: none; white-space: nowrap;
  font-family: var(--f-whisper); font-style: italic; font-size: clamp(13px, 1.3cqw, 18px);
  color: var(--bone); background: rgba(9, 11, 10, 0.78); padding: 3px 10px; border-radius: 3px;
  border: 1px solid rgba(184, 146, 90, 0.35);
}
#look-label { transform: translate(-50%, calc(-100% - 18px)); opacity: 0; transition: opacity 0.2s; z-index: 2; }
#look-label.show { opacity: 1; }
#world-labels { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 2; }
#world-labels.show { opacity: 1; }
#world-labels .wl { left: 0; top: 0; }

#walk-help {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; z-index: 2;
  width: max-content; max-width: calc(100% - 32px); text-align: center; pointer-events: none;
  font-size: 15px; color: var(--bone); background: rgba(9, 11, 10, 0.72); padding: 6px 14px; border-radius: 4px;
  opacity: 0; transition: opacity 1s ease;
}
#walk-help.show { opacity: 1; }

#joystick {
  position: absolute; left: 22px; bottom: 22px; width: 112px; height: 112px; border-radius: 50%; z-index: 2;
  border: 1px solid rgba(184, 146, 90, 0.5); background: rgba(9, 11, 10, 0.35); touch-action: none;
  display: grid; place-items: center;
}
#joystick .knob { width: 46px; height: 46px; border-radius: 50%; background: rgba(243, 200, 112, 0.25); border: 1px solid var(--brass); pointer-events: none; }
.stage:not(.is-3d) #joystick, .stage:not(.is-3d) #walk-help, .stage:not(.is-3d) #look-label { display: none; }

#screen-end { animation: fade-in 1.8s ease; }
@media (prefers-reduced-motion: reduce) { #screen-end { animation: none; } }

/* ---------- Parlour close-ups ---------- */
.closeup-body .small { font-size: 0.85em; }
.statements { width: 100%; max-width: 36em; font-family: Georgia, "Times New Roman", serif; }
.statements .head { font-size: 0.8em; letter-spacing: 0.04em; border-bottom: 1px solid #8a7a5e; padding-bottom: 0.5em; margin-bottom: 0.8em; }
.statements dl { margin: 0; display: grid; gap: 0.3em 0; }
.statements dt { font-weight: bold; font-size: 0.9em; margin-top: 0.4em; }
.statements dd { margin: 0 0 0 1em; font-style: italic; line-height: 1.4; }
.statements .foot { font-size: 0.75em; margin: 1em 0 0; color: #5a4a36; }

/* Seating plan: the room seen from above */
.plan {
  position: relative; flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto auto;
  grid-template-areas: ". n ." "w t e" ". s .";
  gap: 0.8em 0.6em; align-items: center; justify-items: center;
  padding: 2.4em 2.2em; border: 2px solid var(--line); border-radius: 4px;
  background: radial-gradient(ellipse at 50% 50%, rgba(42, 29, 20, 0.45), rgba(18, 13, 9, 0.85)), url("../tex/rug-parlour.jpg") center / cover, #1a120c; /* the parlour rug, seen from above */
}
.plan.shake { animation: shake 0.45s; }
.plan-wall { position: absolute; font-family: var(--f-whisper); font-style: italic; font-size: 0.78em; color: var(--muted); white-space: nowrap; }
.plan-n { top: 0.5em; left: 50%; transform: translateX(-50%); }
.plan-s { bottom: 0.5em; left: 50%; transform: translateX(-50%); }
.plan-w { left: 0.4em; top: 50%; transform: translate(-50%, -50%) rotate(-90deg) translateY(1em); transform-origin: center; }
.plan-e { right: 0.4em; top: 50%; transform: translate(50%, -50%) rotate(90deg) translateY(1em); transform-origin: center; }
.plan-table { grid-area: t; width: min(9em, 22cqw); }
.plan-table svg { width: 100%; display: block; }
.seat { display: grid; justify-items: center; gap: 0.2em; }
.seat-n { grid-area: n; } .seat-e { grid-area: e; } .seat-s { grid-area: s; } .seat-w { grid-area: w; }
.seat-dir { font-family: var(--f-display); color: var(--brass); font-size: 0.85em; }
.seat-row { display: flex; align-items: center; gap: 0.3em; }
.seat-row .round-btn { width: 1.8em; height: 1.8em; font-size: 0.75em; }
.seat-row .round-btn:disabled { opacity: 0.3; cursor: default; }
.seat-name { min-width: 7.2em; text-align: center; font-size: 0.92em; }

/* Notebook */
.notebook .page { min-height: 15em; }
.sign-key { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6em 0.4em; margin-top: 0.6em; }
.sign { display: grid; justify-items: center; gap: 0.15em; }
.sign svg { width: 2.1em; height: 2.1em; color: #2b2219; }
.sign b { font-family: var(--f-display); font-size: 1.05em; }
.guides { margin: 0.4em 0 1em; padding-left: 1.2em; font-family: var(--f-hand); line-height: 1.6; }

/* Slate */
.slate {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8em; justify-items: center;
  padding: 1.6em 1.8em 1em; border: 0.7em solid #2e1d12; border-radius: 4px;
  background: url("../tex/slate-blank.jpg") center / cover, linear-gradient(135deg, #2c3031, #1b1e1f); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}
.slate span svg { width: min(4.2em, 9cqw); height: min(4.2em, 9cqw); color: #e6e3d6; opacity: 0.85; }
.slate-note { grid-column: 1 / -1; margin: 0.4em 0 0 !important; font-family: var(--f-hand); color: #d9d6ca; opacity: 0.8; }

/* Ouija board */
.board {
  position: relative; flex: none; width: min(34em, 56cqw, 100%); aspect-ratio: 512 / 320;
  background: url("../tex/ouija-blank.jpg") center / 100% 100% no-repeat, linear-gradient(180deg, #d2bd90, #bba27a); border-radius: 6px; /* AI blank board; the letters are the game's */
  box-shadow: inset 0 0 0 4px #3a2a1a, inset 0 0 40px rgba(60, 35, 10, 0.4), 0 12px 40px rgba(0, 0, 0, 0.7);
}
.board-key {
  position: absolute; transform: translate(-50%, -50%); background: none; border: 0; padding: 0.15em 0.25em; cursor: pointer;
  color: #2b2219; font-family: Georgia, serif; font-weight: bold; font-size: clamp(13px, 1.9cqw, 22px); border-radius: 4px; z-index: 1;
}
.board-key.word { font-family: var(--f-display); letter-spacing: 0.05em; }
.board-key:hover { background: rgba(43, 34, 25, 0.12); }
.planchette {
  position: absolute; width: 3.2em; height: 3.6em; transform: translate(-50%, -38%); pointer-events: none;
  transition: left 0.55s cubic-bezier(.4,.1,.3,1), top 0.55s cubic-bezier(.4,.1,.3,1);
  background: radial-gradient(circle at 50% 38%, rgba(255, 245, 220, 0.18) 0.5em, #b8925a 0.55em, #b8925a 0.62em, #5a3d22 0.66em);
  clip-path: path('M25 0 C44 6 50 34 44 52 C40 58 10 58 6 52 C0 34 6 6 25 0 Z');
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}
.spelled { font-family: var(--f-display); font-size: 1.4em; letter-spacing: 0.08em; color: var(--candle); min-height: 1.4em; }

/* Cabinet cords */
.cords { display: flex; gap: 1.4em; align-items: flex-start; padding: 0 1em; flex: none; border-top: 6px solid #6a4c24; background: linear-gradient(rgba(5, 3, 3, 0.82), rgba(0, 0, 0, 0.92)), url("../tex/velour_velvet_diff.jpg") center / 240px, #000; min-height: 15em; } /* black velvet inside the cabinet */
.cord { background: none; border: 0; padding: 0 0.4em; cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: transform 0.35s ease; }
.cord .rope { width: 4px; height: 9em; background: repeating-linear-gradient(45deg, #8a7a60 0 3px, #6f6048 3px 6px); }
.cord .tassel { width: 1.4em; height: 2.4em; background: var(--tassel); clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); outline: 1px solid rgba(233, 223, 200, 0.18); }
.cord:hover .tassel { filter: brightness(1.3); }
.cord.pulled { transform: translateY(1.6em); cursor: default; }
.cue-card { width: auto; max-width: 16em; padding: 1em 1.4em; margin: 0.4em 0; transform: rotate(-2deg); }
.cue-card p { margin: 0 !important; }
.key-art svg { width: min(10em, 24cqw); height: auto; color: var(--brass); filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.7)); }

/* ---------- Click-through navigation ---------- */
.nav-btn {
  position: absolute; z-index: 3; display: grid; place-items: center; cursor: pointer;
  color: var(--bone); background: rgba(9, 11, 10, 0.55); border: 1px solid rgba(184, 146, 90, 0.45);
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}
.nav-btn:hover:not(:disabled) { background: rgba(30, 24, 16, 0.85); border-color: var(--brass); }
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.nav-btn svg { width: 26px; height: 26px; }
#nav-left, #nav-right { top: 50%; width: 46px; height: 76px; transform: translateY(-50%); border-radius: 6px; }
#nav-left { left: 12px; }
#nav-right { right: 12px; }
#nav-back { left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px 18px 8px 12px; border-radius: 22px; font-family: var(--f-whisper); font-style: italic; font-size: 17px; }
#nav-back svg { width: 20px; height: 20px; }
.nav-btn[hidden] { display: none; }
.stage:not(.is-3d) .nav-btn { display: none; }
@media (max-height: 520px) { #nav-left, #nav-right { width: 40px; height: 60px; } }

/* ---------- Study close-ups ---------- */
.verse-card { width: auto; max-width: 24em; transform: rotate(-1.5deg); }
.verse-card p { margin: 0 !important; line-height: 1.75; }
.verse-card .sig { text-align: right; margin-top: 0.4em !important; }

.shelf {
  flex: none; display: flex; align-items: flex-end; gap: 0.25em; padding: 1.4em 1.2em 0;
  background: linear-gradient(rgba(10, 6, 3, 0.7), rgba(5, 3, 2, 0.85)), url("../tex/wood-walnut.jpg") center / cover, #0d0805; border: 0.5em solid #3a2414; border-bottom-width: 1em; border-radius: 3px;
}
.shelf .book {
  width: 2.6em; height: 9em; border: 0; border-radius: 3px 3px 0 0; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: #d9b46a;
  /* AI leather spine (tex/spine-blank.jpg), dyed per book like the books in the room; the symbol is the game's */
  background: linear-gradient(90deg, rgba(0,0,0,0.35), transparent 30%, transparent 70%, rgba(0,0,0,0.4)), url("../tex/spine-blank.jpg") center / 100% 100%, var(--spine, #b0574a);
  background-blend-mode: normal, multiply;
  box-shadow: inset 0 0.8em 0 -0.6em rgba(217, 180, 106, 0.6), inset 0 -0.8em 0 -0.6em rgba(217, 180, 106, 0.6);
  transition: transform 0.3s ease, filter 0.2s;
}
.shelf .book:nth-child(5n+2) { --spine: #5f8a62; } .shelf .book:nth-child(5n+3) { --spine: #6c6898; }
.shelf .book:nth-child(5n+4) { --spine: #b08a5a; } .shelf .book:nth-child(5n+5) { --spine: #6a6460; }
.shelf .book svg { width: 1.7em; height: 1.7em; }
.shelf .book:hover:not(:disabled) { filter: brightness(1.35); }
.shelf .book.pulled { transform: translateY(-0.9em) scale(1.06); filter: brightness(1.25); }
.shelf .book:disabled { cursor: default; }
@media (max-width: 600px) { .book { width: 1.9em; height: 7em; } }

.tin-label { width: 15em; text-align: center; border-radius: 50% / 12%; background: radial-gradient(ellipse at 40% 30%, rgba(255, 250, 230, 0.35), rgba(120, 100, 60, 0.25)), url("../tex/paper-letter.jpg") center / cover, #ddd0a8; }
.tin-label p { margin: 0.2em 0 !important; }
.tin-label .big { font-size: 1.3em; letter-spacing: 0.08em; }
.tin-label .poison { color: #8c2a2f; font-size: 1.5em; letter-spacing: 0.2em; }
.tin-label .small { font-size: 0.75em; }

.ledger { width: 100%; max-width: 32em; font-family: Georgia, serif; }
.ledger h4 { margin: 0 0 0.6em; font-family: var(--f-display); font-weight: normal; border-bottom: 1px solid #8a7a5e; }
.ledger table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.ledger td { padding: 0.3em 0.4em; border-bottom: 1px dotted #8a7a5e; font-family: var(--f-hand); }
.ledger td:last-child { text-align: right; white-space: nowrap; }

.safe-door {
  flex: none; display: grid; gap: 0.8em; justify-items: center; padding: 1.6em 1.8em;
  background: url("../tex/safe-door.jpg") center / 100% 100% no-repeat, linear-gradient(135deg, #4a4e52, #2a2d30); border-radius: 8px; /* AI steel door; dials are the game's */
  box-shadow: inset 0 0 0 3px #1a1c1e, inset 0 0 30px rgba(0, 0, 0, 0.5), 0 10px 40px rgba(0, 0, 0, 0.7);
}
.safe-door.shake { animation: shake 0.45s; }
.safe-dials { display: flex; align-items: center; gap: 0.5em; }
.safe-dial { display: grid; justify-items: center; gap: 0.3em; }
.safe-dial span { width: 1.8em; height: 1.8em; display: grid; place-items: center; font-size: 1.5em; font-variant-numeric: tabular-nums; background: #c9b27a; color: #1f1a10; border-radius: 4px; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5); font-family: Georgia, serif; }
.safe-dial .round-btn { width: 1.9em; height: 1.9em; font-size: 0.75em; }
.safe-sep { font-size: 1.8em; color: #c9b27a; }
.safe-plate { margin: 0 !important; font-family: var(--f-type); font-size: 0.8em; letter-spacing: 0.2em; color: #c9b27a; }

.bellboard {
  flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1em 1.2em; padding: 1.4em;
  background: url("../tex/bellboard.jpg") center / 100% 100% no-repeat, linear-gradient(#3a2414, #24160c); border: 0.4em solid #1a100a; border-radius: 4px; /* AI backboard */
}
.bell { background: none; border: 0; cursor: pointer; display: grid; justify-items: center; gap: 0.3em; color: #c49a55; padding: 0.3em; transform-origin: 50% 0; }
.bell svg { width: 2.8em; height: 2.8em; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); transform-origin: 50% 5%; }
.bell span { font-family: var(--f-whisper); font-style: italic; font-size: 0.8em; color: var(--bone); max-width: 7em; text-align: center; }
.bell:hover svg { filter: brightness(1.3) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
.bell.ringing svg { animation: ring 1.1s ease-out; }
@keyframes ring { 0% { transform: rotate(0); } 10% { transform: rotate(24deg); } 25% { transform: rotate(-20deg); } 40% { transform: rotate(14deg); } 55% { transform: rotate(-9deg); } 70% { transform: rotate(5deg); } 100% { transform: rotate(0); } }
.bell-progress { min-height: 1.4em; font-family: var(--f-display); color: var(--candle); letter-spacing: 0.04em; }
@media (prefers-reduced-motion: reduce) { .bell.ringing svg { animation: none; filter: brightness(1.8); } }

/* Report of the built-in click test (?clicktest) */
#clicktest-report { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(560px, calc(100% - 32px)); max-height: 70vh; overflow: auto; background: #0e0c0a; border: 1px solid var(--brass); padding: 12px 14px; box-shadow: 0 10px 40px #000; }
#clicktest-report pre { margin: 0 0 10px; white-space: pre-wrap; font: 13px/1.45 ui-monospace, Menlo, monospace; color: var(--bone); }

/* ---------- Kitchen close-ups ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.closeup-body .lbl { margin: 0.6em 0 0.3em; color: var(--muted); font-size: 0.85em; letter-spacing: 0.08em; text-transform: uppercase; }
.recipe-card { width: 21em; flex: none; }
.recipe-card .title { font-size: 1.5em; margin: 0 0 0.2em; }
.recipe-card .small { font-size: 0.95em; margin: 0.4em 0; }
.recipe-card table { width: 100%; border-collapse: collapse; margin: 0.4em 0; }
.recipe-card td { border-bottom: 1px dotted #8a7a5e; padding: 0.1em 0.3em; }
.recipe-card td:last-child { text-align: right; white-space: nowrap; }

.scale-wrap { flex: none; display: grid; gap: 0.6em; justify-items: center; }
.scale-svg { width: min(34cqw, 340px); min-width: 220px; height: auto; display: block; }
.scale-pick { display: grid; justify-items: center; }
.pot-row { display: flex; gap: 0.5em; flex-wrap: wrap; justify-content: center; }
.pot-btn, .weight-btn {
  min-width: 2.6em; height: 2.6em; padding: 0 0.4em; border-radius: 6px; cursor: pointer; touch-action: manipulation;
  font-family: Georgia, serif; font-size: 1em; display: grid; place-items: center; grid-auto-flow: column; gap: 1px;
}
.pot-btn { background: #b3a685; color: #2b2219; border: 2px solid #5a3a24; }
.weight-btn { background: linear-gradient(#e2c27a, #b8925a); color: #2b2219; border: 2px solid #6b4f24; }
.weight-btn small { font-size: 0.65em; }
.pot-btn[aria-pressed="true"], .weight-btn[aria-pressed="true"] { outline: 3px solid var(--candle); outline-offset: 2px; }
.scale-read { min-height: 2.6em; font-family: var(--f-whisper); font-style: italic; color: var(--candle); }

.med-door { background: linear-gradient(135deg, rgba(141, 135, 122, 0.25), rgba(60, 56, 48, 0.45)), url("../tex/paint-cream.jpg") center / cover, #8d877a; box-shadow: inset 0 0 0 3px #3d3a33, inset 0 0 30px rgba(0, 0, 0, 0.45), 0 10px 40px rgba(0, 0, 0, 0.7); }
.med-door .safe-plate { color: #2b2219; }

.pattern-chart { width: min(30cqw, 300px); min-width: 210px; height: auto; flex: none; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); }
.reels { flex: none; display: grid; grid-template-columns: repeat(3, auto); gap: 1em 1.4em; }
.reel { display: grid; justify-items: center; gap: 0.25em; }
.reel svg { width: 2.6em; height: auto; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
.reel-tag { display: grid; place-items: center; width: 2em; height: 2em; background: var(--paper); color: var(--paper-ink); border-radius: 2px; transform: rotate(-4deg); }
.reel-tag svg { width: 1.3em; height: 1.3em; filter: none; }
.studs { display: flex; gap: 0.8em; margin: 0.8em 0 1em; }
.studs.shake { animation: shake 0.45s; }
.stud {
  --c: #5a4a36; width: 2.6em; height: 2.6em; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  border: 3px solid #c49a55; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45), var(--c) 45%, rgba(0, 0, 0, 0.5));
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}

.diary-page { flex: none; width: min(30em, 100%); background: url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, radial-gradient(ellipse at 30% 20%, #f1e8d2, #ddd0b0 70%, #c9b98f); }
.diary-date { margin: 0 0 0.6em !important; text-align: right; }
.cipher-line { display: flex; flex-wrap: wrap; gap: 0.2em 1.1em; margin: 0 !important; padding: 0.45em 0; border-bottom: 1px dotted rgba(90, 74, 54, 0.55); }
.cipher-line:last-of-type { border-bottom: 0; }
.cipher-word { display: inline-flex; gap: 0.05em; align-items: center; }
.cipher-word svg { width: 1.7em; height: 1.7em; }
.cipher-dot { font-family: var(--f-hand); font-size: 1.2em; padding-left: 0.1em; }
.diary-plain { border-top: 1px solid #8a7a5e; padding-top: 0.5em; margin: 0.8em 0 0 !important; color: #4a3a2a; }
.diary-form { display: flex; gap: 0.6em; flex-wrap: wrap; align-items: center; }
.text-input {
  flex: 1; min-width: 10em; font-family: var(--f-body); font-size: 1.05em; padding: 0.45em 0.6em; border-radius: 4px;
  background: #15110c; color: var(--bone); border: 1px solid var(--brass);
}
.text-input:focus { outline: 2px solid var(--candle); outline-offset: 1px; }

.flower-key { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4em; max-width: 24em; margin: 0.6em 0 1em; padding: 0.6em; border-radius: 6px; background: linear-gradient(135deg, rgba(74, 53, 24, 0.55), rgba(20, 13, 6, 0.75)), url("../tex/wood-walnut.jpg") center / cover, #2a1d0e; box-shadow: inset 0 0 0 2px #a8823f; }
.flower-cell { display: grid; justify-items: center; gap: 0.1em; }
.flower-cell svg { width: 2em; height: 2em; }
.flower-cell span { font-family: var(--f-display); color: #e2c27a; font-size: 0.95em; }
@media (max-width: 600px) { .reels { grid-template-columns: repeat(6, auto); gap: 0.6em; } .flower-key { grid-template-columns: repeat(6, 1fr); } .cipher-word svg { width: 1.45em; height: 1.45em; } .cipher-line { gap: 0.2em 0.8em; } }

/* ---------- Bedroom close-ups and the ending ---------- */
.mirror-canvas { width: min(26cqw, 300px); min-width: 200px; height: auto; flex: none; border-radius: 40% 40% 6px 6px / 18% 18% 6px 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); }
.crane-note { flex: none; width: min(30em, 100%); }
.crane-note p { margin: 0 0 0.6em; line-height: 1.55; }
.jigsaw { flex: none; }
.jig-board { display: grid; grid-template-columns: repeat(2, auto); gap: 2px; padding: 8px; background: linear-gradient(rgba(30, 18, 10, 0.5), rgba(30, 18, 10, 0.5)), url("../tex/wood-mahogany.jpg") center / cover, #3a2616; border-radius: 6px; box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6); }
.jig-board.shake { animation: shake 0.45s; }
.jig-slot, .jig-piece { padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
.jig-slot { width: min(15cqw, 170px); min-width: 110px; aspect-ratio: 190 / 130; border: 1px dashed rgba(184, 146, 90, 0.5); border-radius: 3px; }
.jig-slot.filled { border-color: transparent; }
.jig-slot svg, .jig-piece svg { width: 100%; height: 100%; display: block; }
.jig-tray { display: flex; flex-wrap: wrap; gap: 0.5em; margin: 0.6em 0; }
.jig-piece { width: min(11cqw, 130px); min-width: 90px; aspect-ratio: 190 / 130; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
.jig-piece[aria-pressed="true"] { outline: 3px solid var(--candle); outline-offset: 2px; }
.pin-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1em; margin: 1em 0; padding: 1.4em; border-radius: 4px; border: 0.45em solid #2a1a10; background: url("../tex/cork-board.jpg") center / 100% 100%, #7a5a36; } /* her cork pinboard */
.pin-card { background: url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, var(--paper); color: var(--paper-ink); padding: 0.8em; border-radius: 2px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6); display: grid; gap: 0.5em; align-content: start; }
.pin-card .q { margin: 0; font-size: 1.05em; line-height: 1.35; }
.pin-card .tool-btn { color: var(--paper-ink); border-color: #8a7a5e; }
.pinned { display: flex; gap: 0.5em; align-items: center; font-family: var(--f-whisper); font-style: italic; }
.pinned svg { width: 2.6em; height: 2.6em; flex: none; }
.pin-choices { display: flex; flex-wrap: wrap; gap: 0.3em; }
.pin-choice { width: 2.6em; height: 2.6em; padding: 0.15em; border: 1px solid #8a7a5e; border-radius: 4px; background: rgba(0, 0, 0, 0.06); cursor: pointer; }
.pin-choice svg { width: 100%; height: 100%; }
.pin-card .muted { color: #5a4a36; font-size: 0.85em; margin: 0; }
.accuse { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2em; width: 100%; }
.accuse fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 0.6em 0.9em; margin: 0; }
.accuse legend { font-family: var(--f-display); color: var(--brass); padding: 0 0.3em; }
.accuse label { display: flex; gap: 0.5em; align-items: baseline; padding: 0.3em 0; cursor: pointer; }
.accuse input { accent-color: var(--candle); }
.accuse-go { grid-column: 1 / -1; display: flex; gap: 1em; align-items: center; flex-wrap: wrap; }
.epilogue { display: grid; width: 100%; min-width: 0; box-sizing: border-box; grid-template-columns: repeat(auto-fit, minmax(min(13em, 100%), 1fr)); gap: 12px; max-width: 60em; margin: 4px auto; text-align: left; }
.epi-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; background: rgba(233, 223, 200, 0.04); }
.epi-card h3 { margin: 0 0 4px; font-family: var(--f-display); font-weight: normal; color: var(--brass); font-size: 17px; }
.epi-card p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.45; }
@media (max-width: 700px) { .pin-cards, .accuse { grid-template-columns: 1fr; } }
/* The accusation: the séance table behind it (AI art), the suspects as portrait cards */
.accuse {
  grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 1.2em; border-radius: 8px;
  background: linear-gradient(rgba(10, 8, 7, 0.5), rgba(10, 8, 7, 0.82)), url("../art/accuse-seance.jpg") center / cover, #120e0b;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}
.accuse fieldset { background: rgba(12, 10, 8, 0.55); }
.accuse .q-who { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.8em; }
.accuse .suspect { position: relative; flex-direction: column; align-items: center; gap: 0.35em; padding: 0.4em; border: 1px solid transparent; border-radius: 6px; text-align: center; font-size: 0.92em; line-height: 1.2; }
.accuse .suspect img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; border: 2px solid #3a2d1f; filter: sepia(0.25) brightness(0.8); transition: filter 0.2s, border-color 0.2s; }
.accuse .suspect input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.accuse .suspect:hover img { filter: none; }
.accuse .suspect:has(input:checked) { border-color: var(--candle); background: rgba(243, 200, 112, 0.08); }
.accuse .suspect:has(input:checked) img { filter: none; border-color: var(--candle); }
.accuse .suspect:has(input:focus-visible) { outline: 2px solid var(--candle); outline-offset: 2px; }
@media (max-width: 700px) {
  .accuse { grid-template-columns: 1fr; }
  .accuse .q-who { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Eleanor's candle has burned out: the game goes on in the dark */
body.candle-out .candle-flame { display: none; }
body.candle-out #scene-art { filter: brightness(0.6); }

/* ---------- Team play ---------- */
.team-panel { max-width: 40em; }
.team-panel .text-input { width: 100%; box-sizing: border-box; }
.team-panel .lbl { display: block; margin: 0.8em 0 0.3em; color: var(--muted); font-size: 0.85em; letter-spacing: 0.08em; text-transform: uppercase; }
.team-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; margin-top: 1em; }
.team-choice > div { border: 1px solid var(--line); border-radius: 6px; padding: 0.9em 1em; display: grid; gap: 0.5em; align-content: start; }
.team-choice h3 { margin: 0; font-family: var(--f-display); font-weight: normal; color: var(--brass); }
.team-choice p { margin: 0; color: var(--muted); }
.team-choice .lbl { margin: 0; }
.text-input.code { text-transform: uppercase; letter-spacing: 0.3em; font-family: var(--f-type); }
.team-status { min-height: 1.3em; color: var(--candle); font-style: italic; margin: 0.8em 0 0; }
@media (max-width: 600px) { .team-choice { grid-template-columns: 1fr; } }
.team-btn { position: relative; }
.team-btn.unread::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--candle); }
.team-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 25; width: min(22em, 92vw); box-sizing: border-box;
  display: flex; flex-direction: column; gap: 0.5em; padding: 14px 16px; overflow: auto;
  background: rgba(14, 12, 10, 0.97); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
}
.team-drawer h2 { margin: 0; font-family: var(--f-display); font-weight: normal; color: var(--brass); font-size: 20px; }
.team-drawer h3 { margin: 0.6em 0 0; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: normal; }
.td-head { display: flex; justify-content: space-between; align-items: center; }
.td-code { display: flex; justify-content: space-between; align-items: baseline; }
.td-code span { color: var(--muted); }
.td-code strong { font-family: var(--f-type); font-size: 26px; letter-spacing: 0.25em; color: var(--candle); font-weight: normal; }
.td-invite { display: flex; gap: 0.4em; }
.td-invite .text-input { flex: 1; min-width: 0; font-size: 13px; }
.team-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.team-players li { display: flex; justify-content: space-between; gap: 0.6em; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.tp-room { color: var(--muted); font-style: italic; text-align: right; }
.team-log { list-style: none; margin: 0; padding: 6px 8px; flex: 1; min-height: 8em; overflow: auto; border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 6px; align-content: start; }
.team-log li { line-height: 1.35; overflow-wrap: anywhere; }
.team-log b { color: var(--brass); font-weight: normal; font-family: var(--f-display); }
.team-log .sys { color: var(--muted); font-style: italic; }
.team-chat { display: flex; gap: 0.4em; }
.team-chat .text-input { flex: 1; min-width: 0; }
.team-toasts { position: fixed; top: 64px; right: 16px; z-index: 26; display: grid; gap: 8px; max-width: min(22em, calc(100vw - 32px)); pointer-events: none; }
.team-toast { pointer-events: auto; display: flex; gap: 0.6em; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--brass); border-radius: 6px; background: rgba(20, 16, 12, 0.95); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); animation: fade-in 0.4s ease; overflow-wrap: anywhere; }

/* ---------- AI art ---------- */
#screen-title, #screen-intro, #screen-end { background-size: cover; background-position: center; }
.portrait-art { width: min(26cqw, 300px); height: auto; flex: none; border: 10px solid #6b4f24; box-shadow: inset 0 0 0 2px #a8823f, 0 10px 40px rgba(0, 0, 0, 0.7); }
.epi-card.has-pic { display: grid; grid-template-columns: 64px 1fr; column-gap: 12px; align-items: start; }
.epi-card.has-pic img { grid-row: span 2; width: 64px; height: 85px; object-fit: cover; border-radius: 3px; border: 2px solid #6b4f24; }

/* Intro video */
.video-screen { background: #000; padding: 0; gap: 0; }
.video-screen video { width: 100vw; height: 100vh; height: 100dvh; object-fit: contain; background: #000; }
.video-screen video::cue { font-family: var(--f-whisper); font-size: clamp(16px, 2.4vw, 26px); color: #efe6cf; background: rgba(0, 0, 0, 0.55); }
.video-skip { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 20px; z-index: 31; background: rgba(0, 0, 0, 0.55); }

/* Title screen: the looping house behind a dark shade; the still picture shows if the video cannot play */
.title-loop, .title-shade { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.title-loop { object-fit: cover; z-index: 0; }
.title-shade { z-index: 0; background: linear-gradient(rgba(5, 7, 6, 0.5), rgba(5, 7, 6, 0.86)); }
#screen-title > :not(.title-loop):not(.title-shade) { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .title-loop, .title-shade { display: none; } }

/* ---------- The Fever Room (case 2) ---------- */
.closeup-pic { flex: none; width: min(46cqw, 100%); max-height: 70cqh; object-fit: cover; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); }
.lock-window.glyph { font-family: var(--f-display); font-size: 1.9em; color: #e6d3a6; }
.chart-doc { width: min(40em, 100%); font-size: 0.9em; }
.chart-doc .head { font-size: 0.8em; letter-spacing: 0.04em; border-bottom: 1px solid #8a7a5e; padding-bottom: 0.4em; }
.chart-table { width: 100%; border-collapse: collapse; }
.chart-table th { text-align: left; font-family: var(--f-type); font-weight: normal; font-size: 0.8em; border-bottom: 1px solid #8a7a5e; padding: 0.2em 0.4em; }
.chart-table td { vertical-align: top; padding: 0.3em 0.4em; border-bottom: 1px dotted #8a7a5e; white-space: nowrap; }
.chart-table td.hand { white-space: normal; font-size: 0.95em; line-height: 1.35; }
.book-entries { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 15em)); gap: 0.8em; }
.entry-card { display: grid; gap: 0.4em; text-align: left; padding: 0.9em 1em; border: 1px solid #8a7a5e; border-radius: 3px; cursor: pointer; color: var(--paper-ink); font: inherit; background: url("../tex/paper-letter.jpg") center / 100% 100% no-repeat, var(--paper); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.entry-card:hover:not(:disabled) { outline: 2px solid var(--candle); }
.entry-card:disabled { cursor: default; opacity: 0.55; }
.entry-card.chosen { opacity: 1; outline: 2px solid var(--candle); }
.entry-card.shake { animation: shake 0.45s; }
.entry-name { font-family: var(--f-display); font-size: 1.15em; border-bottom: 1px solid #8a7a5e; }
.entry-text { font-size: 0.88em; line-height: 1.4; }
.sampler-doc { flex: none; padding: 1.4em 2.2em; border-radius: 4px; background: url("../tex/sampler-linen.jpg") center / 100% 100% no-repeat, #ddd2b8; box-shadow: inset 0 0 0 10px #2a1a10, 0 10px 40px rgba(0, 0, 0, 0.7); text-align: center; }
.sampler-title, .sampler-sign { margin: 0.2em 0; font-family: var(--f-hand); color: #5a2a2a; }
.sampler-sign { font-size: 0.9em; white-space: nowrap; }
.sampler-key { background: rgba(255, 250, 235, 0.35); box-shadow: none; margin: 0.6em auto; }
.sampler-key .flower-cell span { color: #5a2a2a; }
.mirror-card .cipher-word.big { justify-content: center; margin-bottom: 0.4em; }
.mirror-card .cipher-word.big svg { width: 3em; height: 3em; }
.manual-doc { width: min(28em, 100%); }
.manual-doc .head { font-size: 0.85em; border-bottom: 1px solid #8a7a5e; padding-bottom: 0.3em; }
.manual-steps { padding-left: 1.3em; line-height: 1.5; }
.test-bench { flex: none; display: flex; gap: 1.4em; align-items: flex-end; }
.tube { position: relative; width: 2.6em; height: 12em; border: 2px solid rgba(220, 230, 235, 0.7); border-top: 0; border-radius: 0 0 1.3em 1.3em; background: rgba(200, 220, 230, 0.06); overflow: hidden; }
.tube .liquid { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(140, 100, 50, 0.7); transition: height 0.6s; }
.tube.filled .liquid { height: 35%; }
.tube.hot .liquid { animation: simmer 0.8s infinite alternate; }
.tube .coin { position: absolute; left: 50%; bottom: 0.5em; width: 1.6em; height: 0.5em; margin-left: -0.8em; border-radius: 50%; background: #c07a3a; }
.tube.hot .coin { background: #4a4c50; transition: background 3s 0.5s; }
@keyframes simmer { from { filter: brightness(1); } to { filter: brightness(1.3); } }
.test-log { max-width: 16em; font-family: var(--f-hand); color: var(--candle); line-height: 1.4; padding-left: 1.2em; }
.test-steps { display: grid; gap: 0.5em; margin: 0.6em 0; }
.test-steps .tool-btn { text-align: left; }
.envelope-doc { position: relative; width: 22em; height: 12em; display: grid; place-items: center; text-align: center; }
.envelope-doc .seal { position: absolute; bottom: 1.2em; right: 1.4em; width: 2.6em; height: 2.6em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #b23a3f, #6a1418); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.letter-doc, .note-doc { width: min(26em, 100%); }
.label-doc { width: 18em; text-align: center; }
.accuse .q-who, .accuse .q-trust { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8em; }
@media (max-width: 600px) { .book-entries { grid-template-columns: 1fr; } .accuse .q-who, .accuse .q-trust { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.test-steps .tool-btn:disabled { opacity: 0.45; cursor: default; }
