/* ════════════════════════════════════════════════════════════════
   NO CAUSE OF DEATH — stylesheet
   Asset paths in this file are relative to css/, hence '../assets/…'.
   ════════════════════════════════════════════════════════════════ */

/* ── FONTS (local, SIL Open Font License — see assets/fonts/) ── */
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/cinzel-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../assets/fonts/cinzel-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../assets/fonts/cinzel-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'IM Fell English'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/im-fell-english-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IM Fell English'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/im-fell-english-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Special Elite'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/special-elite-latin-400-normal.woff2') format('woff2'); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { -webkit-user-drag: none; user-drag: none; -webkit-user-select: none; user-select: none;
      -webkit-touch-callout: none; }

:root {
  --ink: #1a0f00;
  --ink-light: #3d2b1f;
  --parchment: #c8a96e;
  --parchment-light: #e8d5a3;
  --amber: #d4820a;
  --amber-dark: #8b4513;
  --red-seal: #7a1a1a;
  --gold: #c9a227;
  /* Height of the evidence strip at the bottom; overlays keep clear of it */
  --strip-h: 62px;
}

html, body {
  width: 100%; height: 100%;
  background: #0a0500;
  font-family: 'IM Fell English', Georgia, serif;
  color: var(--parchment-light);
  overflow: hidden;
  margin: 0; padding: 0;
  /* Touch: no double-tap zoom, no rubber-band scrolling, no tap flash */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
button, input { touch-action: manipulation; }

#game-wrapper {
  /* The game is a fixed 1600×900 canvas, scaled as a whole by scaleGame().
     vh/vw inside it would follow the browser window instead, so every
     viewport unit in this stylesheet reads --vh/--vw: canvas units here,
     real viewport units (the fallback) for anything outside the canvas. */
  --vh: 9px;
  --vw: 16px;
  position: absolute;
  top: 0; left: 0;
  width: 1600px;
  height: 900px;
  transform-origin: top left;
  overflow: hidden;
}

/* ── SCREENS ── */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
}
.screen.active { display: flex; }
/* Every screen change eases in instead of cutting. No fill-mode on purpose:
   a lingering opacity animation would create a stacking context and push
   the lamp light and dust above the room's own lightboxes. */
.screen.screen-enter { animation: screenEnter 0.55s ease-out; }
@keyframes screenEnter { from { opacity: 0; } to { opacity: 1; } }

/* ── BACKGROUNDS ──
   Brightness is a static filter; the candle flicker is a thin dark layer
   whose opacity animates. Same look as before, but the browser no longer
   re-filters a full-screen image every frame (heavy on iPad).

   NOTE for the designer: earlier versions declared brighter values for some
   scenes (study 0.80, lab 0.90, hall 0.88, door 0.55, puzzle 0.38, open door
   0.85, endings 1.0), but the generic flicker animation overrode all of them,
   so every scene actually rendered at ≈0.45. This file reproduces what you
   saw. To use a scene's intended value, set --bg-bright on that scene, e.g.
   .bg-lab { --bg-bright: 0.90; } */
.bg {
  position: absolute; inset: 0;
  background-image: url('../assets/img/ui/ui-backdrop.webp');
  background-size: cover;
  background-position: center;
  filter: brightness(var(--bg-bright, 0.47));
  z-index: 0;
}
.bg::after {
  content: ''; position: absolute; inset: 0;
  background: #000; opacity: 0; pointer-events: none;
  animation: bgFlicker 4s infinite;
}
@keyframes bgFlicker {
  0%, 100% { opacity: 0.045; }
  25%      { opacity: 0.11; }
  50%      { opacity: 0; }
  75%      { opacity: 0.085; }
}
/* Scripted moments that set their own light switch the flicker off */
.bg.no-flicker::after, .screen .bg.bg-zoomed::after { animation: none; opacity: 0; }

.bg-letters {
  background-image: url('../assets/img/room2/r2-overview.webp');
}
/* Room II has its own, much brighter exposure — tuned for this dark scene */
#screen-room2 .bg-letters { filter: brightness(2.55) contrast(1.05); }
/* Softer vignette here — the default crushes the bureau at the right edge */
#screen-room2 .vignette {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
}
.bg-lab   { background-image: url('../assets/img/room3/r3-lab.webp'); }
.bg-hall  { background-image: url('../assets/img/room4/r4-hall-desk.webp'); }
.bg-study { background-image: url('../assets/img/room1/r1-study.webp'); }

/* Parallax + zoom: all backgrounds get slight overscale; JS drives --px/--py */
.screen .bg {
  transform: scale(1.06) translate(var(--px, 0px), var(--py, 0px));
  will-change: transform;
}
.screen .bg.bg-zoomtrans {
  transition: transform 0.9s cubic-bezier(.22,.61,.36,1), filter 0.9s ease;
}
.screen .bg.bg-zoomed {
  transform: scale(1.65) translate(var(--px, 0px), var(--py, 0px));
  transform-origin: var(--zoom-origin, 50% 50%);
  filter: brightness(0.55) blur(1px);
}

/* Living light — breathing lamp glow, positioned per room via --lx/--ly.
   The element's own opacity switches it on/off; the breathing runs on the
   ::before layer as an opacity animation (cheap on tablets). */
#living-light {
  position: absolute; inset: 0;
  z-index: 6; pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.6s ease;
}
#living-light::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 52% 46% at var(--lx, 50%) var(--ly, 50%),
    rgba(255,196,110,0.18), rgba(255,150,50,0.07) 45%, rgba(0,0,0,0) 72%);
  opacity: 0.78;
  animation: lampBreathe 5.4s ease-in-out infinite;
}
#living-light.on { opacity: 1; }
@keyframes lampBreathe {
  0%, 100% { opacity: 0.78; }
  28%      { opacity: 1; }
  54%      { opacity: 0.69; }
  71%      { opacity: 0.9; }
}

/* Dust motes canvas */
#dust-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 6; pointer-events: none;
  opacity: 0;
  transition: opacity 2.2s ease;
}
#dust-canvas.on { opacity: 1; }

/* Scene hotspots (Room 1a study — same model as Room 3) */
.scene-hotspot {
  position: absolute; cursor: pointer; z-index: 3;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 0.5rem;
  opacity: 0; pointer-events: none;
  transition: opacity 1.4s ease;
  border-radius: 8px;
}
.scene-hotspot.revealed { opacity: 1; pointer-events: auto; }
.scene-hotspot.locked { pointer-events: none !important; }
.scene-hotspot .hs-label {
  font-family: 'Cinzel', serif; font-size: 0.62rem; letter-spacing: 0.28em;
  color: var(--amber); text-transform: uppercase;
  opacity: 0; transition: opacity 0.3s;
  text-shadow: 0 0 8px rgba(0,0,0,0.95), 0 0 3px rgba(0,0,0,0.9);
}
.scene-hotspot:hover .hs-label { opacity: 1; }
.scene-hotspot::before {
  content: ''; position: absolute; inset: 0; border-radius: 8px;
  box-shadow: inset 0 0 60px rgba(255,190,90,0);
  transition: box-shadow 0.45s ease;
}
.scene-hotspot:hover::before { box-shadow: inset 0 0 70px rgba(255,190,90,0.16); }
.scene-hotspot.pulse .hs-label { opacity: 1; animation: hsPulse 2.2s ease-in-out infinite; }
.scene-hotspot.pulse::before { animation: hsGlowPulse 2.2s ease-in-out infinite; }
@keyframes hsPulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes hsGlowPulse {
  0%,100% { box-shadow: inset 0 0 50px rgba(255,190,90,0.07); }
  50%     { box-shadow: inset 0 0 85px rgba(255,190,90,0.26); }
}

/* Room 1a narrative overlay (bottom of the scene) */
#r1a-narrative-overlay {
  position: absolute; left: 50%; bottom: calc(var(--strip-h) + 14px);
  transform: translateX(-50%);
  width: min(880px, 86%);
  z-index: 4;
  background: rgba(6,3,0,0.74);
  border: 1px solid rgba(201,162,39,0.35);
  padding: 0.9rem 1.4rem;
  opacity: 0;
  transition: opacity 1s ease;
}
#r1a-narrative-overlay.revealed { opacity: 1; }
#r1a-narrative-overlay.hidden { opacity: 0 !important; pointer-events: none; }
#r1a-reread {
  position: absolute; left: 1.4rem; bottom: calc(var(--strip-h) + 1rem); z-index: 5;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(10,5,0,0.72); border: 1px solid rgba(201,162,39,0.5);
  color: var(--amber); font-size: 1.15rem; line-height: 1;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.6s ease, background 0.2s, border-color 0.2s;
  font-family: 'Cinzel', serif;
}
#r1a-reread.show { display: flex; opacity: 0.65; }
#r1a-reread.show:hover { opacity: 1; background: rgba(35,18,0,0.9); border-color: var(--amber); }

/* Room 1a cabinet detail overlay */
#r1a-cabinet-detail {
  display: none; position: fixed; inset: 0; z-index: 90;
  box-sizing: border-box;
  padding: 56px 0 calc(var(--strip-h) + 8px); /* clear of timer bar and evidence strip */
  background: rgba(4,2,0,0.9);
  align-items: center; justify-content: center;
}
#r1a-cabinet-detail.open { display: flex; animation: fadeIn 0.5s ease forwards; }
#r1a-cabinet-detail .bookshelf-screen { width: min(1500px, 96%); margin: 0; }
#r1a-back-btn {
  position: absolute; top: 60px; left: 1.2rem; z-index: 95;
  background: rgba(10,5,0,0.85); border: 1px solid var(--amber-dark);
  color: var(--amber); font-family: 'Cinzel', serif;
  font-size: 0.68rem; letter-spacing: 0.2em;
  padding: 0.5rem 1.1rem; cursor: pointer;
  transition: all 0.25s;
}
#r1a-back-btn:hover { border-color: var(--amber); background: rgba(35,18,0,0.92); }

/* Micro-interactions — objects respond like physical things */
.btn:active { transform: translateY(1px); }
.r3-tube:not(.used) { transition: transform 0.18s ease, filter 0.18s ease; }
.r3-tube:not(.used):hover { transform: translateY(-4px) scale(1.04); filter: brightness(1.18); }
.p-tile:not(.p-empty) { transition: filter 0.15s ease; }
.p-tile:not(.p-empty):hover { filter: brightness(1.14); }
.letter-thumb { transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease; }
.letter-thumb:not(.placed):hover { box-shadow: 0 6px 18px rgba(0,0,0,0.55), 0 0 14px rgba(201,162,39,0.15); }
#inventory-strip img { transition: transform 0.18s ease, filter 0.18s ease; }
#inventory-strip img:hover { transform: translateY(-2px) scale(1.05); filter: brightness(1.2); }
/* ══ END v9 FOUNDATION ══════════════════════ */

/* ── ROOM 3 ── */
#r3-board-hotspot:hover #r3-board-hint { opacity: 1 !important; }
#r3-flask-hotspot:hover #r3-flask-hint { opacity: 1 !important; }

/* ── ROOM 3 EFFECTS (v8) ─────────────────── */
/* Effect layers over the flask — tunable independently of the drop zone.
   v10 calibration: bubbles sit lower so they stay inside the glass. */
#r3-pour-glow, #r3-success-bloom, #r3-bubbles {
  position: absolute; top: 10%; left: 36.5%; width: 24%; height: 50%;
  pointer-events: none; z-index: 4;
}
#r3-fail-flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(ellipse at 50% 55%, rgba(160,30,10,0.42), rgba(60,8,0,0.15) 60%, transparent 80%);
  opacity: 0;
}

/* Drop-zone highlight while a tube hovers over the flask */
#r3-drop-zone.drag-over {
  box-shadow: inset 0 0 44px rgba(201,162,39,0.35);
  background: radial-gradient(ellipse at center, rgba(201,162,39,0.12), transparent 70%);
  border-radius: 50% / 40%;
}

/* Pour pulse — a warm flash from within the flask at the moment of pouring */
#r3-pour-glow {
  background: radial-gradient(ellipse at 50% 62%, rgba(255,196,90,0.55), rgba(201,120,30,0.22) 55%, transparent 75%);
  opacity: 0;
}
#r3-pour-glow.pulse { animation: r3PourPulse 0.85s ease-out forwards; }
@keyframes r3PourPulse {
  0%   { opacity: 0;   transform: scale(0.82); }
  22%  { opacity: 1;   transform: scale(1.0); }
  100% { opacity: 0;   transform: scale(1.12); }
}

/* Bubbles — alive once liquid is present */
#r3-bubbles { opacity: 0; transition: opacity 0.8s ease; }
#r3-bubbles.active { opacity: 1; }
.r3-bubble {
  position: absolute; bottom: 18%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,235,200,0.85), rgba(255,215,150,0.25) 60%, transparent 75%);
  animation: r3BubbleRise linear infinite;
  opacity: 0;
}
@keyframes r3BubbleRise {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  12%  { opacity: 0.75; }
  82%  { opacity: 0.55; }
  100% { transform: translateY(-95px) scale(1.15); opacity: 0; }
}

/* Success bloom — warm light blooming from the completed tincture */
#r3-success-bloom {
  background: radial-gradient(ellipse at 50% 58%, rgba(140,220,150,0.5), rgba(201,190,60,0.28) 45%, rgba(201,162,39,0.12) 65%, transparent 80%);
  opacity: 0; transform: scale(0.8);
}
#r3-success-bloom.bloom { animation: r3Bloom 1.6s ease-out forwards, r3BloomPulse 2.6s ease-in-out 1.6s infinite; }
@keyframes r3Bloom {
  0%   { opacity: 0;    transform: scale(0.8); }
  45%  { opacity: 1;    transform: scale(1.18); }
  100% { opacity: 0.85; transform: scale(1.05); }
}
@keyframes r3BloomPulse {
  0%,100% { opacity: 0.85; transform: scale(1.05); }
  50%     { opacity: 0.6;  transform: scale(1.0); }
}

/* Failure — the table jolts, a red surge, the light dips */
#r3-table-wrap.fail-shake { animation: r3Shake 0.55s ease; }
@keyframes r3Shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-9px, 2px); }
  30% { transform: translate(8px, -3px); }
  45% { transform: translate(-6px, 3px); }
  60% { transform: translate(5px, -2px); }
  75% { transform: translate(-3px, 1px); }
}
#r3-fail-flash.flash { animation: r3FailFlash 1.1s ease-out forwards; }
@keyframes r3FailFlash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

.r3-note img:hover { opacity: 1 !important; filter: brightness(1.1) !important; transform: scale(1.03); transition: all 0.2s; }
#r3-board-lightbox.open { display: flex !important; animation: fadeIn 0.4s ease forwards; }
#r3-note-lightbox.open { display: flex !important; animation: fadeIn 0.3s ease forwards; }
#r3-flask-lightbox.open { display: flex !important; animation: fadeIn 0.4s ease forwards; }

.r3-tube {
  touch-action: none;
  width: 90px;
  height: 225px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}
.r3-tube:hover { transform: translateY(-4px) scale(1.05); }
.r3-tube.dragging { opacity: 0.4; cursor: grabbing; }
.r3-tube.used { opacity: 0.25; cursor: default; pointer-events: none; }

/* ── ROOM 3 TRANSITION VIDEO ── */
#room3-transition-video {
  display: none;
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 200;
  background: transparent;   /* the room behind shows until the first frame is drawn */
  transform-origin: 50% 50%;
}
#room3-transition-video.active { display: block; }

.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.75) 100%);
  z-index: 1;
}

.content {
  position: relative; z-index: 2;
  width: 100%; max-width: 1200px;
  padding: 1rem 2rem 1rem;
  padding-top: 56px;
  text-align: center;
}

/* ── TIMER ── */
#timer-bar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 450; /* above puzzle lightboxes (300) and letter modal (400);
                   below transition fades (500) and inventory (700) */
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 2rem;
  background: rgba(10,5,0,0.9);
  border-bottom: 1px solid var(--amber-dark);
}
#timer-bar.visible { display: flex; }
#timer-display {
  font-family: 'Special Elite', monospace;
  font-size: 1.4rem;
  color: var(--amber);
  letter-spacing: 0.1em;
}
#timer-display.urgent { color: var(--red-seal); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
#room-indicator {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--parchment);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
/* ── HINT AREA — fixed bottom right ── */
#hint-area {
  position: absolute;
  bottom: calc(var(--strip-h) + 0.8rem);
  right: 1.5rem;
  z-index: 460; /* above all puzzle lightboxes (300-450), below transition fades (500) */
  display: none; /* shown by JS when timer starts */
  align-items: flex-end;
  gap: 0.8rem;
}
#hint-area.visible { display: flex; }

