/* ============ RESET & BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #c9a35c;
  --gold-bright: #e8c47a;
  --wine: #7a2230;
  --blue: #3fa9f5;
  --blue-deep: #1a3a5c;
  --ink: #2a2018;
  --paper: #ece1c8;
  --paper-dark: #dccba0;
  --bg-0: #050507;
  --bg-1: #0b0b10;
  --bg-2: #14141c;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--gold);
  font-family: 'EB Garamond', serif;
  cursor: default;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

svg { display: block; }

/* ============ AMBIENT LAYERS ============ */
#embers {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: screen;
}

.spotlight {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(circle 260px at var(--mx, 50%) var(--my, 50%), rgba(255, 230, 180, 0.05), rgba(0,0,0,0) 70%);
  transition: background 0.05s linear;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 1.2s steps(4) infinite;
}

@keyframes grainShift {
  0% { transform: translate(0,0); }
  25% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(-1%, -1%); }
  100% { transform: translate(0,0); }
}

.audio-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(201,163,92,0.3);
  background: rgba(10,10,14,0.5);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s, transform 0.3s, color 0.3s;
  backdrop-filter: blur(4px);
}
.audio-toggle:hover { border-color: var(--gold-bright); color: var(--gold-bright); transform: scale(1.08); }
.audio-toggle svg { width: 20px; height: 20px; }
.audio-toggle.muted .icon-on { display: none; }
.audio-toggle:not(.muted) .icon-off { display: none; }

/* ============ SCENES ============ */
.scene {
  position: fixed;
  inset: 0;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.9s ease;
}
.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.scene.instant { transition: none; }

/* ============ SCENE: ROOM ============ */
#scene-room {
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, rgba(60,50,35,0.35), rgba(0,0,0,0) 70%),
    linear-gradient(180deg, #0a0a0f 0%, #050507 55%, #030303 100%);
}

.room-floor {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 30%;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.85) 100%);
}

.room-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 18vw 4vw rgba(0,0,0,0.92);
  pointer-events: none;
}

.door-wrap {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: min(28vw, 300px);
  height: min(44vh, 460px);
  perspective: 1400px;
}

.door-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border: 10px solid #171310;
  border-bottom: none;
  border-radius: 130px 130px 6px 6px / 90px 90px 6px 6px;
  background: #0d0b09;
  box-shadow:
    0 0 0 2px rgba(201,163,92,0.12),
    0 20px 80px rgba(0,0,0,0.8),
    0 0 60px rgba(80,60,20,0.15);
  overflow: hidden;
}

.door {
  position: absolute;
  inset: 6px;
  border-radius: 120px 120px 4px 4px / 84px 84px 4px 4px;
  background:
    repeating-linear-gradient(90deg, #17110c 0px, #1c150e 3px, #17110c 6px),
    linear-gradient(180deg, #241a10 0%, #140e09 100%);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.7,0,.3,1);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.7), inset 0 0 4px rgba(201,163,92,0.15);
}

.door-wrap.opening .door {
  transform: rotateY(-62deg);
}

.door-panel {
  position: absolute;
  left: 12%;
  right: 12%;
  border: 1px solid rgba(201,163,92,0.18);
  border-radius: 6px;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.6);
}
.door-panel.top { top: 8%; height: 36%; }
.door-panel.bottom { top: 50%; height: 42%; }

.lock-plate {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 74px;
  height: 74px;
  transform: translate(-50%, -50%);
}

.lock-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,196,122,0.35), rgba(232,196,122,0) 70%);
  opacity: 0.4;
  animation: lockPulse 3.2s ease-in-out infinite;
}
@keyframes lockPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.92); }
  50% { opacity: 0.55; transform: scale(1.06); }
}

.lock-svg { width: 100%; height: 100%; filter: drop-shadow(0 0 4px rgba(0,0,0,0.6)); }
.lock-ring { fill: #1c150d; stroke: var(--gold); stroke-width: 3; }
.lock-hole-circle, .lock-hole-shaft { fill: #050505; stroke: var(--gold-bright); stroke-width: 1.5; }

.door-wrap.unlocking .lock-glow {
  animation: lockFlash 0.9s ease-out forwards;
}
@keyframes lockFlash {
  0% { opacity: 0.4; }
  60% { opacity: 1; transform: scale(1.8); background: radial-gradient(circle, rgba(255,240,200,0.8), rgba(255,240,200,0) 70%); }
  100% { opacity: 0; transform: scale(2.6); }
}

.door-light-burst {
  position: absolute;
  inset: 6px;
  border-radius: 120px 120px 4px 4px / 84px 84px 4px 4px;
  background: radial-gradient(circle at 30% 50%, rgba(255,244,214,0.95), rgba(255,220,160,0.4) 45%, rgba(0,0,0,0) 75%);
  opacity: 0;
  pointer-events: none;
}
.door-wrap.opening .door-light-burst {
  animation: burstIn 1.3s ease-out 0.5s forwards;
}
@keyframes burstIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.door-shadow {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  width: 70%;
  height: 22px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.7), rgba(0,0,0,0) 70%);
}

