/* im fell english = the inky old-print face for most of the reading.
   pinyon script = the flourishy mastheads. special elite = typewriter
   for the little labels + stamps. eb garamond is just a fallback. */
@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IM+Fell+English:ital@0;1&family=IM+Fell+English+SC&family=Pinyon+Script&family=Special+Elite&display=swap");

:root {
  --ink: #0a0705;
  --page: #e9dfc6; /* aged paper - the book, before + after the tunnel */
  --ink-text: #33240f;
  --ink-dim: rgba(62, 44, 20, 0.6);
  --ink-faint: rgba(70, 50, 25, 0.35);
  --accent: #8c2f23; /* queen-of-hearts red */
  --paper: #e6d9bc;
  --paper-dim: #cdbd9c;
  --gold: #c9a55c;
  --gold-bright: #e8c87a;
  --gold-faint: rgba(201, 165, 92, 0.35);
  --sepia-text: rgba(226, 212, 184, 0.82);
  --sepia-dim: rgba(196, 178, 148, 0.5);
  --teal-science: rgba(146, 178, 168, 0.55);
  /* dark brocade wallpaper the paper scraps sit on */
  --damask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88'%3E%3Crect width='88' height='88' fill='%23251a0f'/%3E%3Cg stroke='%233a2a18' stroke-width='1.3' fill='none'%3E%3Cpath d='M44 0 L88 44 L44 88 L0 44 Z'/%3E%3C/g%3E%3Cg fill='%23352510'%3E%3Cpath d='M44 30 q9 14 0 28 q-9 -14 0 -28 Z'/%3E%3Cpath d='M30 44 q14 9 28 0 q-14 -9 -28 0 Z'/%3E%3Ccircle cx='44' cy='44' r='3'/%3E%3Ccircle cx='0' cy='0' r='2.4'/%3E%3Ccircle cx='88' cy='0' r='2.4'/%3E%3Ccircle cx='0' cy='88' r='2.4'/%3E%3Ccircle cx='88' cy='88' r='2.4'/%3E%3C/g%3E%3C/svg%3E");
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  overflow-x: hidden;
}
body {
  background: var(--page);
  color: var(--sepia-text);
  font-family: "EB Garamond", Georgia, serif;
  overflow-x: hidden;
}

.scroll-runway {
  height: 42000px;
  position: relative;
}

/* painted layers */
#bg-canvas,
#fx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}
#bg-canvas {
  z-index: 1;
}
#fx-canvas {
  z-index: 5;
  pointer-events: none;
}

/* cinematic */
.cbar {
  position: fixed;
  left: 0;
  width: 100%;
  background: #181009;
  z-index: 50;
  pointer-events: none;
  height: 6vh;
}
.cbar.top {
  top: 0;
}
.cbar.bot {
  bottom: 0;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  animation: gs 0.09s steps(2) infinite;
}
@keyframes gs {
  to {
    background-position: 100% 100%;
  }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 45%,
    rgba(46, 30, 12, 0.42) 100%
  );
}

/* corner labels */
.corner {
  position: fixed;
  z-index: 55;
  pointer-events: none;
  font-family: "Special Elite", monospace;
  font-size: 0.55rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(201, 165, 92, 0.22);
  opacity: 0;
  animation: fi 1.5s 3.2s forwards;
}
body.on-paper .corner {
  color: var(--ink-faint);
}
body.on-paper .sound-toggle {
  background: rgba(238, 229, 205, 0.5);
  border-color: var(--ink-faint);
  color: var(--ink-dim);
}
.tl {
  top: calc(6vh + 0.8rem);
  left: 1.5rem;
}
.tr {
  top: calc(6vh + 0.8rem);
  right: 1.5rem;
  text-align: right;
}