#hint-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.3s, filter 0.3s;
  flex-shrink: 0;
}
#hint-btn img {
  height: 90px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 8px rgba(201,162,39,0.35));
  transition: filter 0.3s;
}
#hint-btn:disabled { opacity: 0.22; cursor: not-allowed; }
#hint-btn:not(:disabled):hover img {
  filter: drop-shadow(0 0 16px rgba(201,162,39,0.85));
}

/* Hint text box — slides in to the left of the button */
#hint-display {
  display: none;
  position: relative;
  max-width: min(480px, calc(60 * var(--vw, 1vw)));
  background: rgba(10,8,4,0.95);
  border: 1px solid var(--amber-dark);
  border-radius: 2px;
  padding: 1rem 2rem 1rem 1.1rem;
  box-shadow: 0 0 40px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.4);
  animation: fadeIn 0.4s ease forwards;
  margin-bottom: 1.5rem;
}
#hint-display.visible { display: block; }
#hint-display-text {
  font-family: 'IM Fell English', serif;
  font-size: 1.2rem;
  line-height: 1.75;
  color: var(--parchment-light);
  font-style: italic;
}
#hint-display-close {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--amber-dark);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  opacity: 0.6;
  padding: 0;
}
#hint-display-close:hover { opacity: 1; }

/* ── TYPOGRAPHY ── */
.title-main {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, calc(5 * var(--vw, 1vw)), 3.5rem);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-shadow: 0 0 40px rgba(201,162,39,0.4);
  line-height: 1.1;
  margin-bottom: 0.3rem;
}
.title-sub {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.75rem, calc(1.5 * var(--vw, 1vw)), 1rem);
  letter-spacing: 0.35em;
  color: var(--parchment);
  text-transform: uppercase;
  margin-bottom: 2rem;
}
.room-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.2rem, calc(3 * var(--vw, 1vw)), 1.8rem);
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.room-subtitle {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--amber);
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.narrative {
  font-size: clamp(0.9rem, calc(1.5 * var(--vw, 1vw)), 1.05rem);
  line-height: 1.85;
  color: var(--parchment-light);
  max-width: 860px;
  margin: 0 auto 1.2rem;
}
.narrative em { color: var(--amber); font-style: italic; }

/* ── INTRO SCREEN — larger text ── */
#screen-intro .narrative {
  font-size: clamp(1.05rem, calc(1.8 * var(--vw, 1vw)), 1.2rem);
  line-height: 2;
}
#screen-intro .title-sub {
  font-size: clamp(0.85rem, calc(1.6 * var(--vw, 1vw)), 1.05rem);
}

/* ── ROOM 1A — larger text ── */
#screen-room1a .narrative {
  font-size: 1.15rem;
  line-height: 2;
}
#screen-room1a .room-subtitle {
  font-size: 0.95rem;
  letter-spacing: 0.28em;
}
#screen-room1a .lock-label {
  font-size: 0.9rem;
  letter-spacing: 0.18em;
}
#screen-room1a #lock-feedback {
  font-size: 1.15rem;
  font-style: normal;
}
#screen-room1a .seq-instruction {
  font-size: 1.2rem;
  line-height: 1.9;
  font-style: normal;
}
#screen-room1a .book-response {
  font-size: 1.2rem;
  font-style: normal;
}
#screen-room1a #proceed-block p {
  font-size: 1.2rem;
}
#screen-room1a .feedback {
  font-size: 1.15rem;
  font-style: normal;
}
#screen-room1a .btn {
  font-size: 0.95rem;
}

/* ── ROOM 1B — larger text ── */
#screen-room1 .room-title {
  font-size: clamp(1.4rem, calc(3 * var(--vw, 1vw)), 2rem);
}
#screen-room1 .room-subtitle {
  font-size: 0.95rem;
  letter-spacing: 0.28em;
}
#screen-room1 .narrative {
  font-size: 1.15rem;
  line-height: 2;
}
#screen-room1 .panel p {
  font-size: 1.1rem;
  line-height: 1.85;
}
#screen-room1 .panel > div:first-child {
  font-size: 0.88rem;
  letter-spacing: 0.18em;
}
#screen-room1 .cipher-input {
  font-size: 1.2rem;
}
#screen-room1 .feedback {
  font-size: 1.15rem;
  font-style: normal;
}
#screen-room1 .btn {
  font-size: 0.95rem;
}

/* ── DIVIDER ── */
.ornament {
  display: flex; align-items: center; gap: 1rem;
  margin: 1rem auto;
  max-width: 400px;
}
.ornament::before, .ornament::after {
  content: ''; flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--amber-dark));
}
.ornament::after { background: linear-gradient(to left, transparent, var(--amber-dark)); }
.ornament span { color: var(--gold); font-size: 1rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-block;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.75rem 2.5rem;
  border: 1px solid var(--amber);
  background: transparent;
  color: var(--parchment-light);
  cursor: pointer;
  transition: all 0.3s;
  margin: 0.3rem;
}
.btn:hover { background: rgba(201,162,39,0.15); border-color: var(--gold); color: var(--gold); }
.btn-primary {
  background: rgba(139,69,19,0.3);
  border-color: var(--gold);
  color: var(--gold);
}
.btn-primary:hover { background: rgba(201,162,39,0.25); }

/* ── INPUT ── */
.input-group {
  display: flex; gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.cipher-input {
  font-family: 'Special Elite', monospace;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  padding: 0.6rem 1rem;
  background: rgba(10,5,0,0.7);
  border: 1px solid var(--amber-dark);
  color: var(--parchment-light);
  width: 200px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.3s;
}
.cipher-input:focus { border-color: var(--gold); }
.cipher-input.error { border-color: var(--red-seal); animation: shake 0.4s; }
.cipher-input.correct { border-color: #4a7a4a; }
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)}
}

/* ── FEEDBACK ── */
.feedback {
  font-family: 'IM Fell English', serif;
  font-size: 0.9rem;
  font-style: italic;
  min-height: 1.5rem;
  margin: 0.5rem 0;
  transition: all 0.3s;
}
.feedback.error { color: #c97a7a; }
.feedback.success { color: #7ac97a; }
.feedback.hint { color: var(--amber); }

/* ── PANELS ── */
.panel {
  background: rgba(10,5,0,0.82);
  border: 1px solid var(--amber-dark);
  padding: 1.5rem 2rem;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute; inset: 4px;
  border: 1px solid rgba(201,162,39,0.15);
  pointer-events: none;
}

/* ── CIPHER TABLE ── */

/* ── LETTERS ── */
/* ── ROOM 2 — three-column layout, two phases ── */
#screen-room2 { overflow: hidden; }

/* LEFT — narrative column */

/* MIDDLE — letters / bureau */

/* ── LETTER THUMBNAILS — 3-2 grid ── */

.letter-thumb {
  touch-action: none;
  aspect-ratio: 3/4;
  background-size: cover; background-position: center;
  border: 2px solid transparent;
  cursor: grab;
  transition: border-color 0.3s, transform 0.2s, opacity 0.2s;
  position: relative; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.letter-thumb:hover { border-color: var(--amber); transform: translateY(-3px); }
.letter-thumb.dragging { opacity: 0.4; cursor: grabbing; transform: scale(0.96); }
.letter-thumb.placed { border-color: rgba(201,162,39,0.3); opacity: 0.4; }
.letter-read-hint {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(10,5,0,0.82); color: var(--amber-dark);
  font-family: 'Cinzel', serif; font-size: 0.42rem;
  letter-spacing: 0.12em; padding: 2px 4px;
  border: 1px solid rgba(139,69,19,0.35);
  pointer-events: none; text-transform: uppercase;
}

/* RIGHT — drop slots (phase 1) */

.seq-slot {
  width: 100%; height: 64px;
  background: rgba(10,5,0,0.55);
  border: 1px dashed var(--amber-dark);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 0.68rem;
  color: var(--amber-dark);
  transition: all 0.22s; position: relative; border-radius: 2px;
}
.seq-slot.drag-over {
  border-color: var(--gold); background: rgba(201,162,39,0.14);
  box-shadow: 0 0 14px rgba(201,162,39,0.35);
}
.seq-slot.filled { border-color: var(--amber); background: rgba(201,162,39,0.07); }
.seq-slot .slot-thumb {
  width: 100%; height: 100%;
  background-size: cover; background-position: center; position: relative;
  cursor: grab;
}
.seq-slot .slot-thumb.dragging { opacity: 0.4; cursor: grabbing; }
.seq-slot .slot-num {
  position: absolute; top: 2px; left: 4px;
  background: rgba(10,5,0,0.85); color: var(--amber);
  font-family: 'Cinzel', serif; font-size: 0.5rem;
  padding: 1px 4px; border: 1px solid var(--amber-dark);
  pointer-events: none;
}
.seq-slot .slot-remove {
  position: absolute; top: 2px; right: 3px;
  background: rgba(10,5,0,0.8); color: var(--amber-dark);
  font-size: 0.8rem; cursor: pointer; padding: 3px 7px;
  border: none; line-height: 1; transition: color 0.2s;
  font-family: 'Cinzel', serif; z-index: 3;
}
.seq-slot .slot-remove:hover { color: var(--red-seal); }
.seq-label {
  position: absolute; bottom: -14px; left: 0; right: 0;
  font-size: 0.48rem; color: var(--amber-dark);
  letter-spacing: 0.12em; white-space: nowrap;
  text-align: center; font-family: 'Cinzel', serif; text-transform: uppercase;
}
.room2-pos-num {
  color: var(--amber-dark); font-size: 0.6rem; letter-spacing: 0.1em;
}

/* ── DRAG GHOST ── */

/* ── PHASE 2: bureau lock (middle) ── */

.lock-image-wrap {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto;
}
.lock-image-wrap img {
  width: 100%; display: block;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 30px rgba(0,0,0,0.7);
}
.dial-overlays {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.dial-wrap {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: all;
  display: flex; flex-direction: column; align-items: center;
  gap: 1px; cursor: pointer; user-select: none;
}
.dial-up, .dial-down {
  width: 34px; height: 20px;
  cursor: pointer; touch-action: manipulation;
  background: rgba(10,5,0,0.55);
  border: 1px solid rgba(139,69,19,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem; color: var(--amber-dark);
  transition: background 0.15s, color 0.15s; line-height: 1;
}
.dial-up:hover, .dial-down:hover { background: rgba(139,69,19,0.4); color: var(--gold); }
.dial-face {
  width: 34px; height: 26px;
  background: rgba(5,2,0,0.82);
  border: 1px solid rgba(201,162,39,0.3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(201,162,39,0.7);
  transition: color 0.1s;
}
.dial-wrap.shake { animation: shake 0.4s ease; }
#room2-lock-submit { max-width: 280px; width: 100%; }

/* ── PHASE 2: reference thumbnails (right) ── */

/* ── LETTER MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 400; display: none;
  align-items: center; justify-content: center;
  box-sizing: border-box;
  padding: 56px 1rem calc(var(--strip-h) + 8px);
}
.modal-overlay.open { display: flex; }
.letter-modal {
  width: 100%; max-width: min(820px, 92%); max-height: 100%;
  aspect-ratio: 3/4;
  background-size: contain; background-position: center; background-repeat: no-repeat;
  position: relative; overflow: hidden;
}
.modal-close {
  position: absolute; top: 0.5rem; right: 0.8rem;
  background: rgba(10,5,0,0.7); border: 1px solid var(--amber-dark);
  font-size: 1.1rem; cursor: pointer; color: var(--parchment-light);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-family: 'Cinzel', serif;
}
.modal-close:hover { background: rgba(139,69,19,0.5); border-color: var(--gold); }

/* ══ ROOM 2 — v5 SCENE-FIRST ══════════════════ */
/* Overview scene hotspots */
#r2-overview { position: relative; z-index: 2; width: 100%; height: 100%; }
#r2-table-hotspot { cursor: pointer; }
#r2-bureau-hotspot { cursor: default; }
#r2-bureau-hotspot.active { cursor: pointer; }
#r2-table-hotspot:hover #r2-table-hint,
#r2-bureau-hotspot:hover #r2-bureau-hint { opacity: 1 !important; }
.hotspot-hint {
  font-family: 'Cinzel', serif; font-size: 0.6rem; letter-spacing: 0.24em;
  color: var(--amber); opacity: 0; transition: opacity 0.35s;
  text-transform: uppercase; background: rgba(8,4,0,0.6);
  padding: 0.32rem 0.75rem; border: 1px solid var(--amber-dark);
  white-space: nowrap;
}
.r2-room-label {
  position: absolute; bottom: calc(var(--strip-h) + 14px); left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel', serif; font-size: 0.65rem; letter-spacing: 0.3em;
  color: var(--amber-dark); z-index: 3; text-transform: uppercase;
}
.r2-entry-narrative {
  position: absolute; top: 6.5%; left: 50%; transform: translateX(-50%);
  width: min(700px, 82%); text-align: center; z-index: 4;
  font-family: 'IM Fell English', serif; font-size: 1.04rem; line-height: 1.85;
  color: var(--parchment-light);
  background: rgba(8,4,0,0.7); padding: 1.05rem 1.6rem;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 34px rgba(0,0,0,0.6);
  transition: opacity 1s ease;
}
.r2-entry-narrative em { color: var(--amber); font-style: italic; }

/* Shared lightbox chrome */
#r2-letters-lightbox.open, #r2-bureau-lightbox.open {
  display: flex !important; animation: fadeIn 0.4s ease forwards;
}
.r2-lightbox-close {
  position: absolute; top: 4rem; right: 2rem; background: none; border: none;
  color: var(--parchment-light); font-size: 2rem; cursor: pointer; z-index: 301;
  font-family: 'Cinzel', serif; opacity: 0.7; transition: opacity 0.2s;
}
.r2-lightbox-close:hover { opacity: 1; }

/* Solved state: the order is locked evidence — only reading remains */
#r2-letters-lightbox.solved .r2-desk-controls { display: none; }
#r2-letters-lightbox.solved .slot-remove { display: none; }
#r2-letters-lightbox.solved .r2-staging-row { display: none; }

/* Letters lightbox — the writing desk */
.r2-desk-wrap { position: relative; width: min(92%, 1460px); }
.r2-desk-wrap > img {
  width: 100%; height: auto; display: block;
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}
.r2-desk-instruction {
  position: absolute; top: 3.5%; left: 50%; transform: translateX(-50%);
  width: 74%; text-align: center; z-index: 6;
  font-family: 'IM Fell English', serif; font-size: 0.92rem; line-height: 1.6;
  color: var(--parchment-light); text-shadow: 0 1px 4px #000;
}
.r2-desk-instruction em { color: var(--amber); font-style: italic; }

/* Working area over the green leather pad */
.r2-pad-zone {
  position: absolute; left: 26%; top: 27%; width: 48%; height: 55%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  z-index: 5;
}
.r2-staging-row {
  display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap;
  min-height: 160px;
}
.r2-slots-label {
  font-family: 'Cinzel', serif; font-size: 0.56rem; letter-spacing: 0.24em;
  color: var(--gold); text-transform: uppercase; text-shadow: 0 1px 3px #000;
  margin-bottom: 0.35rem;
}
.r2-slots-row { display: flex; gap: 0.7rem; justify-content: center; align-items: flex-end; }
.r2-slots-row .seq-slot { width: 122px; height: 160px; }
.r2-staging-row .letter-thumb { width: 118px; height: 157px; aspect-ratio: auto; }

.r2-desk-controls {
  position: absolute; bottom: 2%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 0.7rem; z-index: 6; flex-wrap: wrap; width: min(640px, 80%);
}
.r2-desk-controls .btn { width: auto; min-width: 170px; }
.r2-desk-controls .feedback { flex-basis: 100%; margin: 0; }

/* Bureau lightbox — the combination lock */
.r2-bureau-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; width: min(90%, 560px); height: 100%;
  justify-content: center; overflow: hidden;
}
/* The lock image is the flexible element: it shrinks so that the
   instruction, dials, and Unlock button always fit without scrolling. */
.r2-bureau-inner .lock-image-wrap {
  flex: 0 1 auto; min-height: 0;
  width: auto; max-width: min(100%, 480px);
  display: flex; align-items: center; justify-content: center;
}
.r2-bureau-inner .lock-image-wrap img {
  max-height: 100%; width: auto; max-width: 100%;
  object-fit: contain; min-height: 0;
}
.r2-bureau-inner .r2-bureau-instruction,
.r2-bureau-inner #room2-lock-submit,
.r2-bureau-inner .feedback { flex: 0 0 auto; }
.r2-bureau-instruction {
  font-family: 'IM Fell English', serif; font-size: 1rem; line-height: 1.75;
  color: var(--parchment-light); text-align: center; max-width: 480px;
}
.r2-bureau-instruction em { color: var(--amber); font-style: italic; }

#room2-lock-submit { max-width: 280px; width: 100%; }

/* ── LAB VALUES ── */

/* ── CONCLUSION ── */

/* ── FINAL LETTER ── */

/* ── NOTIFICATION ── */
#notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  background: rgba(10,5,0,0.97);
  border: 1px solid var(--amber-dark);
  color: var(--parchment-light);
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 1.15rem;
  padding: 1.4rem 2.8rem;
  z-index: 600;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  text-align: center;
  max-width: min(520px, calc(80 * var(--vw, 1vw)));
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}
#notification.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
#notification.error-notif { border-color: var(--red-seal); color: #e8a0a0; }
#notification.success-notif { border-color: #4a7a4a; }

/* ── SCROLL ── */

/* ── FADE ── */
.fade-in { animation: fadeIn 1.2s ease forwards; }
@keyframes fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.fade-in-slow { animation: fadeIn 2s ease forwards; }

#screen-room1 .content {
  max-width: 100%;
  padding-left: 1.2rem;
  padding-right: 1.2rem;
  margin-left: 1rem;
  margin-right: 1rem;
  width: calc(100% - 2rem);
}

/* ── ROOM 1 TWO-COLUMN LAYOUT ── */
.room1-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.5rem;
  align-items: start;
  text-align: left;
  max-height: calc(72 * var(--vh, 1vh));
  width: 100%;
  overflow: hidden;
}
.room1-left {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}
/* Solved: only the heading and the narrated answer stay in the panel */
#screen-room1 .panel.solved > p,
#screen-room1 .panel.solved .input-group,
#screen-room1 .panel.solved .btn { display: none; }
#screen-room1 .panel.solved .feedback { margin-top: 0 !important; }

.room1-right {
  overflow-y: auto;
  max-height: calc(80 * var(--vh, 1vh));
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dark) transparent;
  min-width: 0;
}