/* ---- KEY ---- */
.key-wrap {
  position: absolute;
  left: 50%;
  bottom: 9%;
  width: 132px;
  height: 66px;
  margin-left: -66px;
  z-index: 8;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.6));
  animation: keyFloat 4.5s ease-in-out infinite;
  transition: filter 0.3s;
}
.key-wrap:hover { filter: drop-shadow(0 6px 22px rgba(232,196,122,0.5)); }
.key-wrap:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 6px; border-radius: 8px; }

@keyframes keyFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-9px) rotate(2deg); }
}

.key-svg { width: 100%; height: 100%; overflow: visible; }
.key-bow { fill: #4a3a1e; stroke: var(--gold-bright); stroke-width: 2.5; }
.key-bow-hole { fill: #050505; }
.key-shaft, .key-tooth { fill: #4a3a1e; stroke: var(--gold-bright); stroke-width: 2; }

.key-glint {
  position: absolute;
  top: 0; left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 100%);
  transform: skewX(-20deg);
  animation: glintSweep 4.5s ease-in-out infinite;
  animation-delay: 1.2s;
  pointer-events: none;
}
@keyframes glintSweep {
  0%, 65%, 100% { left: -40%; opacity: 0; }
  70% { opacity: 0.8; }
  85% { left: 120%; opacity: 0; }
}

.key-wrap.locked-out {
  animation: none;
  opacity: 0.35;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.key-wrap.flying {
  animation: none;
  z-index: 40;
}

/* ---- MESSAGE ---- */
.message-wrap {
  position: absolute;
  left: 50%;
  top: 5%;
  transform: translateX(-50%);
  text-align: center;
  width: 90%;
  max-width: 580px;
  z-index: 9;
}

.message-plate {
  padding: 14px 22px 16px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(8,7,6,0.55), rgba(8,7,6,0.28));
  backdrop-filter: blur(2px);
}

.message-label {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.95rem, 2vw, 1.5rem);
  letter-spacing: 0.05em;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(232,196,122,0.35);
  min-height: 1.4em;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message-sub {
  margin-top: 8px;
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: rgba(201,163,92,0.5);
  min-height: 1.2em;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translate(-50%, 20px);
  padding: 12px 22px;
  border-radius: 30px;
  background: rgba(15,12,8,0.9);
  border: 1px solid rgba(201,163,92,0.3);
  color: var(--gold-bright);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(2,2,3,0.75);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease;
}
.modal-overlay.show { opacity: 1; visibility: visible; }

.modal-box {
  width: min(88vw, 420px);
  padding: 38px 32px 30px;
  background: linear-gradient(180deg, #141019 0%, #0c0a10 100%);
  border: 1px solid rgba(201,163,92,0.25);
  border-radius: 4px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.4);
  transform: scale(0.92) translateY(10px);
  transition: transform 0.35s cubic-bezier(.2,1.4,.4,1);
}
.modal-overlay.show .modal-box { transform: scale(1) translateY(0); }

.modal-sigil { display: flex; justify-content: center; margin-bottom: 18px; }
.modal-sigil svg { width: 46px; height: 46px; }
.modal-sigil circle, .modal-sigil path { fill: none; stroke: var(--gold); stroke-width: 1; }

.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: var(--gold-bright);
  margin-bottom: 14px;
  letter-spacing: 0.03em;
}
.modal-body {
  font-size: 1.02rem;
  line-height: 1.6;
  color: rgba(230,220,200,0.75);
  margin-bottom: 28px;
}

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

.btn {
  padding: 11px 22px;
  border-radius: 3px;
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn-ghost {
  border: 1px solid rgba(201,163,92,0.35);
  color: rgba(230,220,200,0.7);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1408;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(201,163,92,0.35);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(201,163,92,0.5); }
.btn:active { transform: translateY(0) scale(0.97); }

.admin-password-input {
  width: 100%;
  margin: 6px 0 4px;
  padding: 11px 12px;
  border-radius: 3px;
  border: 1px solid rgba(201,163,92,0.3);
  background: rgba(0,0,0,0.35);
  color: var(--gold-bright);
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  text-align: center;
  outline: none;
}
.admin-password-input:focus { border-color: var(--gold); }
.admin-error {
  min-height: 1.3em;
  font-size: 0.8rem;
  color: #e3737b;
  margin: 4px 0 12px;
}
.admin-password-input.shake { animation: shake 0.45s ease; }

/* ============ FLASH ============ */
.flash {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: radial-gradient(circle at 50% 48%, #fff6e0 0%, #f3d896 40%, #000 100%);
  opacity: 0;
  pointer-events: none;
}
.flash.active {
  animation: flashPulse 1.6s ease-in-out forwards;
}
@keyframes flashPulse {
  0% { opacity: 0; }
  45% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============ SCENE: BOOK ============ */
#scene-book {
  background: radial-gradient(ellipse 70% 60% at 50% 45%, #1a140c 0%, #0a0806 55%, #030202 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-table {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, rgba(120,90,40,0.12), rgba(0,0,0,0) 60%);
}

.book {
  position: relative;
  width: min(88vw, 860px);
  height: min(74vh, 540px);
  transform-style: preserve-3d;
  transform: rotateX(4deg);
  filter: drop-shadow(0 40px 60px rgba(0,0,0,0.75));
}

.book-aura {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.book.no-anim, .book.no-anim * {
  transition: none !important;
  animation: none !important;
}

.book.pulsing {
  animation: bookHeartbeat 1.7s ease-in-out infinite;
}
.book.pulsing .book-aura {
  opacity: 1;
  animation: auraPulse 1.7s ease-in-out infinite;
}
@keyframes bookHeartbeat {
  0%, 100% { transform: rotateX(4deg) scale(1); }
  14% { transform: rotateX(4deg) scale(1.035); }
  28% { transform: rotateX(4deg) scale(0.99); }
  42% { transform: rotateX(4deg) scale(1.02); }
  60% { transform: rotateX(4deg) scale(1); }
}
@keyframes auraPulse {
  0%, 60%, 100% { box-shadow: 0 0 40px 8px rgba(63,169,245,0.25), 0 0 100px 26px rgba(63,169,245,0.1); }
  14% { box-shadow: 0 0 80px 22px rgba(63,169,245,0.5), 0 0 160px 55px rgba(63,169,245,0.18); }
}

.book-inside {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  transform-style: preserve-3d;
  transition: opacity 0.3s ease;
}
.book.closed .book-inside {
  opacity: 0;
  pointer-events: none;
}

.book-spine {
  position: absolute;
  left: 50%;
  top: -2%;
  bottom: -2%;
  width: 26px;
  margin-left: -13px;
  background: linear-gradient(90deg, rgba(0,0,0,0.5), rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.5));
  z-index: 3;
  border-radius: 3px;
}
.book.closed .book-spine { opacity: 0; }

.page {
  position: relative;
  flex: 1;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0) 12%),
    var(--paper);
  background-blend-mode: overlay, normal;
  box-shadow: inset 0 0 60px rgba(120,90,40,0.15);
  padding: 40px 34px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  animation: pageRise 0.9s ease 0.15s forwards;
}
.page-left {
  border-radius: 6px 2px 2px 6px;
  transform-origin: right center;
}
.page-right {
  border-radius: 2px 6px 6px 2px;
  transform-origin: left center;
  animation-delay: 0.32s;
}
@keyframes pageRise {
  to { opacity: 1; transform: translateY(0); }
}

.page-lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 37px,
    rgba(120,90,40,0.18) 38px
  );
  pointer-events: none;
}