/* opening: a torn encyclopaedia leaf, pinned to dark brocade */
.refpage {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  perspective: 1300px;
  --dive: 0;
}
.refpage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--damask) repeat, #1d140b;
  opacity: calc(1 - max(0, var(--dive) - 0.35) * 1.9);
}
/* the reference page turns like a book page - hinged on its left edge */
.ref-sheet {
  position: relative;
  width: min(47rem, 92vw);
  max-height: 88vh;
  padding: clamp(1.7rem, 4vw, 3rem) clamp(1.8rem, 4.6vw, 3.2rem);
  text-align: left;
  color: #36281a;
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  transform-origin: 0% 50%;
  transform: rotate(-1deg) rotateY(calc(var(--dive) * -168deg));
  opacity: calc(1 - max(0, var(--dive) - 0.42) * 1.2);
  filter: brightness(calc(1 - var(--dive) * 0.34));
  backface-visibility: hidden;
  will-change: transform, opacity;
}
/* the paper itself - a torn, stained sheet behind the text */
.ref-sheet::before {
  content: "";
  position: absolute;
  inset: -12px -10px;
  z-index: -1;
  background:
    radial-gradient(ellipse at 14% 8%, rgba(255, 252, 242, 0.6), transparent 55%),
    radial-gradient(ellipse at 88% 96%, rgba(120, 84, 44, 0.3), transparent 58%),
    radial-gradient(circle at 70% 30%, rgba(150, 110, 60, 0.16), transparent 40%),
    linear-gradient(168deg, #efe7d1, #e6dabb 60%, #d8c79f);
  filter: url(#paper-torn) drop-shadow(0 20px 36px rgba(0, 0, 0, 0.55));
}

.ref-runhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  border-bottom: 1px solid rgba(70, 50, 25, 0.3);
  padding-bottom: 0.45rem;
}
.ref-runhead span:first-child {
  font-family: "Pinyon Script", cursive;
  font-size: clamp(1.1rem, 2.8vw, 1.7rem);
  color: #5a3d22;
  letter-spacing: 0.01em;
}
.ref-runhead span:last-child {
  font-family: "Special Elite", monospace;
  font-size: clamp(0.5rem, 1.2vw, 0.64rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ref-title {
  margin-top: 0.7rem;
  font-family: "IM Fell English SC", "IM Fell English", serif;
  font-weight: 400;
  font-size: clamp(2.1rem, 5.8vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: #2b1d10;
}
.ref-pron {
  margin-top: 0.25rem;
  font-style: italic;
  font-size: clamp(0.86rem, 1.8vw, 1.02rem);
  color: var(--ink-dim);
}
.ref-pron em { color: #2b1d10; }
/* a fleuron between two rules, slightly off-centre */
.ref-rule {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.9rem 0 1.2rem;
  color: rgba(140, 47, 35, 0.7);
}
.ref-rule::before, .ref-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(70, 50, 25, 0.34);
}
.ref-rule::after { flex: 0.78; }
.ref-rule span { font-size: 0.9rem; line-height: 1; }
.ref-cols {
  display: flex;
  gap: clamp(1.2rem, 3vw, 2.2rem);
  align-items: flex-start;
}
.ref-body {
  flex: 1 1 auto;
  font-size: clamp(0.96rem, 1.95vw, 1.12rem);
  line-height: 1.66;
  text-align: justify;
  hyphens: auto;
}
.ref-body p { margin-bottom: 0.8rem; }
.ref-lead .dropcap {
  float: left;
  font-family: "IM Fell English SC", serif;
  font-size: 3.2em;
  line-height: 0.7;
  padding: 0.06em 0.12em 0 0;
  color: var(--accent);
}
.ref-body em { font-style: italic; color: #2b1d10; }
.ref-body sup {
  font-size: 0.64em;
  color: var(--accent);
  padding-left: 0.05em;
}
.ref-faint { color: var(--ink-faint); font-style: italic; }
.ref-h2 {
  margin: 0.3rem 0 0.55rem;
  font-family: "IM Fell English SC", serif;
  font-weight: 400;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  letter-spacing: 0.04em;
  color: #2b1d10;
}
/* the infobox - a tilted index-card scrap, taped on */
.ref-box {
  position: relative;
  flex: 0 0 clamp(8.8rem, 22vw, 12rem);
  margin-top: 0.4rem;
  border: 1px solid rgba(96, 66, 32, 0.45);
  background:
    radial-gradient(ellipse at 80% 90%, rgba(120, 84, 44, 0.18), transparent 60%),
    linear-gradient(160deg, #f0e7cf, #e2d3ac);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32), 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: clamp(0.68rem, 1.4vw, 0.8rem);
  transform: rotate(1.6deg);
}
.ref-box::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 46px;
  height: 18px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(214, 198, 150, 0.55);
  border: 1px solid rgba(150, 120, 70, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.rb-head {
  background: rgba(120, 84, 44, 0.2);
  border-bottom: 1px solid rgba(96, 66, 32, 0.35);
  padding: 0.4rem 0.6rem;
  font-family: "IM Fell English SC", serif;
  letter-spacing: 0.04em;
  color: #2b1d10;
}
.ref-box dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.6rem;
  padding: 0.6rem;
  line-height: 1.4;
}
.ref-box dt {
  font-family: "Special Elite", monospace;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}
.ref-box dd { color: var(--ink-dim); }
.ref-box dd em { font-style: italic; color: #2b1d10; }
.ref-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 1.2rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(70, 50, 25, 0.3);
  font-family: "Special Elite", monospace;
  font-size: clamp(0.5rem, 1.2vw, 0.64rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ref-cue { color: rgba(140, 47, 35, 0.75); }
.ref-loading { animation: bob 2s ease-in-out infinite; transition: opacity 0.6s; }
.refpage.ready .ref-loading { opacity: 0; animation: none; }

/* red rubber-stamp tagline, slapped on crooked */
.ref-stamp {
  position: absolute;
  top: clamp(2.6rem, 7vw, 4.2rem);
  right: clamp(1rem, 3vw, 2.2rem);
  font-family: "Special Elite", monospace;
  font-size: clamp(0.6rem, 1.5vw, 0.82rem);
  line-height: 1.35;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(150, 40, 30, 0.72);
  border: 2px solid rgba(150, 40, 30, 0.55);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  transform: rotate(8deg);
  mix-blend-mode: multiply;
  opacity: 0.88;
}
/* handwritten margin note */
.ref-note {
  position: absolute;
  top: clamp(0.4rem, 2vw, 1.2rem);
  right: clamp(7rem, 22vw, 12rem);
  font-family: "Pinyon Script", cursive;
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  line-height: 1.1;
  text-align: center;
  color: rgba(40, 60, 110, 0.7);
  transform: rotate(-7deg);
}

@media (max-width: 640px) {
  .ref-cols { flex-direction: column; }
  .ref-box { flex-basis: auto; width: 100%; transform: rotate(0.8deg); }
  .ref-stamp { top: 3.4rem; }
  .ref-note { display: none; }
}

/* the title card you fall through - same torn-paper-on-brocade world as page one */
.dive-line {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  padding: 0 1.5rem;
}
.dive-line::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    var(--damask) repeat,
    #1d140b;
}
.dl-card {
  position: relative;
  max-width: 33rem;
  padding: clamp(1.8rem, 5vw, 2.8rem) clamp(2rem, 6vw, 3.4rem);
  text-align: center;
  color: #2b1d10;
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  transform: translateY(12px) rotate(-1deg);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.dive-line.on .dl-card { transform: translateY(0) rotate(-1deg); }
.dl-card::before {
  content: "";
  position: absolute;
  inset: -12px -10px;
  z-index: -1;
  background:
    radial-gradient(ellipse at 16% 8%, rgba(255, 252, 242, 0.6), transparent 55%),
    radial-gradient(ellipse at 86% 96%, rgba(120, 84, 44, 0.3), transparent 58%),
    linear-gradient(168deg, #efe7d1, #e6dabb 60%, #d8c79f);
  filter: url(#paper-torn) drop-shadow(0 18px 38px rgba(0, 0, 0, 0.6));
}
.dl-title {
  font-family: "IM Fell English SC", serif;
  font-size: clamp(1.9rem, 5.6vw, 3rem);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: #2b1d10;
}
.dl-rule {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 72%;
  margin: 0.85rem auto 1rem;
  color: rgba(140, 47, 35, 0.7);
}
.dl-rule::before, .dl-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(70, 50, 25, 0.32);
}
.dl-rule span { font-size: 0.9rem; line-height: 1; }
.dl-quote {
  font-style: italic;
  font-size: clamp(1rem, 2.3vw, 1.28rem);
  line-height: 1.55;
  color: #3c2c1a;
}
.dl-attr {
  margin-top: 0.7rem;
  font-family: "Special Elite", monospace;
  font-size: clamp(0.5rem, 1.2vw, 0.62rem);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}
.dl-cue {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(70, 50, 25, 0.22);
  font-family: "Special Elite", monospace;
  font-size: clamp(0.6rem, 1.4vw, 0.74rem);
  letter-spacing: 0.05em;
  line-height: 1.4;
  color: #5a3d22;
}
.dl-cue span:last-child { color: rgba(140, 47, 35, 0.78); }
/* the sound cue is the loud one - it points up to the toggle */
.dl-sound {
  color: var(--accent) !important;
  font-size: 1.12em;
  letter-spacing: 0.06em;
  text-shadow: 0 0 0 transparent;
  animation: dl-sound-beat 1.5s ease-in-out infinite;
}
@keyframes dl-sound-beat {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; text-shadow: 0 0 12px rgba(140, 47, 35, 0.4); }
}
@media (prefers-reduced-motion: reduce) {
  .dl-sound { animation: none; opacity: 1; }
}

/* inspect hint (shows while you're holding a prop) */
.inspect-hint {
  position: fixed;
  bottom: calc(6vh + 3.6rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 66;
  pointer-events: none;
  font-family: "Special Elite", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(232, 200, 122, 0.8);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.45s;
}
.inspect-hint.on {
  opacity: 1;
}

/* specimen tag (hover label on the 3d props) */
.specimen-tag {
  position: fixed;
  z-index: 66;
  pointer-events: none;
  transform: translate(-50%, -100%);
  font-family: "Special Elite", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #3a2a14;
  background: linear-gradient(170deg, #ead9b6, #d4bd8e);
  border: 1px solid rgba(96, 66, 32, 0.4);
  border-radius: 2px;
  padding: 0.3rem 0.65rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.35s;
}
.specimen-tag.on {
  opacity: 1;
}

/* grab cue - deliberately NOT parchment, so "you can touch this" reads
   as its own thing, separate from the written tags */
.turn-cue {
  position: fixed;
  z-index: 67;
  pointer-events: none;
  transform: translate(-50%, 0);
  font-family: "Special Elite", monospace;
  font-size: 0.56rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-bright);
  background: rgba(16, 10, 4, 0.7);
  border: 1px solid rgba(232, 200, 122, 0.55);
  border-radius: 2rem;
  padding: 0.3rem 0.75rem;
  opacity: 0;
  transition: opacity 0.3s;
  animation: turn-pulse 1.5s ease-in-out infinite;
}
.turn-cue.on {
  opacity: 1;
}
@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 13px rgba(232, 200, 122, 0.18); }
  50% { box-shadow: 0 0 26px rgba(232, 200, 122, 0.5); }
}
@media (prefers-reduced-motion: reduce) {
  .turn-cue { animation: none; }
}

/* white rabbit plate */
.rabbit-plate {
  position: fixed;
  left: 27%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-2deg) scale(0.96);
  z-index: 58;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 1.2s ease,
    transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
  width: clamp(150px, 22vw, 240px);
}
.rabbit-plate.on {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-2deg) scale(1);
}
/* while the plate's up, push the hero text over to the right */
.text-layer.beside-plate .hero {
  margin-left: 30vw;
  max-width: 24rem;
  text-align: left;
}
@media (max-width: 700px) {
  .rabbit-plate {
    left: 50%;
    top: 32%;
  }
  .text-layer.beside-plate .hero {
    margin-left: 0;
    margin-top: 38vh;
    max-width: 90vw;
    text-align: center;
    font-size: 0.95rem;
  }
}
.rabbit-plate img {
  width: 100%;
  display: block;
  border: 1px solid rgba(201, 165, 92, 0.25);
  outline: 6px solid rgba(20, 14, 8, 0.85);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  filter: sepia(0.18) brightness(0.94);
}
.rp-caption {
  margin-top: 0.7rem;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  font-style: italic;
}

/* hero text */
.text-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 2rem;
}
/* the "after the tunnel" beat - a torn note in the same letterpress world */
.hero {
  position: relative;
  font-family: "IM Fell English SC", "IM Fell English", serif;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(1.15rem, 2.8vw, 1.95rem);
  text-align: center;
  max-width: 28rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: #2b1d10;
  padding: clamp(1.6rem, 4vw, 2.6rem) clamp(2rem, 5vw, 3.2rem);
  opacity: 0;
  transform: translateY(8px) rotate(-1.2deg);
  transition:
    opacity 0.85s ease,
    transform 0.85s ease;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -10px -8px;
  z-index: -1;
  background:
    radial-gradient(ellipse at 16% 8%, rgba(255, 252, 242, 0.6), transparent 55%),
    radial-gradient(ellipse at 86% 96%, rgba(120, 84, 44, 0.28), transparent 58%),
    linear-gradient(168deg, #efe7d1, #e6dabb 60%, #d8c79f);
  filter: url(#paper-torn) drop-shadow(0 16px 32px rgba(0, 0, 0, 0.42));
}
.hero.on {
  opacity: 1;
  transform: translateY(0) rotate(-1.2deg);
}
.hero em {
  font-style: italic;
  color: var(--accent);
}
.hero .dim {
  font-size: 0.78em;
  font-style: italic;
  color: var(--ink-dim);
}
.sub {
  font-size: clamp(0.7rem, 1.4vw, 0.85rem);
  font-variant: small-caps;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin-top: 0.8rem;
  opacity: 0;
  transition: opacity 0.85s 0.25s;
}
.sub.on {
  opacity: 1;
}

/* memory caption cards - aged paper scraps */
.memcard {
  position: fixed;
  top: 54%;
  z-index: 12;
  pointer-events: none;
  max-width: clamp(12rem, 21vw, 16rem);
  opacity: 0;
  transition:
    opacity 0.9s ease,
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  transform: translateY(16px);
}
.memcard.on {
  opacity: 1;
  transform: translateY(0);
}
.memcard.left {
  left: clamp(1rem, 6vw, 5rem);
  transform: translateY(16px) rotate(-1.3deg);
}
.memcard.right {
  right: clamp(1rem, 6vw, 5rem);
  text-align: right;
  transform: translateY(16px) rotate(1.1deg);
}
.memcard.left.on {
  transform: translateY(0) rotate(-1.3deg);
}
.memcard.right.on {
  transform: translateY(0) rotate(1.1deg);
}
.mc-inner {
  /* aged cream paper, lit by lantern light */
  background:
    radial-gradient(ellipse at 8% 6%, rgba(255, 250, 235, 0.5), transparent 55%),
    radial-gradient(ellipse at 94% 96%, rgba(146, 105, 58, 0.4), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(120, 84, 44, 0.35), transparent 60%),
    linear-gradient(166deg, #ead9b6, #d9c294 58%, #c8ad7c);
  border: 1px solid rgba(96, 66, 32, 0.35);
  border-radius: 2px 7px 3px 8px;
  padding: 0.9rem 1.15rem;
  box-shadow:
    0 10px 34px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 0 26px rgba(124, 90, 46, 0.28);
}
.mc-text {
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  font-style: normal;
  font-size: clamp(0.8rem, 1.6vw, 0.98rem);
  color: #332413;
  line-height: 1.58;
}
.mc-text em {
  color: #7a3326;
  font-weight: 500;
}

/* hud */
.hud-timer,
.hud-mem {
  position: fixed;
  bottom: calc(6vh + 1.4rem);
  z-index: 62;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s;
}
.hud-timer {
  right: clamp(1rem, 3vw, 2.5rem);
  text-align: right;
}
.hud-mem {
  left: clamp(1rem, 3vw, 2.5rem);
}
.hud-timer.on,
.hud-mem.on {
  opacity: 1;
}
.hud-val {
  font-family: "Special Elite", monospace;
  font-size: clamp(0.85rem, 2vw, 1.25rem);
  color: rgba(201, 165, 92, 0.65);
  letter-spacing: 0.04em;
}
.hud-depth {
  margin-top: 0.45rem;
  font-size: clamp(0.6rem, 1.4vw, 0.8rem);
  color: rgba(201, 165, 92, 0.4);
}
.hud-label {
  font-family: "Special Elite", monospace;
  font-size: 0.38rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(201, 165, 92, 0.24);
  margin-top: 0.14rem;
}
.hud-mem .hud-val {
  color: rgba(232, 200, 122, 0.7);
}

/* scroll prompt */
.scroll-prompt {
  position: fixed;
  bottom: calc(6vh + 1.6rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 65;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  animation: fi 2s 2.2s forwards;
  transition: opacity 0.6s;
}
.scroll-prompt.hide {
  animation: none;
  opacity: 0;
}
.scroll-prompt span {
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}
.scroll-arrow {
  display: block;
  width: 1px;
  height: 24px;
  margin: 0.4rem auto 0;
  background: linear-gradient(rgba(62, 44, 20, 0.55), transparent);
  animation: bob 2.5s ease-in-out infinite;
}
@keyframes fi {
  to {
    opacity: 1;
  }
}
@keyframes bob {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 0.85; transform: translateY(5px); }
}

/* sound toggle */
.sound-toggle {
  position: fixed;
  top: calc(6vh + 3.1rem);
  right: 1.5rem;
  z-index: 90;
  background: rgba(10, 7, 5, 0.4);
  border: 1px solid rgba(201, 165, 92, 0.18);
  border-radius: 2rem;
  color: rgba(201, 165, 92, 0.45);
  font-family: "Special Elite", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.34rem 0.9rem;
  cursor: pointer;
  opacity: 0;
  animation: fi 1.5s 4.5s forwards;
  transition: color 0.4s, border-color 0.4s;
}
.sound-toggle:hover {
  color: var(--gold-bright);
  border-color: rgba(201, 165, 92, 0.45);
}
.sound-toggle.playing {
  color: var(--gold-bright);
  border-color: rgba(201, 165, 92, 0.4);
}
/* the "sound on" beat - make the button obvious top-right */
.sound-toggle.notice:not(.playing) {
  opacity: 1;
  color: var(--gold-bright);
  background: rgba(40, 24, 10, 0.6);
  border-color: rgba(232, 200, 122, 0.9);
  animation: pulse-ring 1.3s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 200, 122, 0); transform: scale(1); }
  50%      { box-shadow: 0 0 26px 6px rgba(232, 200, 122, 0.5); transform: scale(1.07); }
}
@media (prefers-reduced-motion: reduce) {
  .sound-toggle.notice:not(.playing) { animation: none; }
}
.sound-toggle .st-icon {
  margin-right: 0.45rem;
}

/* finale: a torn closing note on dark brocade, then the door out */
.finale {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s;
  background: var(--damask) repeat, #1d140b;
  overflow: hidden;
}
.finale.on {
  opacity: 1;
}
.finale-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 44rem;
  margin: 0 auto;
  padding: 7vh 2rem;
}
/* the torn closing note */
.fin-sheet {
  position: relative;
  max-width: 32rem;
  padding: clamp(1.6rem, 4vw, 2.6rem) clamp(1.8rem, 4.5vw, 3rem);
  color: #36281a;
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  transform: rotate(-1.3deg);
}
.fin-sheet::before {
  content: "";
  position: absolute;
  inset: -12px -10px;
  z-index: -1;
  background:
    radial-gradient(ellipse at 16% 10%, rgba(255, 252, 242, 0.6), transparent 55%),
    radial-gradient(ellipse at 86% 94%, rgba(120, 84, 44, 0.3), transparent 58%),
    linear-gradient(166deg, #efe7d1, #e6dabb 60%, #d8c79f);
  filter: url(#paper-torn) drop-shadow(0 20px 36px rgba(0, 0, 0, 0.6));
}
.fin-rule {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.1rem;
  color: rgba(140, 47, 35, 0.7);
}
.fin-rule::before, .fin-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(70, 50, 25, 0.34);
}
.fin-rule span { font-size: 0.9rem; line-height: 1; }
.fin-lede,
.fin-turn {
  opacity: 0;
  will-change: opacity;
}
.fin-lede {
  font-family: "IM Fell English SC", "IM Fell English", serif;
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  color: #2b1d10;
  line-height: 1.5;
  margin-bottom: 1.1rem;
}
.fin-turn {
  font-style: italic;
  font-size: clamp(0.98rem, 2vw, 1.16rem);
  color: var(--ink-dim);
  line-height: 1.85;
}
.fin-turn em, .fin-lede em { color: var(--accent); }

/* the second door - ornate, ajar, the way out written on the leaf */
.door {
  --open: 0;
  display: block;
  width: clamp(230px, 44vw, 400px);
  margin: 2.2rem auto 0;
  text-decoration: none;
  opacity: 0;
  pointer-events: none; /* only live once the finale is up - see .finale.on below */
  will-change: opacity;
}
/* a real carved doorway (Stone Town, Zanzibar - CC BY R. Mortel), toned
   to sepia. it splits down the carved seam and swings open in 3D as you
   arrive, revealing warm light + the way through. */
.door-img {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 92.25%; /* 738/800 - reliable aspect box, no collapse */
  perspective: 1200px;
  filter: drop-shadow(0 26px 50px rgba(0, 0, 0, 0.6));
}
/* the loveliest garden you ever saw - revealed as the doors part */
.door-within {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 9%;
  border-radius: 3px;
  background: #241a10 url("media/garden.jpg") center/cover no-repeat;
  box-shadow: inset 0 0 60px rgba(20, 12, 6, 0.78); /* edges sink into the doorway */
  overflow: hidden;
}
/* sunlight bloom at the top + a scrim along the bottom so the words read */
.door-within::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 85% 55% at 50% 28%, rgba(255, 244, 206, 0.32), transparent 62%),
    linear-gradient(to top, rgba(18, 11, 5, 0.74), transparent 34%);
  pointer-events: none;
}
.door-step {
  position: relative;
  z-index: 2;
  font-family: "IM Fell English SC", serif;
  font-size: clamp(0.95rem, 2.3vw, 1.35rem);
  letter-spacing: 0.16em;
  color: #ffe7ad;
  text-shadow: 0 1px 9px rgba(0, 0, 0, 0.95), 0 0 16px rgba(0, 0, 0, 0.55);
  opacity: calc(max(0, var(--open) - 0.25) * 1.7);
  transition: color 0.35s;
}
.door:hover .door-step { color: #fff7e3; }
/* the two carved leaves, each half of the photo, hinged on the outside */
.door-gate {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.5%;
  background-image: url("media/door.jpg");
  background-size: 200% 100%;
  background-repeat: no-repeat;
  backface-visibility: hidden;
  filter: brightness(0.97) contrast(1.04);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.45);
  will-change: transform;
}
.door-gate.left {
  left: 0;
  background-position: left center;
  transform-origin: left center;
  transform: rotateY(calc(var(--open) * 84deg));
  border-right: 1px solid rgba(20, 12, 6, 0.6);
}
.door-gate.right {
  right: 0;
  background-position: right center;
  transform-origin: right center;
  transform: rotateY(calc(var(--open) * -84deg));
}
.door:hover .door-gate.left { transform: rotateY(calc(var(--open) * 84deg + 7deg)); }
.door:hover .door-gate.right { transform: rotateY(calc(var(--open) * -84deg - 7deg)); }
/* on the dark brocade now - light sepia ink */
.door-cite {
  display: block;
  margin-top: 1.2rem;
  font-family: "Special Elite", monospace;
  font-size: clamp(0.68rem, 1.5vw, 0.82rem);
  letter-spacing: 0.04em;
  color: var(--sepia-dim);
  line-height: 1.7;
}
.door-cite em { font-style: italic; color: var(--sepia-text); }
.dc-num { color: rgba(201, 165, 92, 0.7); }

.fin-foot {
  margin-top: 2.2rem;
  opacity: 0;
  font-variant: small-caps;
  font-size: 0.9rem;
  letter-spacing: 0.16em;
}
.fin-foot a {
  color: var(--gold-bright);
  text-decoration: none;
  pointer-events: none;
  border-bottom: 1px solid rgba(201, 165, 92, 0.4);
  padding-bottom: 2px;
  transition: color 0.4s;
}
.fin-foot a:hover { color: #fff3cf; }

/* the way out is only clickable once you've actually landed */
.finale.on .door,
.finale.on .fin-foot a { pointer-events: auto; }
.fb-sep {
  margin: 0 0.8rem;
  color: rgba(201, 165, 92, 0.5);
}

/* small screens */
@media (max-width: 700px) {
  .cbar {
    height: 4vh;
  }
  .memcard {
    max-width: 10.5rem;
    top: 58%;
  }
  .hud-depth,
  .hud-timer .hud-label + .hud-depth + .hud-label {
    display: none;
  }
  .corner {
    font-size: 0.42rem;
  }
  .rabbit-plate {
    width: 132px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }
  .scroll-arrow {
    animation: none;
  }
}

/* short screens (small laptops, landscape) — tighten the full-screen
   "pages" so they don't get clipped. pure css, no runtime cost. */
@media (max-height: 740px) {
  .ref-sheet {
    padding: clamp(0.85rem, 2.2vh, 1.6rem) clamp(1.5rem, 4vw, 2.6rem);
  }
  .ref-title { margin-top: 0.35rem; font-size: clamp(1.5rem, 4.3vw, 2.4rem); }
  .ref-pron { margin-top: 0.12rem; font-size: clamp(0.76rem, 1.6vw, 0.92rem); }
  .ref-rule { margin: 0.45rem 0 0.7rem; }
  .ref-runhead { padding-bottom: 0.3rem; }
  .ref-body { font-size: clamp(0.8rem, 1.65vw, 0.96rem); line-height: 1.48; }
  .ref-body p { margin-bottom: 0.5rem; }
  .ref-h2 { margin: 0.15rem 0 0.4rem; }
  .ref-foot { margin-top: 0.65rem; padding-top: 0.4rem; }

  .dl-card { padding: clamp(1rem, 3vh, 2.1rem) clamp(1.8rem, 5vw, 3rem); }
  .dl-title { font-size: clamp(1.5rem, 5vw, 2.4rem); }
  .dl-quote { font-size: clamp(0.86rem, 2vw, 1.1rem); line-height: 1.42; }
  .dl-cue { margin-top: 0.9rem; padding-top: 0.75rem; gap: 0.34rem; }

  .door { width: clamp(185px, 30vw, 290px); margin-top: 1.3rem; }
  .fin-sheet { padding: clamp(1rem, 3vh, 2rem) clamp(1.6rem, 4.5vw, 2.6rem); }
  .fin-lede { font-size: clamp(1.05rem, 2.6vw, 1.5rem); margin-bottom: 0.8rem; }
  .fin-turn { font-size: clamp(0.9rem, 1.8vw, 1.05rem); line-height: 1.6; }
}
/* very short — drop the least-essential bits so the rest fits */
@media (max-height: 620px) {
  .ref-box { display: none; }
  .ref-sheet { padding-top: 0.65rem; padding-bottom: 0.65rem; }
  .ref-body { font-size: 0.82rem; line-height: 1.38; }
  .ref-body p { margin-bottom: 0.4rem; }
  .ref-lead .dropcap { font-size: 2.3em; }
  .dl-quote br { display: none; }
  .fin-turn br { display: none; }
  .door { width: clamp(155px, 24vw, 225px); }
}