/* ── BOOKSHELF STAGE ── */
/* Bookshelf screen — always two-column */
.bookshelf-screen {
  position: relative; z-index: 2;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 56px 1.2rem 1rem;
  margin-left: 1rem;
  margin-right: 1rem;
  width: calc(100% - 2rem);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1.5rem;
}
.bookshelf-text-block {
  width: 400px;
  max-width: 400px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  flex-shrink: 0;
  position: sticky;
  top: 56px;
}

/* Books container — always fills right column */
.books-container {
  position: relative;
  width: 100%;
  flex: 1;
  height: calc(calc(100 * var(--vh, 1vh)) - 120px);
  min-height: 340px;
  max-height: 680px;
  overflow: hidden;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  flex-shrink: 0;
}
.books-container img.shelf-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  filter: brightness(0.92);
  z-index: 0;
}
.book-spine {
  position: absolute;
  top: 15%;
  cursor: pointer;
  transition: background 0.3s;
  border-radius: 2px;
  z-index: 1;
}
.book-spine:hover {
  background: rgba(201,162,39,0.2);
  outline: 2px solid rgba(201,162,39,0.5);
}

/* Book response — selected book confirmation */
.book-response {
  font-family: 'IM Fell English', serif;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--gold);
  line-height: 1.6;
  transition: opacity 0.4s;
  min-height: 1.2rem;
  text-align: left;
}

/* ── CANDLE FLASH OVERLAY ── */
#candle-flash {
  position: absolute; inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
}
/* Two layers: warm flare on top, darkness underneath */
#candle-flash::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 48% 40%, rgba(255,210,100,0.72) 0%, rgba(180,100,20,0.35) 40%, rgba(0,0,0,0) 75%);
}
#candle-flash::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
  opacity: 0;
}
@keyframes candleFlash {
  /* flare up */
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  /* snuff — room goes nearly black */
  22%  { opacity: 0.15; }
  /* darkness holds */
  38%  { opacity: 0.08; }
  /* second smaller flare */
  52%  { opacity: 0.7; }
  68%  { opacity: 0.1; }
  /* settle */
  100% { opacity: 0; }
}
@keyframes candleDark {
  0%,8%  { opacity: 0; }
  /* darkness phase */
  22%    { opacity: 1; }
  38%    { opacity: 0.95; }
  52%    { opacity: 0; }
  100%   { opacity: 0; }
}
#candle-flash.flash         { animation: candleFlash 1.4s ease forwards; }
#candle-flash.flash::after  { animation: candleDark  1.4s ease forwards; }
@keyframes spineShake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-5px); }
  40%,80%  { transform: translateX(5px); }
}
@keyframes spinePulse {
  0%   { outline: 2px solid rgba(201,162,39,0);   background: rgba(201,162,39,0);    transform: scaleX(1);    }
  30%  { outline: 3px solid rgba(201,162,39,0.85); background: rgba(201,162,39,0.25); transform: scaleX(1.04); }
  100% { outline: 2px solid rgba(201,162,39,0.2);  background: rgba(201,162,39,0.1);  transform: scaleX(1);    }
}
.book-spine.wrong   { animation: spineShake 0.4s ease forwards; }
.book-spine.correct { animation: spinePulse 0.6s ease forwards; pointer-events: none; }

/* ── GO-TO-DESK BUTTON ── */

/* ── INTRO PORTRAIT LAYOUT ── */
.intro-portrait-wrap {
  position: absolute;
  left: calc(3 * var(--vw, 1vw));
  top: 50%;
  transform: translateY(-50%);
  width: clamp(160px, calc(18 * var(--vw, 1vw)), 260px);
  z-index: 3;
}
.intro-portrait-wrap.right {
  left: auto;
  right: calc(3 * var(--vw, 1vw));
}
.intro-portrait {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 30px rgba(0,0,0,0.7);
  filter: brightness(0.9);
  display: block;
}
.intro-portrait-caption {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--amber-dark);
  text-align: center;
  margin-top: 0.4rem;
  text-transform: uppercase;
}

/* ── INTRO REVEAL SEQUENCE ── */
.intro-hidden { opacity: 0; pointer-events: none; }

@keyframes titlePulse {
  0%,100% { text-shadow: 0 0 40px rgba(201,162,39,0.4); }
  50%     { text-shadow: 0 0 60px rgba(201,162,39,0.75), 0 0 120px rgba(201,162,39,0.2); }
}
#intro-title-clickable {
  cursor: pointer;
  animation: titlePulse 3s ease-in-out infinite;
  transition: opacity 0.4s;
}
#intro-title-clickable:hover { opacity: 0.85; }

.intro-reveal {
  animation: fadeIn 1.2s ease forwards;
}
.intro-reveal-slow {
  animation: fadeIn 1.8s ease forwards;
}

/* portrait reveal */
.intro-portrait-wrap { opacity: 0; }

/* ── INTRO: PURE BLACK ── */
#screen-intro { overflow-y: hidden; background: #000; }

/* ── INTRO: TITLE FULL IMAGE (full screen cover) ── */
#intro-title-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  z-index: 1; opacity: 0; pointer-events: none;
  transition: opacity 3s ease;
  transform: scale(1.08);
}
#intro-title-bg.visible { opacity: 1; }

/* ── INTRO: START BUTTON IMAGE ── */
#intro-start-btn {
  position: absolute;
  left: 50%; top: 70%;
  transform: translateX(-50%);
  width: min(260px, calc(34 * var(--vw, 1vw)));
  z-index: 3; opacity: 0; cursor: pointer;
  transition: opacity 1.0s ease;
}
#intro-start-btn.visible { opacity: 1; }
@keyframes startPulse {
  0%,100% { filter: brightness(0.75); }
  50%     { filter: brightness(1.5); }
}
#intro-start-btn.glowing { animation: startPulse 2.2s ease-in-out infinite; }

/* ── INTRO: FADE OVERLAY (blacks out content before door) ── */
#intro-fade-overlay {
  position: absolute; inset: 0;
  background: #000;
  z-index: 4; opacity: 0;
  pointer-events: none;
  transition: opacity 2.5s ease;
}

/* ── INTRO: DOOR ENTER IMAGE (full screen, beat 3) ── */
#intro-door-enter {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  z-index: 5; opacity: 0; cursor: pointer;
  pointer-events: none;
  transition: opacity 2.5s ease;
}
#intro-door-enter.visible { opacity: 1; pointer-events: auto; }

/* ── INTRO: CONTENT POSITION (text phase) ── */
#screen-intro .content { padding-top: calc(10 * var(--vh, 1vh)); }

/* ── INTRO TEXT FADE-OUT ── */
.intro-fadeout {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 2.5s ease !important;
}
#screen-room4 .bg {
  background-image: url('../assets/img/room4/r4-hall-desk.webp');
  background-position: center center;
}

/* ── ANATOMICAL PLATE LIGHTBOX ── */
#poster-lightbox {
  display: none;
  position: absolute; inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
}
#poster-lightbox.open { display: flex; animation: fadeIn 0.3s ease forwards; }
#poster-lightbox img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}
#poster-lightbox-close {
  position: absolute; top: 1.5rem; right: 2rem;
  background: none; border: none;
  color: var(--parchment-light); font-size: 2rem;
  cursor: pointer; z-index: 401; line-height: 1;
  font-family: 'Cinzel', serif;
  opacity: 0.7; transition: opacity 0.2s;
}
#poster-lightbox-close:hover { opacity: 1; }

/* ── BOOKCASE LOCK INPUT ── */
#bookcase-lock {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
#bookcase-lock.visible { display: flex; animation: fadeIn 0.5s ease forwards; }
.lock-inputs { display: flex; gap: 0.5rem; align-items: center; }
.lock-input {
  width: 2.8rem; height: 2.8rem;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  text-transform: uppercase;
  background: rgba(10,5,0,0.7);
  border: 1px solid var(--amber-dark);
  color: var(--gold);
  caret-color: var(--gold);
  border-radius: 2px;
}
.lock-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 8px rgba(201,162,39,0.4); }
.lock-input.error { animation: spineShake 0.4s ease forwards; border-color: var(--red-seal); }
.lock-label {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--amber-dark);
  text-transform: uppercase;
}
#lock-feedback {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--parchment-light);
  min-height: 1.2rem;
  text-align: center;
}

/* ── END SCREEN — MARA PORTRAIT ── */

/* ── INVENTORY STRIP ── */
#inventory-strip {
  display: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 700;
  background: rgba(10,5,0,0.92);
  border-top: 1px solid var(--amber-dark);
  height: var(--strip-h);
  padding: 0 1.5rem 0.55rem;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}
#inventory-strip.visible { display: flex; }
.inventory-label {
  font-family: 'Cinzel', serif;
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  color: var(--amber-dark);
  text-transform: uppercase;
  white-space: nowrap;
}
.inventory-items {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.inv-item {
  width: 60px; height: 45px;
  touch-action: none;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--amber-dark);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}
.inv-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.inv-item-label {
  position: absolute;
  bottom: -13px;
  left: 0; right: 0;
  font-family: 'Cinzel', serif;
  font-size: 0.45rem;
  letter-spacing: 0.12em;
  color: var(--amber-dark);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

/* ── EVIDENCE LIGHTBOX ── */
#evidence-lightbox {
  display: none;
  position: absolute; inset: 0;
  z-index: 440; /* below HUD so the timer stays visible while reading */
  box-sizing: border-box;
  padding: 56px 0 calc(var(--strip-h) + 8px);
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease forwards;
}
#evidence-lightbox.open { display: flex; }
#evidence-lightbox img {
  max-width: 55%;
  max-height: 88%;
  object-fit: contain;
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}

/* ── R4 EFFECTS (v9/v12) — the power shift ── */
/* The three portraits carry the arc. No grayscale on the final state —
   the verslagen portrait (bowed head, downcast eyes, smaller frame) IS the
   collapse; only a faint light dip underlines it. */
#r4-pryce.defeated {
  filter: drop-shadow(-8px 0 24px rgba(0,0,0,0.8)) brightness(0.9) !important;
  transform: scale(0.985) translateY(6px);
}
/* Evidence flash: laid on the table, then settles away */
#r4-evidence-flash.show { display: flex !important; animation: r4EvidenceIn 1.5s ease forwards; }
@keyframes r4EvidenceIn {
  0%   { opacity: 0; transform: scale(0.75); }
  16%  { opacity: 1; transform: scale(1.02); }
  24%  { transform: scale(1.0); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: scale(0.97); }
}

/* ── R4 DROP ZONE ── */
#r4-drop-zone {
  width: 220px; height: 160px;
  border: 2px dashed var(--amber-dark);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: crosshair;
}
#r4-drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(201,162,39,0.1);
}
.inv-item.draggable-evidence { cursor: grab; }
.inv-item.draggable-evidence:active { cursor: grabbing; opacity: 0.6; }
#diary-note-lightbox {
  display: none;
  position: absolute; inset: 0;
  z-index: 450;
  background: rgba(0,0,0,0.9);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
}
#diary-note-lightbox.open { display: flex; animation: fadeIn 0.4s ease forwards; }
#diary-note-lightbox img {
  max-width: calc(88 * var(--vw, 1vw));
  max-height: calc(78 * var(--vh, 1vh));
  object-fit: contain;
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}
#diary-note-close {
  position: absolute; top: 1.5rem; right: 2rem;
  background: none; border: none;
  color: var(--parchment-light); font-size: 2rem;
  cursor: pointer; z-index: 451; line-height: 1;
  font-family: 'Cinzel', serif;
  opacity: 0.7; transition: opacity 0.2s;
}
#diary-note-close:hover { opacity: 1; }
#stop-narration-btn {
  display: none;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  padding: 0.35rem 1.1rem;
  background: transparent;
  border: 1px solid var(--amber-dark);
  color: var(--amber-dark);
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s;
  z-index: 451;
  flex-shrink: 0;
}
#stop-narration-btn.visible { display: inline-block; }
#stop-narration-btn:hover { border-color: var(--amber); color: var(--amber); }

/* ── CIPHER BOOK LIGHTBOX ── */
#cipher-book-lightbox {
  display: none;
  position: absolute; inset: 0;
  z-index: 450;
  background: rgba(0,0,0,0.9);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#cipher-book-lightbox.open { display: flex; animation: fadeIn 0.4s ease forwards; }
#cipher-book-lightbox img {
  max-width: calc(88 * var(--vw, 1vw));
  max-height: calc(84 * var(--vh, 1vh));
  object-fit: contain;
  box-shadow: 0 0 60px rgba(0,0,0,0.9);
}
#cipher-book-close {
  position: absolute; top: 1.5rem; right: 2rem;
  background: none; border: none;
  color: var(--parchment-light); font-size: 2rem;
  cursor: pointer; z-index: 451; line-height: 1;
  font-family: 'Cinzel', serif;
  opacity: 0.7; transition: opacity 0.2s;
}
#cipher-book-close:hover { opacity: 1; }

/* ── INVENTORY NEW ITEM GLOW ── */
@keyframes invGlow {
  0%   { box-shadow: 0 0 0px rgba(201,162,39,0);    border-color: var(--amber-dark); }
  20%  { box-shadow: 0 0 18px rgba(201,162,39,0.9); border-color: var(--gold); }
  60%  { box-shadow: 0 0 12px rgba(201,162,39,0.6); border-color: var(--gold); }
  100% { box-shadow: 0 0 0px rgba(201,162,39,0);    border-color: var(--amber-dark); }
}
.inv-item.new-item {
  animation: invGlow 2.4s ease forwards;
}

/* ── INVENTORY FLY-IN GHOST ── */
#inv-fly-ghost {
  position: absolute;
  z-index: 505;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--amber);
  box-shadow: 0 0 40px rgba(201,162,39,0.5);
  transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
}

/* ── ROOM 1A TIMED REVEALS ── */
#room1a-text-block  { opacity: 0; transition: opacity 1.2s ease; }
#room1a-text-block.revealed  { opacity: 1; }

.books-container    { opacity: 0; filter: brightness(0); transition: opacity 2.5s ease, filter 2.5s ease; }
.books-container.revealed    { opacity: 1; filter: brightness(0.92); }

/* ── EMBEDDED ANATOMICAL PLATES ── */