.letter-text {
  position: relative;
  font-family: 'Caveat', cursive;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  line-height: 1.9;
  color: var(--ink);
  white-space: pre-wrap;
}

.ink-char {
  display: inline-block;
  opacity: 0;
  animation: inkReveal 0.45s ease forwards;
}
@keyframes inkReveal {
  from { opacity: 0; transform: translateY(5px) rotate(-3deg); filter: blur(2px); }
  to   { opacity: 1; transform: translateY(0) rotate(0); filter: blur(0); }
}

.candle {
  position: absolute;
  right: 20px;
  bottom: 18px;
  width: 20px;
  height: 60px;
  opacity: 0.85;
}
.candle-body {
  position: absolute;
  bottom: 0; left: 4px;
  width: 12px; height: 44px;
  background: linear-gradient(180deg, #f2e6c8, #d8c79a);
  border-radius: 2px;
}
.candle-flame {
  position: absolute;
  top: -14px; left: 6px;
  width: 8px; height: 16px;
  background: radial-gradient(ellipse at 50% 70%, #fff3c4, #f5a623 60%, rgba(245,166,35,0) 80%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  filter: blur(0.3px) drop-shadow(0 0 8px rgba(245,166,35,0.7));
  animation: flicker 2.4s ease-in-out infinite;
  transform-origin: bottom center;
}
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  20% { transform: scale(1.08, 0.94) rotate(-2deg); }
  45% { transform: scale(0.92, 1.06) rotate(2deg); }
  70% { transform: scale(1.05, 0.97) rotate(-1deg); }
}

.answer-area {
  position: relative;
  font-family: 'Caveat', cursive;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  line-height: 1.9;
  color: var(--ink);
  height: 54%;
  outline: none;
  overflow-y: auto;
  opacity: 0;
  animation: fadeIn 0.8s ease 1.4s forwards;
}
.answer-area:empty:before {
  content: attr(data-placeholder);
  color: rgba(42,32,24,0.4);
  font-style: italic;
}
.answer-area.shake, .signature-input.shake { animation: shake 0.45s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes fadeIn { to { opacity: 1; } }

.signature-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(42,32,24,0.18);
  opacity: 0;
  animation: fadeIn 0.8s ease 1.55s forwards;
}
.signature-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: rgba(42,32,24,0.5);
  white-space: nowrap;
}
.signature-input {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 1px solid rgba(42,32,24,0.35);
  background: transparent;
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  color: var(--ink);
  padding: 2px 4px;
  outline: none;
}
.signature-input:focus { border-bottom-color: var(--wine); }

