/* Dream temple: RuneScape lettering, aged bronze, night stone and parchment.
   The original scroll timing, geometry and event handlers remain the engine. */
@font-face {
  font-family: "RuneScape Bold";
  src: url("/realm/RuneScape-Bold-12.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "RuneScape Plain";
  src: url("/realm/RuneScape-Plain-12.ttf") format("truetype");
  font-display: swap;
}
:root {
  --bg: #080e19;
  --surface: #292b27;
  --surface-2: #34362f;
  --line: #62553b;
  --line-soft: #413d30;
  --ink: #eee4c7;
  --ink-dim: #c0b8a2;
  --ink-faint: #a79c80;
  --gold: #efd084;
  --gold-deep: #b69a5b;
  --gold-dark: #73603a;
  --mono: "RuneScape Plain", serif;
  --rune: "RuneScape Bold", serif;
  --anchor-height: 100px;
}
body { background: var(--bg); }
#dream-realm {
  position: fixed;
  inset: -40px 0;
  z-index: 0;
  background: linear-gradient(180deg, #07102033, #07102012 60%, #080e1999),
    url("/realm/dream-temple.webp") center / cover;
  opacity: var(--realm-opacity, 1);
  transform: translateY(var(--realm-shift, 0px));
  pointer-events: none;
}
#field { z-index: 1; }
#vignette {
  background: radial-gradient(ellipse at 50% 40%, #040a1533, #040a1500 40%, #040a1580 100%);
}
#realm-frame {
  position: fixed;
  inset: 12px;
  z-index: 4;
  pointer-events: none;
  border: 1px solid #a38a514f;
  box-shadow: inset 0 0 0 3px #04080944, 0 0 0 3px #04080944;
}
#realm-frame::before, #realm-frame::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid #baa06b;
}
#realm-frame::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
#realm-frame::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }
#act-hero { min-height: 100svh; padding-top: clamp(62px, 6svh, 86px); padding-bottom: 9vh; }
#arrival { margin-bottom: 32px; text-shadow: 0 3px 0 #050910, 0 0 35px #03070c; }
.key-mark {
  position: relative; display: grid; justify-items: center; isolation: isolate;
  margin: 0 auto 26px; padding: 0 18px 9px; border: 0; border-radius: 50%;
  color: var(--gold); background: none; box-shadow: none; cursor: pointer;
  font: 23px/1.2 var(--rune); letter-spacing: 0; text-transform: none;
}
.key-object { display: block; width: clamp(150px, 18vw, 195px); height: auto; filter: drop-shadow(0 5px 2px #000a) drop-shadow(0 0 16px #c49b3b30); }
.key-aura { position: absolute; z-index: -1; inset: 4% -22% 8%; border-radius: 50%; background: radial-gradient(ellipse, #e4b74424, #e4b74409 45%, transparent 70%); }
.key-mark:hover:not(:disabled) .key-object { filter: drop-shadow(0 5px 2px #000a) drop-shadow(0 0 22px #e3ba5260); }
.key-mark:hover:not(:disabled) { color: var(--gold); }
.key-mark:focus-visible { outline: 2px solid #edcf8e; outline-offset: 8px; }
.key-mark:disabled { opacity: .75; cursor: wait; }
.key-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.brand {
  font-family: var(--rune);
  font-size: clamp(54px, 7.5vw, 88px);
  line-height: 1;
  letter-spacing: 0;
  text-indent: 0;
  color: var(--gold);
}
.brand .tld { color: inherit; }
.tag { font-size: clamp(19px, 2.3vw, 25px); margin-top: 22px; }
#act-hero #form {
  width: min(590px, 100%);
  padding: 24px;
  gap: 16px;
  background: linear-gradient(125deg, #33382eef, #181e20f5);
  border: 2px solid #8e7952;
  box-shadow: inset 0 0 0 2px #111b1b, inset 0 0 0 3px #9e855633, 0 10px 40px #0009;
}
.name-label { display: block; font: 20px var(--mono); color: var(--gold); margin-bottom: 8px; }
#inscription { padding: 0 0 5px; border-color: #6a634b; }
#inscription:focus-within { border-color: var(--gold); box-shadow: 0 1px var(--gold); }
#mirror { font: 30px/1.2 var(--mono); letter-spacing: .02em; }
#mirror .ph { font-style: normal; color: #beb99f; white-space: normal; font-size: clamp(18px, 4.5vw, 26px); }
#mirror .ph-name { display: inline-block; white-space: nowrap; }
#decode-btn, #card-save-btn, #again-btn, #skip-btn {
  font: 22px/1.1 var(--rune);
  text-transform: none;
  text-indent: 0;
  letter-spacing: 0;
  border-radius: 2px;
  min-height: 44px;
  padding: 12px 20px;
}
#decode-btn, #card-save-btn {
  color: var(--gold);
  text-shadow: 1px 2px #211c12;
  background: linear-gradient(#746746, #514b35);
  border: 2px solid #c1a567;
  box-shadow: inset 0 0 0 2px #332e22, 0 3px 0 #101513;
}
#decode-btn:hover, #card-save-btn:hover { filter: brightness(1.18); }
#sound-btn {
  top: 27px;
  right: 30px;
  font: 18px var(--mono);
  letter-spacing: 0;
  color: var(--ink);
  background: #161d21de;
  border: 1px solid #82704c;
  border-radius: 2px;
  padding: 7px 11px;
}
body.decoded #act-hero { padding-top: calc(var(--anchor-height) + 40px); padding-bottom: 80px; }
body.decoded #arrival .brand { font-size: 36px; }
body.decoded .key-mark { display: none; }
body.decoded #form { transform: none; }
#intro-line { color: var(--ink); text-shadow: 0 2px 8px #000; }
.scroll-hint span { font-size: 19px; text-transform: none; letter-spacing: 0; text-indent: 0; }
#anchor { padding: 24px 105px 20px; background: linear-gradient(#10191cf5 65%, #10191c00); }
.anchor-label { font-size: 18px; text-transform: none; letter-spacing: .03em; text-indent: 0; margin-bottom: 8px; }
#cartouches { --name-cell: 32px; --name-gap: 4px; --name-font: 26px; --name-height: 38px; gap: 8px 18px; }
.name-word { display: inline-flex; flex-wrap: nowrap; gap: calc(var(--name-gap) * var(--name-scale, 1)); }
.name-word .cartouche { width: calc(var(--name-cell) * var(--name-scale, 1)); height: calc(var(--name-height) * var(--name-scale, 1)); font-size: calc(var(--name-font) * var(--name-scale, 1)); flex-shrink: 0; }
#mirror { white-space: normal; overflow: visible; }
.mirror-word { display: inline-block; white-space: nowrap; }
.cartouche {
  font: 26px var(--rune);
  width: 32px;
  height: 38px;
  border-radius: 2px;
  border: 2px solid #7d704e;
  background: linear-gradient(145deg, #404034, #232b29);
  box-shadow: inset 1px 1px #b9a77a33, 1px 2px 0 #020606;
}
.cartouche.lit { background: #645533; border-color: #f1ce72; box-shadow: 0 0 16px #daa74b45; }
.seal-stage { padding-top: max(calc(var(--anchor-height) + 28px), 22vh); }
.seal-kicker { font-size: 22px; letter-spacing: .04em; text-indent: 0; text-transform: none; margin-bottom: 20px; }
.seal-word, #finale-word {
  font-family: var(--rune);
  font-size: clamp(38px, 9vw, 96px);
  line-height: 1.1;
  letter-spacing: .10em;
  text-indent: .10em;
  text-shadow: 2px 3px 0 #302716, 0 0 38px #d4ac4b40;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.seal-def { color: #c9c6b9; text-shadow: 0 2px 6px #000; }
.gathering .seal-word { font-size: clamp(32px, 7vw, 62px); }
#ark-count, #treasure-count { font-size: 18px; letter-spacing: .04em; text-transform: none; }
#ark { bottom: 3vh; }
/* Same prop in two aligned states; the existing ark pulse and ceremony drive it. */
#story-box { position: relative; width: 210px; height: 210px; }
.story-box-state {
  position: absolute;
  inset: 0;
  background: url("/realm/story-gold-box.webp") 0 0 / 200% 100% no-repeat;
  transition: opacity .7s var(--ease);
  filter: drop-shadow(0 5px 3px #0008);
}
.story-box-open { background-position: 100% 0; opacity: 0; }
#ark.open .story-box-closed { opacity: 0; }
#ark.open .story-box-open { opacity: 1; }
#ark-glow {
  position: absolute;
  left: 22%;
  top: 40%;
  width: 56%;
  height: 14%;
  background: radial-gradient(ellipse, #ffe7a259, transparent 70%);
  filter: blur(9px);
  pointer-events: none;
}
#ark.open #ark-glow { top: 50%; background: radial-gradient(ellipse, #ffe7a2bb, transparent 70%); }
.ow { font-family: var(--mono); font-size: 17px; }
.layer { border: 2px solid #7c6b45; border-radius: 2px; background: linear-gradient(120deg, #30382eef, #1c2528f5); box-shadow: inset 0 0 0 2px #0f171a; }
.layer-name { font: 28px var(--rune); color: var(--gold); }
.layer-num, .layer-sub { font: 18px var(--mono); }
.chip { font: 23px var(--mono); border-radius: 2px; padding: 7px 12px; background: #151d1de6; border-color: #685e46; }
.chip:hover { background: #474830; border-color: #bea16b; }
#depth-ctl button { font: 21px var(--mono); border-radius: 2px; }
#reading { padding: 24px; }
#reading-card {
  color: #342b1b;
  width: min(560px, 100%);
  max-height: calc(100svh - 48px);
  overflow-y: auto;
  border: 5px solid #776445;
  outline: 1px solid #c6ab73;
  border-radius: 2px;
  padding: 40px 32px 30px;
  background: radial-gradient(ellipse at 45% 30%, #f2e6c5, #d6c296);
  box-shadow: inset 0 0 35px #8a6a3b50, 0 25px 120px #000c;
}
#reading-close { color: #665032; font-size: 22px; width: 44px; height: 44px; top: 4px; right: 4px; }
#reading-close:hover { color: #21190e; }
#reading-word { font: clamp(38px, 9vw, 66px)/1.1 var(--rune); color: #473317; letter-spacing: .06em; overflow-wrap: anywhere; }
#reading-word .wl { text-shadow: none; }
#reading-meta { color: #665338; font: 18px var(--mono); letter-spacing: .04em; text-transform: none; }
#reading-meta .dot { color: #72511b; }
#reading-def { color: #3d3426; font-size: 19px; }
#reading-provenance .pl { font-family: var(--rune); border-color: #ad9567; color: #79694b; }
#reading-provenance { gap: 8px 14px; }
.provenance-word { display: inline-flex; flex-wrap: nowrap; gap: 4px; max-width: 100%; }
#reading-provenance .pl { min-width: 0; }
#reading-provenance .pl.lit { background: #6c5734; color: var(--gold); border-color: #66502b; box-shadow: none; }
#reading-treasure { font: 21px var(--mono); color: var(--gold); background: #675333; border: 3px double #d8be80; box-shadow: 0 3px 0 #372e1f; width: 92px; height: 92px; }
#reading-treasure.done { background: #405440; color: #f0e7c5; border-color: #96a176; }
#card-canvas { border-radius: 2px; border: 3px double #c3a367; }
button:focus-visible, .chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
@media (max-width: 600px) {
  #realm-frame { inset: 7px; }
  #dream-realm { background-position: 84% center; }
  #sound-btn { right: 19px; top: 18px; }
  #act-hero { padding-left: 26px; padding-right: 26px; }
  #act-hero #form { flex-direction: column; align-items: stretch; padding: 20px; gap: 20px; }
  #inscription { width: 100%; }
  #decode-btn { width: 100%; }
  .brand { font-size: clamp(43px, 10.5vw, 62px); }
  .key-mark { margin-bottom: 22px; font-size: 21px; }
  .key-object { width: 164px; }
  .tag { font-size: 19px; }
  #anchor { padding: 61px 20px 20px; }
  .cartouche { width: 26px; height: 32px; font-size: 24px; }
  .cartouche.space { width: 9px; }
  #cartouches { --name-cell: 26px; --name-gap: 3px; --name-font: 24px; --name-height: 32px; gap: 7px 12px; }
  .seal-stage { padding-left: 26px; padding-right: 26px; }
  .seal-def { margin-top: 22px; line-height: 1.55; }
  #ark { bottom: 1vh; transform: translateX(-50%) scale(.75); }
  #ark.pulse { transform: translateX(-50%) scale(.83); }
  #reading-card { padding: 48px 22px 24px; }
  #reading-def { font-size: 17px; }
}
@media (max-height: 600px) {
  body.predecoded { overflow-y: auto; }
  #act-hero { padding-top: 70px; padding-bottom: 50px; }
}
@media (max-width: 360px) {
  #cartouches { --name-cell: 24px; --name-font: 22px; --name-height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  #dream-realm { transform: none; }
  .story-box-state { transition: none; }
  .seal-stage { padding-top: calc(var(--anchor-height) + 28px); }
}