.book-spine.queued {
  background: rgba(201,162,39,0.18);
  outline: 2px solid rgba(201,162,39,0.6);
}
.book-sequence-indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--ink);
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.seq-instruction {
  font-family: 'IM Fell English', serif;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--amber);
  text-align: left;
  margin-top: 0.6rem;
  line-height: 1.6;
  min-height: 1rem;
}
/* Confirm sequence button */
#confirm-sequence-btn {
  display: none;
  margin-top: 0.8rem;
  width: 100%;
  text-align: center;
}
#confirm-sequence-btn.visible { display: inline-block; animation: fadeIn 0.4s ease forwards; }

/* ── DOOR SCREEN ── */
#screen-door .bg,
#screen-puzzle .bg {
  background-image: url('../assets/img/room1/r1-door.webp');
  background-position: center center;
}
#screen-door.door-open-mode .bg {
  background-image: url('../assets/img/room1/r1-door-open.webp');
}
#screen-door.door-open-mode .door-layout { display: none !important; }
.door-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.5rem;
  align-items: start;
  width: calc(100% - 2rem);
  max-width: 100%;
  padding: 56px 1.2rem 1rem;
  margin: 0 1rem;
  position: relative; z-index: 2;
}
.door-left {
  display: flex; flex-direction: column;
  gap: 1rem;
  position: sticky; top: 56px;
}
.door-right {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(calc(100 * var(--vh, 1vh)) - 120px);
}
/* Key clickable object in left column */
.door-key-object {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--amber-dark);
  background: rgba(10,5,0,0.75);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}
.door-key-object:hover {
  border-color: var(--gold);
  background: rgba(201,162,39,0.08);
}
.door-key-object.used {
  opacity: 0.35; cursor: default; pointer-events: none;
}
.door-key-thumb {
  width: 56px; height: 56px;
  background-image: url('../assets/img/evidence/ev-journal-key.webp');
  background-size: contain; background-position: center; background-repeat: no-repeat;
  flex-shrink: 0;
  border: 1px solid var(--amber-dark);
  animation: keyFloat 2.5s ease-in-out infinite;
}
.door-key-thumb.used { animation: none; }
@keyframes keyFloat {
  0%,100% { transform: rotate(-12deg) translateY(0); }
  50%      { transform: rotate(-12deg) translateY(-4px); }
}
.door-key-text {
  font-family: 'IM Fell English', serif;
  font-size: 0.9rem; font-style: italic;
  color: var(--parchment); line-height: 1.6;
}
/* Door image in right column — atmospheric */
.door-image-wrap {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1;
  background-image: url('../assets/img/room1/r1-door.webp');
  background-size: cover; background-position: center;
  border: 1px solid var(--amber-dark);
  box-shadow: 0 0 60px rgba(0,0,0,0.7);
  filter: brightness(0.9);
  position: relative;
}
/* Beat 3 — door opened state */
.door-image-wrap.opened {
  filter: brightness(1.1);
  box-shadow: 0 0 80px rgba(201,162,39,0.3), 0 0 30px rgba(0,0,0,0.5);
  transition: filter 1s ease, box-shadow 1s ease;
}

/* ── PUZZLE SCREEN ── */
/* Same grid as door screen so puzzle sits in identical position to door-image-wrap */
.puzzle-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.5rem;
  align-items: start;
  width: calc(100% - 2rem);
  max-width: 100%;
  padding: 56px 1.2rem 1rem;
  margin: 0 1rem;
  position: relative; z-index: 2;
}
.puzzle-left {
  display: flex; flex-direction: column;
  gap: 1rem;
  position: sticky; top: 56px;
}
/* Right column matches door-right exactly */
.puzzle-right {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(calc(100 * var(--vh, 1vh)) - 120px);
}
/* Puzzle frame + H reveal sized identically to door-image-wrap */
#puzzle-grid-wrap-outer {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
/* Scale puzzle frame to fill the same square as door-image-wrap */
#puzzle-grid-wrap-outer .puzzle-frame {
  /* Override fixed 492px — scale to container instead */
  width: 100%;
  aspect-ratio: 1;
  padding: 6px;
}
#puzzle-grid-wrap-outer .puzzle-grid-wrap {
  width: 100%;
  height: 100%;
}
/* Tiles scale with the container via CSS custom properties set by JS */
/* Beat 3 — reward text in left column */
#puzzle-beat3 {
  display: none;
  flex-direction: column; gap: 0.8rem;
}
#puzzle-beat3.show { display: flex; animation: fadeIn 0.8s ease forwards; }

/* Puzzle solved — H image: same size as door-image-wrap */
#puzzle-h-reveal {
  display: none;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1;
  background-size: cover; background-position: center;
  border: 2px solid rgba(201,162,39,.45);
  box-shadow: 0 0 60px rgba(201,162,39,.2);
  animation: riseIn .7s ease forwards, imgGlow 3s ease-in-out 1.5s infinite;
}
#puzzle-h-reveal.show { display: block; }

/* ── DOOR + PUZZLE TEXT SIZES — match other rooms ── */
#screen-door .room-subtitle,
#screen-puzzle .room-subtitle {
  font-size: 0.95rem;
  letter-spacing: 0.28em;
}
#screen-door .narrative,
#screen-puzzle .narrative {
  font-size: 1.15rem;
  line-height: 2;
}
#screen-door .door-key-text {
  font-size: 1.05rem;
  line-height: 1.7;
}
#screen-puzzle .puzzle-stats {
  font-size: 0.82rem;
  letter-spacing: 0.18em;
}
#screen-puzzle #puzzle-beat3 .narrative {
  font-size: 1.15rem;
  line-height: 2;
}

#screen-door #door-beat3 .btn {
  font-size: 0.95rem;
  padding: 0.85rem 1.6rem;
}

.puzzle-frame {
  position: relative;
  padding: 6px;
  background: linear-gradient(135deg, rgba(201,162,39,.28), rgba(139,69,19,.38), rgba(201,162,39,.18));
  box-shadow: 0 0 0 1px rgba(201,162,39,.25), 0 0 50px rgba(0,0,0,.85),
              inset 0 0 18px rgba(0,0,0,.45);
  flex-shrink: 0;
}
.puzzle-frame::before {
  content:''; position:absolute; inset:2px;
  border:1px solid rgba(201,162,39,.12); pointer-events:none; z-index:10;
}
.puzzle-grid-wrap {
  position: relative;
  width:  492px; /* 4*120 + 3*4 */
  height: 492px;
  background: #05020a;
}
.p-tile {
  position: absolute;
  width:  120px;
  height: 120px;
  transition: transform .18s cubic-bezier(.25,.46,.45,.94);
  cursor: pointer;
  overflow: hidden;
  will-change: transform;
  background-size: 492px 492px;
  background-repeat: no-repeat;
}
.p-tile::after {
  content:''; position:absolute; inset:0;
  border: 1px solid rgba(0,0,0,.55);
  pointer-events: none;
}
.p-tile:hover:not(.p-empty) { filter: brightness(1.14); z-index: 2; }
.p-tile:hover:not(.p-empty)::after { border-color: rgba(201,162,39,.45); }
.p-tile.p-empty {
  cursor: default;
  background: #05020a !important;
  box-shadow: inset 0 0 22px rgba(0,0,0,.9);
}
.p-tile.p-ok::after {
  border-color: rgba(201,162,39,.3);
  box-shadow: inset 0 0 0 1px rgba(201,162,39,.15);
}
@keyframes p-bump {
  0%,100% { filter:brightness(1); }
  40%     { filter:brightness(1.3); }
}
.p-tile.p-bump { animation: p-bump .22s ease; }

.puzzle-stats {
  display: flex; justify-content: space-between; align-items: center;
  width: 504px;
  font-family: 'Special Elite', monospace;
  font-size: .68rem; letter-spacing: .18em;
  color: var(--amber-dark); text-transform: uppercase;
}
.puzzle-stats span { color: var(--amber); }

/* ── KEY DRAG ── */
#key-drag-ghost {
  position: absolute; z-index: 9999; pointer-events: none;
  width: 72px; height: 72px;
  background-image: url('../assets/img/evidence/ev-journal-key.webp');
  background-size: contain; background-position: center; background-repeat: no-repeat;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(201,162,39,0.85));
}
.key-drop-zone.drag-active {
  outline: 2px dashed rgba(201,162,39,0.55);
  box-shadow: inset 0 0 30px rgba(201,162,39,0.1);
}

/* ── FULLSCREEN BUTTON ── */
#fullscreen-btn {
  position: absolute;
  top: 1rem; right: 1.2rem;
  z-index: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 48px; height: 48px;
  padding: 0;
  opacity: 1;
  transition: opacity 0.2s;
}
#fullscreen-btn:hover { opacity: 1; }
#fullscreen-btn.hidden { display: none; }
#fullscreen-btn.pulsing {
  animation: fsPulse 1.8s ease-in-out infinite;
}
@keyframes fsPulse {
  0%,100% { filter: drop-shadow(0 0 6px rgba(201,162,39,0.6)); opacity: 0.9; }
  50%      { filter: drop-shadow(0 0 24px rgba(201,162,39,1)); opacity: 1; }
}
/* Fullscreen icon inside timer bar */
#fs-timer-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 28px; height: 28px;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
#fs-timer-btn:hover { opacity: 1; }
#fs-timer-btn.hidden { display: none; }
/* Fullscreen btn on end/debrief screens */
#fs-end-btn {
  position: absolute;
  top: 1rem; right: 1.2rem;
  z-index: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 36px; height: 36px;
  padding: 0;
  opacity: 0.75;
  transition: opacity 0.2s;
  display: none;
}
#fs-end-btn:hover { opacity: 1; }
#fs-end-btn.visible { display: block; }
#fs-timer-btn.hidden { display: none; }
/* Start button disabled state */
#intro-start-btn.visible.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  filter: grayscale(0.4);
}
#fullscreen-prompt {
  position: absolute;
  left: 50%;
  top: calc(70% + min(130px, calc(17 * var(--vw, 1vw))));
  transform: translateX(-50%);
  font-family: 'IM Fell English', serif;
  font-size: 0.85rem;
  color: var(--amber-dark);
  letter-spacing: 0.12em;
  font-style: italic;
  text-align: center;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  white-space: nowrap;
}
#fullscreen-prompt.visible { opacity: 1; }
#intro-credit {
  position: absolute;
  bottom: 1.5rem;
  left: 1.8rem;
  width: 260px;
  opacity: 0;
  transition: opacity 1.0s ease;
  z-index: 3;
}
#intro-credit.visible { opacity: 1; }

.room1-header { text-align: center; margin-bottom: 0.5rem; }
.intro-portrait-wrap.intro-reveal { animation: fadeIn 1.4s ease forwards; }

/* ════════════════════════════════════════════════════════════════
   v3 ADDITIONS — touch, zones, skip intro, rotate notice
   ════════════════════════════════════════════════════════════════ */

/* ── SCENE ZONES ──
   Every clickable area in a scene carries .zone. Geometry lives here, in
   one place, as percentages of the 1600×900 scene. */
.zone { position: absolute; cursor: pointer; z-index: 3; border-radius: 10px; }
.zone::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 70px rgba(255,190,90,0.22), 0 0 26px rgba(255,190,90,0.10);
}
/* Touch devices: after a while without input the zones glow up softly once,
   so a player without a mouse can still discover them. */
.zone.zone-cue::after { animation: zoneCue 2.8s ease-in-out; }
@keyframes zoneCue {
  0%, 100% { opacity: 0; }
  30%, 60% { opacity: 1; }
}

/* Room I — the study */
#hs-cabinet { left: 12%;   top: 7.5%; width: 31%;   height: 52%; }
#hs-plate1  { left: 66%;   top: 6%;   width: 16.5%; height: 28.5%; }
#hs-plate2  { left: 84%;   top: 9.5%; width: 15.5%; height: 29%; }
/* Room II — the correspondence */
#r2-table-hotspot  { top: 56%; left: 3%;  width: 50%; height: 40%;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 0.4rem; }
#r2-bureau-hotspot { top: 10%; left: 63%; width: 34%; height: 82%;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 1rem; }
/* Room III — the laboratory */
#r3-board-hotspot { top: 2%;  left: 2%;  width: 38%; height: 28%;
  display: flex; align-items: flex-end; justify-content: center; padding: 0 0 0.4rem 3rem; }
#r3-flask-hotspot { top: 38%; left: 68%; width: 18%; height: 45%;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 0.5rem; }
.zone:hover .hotspot-hint { opacity: 1; }
#r3-overview .r3-room-label {
  position: absolute; bottom: calc(var(--strip-h) + 14px); left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel', serif; font-size: 0.65rem; letter-spacing: 0.3em;
  color: var(--amber-dark); z-index: 3; text-transform: uppercase;
}

/* ── DRAG GHOST (one for every drag in the game) ── */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none;
  background-size: contain; background-position: center; background-repeat: no-repeat;
  will-change: transform;
}
.drag-ghost.paper {
  background-size: cover; border: 2px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
}
.drag-ghost.glow { filter: drop-shadow(0 0 14px rgba(201,162,39,0.85)); }

/* ── SKIP INTRO ── */
#intro-skip-btn {
  position: absolute; right: 2rem; bottom: 2rem; z-index: 4;
  font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--amber);
  background: rgba(10,5,0,0.6); border: 1px solid var(--amber-dark);
  padding: 0.7rem 1.4rem; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.8s ease, border-color 0.2s, background 0.2s;
}
#intro-skip-btn.visible { opacity: 0.75; pointer-events: auto; }
#intro-skip-btn.visible:hover { opacity: 1; border-color: var(--gold); background: rgba(35,18,0,0.85); }

/* Start button: enabled state without fullscreen requirement (touch devices) */
#intro-start-btn.visible:not(.disabled) { cursor: pointer; }

/* ── ROTATE NOTICE (touch devices held upright) ── */
#rotate-notice {
  display: none; position: fixed; inset: 0; z-index: 100000;
  background: #050200; color: var(--parchment-light);
  flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem;
  text-align: center; padding: 2rem;
}
#rotate-notice .rotate-icon {
  width: 64px; height: 100px; border: 2px solid var(--gold); border-radius: 10px;
  animation: rotateHint 2.4s ease-in-out infinite;
}
#rotate-notice .rotate-title {
  font-family: 'Cinzel', serif; font-size: 1.1rem; letter-spacing: 0.2em; color: var(--gold);
  text-transform: uppercase;
}
#rotate-notice .rotate-text { font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.1rem; }
@keyframes rotateHint {
  0%, 20%   { transform: rotate(0deg); }
  50%, 80%  { transform: rotate(-90deg); }
  100%      { transform: rotate(0deg); }
}
@media (orientation: portrait) and (any-pointer: coarse) {
  #rotate-notice { display: flex; }
}

/* ── TOUCH TWEAKS ── */
@media (hover: none) {
  /* Hover states stick after a tap on touch screens — keep them calm */
  .letter-thumb:hover, .ref-thumb:hover, .inv-item:hover { transform: none; }
}

/* ════════════════════════════════════════════════════════════════
   v3.1 FIXES
   ════════════════════════════════════════════════════════════════ */

/* Inventory lightboxes (plates, diary page, cipher key, Voss's note, vial):
   one model — below the timer bar, clear of the evidence strip, close
   button always fully visible under the bar. */
#poster-lightbox, #diary-note-lightbox, #cipher-book-lightbox,
#mara-note-lightbox, #vial-lightbox {
  z-index: 440 !important;
  padding: 64px 1rem calc(var(--strip-h) + 10px) !important;
  box-sizing: border-box;
}
#poster-lightbox img, #diary-note-lightbox img, #cipher-book-lightbox img,
#mara-note-lightbox img, #vial-lightbox img {
  max-height: 100% !important;
  min-height: 0;
}
#diary-note-lightbox img { max-height: calc(100% - 3rem) !important; }
#poster-lightbox-close, #diary-note-close, #cipher-book-close,
.lb-close {
  top: 4.2rem !important; right: 2rem !important;
  z-index: 445 !important;
}

/* Title screen: the fullscreen step must be impossible to miss */
#fullscreen-prompt {
  top: calc(70% + min(150px, calc(19 * var(--vw, 1vw))));
  font-family: 'Cinzel', serif;
  font-style: normal;
  font-size: 1rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(10,5,0,0.78);
  border: 1px solid var(--amber);
  padding: 0.75rem 1.6rem;
  text-shadow: 0 0 10px rgba(0,0,0,0.9);
  cursor: pointer;
}
#fullscreen-prompt.visible {
  pointer-events: auto;
  animation: promptGlow 2.2s ease-in-out infinite;
}
#fullscreen-prompt:hover { color: var(--parchment-light); border-color: var(--gold); }
#fullscreen-prompt .fs-prompt-icon {
  display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.7em;
  vertical-align: -0.08em;
  border: 2px solid currentColor; border-radius: 2px;
}
@keyframes promptGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(201,162,39,0.25); }
  50%      { box-shadow: 0 0 28px rgba(201,162,39,0.75); }
}
#fullscreen-btn {
  width: 76px; height: 56px;
  top: 1.2rem; right: 1.4rem;
  padding: 6px 8px;
  background: rgba(10,5,0,0.6);
  border: 1px solid var(--amber-dark);
  border-radius: 6px;
}
#fullscreen-btn.pulsing { animation: fsRing 1.8s ease-in-out infinite; border-color: var(--gold); }
@keyframes fsRing {
  0%, 100% { box-shadow: 0 0 8px rgba(201,162,39,0.4), 0 0 0 0 rgba(201,162,39,0.5); }
  50%      { box-shadow: 0 0 26px rgba(201,162,39,0.95), 0 0 0 7px rgba(201,162,39,0); }
}