.seal-btn {
  position: absolute;
  right: 30px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--wine);
  opacity: 0;
  animation: fadeIn 0.8s ease 1.75s forwards;
  transition: transform 0.25s ease;
}
.seal-btn:hover { transform: scale(1.06) rotate(-3deg); }
.seal-btn:active { transform: scale(0.94) rotate(0deg); }
.seal-btn svg { width: 46px; height: 46px; }
.seal-btn circle { fill: radial-gradient(circle, #922, #6a1620); fill: #7a2230; stroke: #e8c47a; stroke-width: 1; }
.seal-btn path { fill: #e8c47a; }
.seal-btn span {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(122,34,48,0.85);
}

/* ---- closing: the right page swings shut over the left page,
   like an actual book, then the whole book shrinks down to a
   small sealed tome ---- */
.book {
  perspective: 1600px;
  transition: width 0.9s cubic-bezier(.6,0,.4,1), height 0.9s cubic-bezier(.6,0,.4,1);
}
.book.small {
  width: 190px;
  height: 250px;
}

.book-inside.closing .page-right {
  animation: pageSwingShut 0.85s cubic-bezier(.55,0,.45,1) forwards;
  transform-origin: left center;
  backface-visibility: hidden;
  z-index: 4;
}
.book-inside.closing .page-left {
  animation: pageDim 0.85s ease forwards;
}
@keyframes pageSwingShut {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(-178deg); }
}
@keyframes pageDim {
  0%, 40% { filter: brightness(1); }
  100% { filter: brightness(0.7); }
}

/* ---- the sealed cover, styled after a card-back wax seal ---- */
.book-cover {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease;
  background:
    repeating-linear-gradient(115deg, rgba(0,0,0,0.08) 0px, rgba(0,0,0,0.08) 2px, transparent 2px, transparent 5px),
    linear-gradient(160deg, #6b4226 0%, #4a2c18 45%, #2c1a0f 100%);
  box-shadow: inset 0 0 0 3px rgba(201,163,92,0.55), inset 0 0 0 6px rgba(0,0,0,0.35), inset 0 0 40px rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.book.closed .book-cover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.book-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(201,163,92,0.55);
  opacity: 0.85;
}
.book-corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.book-corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.book-corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.book-corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.seal-emblem {
  width: 62%;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6));
}
.wax-blobs circle {
  fill: #7a1f2b;
  stroke: #5a1520;
  stroke-width: 1;
}
.seal-star {
  fill: url(#sealGold);
  stroke: #8a6a2e;
  stroke-width: 1.5;
}
.seal-ring {
  fill: url(#sealGold);
  stroke: #8a6a2e;
  stroke-width: 2;
}
.seal-disc {
  fill: url(#sealBlue);
  stroke: #0d1f38;
  stroke-width: 1.5;
}
.seal-spiral {
  stroke: url(#sealGold);
  stroke-width: 7;
  stroke-linecap: round;
}

.cover-codes {
  position: absolute;
  inset: -10%;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
  opacity: 0.5;
  filter: blur(0.5px);
}
.code-row {
  position: absolute;
  left: -12%;
  width: 124%;
  white-space: nowrap;
  letter-spacing: 0.14em;
  color: rgba(201,163,92,0.32);
  animation: codeFlicker 3.6s ease-in-out infinite;
}
.code-row.script-latin { font-family: 'EB Garamond', serif; font-style: italic; }
.code-row.script-greek { font-family: 'Noto Serif', serif; }
.code-row.script-egy { font-family: 'Noto Sans Egyptian Hieroglyphs', 'Noto Serif', serif; }
@keyframes codeFlicker {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.5; }
}

.book-caption {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 480px;
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: #cfe6fb;
  text-align: center;
  line-height: 1.6;
  text-shadow: 0 0 20px rgba(63,169,245,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.book-caption.show { opacity: 1; }

/* ============ SCENE: ADMIN ============ */
#scene-admin {
  background: radial-gradient(ellipse 80% 70% at 50% 30%, #14100c 0%, #050403 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.admin-panel {
  width: min(94vw, 1020px);
  height: min(86vh, 700px);
  background: linear-gradient(180deg, #141019, #0b090c);
  border: 1px solid rgba(201,163,92,0.25);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  border-bottom: 1px solid rgba(201,163,92,0.15);
  flex-shrink: 0;
}
.admin-title {
  font-family: 'Cinzel', serif;
  color: var(--gold-bright);
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}
.admin-close {
  font-size: 1.7rem;
  line-height: 1;
  color: rgba(230,220,200,0.55);
  padding: 4px 8px;
  transition: color 0.2s ease;
}
.admin-close:hover { color: var(--gold-bright); }

.admin-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.admin-col {
  flex: 1;
  padding: 22px 24px;
  overflow-y: auto;
  border-right: 1px solid rgba(201,163,92,0.1);
}
.admin-col-wide { flex: 1.6; border-right: none; }
.admin-col h3 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.admin-add-form { display: flex; gap: 8px; margin-bottom: 18px; }
.admin-add-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 3px;
  border: 1px solid rgba(201,163,92,0.25);
  background: rgba(0,0,0,0.3);
  color: #e7dcc4;
  font-family: 'EB Garamond', serif;
  font-size: 0.92rem;
  outline: none;
}
.admin-add-form input:focus { border-color: var(--gold); }
.admin-add-form button {
  padding: 9px 18px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1408;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  flex-shrink: 0;
}

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-question-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  font-family: 'EB Garamond', serif;
  color: #e7dcc4;
  font-size: 0.88rem;
}
.admin-question-row.inactive { opacity: 0.4; }
.admin-question-row.inactive .admin-question-text { text-decoration: line-through; }
.admin-question-text { flex: 1; }
.admin-question-row button {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: rgba(230,220,200,0.6);
  border: 1px solid rgba(201,163,92,0.25);
  padding: 5px 9px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.admin-question-row button:hover { color: var(--gold-bright); border-color: var(--gold); }

.admin-history { display: flex; flex-direction: column; gap: 14px; }
.admin-history-entry {
  padding: 14px 16px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid var(--gold);
}
.admin-history-date {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 6px;
}
.admin-history-q {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  color: rgba(230,220,200,0.78);
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.admin-history-a {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: #e7dcc4;
  line-height: 1.5;
  white-space: pre-wrap;
}
.admin-history-sig {
  margin-top: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: rgba(201,163,92,0.65);
  text-align: right;
}
.admin-empty {
  color: rgba(230,220,200,0.4);
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  .admin-body { flex-direction: column; overflow-y: auto; }
  .admin-col { border-right: none; border-bottom: 1px solid rgba(201,163,92,0.1); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .door-wrap { width: 54vw; height: 38vh; top: 60%; }
  .key-wrap { width: 100px; height: 50px; margin-left: -50px; bottom: 6%; }
  .message-wrap { top: 4%; max-width: 92%; }
  .message-plate { padding: 10px 14px 12px; }
  .book { height: 82vh; width: 90vw; }
  .book-inside { flex-direction: column; }
  .book-spine { left: 0; right: 0; top: 50%; bottom: auto; height: 20px; width: auto; margin: -10px 0 0; }
  .page { padding: 24px 20px; }
  .answer-area { height: 42%; }
  .signature-line { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