/* Hint pop-up: a click anywhere on it closes it */
#hint-display { cursor: pointer; }

/* ════════════════════════════════════════════════════════════════
   v3.3 — ROOM I: the volumes, the cipher wheel, the pulse drum
   ════════════════════════════════════════════════════════════════ */

/* ── The painted volumes on the shelf ── */
.book-spine {
  position: absolute; top: auto;
  cursor: pointer;
  border-radius: 0; background: none !important; outline: none !important;
  transition: transform 0.38s cubic-bezier(.3,.7,.3,1), filter 0.3s ease, opacity 0.35s ease;
  transform-origin: 50% 100%;
  z-index: 1;
}
.book-spine img { display: block; width: 100%; height: 100%; pointer-events: none; }
.book-spine:hover { filter: brightness(1.18) drop-shadow(0 0 10px rgba(201,162,39,0.45)); transform: translateY(-1.2%); }
.book-spine.pulled { transform: translateY(-7%) scale(1.06); filter: brightness(1.2) drop-shadow(0 18px 18px rgba(0,0,0,0.75)); z-index: 3; }
.book-spine.taken  { opacity: 0; pointer-events: none; transform: translateY(-4%); }
.book-spine.wrong, .book-spine.correct, .book-spine.queued { animation: none; }

/* ── The stand: three slots for the chosen volumes ── */
.book-stand {
  display: flex; gap: 14px; margin: 1.7rem 0 0.5rem;
}
.stand-slot {
  position: relative;
  width: 66px; height: 178px;
  border: 1px dashed rgba(201,162,39,0.45);
  background: linear-gradient(180deg, rgba(40,24,8,0.55), rgba(15,8,2,0.75));
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px;
  transition: border-color 0.2s, background 0.2s;
}
.stand-slot.filled { border-style: solid; border-color: rgba(201,162,39,0.35); }
.stand-slot.drag-over { border-color: var(--gold); background: rgba(201,162,39,0.14); }
.stand-num {
  position: absolute; top: -1.35rem; left: 0; right: 0; text-align: center;
  font-family: 'Cinzel', serif; font-size: 0.8rem; letter-spacing: 0.15em; color: var(--amber);
}
.stand-book { height: 164px; cursor: pointer; transition: transform 0.2s, filter 0.2s; }
.stand-book img { height: 100%; width: auto; display: block; pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.7)); }
.stand-book:hover { transform: translateY(-4px); filter: brightness(1.15); }
.stand-book.dragging { opacity: 0.35; }
.stand-book.wrong   { animation: spineShake 0.45s ease; }
.stand-book.correct img { filter: drop-shadow(0 0 14px rgba(201,162,39,0.85)); }
#book-response { font-size: 0.9rem; line-height: 1.45; min-height: 3.9rem; }
#seq-instruction { font-size: 1rem; }

/* ── The reader: an open volume over the shelf ── */
#book-reader {
  position: absolute; inset: 0; z-index: 6;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(6,3,1,0.86);
}
#book-reader.open { display: flex; animation: fadeIn 0.35s ease forwards; }
.reader-book {
  position: relative;
  width: min(100%, 760px); aspect-ratio: 1448 / 1086;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  overflow: hidden;
}
#book-reader.open .reader-book { animation: readerIn 0.45s cubic-bezier(.2,.8,.3,1); }
@keyframes readerIn { from { transform: scale(0.92); opacity: 0.2; } to { transform: scale(1); opacity: 1; } }
.reader-book > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.reader-page {
  position: absolute; left: 0; top: 0;
  transform-origin: 0 0;
  color: #2a1808;
  box-sizing: border-box;
  pointer-events: none;
}
.reader-left { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 30px; }
.reader-kicker { font-family: 'IM Fell English', serif; font-style: italic; font-size: 19px; color: #5a3a18; margin-bottom: 34px; }
.reader-title { font-family: 'Cinzel', serif; font-weight: 700; font-size: 36px; line-height: 1.25; letter-spacing: 0.02em; color: #24140a; }
.reader-rule { width: 120px; height: 2px; background: #6b4720; margin: 30px auto 22px; opacity: 0.7; }
.reader-chapter { font-family: 'Cinzel', serif; font-size: 20px; letter-spacing: 0.22em; color: #5a3a18; }
.reader-right { display: flex; flex-direction: column; justify-content: center; padding: 30px 26px; }
.reader-text {
  font-family: 'IM Fell English', serif; font-size: 30px; line-height: 1.55;
  text-align: left; color: #24140a; margin: 0;
}
.reader-folio { font-family: 'IM Fell English', serif; font-style: italic; font-size: 18px; text-align: center; color: #6b4720; margin-top: 26px; }
.reader-actions { display: flex; gap: 14px; }
.reader-actions .btn { margin: 0; font-size: 0.85rem; }
.reader-actions .btn[disabled] { opacity: 0.4; cursor: default; }
.reader-note { min-height: 1.2rem; font-family: 'IM Fell English', serif; font-style: italic; color: var(--amber); font-size: 0.95rem; }

/* ── The diary: three columns ── */
.room1-layout {
  grid-template-columns: 330px minmax(0, 1fr) 400px;
  gap: 1.4rem;
  max-height: 640px;
}
.room1-right { max-height: 640px; overflow: hidden; padding-right: 0; }
.room1-right .diary-page { max-height: 600px; }
.diary-howto { font-family: 'IM Fell English', serif; font-style: italic; font-size: 0.98rem; line-height: 1.6; color: var(--amber); margin: 0; }
#screen-room1 .panel.solved .diary-howto { display: none; }
.feedback.note { color: var(--amber); }

.room1-tools { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; min-width: 0; }
.room1-tools.solved { opacity: 0.55; pointer-events: none; transition: opacity 1s ease; }
.cipher-wheel-wrap { display: flex; align-items: center; gap: 10px; }
#cipher-wheel { width: 236px; height: 236px; touch-action: none; cursor: grab; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.7)); }
#cipher-wheel:active { cursor: grabbing; }
.wheel-letter { font-family: 'Cinzel', serif; font-weight: 700; fill: #2a1a0c; user-select: none; pointer-events: none; }
.wheel-letter.outer { font-size: 13px; }
.wheel-letter.inner { font-size: 11.5px; fill: #3a2208; }
.wheel-step {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--amber-dark); background: rgba(20,10,2,0.8); color: var(--gold);
  font-size: 1.25rem; cursor: pointer; line-height: 1;
}
.wheel-step:hover { background: rgba(201,162,39,0.2); }
.wheel-reading { font-family: 'Cinzel', serif; font-size: 0.95rem; letter-spacing: 0.12em; color: var(--gold); }
.wheel-reading span { font-family: 'IM Fell English', serif; font-style: italic; letter-spacing: 0; color: var(--parchment-light); text-transform: none; }

.phrase-list { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.phrase {
  width: 100%; text-align: left;
  font-family: 'Special Elite', monospace; font-size: 0.98rem; letter-spacing: 0.03em;
  color: #2a1a0c;
  background: linear-gradient(180deg, #e6d6b0, #d6c194);
  border: 1px solid rgba(90,60,20,0.6);
  padding: 7px 12px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.phrase:hover { background: linear-gradient(180deg, #efe0bc, #ddc99e); }
.phrase.read { font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.12rem; letter-spacing: 0; }
.phrase.garbled { color: #8a2a1a; }
.phrase.chosen { background: linear-gradient(180deg, #f3e2b4, #e2c47e); box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(201,162,39,0.55); }
.phrase.wrong { animation: spineShake 0.45s ease; }
#name-sign-btn { width: 100%; margin: 0.3rem 0 0; }
#name-sign-btn[disabled] { opacity: 0.4; cursor: default; }

/* ── The lock: drum, tray, card, wheels ── */
.puzzle-layout { grid-template-columns: 430px 1fr; }
.puzzle-right { min-height: 0; padding-top: 4px; }
#screen-puzzle .narrative { font-size: 1.05rem; line-height: 1.75; }
.pulse-card {
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 0.98rem; line-height: 1.5;
  color: #2a1a0c;
  background: linear-gradient(180deg, #ecdcb6, #dcc79c);
  padding: 10px 14px; transform: rotate(-0.6deg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.55);
}
.pulse-card-title { font-family: 'Cinzel', serif; font-style: normal; font-size: 0.78rem; letter-spacing: 0.16em; color: #5a3a18; margin-bottom: 4px; text-transform: uppercase; }
.pulse-tray {
  display: flex; flex-direction: column; gap: 9px;
  padding: 10px; background: linear-gradient(180deg, #3a2410, #24160a);
  border: 1px solid rgba(201,162,39,0.35); box-shadow: inset 0 2px 10px rgba(0,0,0,0.7);
}
.tray-strip { cursor: grab; transition: transform 0.15s, opacity 0.25s; box-shadow: 0 3px 8px rgba(0,0,0,0.6); }
.tray-strip canvas { display: block; width: 100%; height: auto; pointer-events: none; }
.tray-strip:hover { transform: translateX(4px); }
.tray-strip.placed { opacity: 0.32; }
.tray-strip.dragging { opacity: 0.2; }
.drag-ghost.strip-ghost { box-shadow: 0 8px 18px rgba(0,0,0,0.7); }
.pulse-actions { display: flex; gap: 10px; }
.pulse-actions .btn { margin: 0; flex: 1; font-size: 0.85rem; }
.pulse-actions .btn[disabled] { opacity: 0.4; cursor: default; }
#pulse-feedback { min-height: 1.4rem; font-size: 1rem; }

#puzzle-h-reveal {
  display: block;
  position: relative;
  width: 100%; max-width: 700px; aspect-ratio: 1;
  background-image: none;
  border: 2px solid rgba(201,162,39,.45);
  box-shadow: 0 0 60px rgba(201,162,39,.15);
  animation: riseIn .7s ease forwards;
  overflow: hidden;
}
#puzzle-h-reveal.cleared { animation: imgGlow 3s ease-in-out 1.5s infinite; }
#puzzle-h-reveal.shake { animation: spineShake 0.45s ease; }
.drum-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.drum-h { opacity: 0; transition: opacity 2.6s ease; }
#puzzle-h-reveal.cleared .drum-h { opacity: 1; }
#puzzle-h-reveal.cleared .drum-slot,
#puzzle-h-reveal.cleared .drum-wheel { opacity: 0; pointer-events: none; transition: opacity 0.9s ease; }

/* Slots and wheels: % of the 1254 × 1254 drum picture */
.drum-slot {
  position: absolute; top: 29.1%; width: 8.85%; height: 12.2%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 3px;
  transition: box-shadow 0.2s, background 0.2s;
}
#drum-slot-0 { left: 35.4%; }
#drum-slot-1 { left: 46.0%; }
#drum-slot-2 { left: 56.6%; }
.drum-slot span {
  position: absolute; top: 6%; left: 0; right: 0; text-align: center;
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 15px; color: rgba(70,40,10,0.85);
}
.drum-slot canvas { width: 100%; height: auto; display: block; margin-top: 18%; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.drum-slot.filled { cursor: pointer; }
.drum-slot.drag-active { box-shadow: 0 0 0 2px rgba(201,162,39,0.7), 0 0 18px rgba(201,162,39,0.5); }
.drum-slot.drag-over  { background: rgba(255,230,160,0.35); }
#puzzle-h-reveal.turned .drum-slot { animation: drumTurn 0.6s ease; }
@keyframes drumTurn { 0% { transform: translateY(0); } 40% { transform: translateY(-6%); } 100% { transform: translateY(0); } }

.drum-wheel {
  position: absolute; top: 60.2%; width: 6.15%; height: 10.9%;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.35; transition: opacity 0.6s ease;
}
#drum-wheel-0 { left: 39.7%; }
#drum-wheel-1 { left: 47.2%; }
#drum-wheel-2 { left: 54.6%; }
#puzzle-h-reveal.turned .drum-wheel { opacity: 1; }
.wheel-digit {
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 34px; line-height: 1;
  color: #2a1606; text-shadow: 0 1px 0 rgba(255,225,150,0.6);
  pointer-events: none;
}
.wheel-digit.roll-up   { animation: rollUp 0.18s ease; }
.wheel-digit.roll-down { animation: rollDown 0.18s ease; }
@keyframes rollUp   { from { transform: translateY(40%); opacity: 0.2; } to { transform: none; opacity: 1; } }
@keyframes rollDown { from { transform: translateY(-40%); opacity: 0.2; } to { transform: none; opacity: 1; } }
.wheel-up, .wheel-down { position: absolute; left: 0; right: 0; height: 50%; cursor: pointer; }
.wheel-up { top: 0; } .wheel-down { bottom: 0; }
#puzzle-h-reveal:not(.turned) .wheel-up, #puzzle-h-reveal:not(.turned) .wheel-down { cursor: default; }
#puzzle-h-reveal.turned .wheel-up:hover   { background: linear-gradient(180deg, rgba(255,230,160,0.35), transparent); }
#puzzle-h-reveal.turned .wheel-down:hover { background: linear-gradient(0deg, rgba(255,230,160,0.35), transparent); }

/* ── One record, enlarged ── */
#strip-lightbox {
  display: none; position: absolute; inset: 0; z-index: 450;
  background: rgba(0,0,0,0.9);
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  cursor: pointer;
}
#strip-lightbox.open { display: flex; animation: fadeIn 0.25s ease forwards; }
#strip-lightbox canvas { width: 1400px; max-width: 94%; height: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.9); }
.strip-lightbox-note { font-family: 'IM Fell English', serif; font-style: italic; color: var(--parchment-light); opacity: 0.75; }
/* Draggables on touch screens: the finger drags, the page does not pan */
.tray-strip, .stand-book { touch-action: none; -webkit-touch-callout: none; }

/* ── v3.3.1 — the drum rolls; the reading table ── */
#puzzle-h-reveal::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,236,170,0.55) 48%, transparent 61%);
  transform: translateX(-120%); opacity: 0;
}
#puzzle-h-reveal.rolling::after { animation: brassGlint 0.9s ease-out forwards; }
@keyframes brassGlint { 0% { transform: translateX(-120%); opacity: 1; } 100% { transform: translateX(120%); opacity: 1; } }
#puzzle-h-reveal.rolling .drum-slot canvas { animation: rollAway 0.7s cubic-bezier(.5,0,.8,.4) forwards; }
@keyframes rollAway { to { transform: translateY(-130%) scaleY(0.4); opacity: 0; } }
#puzzle-h-reveal.turned .drum-slot canvas { opacity: 0; }
#puzzle-h-reveal.turned .drum-slot span { color: rgba(70,40,10,0.45); }
#puzzle-h-reveal.turned .drum-slot { animation: none; }
#puzzle-h-reveal.turned .drum-wheel { opacity: 1; filter: drop-shadow(0 0 10px rgba(255,220,130,0.75)); animation: wheelsAlive 1.2s ease; }
@keyframes wheelsAlive { 0% { filter: drop-shadow(0 0 0 rgba(255,220,130,0)); } 40% { filter: drop-shadow(0 0 22px rgba(255,220,130,1)); } 100% { filter: drop-shadow(0 0 10px rgba(255,220,130,0.75)); } }
#puzzle-h-reveal.cleared .drum-wheel { filter: none; }

#strip-lightbox { cursor: default; }
.strip-sheet { position: relative; width: 1400px; max-width: 94%; cursor: crosshair; }
.strip-sheet canvas { width: 100%; height: auto; display: block; box-shadow: 0 10px 40px rgba(0,0,0,0.9); }
#strip-lightbox canvas { max-width: none; }
.strip-ticks { position: absolute; left: 0; right: 0; top: 0; height: 12%; }
.strip-tick {
  position: absolute; top: 4px; width: 14px; height: 28px; margin-left: -7px; cursor: pointer;
  background: linear-gradient(90deg, transparent 5px, #5a5a62 5px, #5a5a62 8px, transparent 8px);
  opacity: 0.9;
}
.strip-tick:hover { filter: brightness(1.6); }
.strip-tally { display: flex; align-items: center; gap: 14px; font-family: 'Cinzel', serif; font-size: 1.15rem; letter-spacing: 0.1em; color: var(--gold); }
.strip-tally #strip-tally-n { font-size: 1.6rem; }
.strip-tally .btn { margin: 0; font-size: 0.75rem; padding: 0.4rem 1rem; }
.strip-close { position: absolute; top: 64px; right: 40px; background: none; border: none; color: var(--parchment-light); font-size: 2rem; cursor: pointer; opacity: 0.75; font-family: 'Cinzel', serif; }
.strip-close:hover { opacity: 1; }

/* ════════════════════════════════════════════════════════════════
   v3.4 — THE DIARY, prototype of the larger layout:
   the object fills the screen, the panel beside it holds only the
   question and the tool; narration appears as a caption and fades.
   ════════════════════════════════════════════════════════════════ */
.diary-stage {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  box-sizing: border-box;
  padding: 54px 26px 74px 22px;
  display: flex; align-items: center; gap: 26px;
}
.diary-book {
  position: relative; flex: 0 0 auto;
  height: 100%; max-height: 770px; aspect-ratio: 1448 / 1086;
  box-shadow: 0 18px 60px rgba(0,0,0,0.85);
  overflow: hidden;
}
.diary-book > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.diary-text {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  box-sizing: border-box; padding: 6px 4px;
  font-family: 'IM Fell English', serif; font-size: 27px; line-height: 1.48;
  color: #24140a;
  display: flex; flex-direction: column; justify-content: center;
}
.diary-text p { margin: 0 0 0.75em; }
.diary-sign { text-align: right; font-style: italic; }
.diary-text .ph {
  cursor: pointer; white-space: nowrap;
  font-family: 'Special Elite', monospace; font-size: 0.86em; letter-spacing: 0.02em;
  color: #3a1a0a; border-radius: 3px; padding: 0 2px;
  transition: background 0.2s, box-shadow 0.2s;
}
.diary-text .ph:hover { background: rgba(160,100,30,0.16); }
.diary-text .ph-key {
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.12em;
  color: #a51e0a; margin-right: 3px; letter-spacing: 0; vertical-align: 0.42em; line-height: 0;
  text-shadow: 0 0 0.6px #a51e0a;
}
.diary-text .ph.read { font-family: 'IM Fell English', serif; font-size: 1em; font-style: italic; letter-spacing: 0;
  color: #1a0c04; background: rgba(201,162,39,0.18); white-space: normal; }
.diary-text .ph.read .ph-key { opacity: 0.55; }
.diary-text .ph.garbled { color: #8a2a1a; }
.diary-text .ph.chosen { background: rgba(201,162,39,0.5); box-shadow: 0 0 0 2px rgba(120,70,10,0.8); }
.diary-text .ph.wrong { animation: spineShake 0.45s ease; }
.diary-book.revealed .ph.read { background: rgba(201,162,39,0.12); }
.diary-caption {
  position: absolute; left: 6%; right: 6%; bottom: 3.5%;
  padding: 12px 20px; text-align: center;
  font-family: 'IM Fell English', serif; font-size: 1.25rem; line-height: 1.55;
  color: var(--parchment-light);
  background: rgba(8,4,1,0.82); border: 1px solid rgba(201,162,39,0.35);
  transition: opacity 1.4s ease; pointer-events: none;
}
.diary-caption em { color: var(--amber); }
.diary-caption.faded { opacity: 0; }

.diary-panel {
  flex: 1 1 auto; min-width: 0; align-self: stretch;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center;
}
.diary-panel .room-subtitle { font-size: 1rem; letter-spacing: 0.26em; }
.diary-question { font-family: 'IM Fell English', serif; font-size: 1.6rem; line-height: 1.4; color: var(--parchment-light); margin: 0; }
.diary-tools { display: flex; flex-direction: column; align-items: center; gap: 12px; transition: opacity 0.8s ease; }
.diary-tools.solved { display: none; }
.diary-panel #cipher-wheel { width: 270px; height: 270px; }
.diary-panel .wheel-step { width: 48px; height: 48px; font-size: 1.45rem; }
.diary-panel .wheel-reading { font-size: 1.25rem; }
.diary-panel #name-sign-btn { width: 300px; margin: 0; font-size: 0.95rem; }
.diary-panel #room1-feedback { font-size: 1.2rem; line-height: 1.6; min-height: 2rem; max-width: 380px; }
.diary-panel #room1-feedback.success { font-size: 1.25rem; }

/* ── v3.4 — the lock: wheels blank until the drum has turned; the tray stays readable ── */
.wheel-digit { opacity: 0; }
#puzzle-h-reveal.turned .wheel-digit { opacity: 1; animation: digitsAppear 1.1s cubic-bezier(.2,.8,.3,1) both; }
#drum-wheel-1 .wheel-digit { animation-delay: 0.15s !important; }
#drum-wheel-2 .wheel-digit { animation-delay: 0.3s !important; }
@keyframes digitsAppear {
  0%   { opacity: 0; transform: translateY(-60%) scale(0.6); text-shadow: 0 0 0 rgba(255,220,130,0); }
  55%  { opacity: 1; transform: translateY(6%) scale(1.12); text-shadow: 0 0 18px rgba(255,225,150,1); }
  100% { opacity: 1; transform: none; text-shadow: 0 1px 0 rgba(255,225,150,0.6); }
}
#puzzle-h-reveal.turned .wheel-digit.roll-up   { animation: rollUp 0.18s ease; }
#puzzle-h-reveal.turned .wheel-digit.roll-down { animation: rollDown 0.18s ease; }
.drum-wheel { opacity: 1; }
#puzzle-h-reveal:not(.turned) .drum-wheel { opacity: 1; }

.tray-strip { position: relative; cursor: zoom-in; }
.tray-strip.placed { opacity: 1; filter: saturate(0.75) brightness(0.92); }
.tray-strip.placed::before {
  content: attr(data-slot); position: absolute; left: -2px; top: 50%; transform: translate(-100%, -50%);
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 0.85rem; color: var(--gold);
  width: 26px; text-align: center;
}
.pulse-tray { padding-left: 34px; }
.tray-strip::after {
  content: '⌕'; position: absolute; right: 6px; top: 4px;
  font-size: 1.2rem; line-height: 1; color: rgba(60,35,10,0.55);
  transition: color 0.2s, transform 0.2s;
}
.tray-strip:hover::after { color: rgba(60,35,10,0.95); transform: scale(1.2); }
.pulse-tray.beckon .tray-strip { animation: trayBeckon 1.2s ease 2; }
@keyframes trayBeckon { 0%,100% { box-shadow: 0 3px 8px rgba(0,0,0,0.6); } 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(201,162,39,0.8); } }

/* ════════════════════════════════════════════════════════════════
   v3.5 — THE LARGER LAYOUT, everywhere
   Object large on the left, a calm panel on the right with only the
   question and the tools. Text sizes are canvas pixels: at 1600 × 900
   scaled to a 13" laptop they still read comfortably.
   ════════════════════════════════════════════════════════════════ */
:root { --stage-pad: 54px 26px 74px 22px; }

/* ── Door and lock ── */
.door-layout, .puzzle-layout {
  display: flex; flex-direction: row-reverse; align-items: center; gap: 30px;
  width: 100%; height: 100%; max-width: none; box-sizing: border-box;
  padding: var(--stage-pad); margin: 0;
  position: relative; z-index: 2;
}
.door-right, .puzzle-right {
  flex: 0 0 auto; height: 100%; max-height: 770px; aspect-ratio: 1;
  min-height: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.door-image-wrap, #puzzle-h-reveal { width: 100%; height: 100%; max-width: none; }
.door-left, .puzzle-left {
  flex: 1 1 auto; min-width: 0; align-self: stretch; position: static;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
#screen-door .room-subtitle, #screen-puzzle .room-subtitle { font-size: 1.05rem; letter-spacing: 0.26em; }
#screen-door .narrative, #screen-puzzle .narrative, #screen-puzzle #puzzle-beat3 .narrative {
  font-size: 1.3rem; line-height: 1.65;
}
#puzzle-beat2 { display: flex; flex-direction: column; gap: 14px; }
.pulse-card { font-size: 1.12rem; padding: 12px 18px; }
.pulse-card-title { font-size: 0.85rem; }
.pulse-tray { gap: 10px; padding: 12px 12px 12px 40px; }
.tray-strip { cursor: grab; }
.tray-strip:active { cursor: grabbing; }
.tray-strip::after { content: none; }
.tray-strip.placed::before { font-size: 1rem; width: 30px; }
.strip-zoom {
  position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid #6b4720; background: radial-gradient(circle at 40% 35%, #f3d78a, #a8782a 60%, #5e3d12);
  color: #2a1606; font-size: 1.15rem; line-height: 1; cursor: zoom-in;
  box-shadow: 0 2px 6px rgba(0,0,0,0.55); padding: 0;
}
.strip-zoom:hover { filter: brightness(1.15); transform: scale(1.08); }
.pulse-tray.beckon .strip-zoom { animation: zoomBeckon 1.2s ease 2; }
@keyframes zoomBeckon { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(201,162,39,0.9); } }
.pulse-actions .btn { font-size: 0.95rem; padding: 0.8rem 1rem; }
#pulse-feedback { font-size: 1.15rem; line-height: 1.55; }
.strip-place { display: flex; align-items: center; gap: 10px; font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.15rem; color: var(--parchment-light); }
.strip-place .btn { margin: 0; min-width: 64px; font-size: 0.95rem; padding: 0.45rem 0.9rem; }
.strip-lightbox-note { font-size: 1.05rem; }
.drum-slot span { font-size: 18px; }
.wheel-digit { font-size: 38px; }
.puzzle-left { gap: 12px; }
#puzzle-beat2 { gap: 12px; }
#screen-puzzle .narrative { font-size: 1.22rem; line-height: 1.6; }

/* ── Bookshelf: the cabinet large on the left, the stand beside it ── */
#r1a-cabinet-detail .bookshelf-screen {
  width: 100%; height: 100%; box-sizing: border-box; margin: 0;
  padding: 50px 26px 0 22px;
  display: flex; flex-direction: row-reverse; align-items: center; gap: 30px;
}
#r1a-cabinet-detail .books-container {
  flex: 0 0 auto; width: auto; height: 100%; max-height: 720px; aspect-ratio: 1536 / 1024;
}
#r1a-cabinet-detail .bookshelf-text-block {
  flex: 1 1 auto; width: auto; max-width: none; position: static;
  align-self: stretch; justify-content: center; gap: 0.9rem;
}
#r1a-cabinet-detail .room-subtitle { font-size: 1.05rem; letter-spacing: 0.26em; }
#r1a-cabinet-detail .narrative { font-size: 1.3rem; line-height: 1.6; }
#screen-room1a .seq-instruction { font-size: 1.25rem; line-height: 1.55; }
#screen-room1a .book-response { font-size: 1.12rem; line-height: 1.5; }
#screen-room1a .lock-label { font-size: 1rem; color: var(--amber); }
#r1a-cabinet-detail .lock-input { width: 3.4rem; height: 3.4rem; font-size: 1.7rem; }
#r1a-cabinet-detail #confirm-sequence-btn { font-size: 0.95rem; padding: 0.8rem 1.4rem; }
#r1a-cabinet-detail #book-seq-feedback { font-size: 1.15rem; line-height: 1.5; }
.stand-slot { width: 78px; height: 210px; }
.stand-book { height: 194px; }
.stand-num { font-size: 0.95rem; }
#r1a-back-btn { font-size: 0.8rem; top: 58px; }
#book-reader .reader-book { width: min(100%, 900px); }
.reader-actions .btn { font-size: 0.95rem; padding: 0.75rem 1.4rem; }
.reader-note { font-size: 1.1rem; }
#r1a-back-btn { left: auto; right: 26px; top: 56px; }

/* ── Room II: the entry text, the desk, the letters, the bureau lock ── */
.r2-entry-narrative { font-size: 1.3rem; line-height: 1.65; width: min(860px, 86%); padding: 1.1rem 1.8rem; }
.r2-desk-wrap { width: auto; height: 100%; max-height: 780px; aspect-ratio: 1672 / 941; max-width: 96%; }
.r2-desk-wrap > img { width: 100%; height: 100%; object-fit: contain; }
.r2-desk-instruction { font-size: 1.22rem; line-height: 1.5; top: 2.2%; width: 70%;
  background: rgba(8,4,0,0.62); padding: 0.5rem 1rem; border-radius: 3px; }
.r2-slots-label { font-size: 0.8rem; }
.seq-slot .slot-num { font-size: 0.75rem; padding: 2px 6px; }
.seq-slot .slot-remove { font-size: 1rem; padding: 4px 8px; }
.room2-pos-num { font-size: 0.85rem; }
.seq-label { font-size: 0.7rem; bottom: -18px; }
.letter-read-hint { font-size: 0.62rem; padding: 3px 6px; color: var(--amber); }
.r2-desk-controls { bottom: 1.5%; }
.r2-desk-controls .btn { font-size: 0.95rem; padding: 0.7rem 1.4rem; min-width: 200px; }
.r2-desk-controls .feedback { font-size: 1.15rem; line-height: 1.45; text-align: center;
  background: rgba(8,4,0,0.62); padding: 0.3rem 0.8rem; }
.letter-modal { height: 100%; width: auto; max-width: 96%; aspect-ratio: 1085 / 1450; }
.modal-close { width: 40px; height: 40px; font-size: 1.4rem; }

.r2-bureau-inner {
  flex-direction: row; width: 100%; height: 100%; box-sizing: border-box;
  padding: 0 60px 0 40px; gap: 46px; justify-content: center; align-items: center;
}
.r2-bureau-inner .lock-image-wrap { flex: 0 0 auto; height: 100%; max-height: 760px; width: auto; max-width: none; aspect-ratio: 1122 / 1402; }
.r2-bureau-inner .lock-image-wrap img { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.r2-bureau-panel { flex: 0 1 560px; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.r2-bureau-instruction { font-size: 1.3rem; line-height: 1.65; max-width: 560px; }
#room2-lock-submit { font-size: 1rem; padding: 0.8rem 1.4rem; max-width: 320px; }
#room2-feedback { font-size: 1.15rem; line-height: 1.5; text-align: center; }
.dial-up, .dial-down { width: 52px; height: 30px; font-size: 0.9rem; }
.dial-face { width: 52px; height: 44px; font-size: 1.6rem; }
.letter-modal { cursor: zoom-in; transition: background-size 0.25s ease; touch-action: none; }
.letter-modal.zoomed { background-size: 210%; cursor: zoom-out; }
.letter-modal::after {
  content: 'Touch the page to read closely'; position: absolute; left: 0; right: 0; bottom: 10px;
  text-align: center; font-family: 'IM Fell English', serif; font-style: italic; font-size: 1rem;
  color: var(--parchment-light); opacity: 0.75; pointer-events: none; text-shadow: 0 1px 3px #000;
}
.letter-modal.zoomed::after { content: none; }

/* ── Room III: the board and the table, larger ── */
#r3-board-wrap { position: relative; height: 100%; max-height: 780px; aspect-ratio: 1672 / 941; max-width: 96%; }
.r3-board-instruction {
  position: absolute; bottom: 1.2%; left: 50%; transform: translateX(-50%);
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 1.1rem;
  color: var(--parchment-light); background: rgba(8,4,0,0.7); padding: 0.25rem 0.9rem; white-space: nowrap;
}
#r3-table-wrap { width: min(94%, 1380px) !important; height: min(52%, 470px) !important; }
#r3-tubes-strip { max-width: 1380px !important; gap: 1.1rem !important; }
#r3-progress-label { font-size: 0.85rem !important; color: var(--amber) !important; }
#r3-flask-feedback { font-size: 1rem !important; }
#r3-note-img { max-width: 70% !important; max-height: 94% !important; }
/* The panels keep clear of the hint lamp in the lower right corner */
.door-left, .puzzle-left, #r1a-cabinet-detail .bookshelf-text-block, .diary-panel { padding-bottom: 70px; box-sizing: border-box; }
#r1a-cabinet-detail .bookshelf-text-block { gap: 0.7rem; }
#r1a-cabinet-detail .narrative { font-size: 1.2rem; line-height: 1.5; }
.stand-slot { height: 184px; }
.stand-book { height: 168px; }
#r1a-cabinet-detail .bookshelf-text-block { padding-bottom: 96px; }

/* ── v5.1 — the letters on their own paper (see LETTER_PAPERS in room2.js) ── */
.letter-modal { aspect-ratio: auto; width: auto; max-width: none; height: auto; max-height: none; cursor: default;
  background: none !important; display: flex; align-items: center; justify-content: center; overflow: visible; }
.letter-modal::after { content: none !important; }
.letter-modal .modal-close { top: -0.2rem; right: -2.4rem; }
.letter-sheet { position: relative; overflow: hidden; box-shadow: 0 20px 70px rgba(0,0,0,0.9); }
.letter-paper {
  position: absolute; left: 0; top: 0; width: 1086px; height: 1448px; transform-origin: 0 0;
  background-size: 100% 100%; background-repeat: no-repeat;
}
.letter-text {
  position: absolute; box-sizing: border-box; overflow: hidden;
  font-family: "Special Elite", monospace; line-height: 1.42; text-align: left;
  color: rgba(34, 19, 7, 0.93); mix-blend-mode: multiply;
  text-shadow: 0 0 1px rgba(34, 19, 7, 0.35);
}
.letter-text p { margin: 0 0 0.8em; }
.letter-text u { text-decoration-thickness: 0.06em; text-underline-offset: 0.18em; }
.letter-head { margin-bottom: 1.2em; font-size: 0.95em; }
.letter-greet { margin-bottom: 0.85em !important; }
.letter-sign { text-align: right; margin-top: 1.1em !important; }
.letter-curl { float: right; shape-outside: polygon(0 0, 100% 0, 100% 100%); }
.letter-paper.memo .letter-text { font-family: "IM Fell English", serif; font-style: italic; line-height: 1.45; }
.letter-paper.memo .letter-head { font-style: normal; }
.modal-close { z-index: 3; }
.narrative-cue { margin: 0; font-family: 'IM Fell English', serif; font-size: 1.2rem; color: var(--amber); }
.r2-bureau-cue { text-align: center; max-width: 560px; }

/* ════════════════════════════════════════════════════════════════
   v3.6 — ROOM IV: THE CROSS-EXAMINATION
   ════════════════════════════════════════════════════════════════ */
#screen-room4 { overflow: hidden; }
.r4-stage {
  position: absolute; inset: 0; z-index: 1; overflow: hidden;
  --push: 0; --mx: 0; --my: 0;
  scale: calc(1 + var(--push) * 0.028);
  transform-origin: 72% 42%;
  transition: scale 2.4s cubic-bezier(.4,0,.2,1), filter 2.5s ease;
  filter: brightness(0.7);
}
.r4-stage.lit { filter: brightness(1); }
.r4-stage.impact { animation: r4Jolt 0.42s cubic-bezier(.36,.07,.19,.97); }
@keyframes r4Jolt {
  0% { translate: 0 0; } 15% { translate: -10px 4px; } 30% { translate: 9px -5px; }
  45% { translate: -6px 3px; } 60% { translate: 4px -2px; } 80% { translate: -2px 1px; } 100% { translate: 0 0; }
}
.r4-stage.impact::after {
  content: ''; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: radial-gradient(ellipse at 70% 40%, rgba(255,230,170,0.55), transparent 60%);
  animation: r4Flash 0.5s ease-out forwards;
}
@keyframes r4Flash { from { opacity: 1; } to { opacity: 0; } }
.r4-stage.defeated { scale: 1.0; filter: brightness(0.62) saturate(0.85); transition: scale 6s ease, filter 6s ease; }
.r4-stage.walkout .r4-pryce { opacity: 0; translate: 6% 0; transition: opacity 2.5s ease, translate 2.5s ease; }
.r4-stage .bg { transform: translate(calc(var(--mx) * -10px), calc(var(--my) * -6px)); }

.r4-pryce {
  position: absolute; right: 3%; bottom: 0; height: 92%; z-index: 2;
  object-fit: contain; object-position: bottom;
  filter: drop-shadow(-10px 0 28px rgba(0,0,0,0.85));
  transform: translate(calc(var(--mx) * -24px), calc(var(--my) * -10px));
  transform-origin: 50% 100%;
  animation: r4Breathe 5.2s ease-in-out infinite;
  transition: opacity 0.42s ease, translate 0.9s cubic-bezier(.3,.7,.3,1), filter 1.5s ease;
}
@keyframes r4Breathe { 0%,100% { scale: 1; } 50% { scale: 1.006 1.011; } }
.r4-pryce.swap-out { opacity: 0; }
.r4-pryce.mood-calm      { translate: 0 0; }
.r4-pryce.mood-doubt     { translate: 2% 0; filter: drop-shadow(-10px 0 28px rgba(0,0,0,0.85)) brightness(0.92); }
.r4-pryce.mood-defeated  { translate: 1% 2%; filter: drop-shadow(-8px 0 24px rgba(0,0,0,0.8)) brightness(0.85); }
.r4-pryce.swap-in { animation: r4Breathe 5.2s ease-in-out infinite, r4Appear 0.7s ease-out; }
@keyframes r4Appear { from { opacity: 0; } to { opacity: 1; } }
.r4-lamp-face {
  position: absolute; right: 8%; top: 4%; width: 34%; height: 52%; z-index: 3; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,190,110,0.22), transparent 62%);
  mix-blend-mode: soft-light; animation: r4LampFlicker 3.7s infinite;
}
.r4-lamp { position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at 22% 18%, rgba(255,180,90,0.10), transparent 55%); animation: r4LampFlicker 5.1s infinite reverse; }
@keyframes r4LampFlicker { 0%,100% { opacity: 1; } 18% { opacity: 0.82; } 22% { opacity: 1; } 47% { opacity: 0.9; } 51% { opacity: 0.7; } 55% { opacity: 1; } 78% { opacity: 0.88; } }

#r4-cold-overlay {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
  background: linear-gradient(105deg, rgba(10,20,40,0.55), rgba(30,45,70,0.35) 55%, rgba(60,80,110,0.25));
  mix-blend-mode: multiply;
}
#r4-cold-overlay.on { opacity: 1; }

/* v3.7 — the desk layer moves with the hall picture */
.r4-desk-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none;
  transform: translate(calc(var(--mx) * -10px), calc(var(--my) * -6px)); }
/* His words on the desk paper, in perspective (matrix set in room4.js) */
.r4-desk-text {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; box-sizing: border-box;
  font-family: 'IM Fell English', serif; font-size: 20px; line-height: 1.3; color: #1a0c03;
  transition: opacity 0.5s ease;
}
.r4-desk-text p { margin: 0 0 7px; opacity: 0; transition: opacity 0.9s ease; mix-blend-mode: multiply; }
.r4-desk-text p.spoken { opacity: 1; }
.r4-desk-text.gone { opacity: 0; }

/* The brass balance on the desk */
.r4-balance { position: absolute; left: 672px; top: 452px; width: 340px; height: 340px; transition: filter 0.6s; }
.r4-balance.struck { animation: r4BalGlow 1.1s ease-out; }
@keyframes r4BalGlow { 0% { filter: drop-shadow(0 0 0 rgba(255,210,120,0)) brightness(1); }
  25% { filter: drop-shadow(0 0 16px rgba(255,210,120,0.55)) brightness(1.25); } 100% { filter: none; } }
.bal-weights { position: absolute; inset: 0; }
.r4-balance .bal-weight { position: absolute; transform: translate(-50%, -100%); height: auto;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6)); }
.r4-balance .bal-weight.w-l { width: 9%; }
.r4-balance .bal-weight.w-m { width: 6.6%; }
.r4-balance .bal-weight.w-s { width: 5.6%; }
.r4-balance .bal-weight.drop { animation: r4WeightDrop 0.62s cubic-bezier(.5,0,.75,0) both; }
@keyframes r4WeightDrop {
  0% { transform: translate(-50%, -360%); opacity: 0; }
  20% { opacity: 1; }
  62% { transform: translate(-50%, -100%); animation-timing-function: cubic-bezier(.2,.6,.4,1); }
  78% { transform: translate(-50%, -112%); }
  100% { transform: translate(-50%, -100%); }
}
/* the front lip of the dish, drawn over the weights so they sit in it */
.r4-balance .bal-lip { clip-path: inset(62.9% 0 0 0); pointer-events: none; }
.r4-balance img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.r4-balance .bal-beam { transform-origin: 50% 18.98%; }
.r4-balance .bal-pan { position: absolute; inset: 0; }
.r4-balance .bal-pan > img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.r4-balance.danger { filter: drop-shadow(0 0 9px rgba(190,40,20,0.35)); }
.bal-label { position: absolute; top: 70.5%; transform: translateX(-50%);
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 14px; letter-spacing: 0.04em;
  color: var(--parchment-light); opacity: 0.72; text-shadow: 0 1px 3px #000, 0 0 8px #000; white-space: nowrap; }
.bal-l { left: 18.4%; }
.bal-r { left: 81%; }

/* The statement, lifted from the desk (matrix animated in room4.js) */
.r4-sheet {
  position: absolute; left: 0; top: 0; z-index: 12; transform-origin: 0 0; display: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6)); transition: filter 1s ease;
}
.r4-sheet.on { display: block; }
.r4-sheet.up { filter: drop-shadow(0 26px 34px rgba(0,0,0,0.85)); }
.r4-sheet > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.r4-statement {
  position: absolute; inset: 0; box-sizing: border-box; padding: 52px 66px 40px; color: #24140a;
  display: flex; flex-direction: column; justify-content: center;
}
.r4-sheet-title { font-family: 'Cinzel', serif; font-size: 15px; letter-spacing: 0.2em; color: #6b4720; margin-bottom: 12px; text-transform: uppercase; }
.r4-line {
  position: relative; font-family: 'IM Fell English', serif; font-size: 26px; line-height: 1.32;
  padding: 6px 12px; margin: 3px 0; border: 1px dashed transparent; border-radius: 3px;
  transition: background 0.2s, border-color 0.2s;
}
.r4-line.r4-target { border-color: rgba(120,70,10,0.4); }
.r4-line.drag-over { background: rgba(201,162,39,0.35); border-color: #8b5a10; }
.r4-line.hinted { background: rgba(201,162,39,0.22); box-shadow: inset 4px 0 0 #8b5a10; }
.r4-line.pressed { animation: r4Press 0.4s ease; }
@keyframes r4Press { 40% { transform: translateX(6px); } }
.r4-line.struck span { background-image: linear-gradient(transparent 52%, rgba(150,20,10,0.9) 52%, rgba(150,20,10,0.9) 60%, transparent 60%);
  background-repeat: no-repeat; background-size: 100% 100%; animation: r4Ink 0.7s ease-out both;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
@keyframes r4Ink { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
.r4-statement.struck-all .r4-line:not(.struck) { opacity: 0.55; }

/* The cue line above the sheet, and the subtitles below it — no boxes */
.r4-cue {
  position: absolute; left: 60px; top: 78px; width: 680px; z-index: 13; pointer-events: none;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 24px; color: var(--amber);
  text-shadow: 0 1px 4px #000, 0 0 14px rgba(0,0,0,0.9); opacity: 0; transition: opacity 0.6s ease;
}
.r4-cue.show { opacity: 1; }
.r4-subtitle {
  position: absolute; left: 50px; top: 598px; width: 690px; z-index: 13; pointer-events: none;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 25px; line-height: 1.42;
  color: var(--parchment-light); opacity: 0; transition: opacity 0.4s ease;
  text-shadow: 0 1px 3px #000, 0 0 12px #000, 0 0 22px rgba(0,0,0,0.85);
}
.r4-subtitle.narrator { font-style: normal; color: #e8d2a0; letter-spacing: 0.01em; }
/* Pryce's words beside his head; anchored at the bottom so longer lines grow upward */
.r4-subtitle.speech { left: auto; right: 478px; top: auto; bottom: 470px; width: 600px; text-align: right; font-size: 27px; }
.r4-subtitle.speech.beside { width: 400px; }
.r4-subtitle.show { opacity: 1; }

/* First time: the evidence below glows, one ghost shows the way */
.inv-item.r4-glow { animation: r4InvGlow 1.3s ease-in-out 4; }
@keyframes r4InvGlow { 0%,100% { box-shadow: 0 0 0 rgba(201,162,39,0); } 50% { box-shadow: 0 0 18px 4px rgba(230,190,90,0.75); border-color: var(--gold); } }
.r4-tut-ghost {
  position: absolute; z-index: 720; width: 80px; height: 60px; pointer-events: none;
  background-size: cover; background-position: center; border: 1px solid var(--gold);
  box-shadow: 0 10px 26px rgba(0,0,0,0.7), 0 0 20px rgba(230,190,90,0.5); opacity: 0.85;
  transition: left 1.7s cubic-bezier(.45,.05,.3,1), top 1.7s cubic-bezier(.45,.05,.3,1), opacity 0.8s ease;
}
.r4-tut-ghost.fade { opacity: 0; }

/* A wax seal on evidence that has answered him */
.inv-item.r4-sealed::after {
  content: ''; position: absolute; right: -7px; bottom: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #8fbf6a 0%, #3f7a35 45%, #1f4219 100%);
  box-shadow: inset 0 0 0 3px rgba(25,60,20,0.9), inset 0 0 0 4px rgba(230,200,110,0.55), 0 2px 4px rgba(0,0,0,0.7);
  animation: r4Seal 0.55s cubic-bezier(.2,.9,.3,1.4);
}
.inv-item.r4-sealed { opacity: 0.78; }
@keyframes r4Seal { from { transform: scale(2.4); opacity: 0; } 60% { opacity: 1; } to { transform: scale(1); opacity: 1; } }

.r4-show {
  position: absolute; inset: 0; z-index: 30; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 56px 0 84px; box-sizing: border-box; background: rgba(4,2,0,0.86);
}
.r4-show.open { display: flex; animation: fadeIn 0.35s ease forwards; }
.r4-show-ask { font-family: 'Cinzel', serif; font-size: 1.3rem; letter-spacing: 0.24em; color: var(--gold); text-transform: uppercase; }
.r4-show-help { display: none; font-family: 'IM Fell English', serif; font-style: italic; font-size: 22px; color: var(--parchment-light); opacity: 0.85; margin-top: -4px; }
.r4-show-help.on { display: block; animation: fadeIn 0.6s ease 0.8s both; }
.r4-show-row { display: flex; align-items: center; gap: 30px; height: 100%; max-height: 690px; }
.r4-show-paper { position: relative; height: 100%; display: flex; align-items: center; animation: r4Fly 0.5s cubic-bezier(.2,.8,.3,1); }
@keyframes r4Fly { from { transform: scale(0.6) translateY(120px); opacity: 0; } to { transform: none; opacity: 1; } }
.r4-zonewrap { position: relative; height: 100%; display: inline-block; box-shadow: 0 16px 50px rgba(0,0,0,0.9); }
.r4-zonewrap > img { height: 100%; width: auto; max-width: 1080px; display: block; user-select: none; -webkit-user-drag: none; }
/* zones on the evidence: invisible until the mouse finds them; faintly marked on touch screens */
.r4-zone { position: absolute; box-sizing: border-box; cursor: pointer; border-radius: 4px;
  border: 1.5px solid transparent; transition: background 0.18s, border-color 0.18s, box-shadow 0.18s; }
.r4-zone.hover { border-color: rgba(230,190,90,0.85); background: rgba(240,200,110,0.16);
  box-shadow: 0 0 14px rgba(240,200,110,0.35); }
.r4-show-paper.touch .r4-zone { border: 1.5px dashed rgba(170,120,40,0.45); }
.r4-zone.found { border-color: #e9c46a; background: rgba(240,200,110,0.30); box-shadow: 0 0 22px rgba(240,200,110,0.7);
  animation: r4ZoneFound 0.6s cubic-bezier(.2,.9,.3,1.4); }
@keyframes r4ZoneFound { from { transform: scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }
.r4-zone.missed { animation: r4ZoneMiss 0.5s ease; }
@keyframes r4ZoneMiss { 30% { background: rgba(150,30,20,0.25); border-color: rgba(190,60,40,0.8); } 100% { background: transparent; } }

/* The narrator's screen */
.r4-intro { position: absolute; inset: 0; z-index: 25; display: none; background: #060302;
  align-items: center; justify-content: center; transition: opacity 2s ease; }
.r4-intro.on { display: flex; }
.r4-intro.out { opacity: 0; pointer-events: none; }
.r4-intro-glow { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 55% 45% at 50% 52%, rgba(255,170,80,0.13), transparent 70%);
  animation: r4LampFlicker 4.3s infinite; }
.r4-intro-text { position: relative; max-width: 980px; text-align: center; padding-bottom: 40px;
  font-family: 'IM Fell English', serif; font-size: 34px; line-height: 1.55; color: #ecd9ae; }
.r4-intro-text p { margin: 0 0 14px; }
.r4-intro-text span { opacity: 0; transition: opacity 1.1s ease, color 1.4s ease; text-shadow: 0 0 18px rgba(0,0,0,0.9); }
.r4-intro-text span.said { opacity: 1; }
.r4-intro-text span.past { opacity: 0.42; }
.r4-show-paper.text { width: 680px; height: auto; max-height: 100%; display: block; overflow: auto; box-sizing: border-box; padding: 40px 48px;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 24px; line-height: 1.5; color: #2a1a0c; cursor: pointer;
  background: linear-gradient(180deg, #ecdcb4, #dcc597); box-shadow: 0 16px 50px rgba(0,0,0,0.9); }
.r4-show-paper.text p { margin: 0 0 0.8em; }
.r4-proof.found { background: rgba(201,162,39,0.55); box-shadow: 0 0 0 3px rgba(201,162,39,0.6); border-radius: 3px; }
.r4-show-paper.miss { animation: spineShake 0.4s ease; }
.r4-loupe {
  position: absolute; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  border: 4px solid #c9a227; box-shadow: 0 0 0 3px rgba(0,0,0,0.5), 0 0 30px rgba(255,220,130,0.9), inset 0 0 30px rgba(255,230,160,0.45);
  animation: r4LoupeIn 0.6s cubic-bezier(.2,.9,.3,1.4);
}
@keyframes r4LoupeIn { from { transform: translate(-50%, -50%) scale(2.2); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.r4-watch { position: relative; flex: 0 0 auto; width: 290px; height: 290px; filter: drop-shadow(0 10px 22px rgba(0,0,0,0.85)); }
.r4-watch img { position: absolute; inset: 0; width: 100%; height: 100%; }
.r4-watch .watch-hand { transform-origin: 49.68% 59.25%; transition: transform 0.16s cubic-bezier(.3,1.8,.5,1);
  filter: drop-shadow(1px 2px 1.5px rgba(0,0,0,0.5)); }
.r4-watch.urgent { animation: r4WatchPulse 1s ease-in-out infinite; }
@keyframes r4WatchPulse { 0%,100% { scale: 1; } 12% { scale: 1.035; } }
.r4-cue { transition: opacity 0.4s ease; }

/* ════════════════════════════════════════════════════════════════
   v4.0 — THE DEBRIEF: two pages over the hall Mara has just left
   ════════════════════════════════════════════════════════════════ */
.end-pointer { margin-top: 1rem; max-width: 300px; font-family: 'IM Fell English', serif; font-style: italic;
  font-size: 1.02rem; line-height: 1.45; letter-spacing: 0; color: var(--parchment-light); }
#screen-debrief { overflow: hidden; }
#screen-debrief .bg-debrief { background-image: url('../assets/img/end/end-debrief-bg.webp'); background-size: cover; background-position: center; filter: none; }
#screen-debrief .bg-debrief::after { animation: none; opacity: 0; }
.db-bar { position: absolute; left: 0; right: 0; top: 52px; height: 48px; z-index: 5;
  display: flex; align-items: center; justify-content: center; }
.db-back, .db-again { position: absolute; top: 4px; margin: 0; }
.db-back { left: 60px; opacity: 0.8; }
.db-again { right: 60px; }
.db-tabs { display: flex; gap: 26px; }
.db-tab { min-width: 300px; height: 40px; border-radius: 6px 6px 3px 3px; cursor: pointer;
  font-family: 'Cinzel', serif; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase;
  background: linear-gradient(180deg, #3a2210, #2a170a); color: #a88c5c; border: 1px solid var(--amber-dark);
  box-shadow: 0 6px 16px rgba(0,0,0,0.6); transition: background 0.2s, color 0.2s, transform 0.2s; }
.db-tab:hover { color: #e3cc98; }
.db-tab.on { background: linear-gradient(180deg, #6a4019, #4e2d12); color: #f0deb2; border-color: var(--gold); transform: translateY(-2px); }

.db-page { position: absolute; left: 0; right: 0; top: 108px; bottom: 70px; z-index: 3;
  opacity: 0; pointer-events: none; transform: translateX(40px); transition: opacity 0.45s ease, transform 0.55s cubic-bezier(.2,.8,.3,1); }
.db-page.on { opacity: 1; pointer-events: auto; transform: none; }
.db-paper { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* page 1: the case file */
.db-file { position: absolute; left: 50%; top: 0; width: 1250px; height: 716px; transform: translateX(-50%) rotate(-0.3deg);
  filter: drop-shadow(0 18px 30px rgba(0,0,0,0.75)); }
.db-file-body { position: absolute; inset: 46px 92px 34px; display: flex; flex-direction: column; color: #24140a; }
.db-file-title { font-family: 'Cinzel', serif; font-size: 17px; letter-spacing: 0.22em; text-transform: uppercase; color: #4e3014; text-align: center; }
.db-score { display: flex; justify-content: center; gap: 46px; margin: 8px 0 10px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(110,70,25,0.4); font-family: 'IM Fell English', serif; font-size: 21px; color: #4a2e14; }
.db-score b { font-family: 'Cinzel', serif; font-size: 30px; color: #2a170a; margin-right: 6px; font-weight: 600; }
.db-rooms { display: flex; flex-direction: column; gap: 8px; }
.db-room { display: grid; grid-template-columns: 200px 1fr 190px; gap: 20px; align-items: start;
  padding-bottom: 8px; border-bottom: 1px dashed rgba(110,70,25,0.28); }
.db-room-head { font-family: 'Cinzel', serif; font-size: 16px; letter-spacing: 0.06em; color: #24140a; line-height: 1.35; font-weight: 600; }
.db-num { display: block; font-size: 14px; letter-spacing: 0.2em; color: #6b4720; }
.db-room-text { font-family: 'IM Fell English', serif; font-size: 19.5px; line-height: 1.27; color: #1e1108; }
.db-hard { margin-top: 5px; color: #6a1f0e; }
.db-room-stats { display: flex; gap: 16px; justify-content: flex-end; font-family: 'Cinzel', serif; font-size: 20px; color: #2a170a; text-align: center; }
.db-room-stats small { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #5a3a18; }
.db-takeaway { margin-top: auto; font-family: 'IM Fell English', serif; font-size: 19px; line-height: 1.35; color: #24140a; text-align: center; }
.db-label { display: block; font-family: 'Cinzel', serif; font-style: normal; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: #4e3014; margin-bottom: 3px; font-weight: 600; }

.db-voss-note { position: absolute; right: 14px; bottom: 10px; width: 150px; padding: 16px 14px 14px; cursor: pointer;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 16px; line-height: 1.3; color: #3a220e;
  background: linear-gradient(160deg, #e7d4a6 0%, #d3b77f 55%, #b99a62 100%); border: none; transform: rotate(4deg);
  box-shadow: 0 10px 22px rgba(0,0,0,0.7); clip-path: polygon(0 0, 82% 0, 100% 18%, 100% 100%, 0 100%); transition: transform 0.25s; }
.db-voss-note:hover { transform: rotate(2deg) translateY(-4px); }
.db-voss { position: absolute; right: 60px; bottom: 120px; width: 560px; height: 360px; z-index: 6; cursor: pointer;
  opacity: 0; pointer-events: none; transform: translateY(30px) rotate(1.5deg); transition: opacity 0.35s, transform 0.45s cubic-bezier(.2,.8,.3,1);
  filter: drop-shadow(0 16px 30px rgba(0,0,0,0.85)); }
.db-voss.open { opacity: 1; pointer-events: auto; transform: rotate(1.5deg); }
.db-voss p { position: absolute; inset: 44px 52px; margin: 0; font-family: 'IM Fell English', serif; font-size: 19px; line-height: 1.42; color: #24140a; }

/* page 2: Pryce's six statements */
.db-cards { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 1470px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 24px; }
.db-card { position: relative; height: 352px; transform: rotate(var(--tilt, 0deg)); filter: drop-shadow(0 12px 20px rgba(0,0,0,0.7)); }
.db-card-body { position: absolute; inset: 24px 36px 24px 34px; display: flex; flex-direction: column; color: #1e1108; }
.db-err { font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; color: #7e1e10; font-weight: 700; }
.db-quote { margin-top: 4px; font-family: 'IM Fell English', serif; font-size: 19px; line-height: 1.25; }
.db-quote s { text-decoration: line-through; text-decoration-color: rgba(150,20,10,0.9); text-decoration-thickness: 2px; }
.db-did { margin-top: 5px; font-family: 'IM Fell English', serif; font-size: 18px; line-height: 1.25; color: #1e1108; }
.db-route { margin-top: 6px; font-family: 'IM Fell English', serif; font-size: 16.5px; line-height: 1.24; color: #2a170a; }
.db-route-label { display: block; font-family: 'Cinzel', serif; font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: #6a1f0e; margin-bottom: 1px; }
.db-route.clean .db-route-label { color: #2f4a1e; }
.db-route-item { display: block; padding-left: 12px; text-indent: -12px; }
.db-route-item::before { content: '– '; }
.db-clinic { margin-top: auto; padding-top: 6px; border-top: 1px solid rgba(110,70,25,0.5);
  font-family: 'IM Fell English', serif; font-size: 17.5px; line-height: 1.25; color: #1e1108; }

/* ════════════════════════════════════════════════════════════════
   v4.1 — ROOM III: THE WORKBENCH
   ════════════════════════════════════════════════════════════════ */
#r3-flask-lightbox.r3-bench-overlay { position: absolute; inset: 0; z-index: 400; display: none; background: #000; padding: 0; }
#r3-flask-lightbox.r3-bench-overlay.open { display: block !important; animation: fadeIn 0.4s ease forwards; }
.r3-bench { position: absolute; inset: 0; overflow: hidden; }
.r3-bench.blast { animation: r3Blast 0.7s cubic-bezier(.36,.07,.19,.97); }
@keyframes r3Blast { 0% { translate: 0 0; } 10% { translate: -16px 9px; } 22% { translate: 14px -10px; } 36% { translate: -10px 6px; }
  52% { translate: 7px -4px; } 70% { translate: -3px 2px; } 100% { translate: 0 0; } }
.r3-bench-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.r3-bench-glow { position: absolute; left: 560px; top: 260px; width: 480px; height: 480px; pointer-events: none; z-index: 1;
  background: radial-gradient(circle, rgba(255,175,70,0.45), rgba(255,140,40,0.12) 45%, transparent 70%);
  opacity: 0; transition: opacity 1.6s ease; mix-blend-mode: screen; }
.r3-bench-glow.on { opacity: 1; animation: r3GlowPulse 2.8s ease-in-out 1.6s infinite; }
@keyframes r3GlowPulse { 50% { opacity: 0.72; } }
.r3-shelf { position: absolute; inset: 0; }   /* no z-index: its bottles and droppers layer with the flask */

.r3-dropper { position: absolute; z-index: -1; pointer-events: none; transform-origin: 50% 99.1%; }
.r3-dropper.free { z-index: 6;
  transition: left 0.75s cubic-bezier(.45,.05,.3,1), top 0.75s cubic-bezier(.45,.05,.3,1), width 0.75s cubic-bezier(.45,.05,.3,1),
              height 0.75s cubic-bezier(.45,.05,.3,1), transform 0.75s cubic-bezier(.45,.05,.3,1); }
.r3-dropper.held { filter: drop-shadow(6px 8px 8px rgba(0,0,0,0.55)); }
.r3-dropper.squeeze { animation: r3Squeeze 0.32s ease; }
@keyframes r3Squeeze { 40% { scale: 1 0.96; } }

.r3-bottle { position: absolute; z-index: 4; cursor: pointer; transform-origin: 50% 98.7%;
  transition: left 0.7s cubic-bezier(.45,.05,.3,1), top 0.7s cubic-bezier(.45,.05,.3,1), transform 0.7s cubic-bezier(.45,.05,.3,1), filter 0.2s; }
.r3-bottle .r3-bottle-img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.r3-bottle:not(.out):hover { translate: 0 -5px; filter: brightness(1.18) drop-shadow(0 0 8px rgba(255,200,120,0.35)); }
.r3-bottle.out { z-index: 5; filter: drop-shadow(8px 10px 10px rgba(0,0,0,0.6)); }
.r3-bottle-shadow { position: absolute; left: 14%; right: 10%; bottom: 0; height: 7%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.6), transparent 70%); transform: translate(6%, 40%); }
/* the mark on the label: label at x 200–830, y 545–1255 of the 1024 × 1536 picture */
.r3-mark { position: absolute; left: 30%; top: 41%; width: 40%; height: 34%; pointer-events: none;
  fill: #2a180b; stroke: #2a180b; opacity: 0.9; mix-blend-mode: multiply; }

.r3-flask { position: absolute; z-index: 2; left: 662.97px; top: 298.53px; width: 276.76px; height: 415.14px; pointer-events: none; }
.r3-flask.rumble { animation: r3Rumble 0.09s linear infinite; }
@keyframes r3Rumble { 0% { translate: -1.5px 0; } 25% { translate: 1.5px -1px; } 50% { translate: -1px 1px; } 75% { translate: 2px 0; } 100% { translate: -1.5px 0; } }
.r3-flask-shadow { position: absolute; left: 12%; right: 12%; bottom: -1.5%; height: 8%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.65), transparent 70%); }
.r3-liquid { position: absolute; left: 0; top: 0; }
.r3-flask-glass { position: absolute; inset: 0; width: 100%; height: 100%; transition: opacity 0.25s; }
.r3-liquid { z-index: 1; }
/* the glass's reflections, laid again over the liquid: only the bright parts count */
.r3-flask-shine { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none;
  mix-blend-mode: screen; filter: brightness(0.55) contrast(2.6); transition: opacity 0.25s; }
.r3-flask-shine.gone { opacity: 0; }
.r3-flask-glass.gone { opacity: 0; }
.r3-flask-glass.cracked { opacity: 0; }
.r3-flask-glass.cracked.on { opacity: 1; transition: none; }
.r3-flask-glass.cracked.fadeout { opacity: 0; transition: opacity 0.8s; }
.r3-drop-hit { position: absolute; z-index: 3; left: 680px; top: 40px; width: 240px; height: 680px; cursor: pointer; }

.r3-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 7; pointer-events: none; }
.r3-bench-flash { position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 62%, rgba(255,240,200,1), rgba(255,170,80,0.65) 22%, rgba(80,30,10,0.15) 55%, transparent 80%); }
.r3-bench-flash.go { animation: r3Flash 0.75s ease-out forwards; }
@keyframes r3Flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.r3-feedback { position: absolute; z-index: 9; left: 0; right: 0; top: 742px; text-align: center; pointer-events: none;
  font-family: 'Cinzel', serif; font-size: 22px; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0; transition: opacity 0.6s;
  text-shadow: 0 2px 10px #000, 0 0 20px #000; }
.r3-feedback.show { opacity: 1; }
.r3-feedback.good { color: #f0c870; }
.r3-feedback.bad { color: #d9826a; }
.r3-bench-cue { position: absolute; z-index: 9; left: 0; right: 0; top: 784px; text-align: center; pointer-events: none;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 22px; color: var(--parchment-light);
  text-shadow: 0 1px 4px #000, 0 0 14px #000; opacity: 0; transition: opacity 0.5s; }
.r3-bench-cue.show { opacity: 0.92; }
.r3-bench-close { position: absolute; z-index: 10; top: 64px; right: 28px; background: none; border: none; cursor: pointer;
  color: var(--parchment-light); font-size: 2rem; font-family: 'Cinzel', serif; opacity: 0.75; }

/* v4.4 — the camera to the desk: the chair on its own layer */
#screen-room1a.desk-cam { overflow: hidden; }
.desk-cam-chair { position: absolute; z-index: 0; pointer-events: none; will-change: transform; }

/* v5.0 — the hint button glows when a wrong answer points to it */
#hint-btn.glow:not(:disabled) { animation: hintGlow 1.6s ease-in-out 2; }
@keyframes hintGlow { 50% { filter: drop-shadow(0 0 14px rgba(240,200,110,0.95)) brightness(1.5); transform: scale(1.08); } }

/* v5.0 — Voss's writing on the diary on the desk (seen from the room, not readable) */
.desk-diary-ink { position: absolute; left: 0; top: 0; width: 300px; height: 420px; transform-origin: 0 0;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: 17px; line-height: 1.42; color: #2a1406;
  opacity: 0.55; mix-blend-mode: multiply; overflow: hidden; pointer-events: none; }
