:root {
  color-scheme: dark;
  --bg: #050607;
  --ink: #c8d3cc;
  --ink-dim: #76837c;
  --eerie: #8fe3b0;
  --eerie-hot: #d4ffe6;
  --violet: #7a4dff;
  --blood: #ff3b4e;
  --brass: #b08d57;
  --s: 190px;
  --h: calc(var(--s) / 2);
  --serif: "Cormorant Garamond", "Noto Serif SC", "Songti SC", serif;
  --cn: "Noto Serif SC", "Songti SC", "STSong", serif;
  --display: "Cinzel Decorative", "Cinzel", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--cn);
  overflow-x: hidden;
  overscroll-behavior-y: none; /* no pull-to-refresh: a reload would re-lock the vault */
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.defs { position: absolute; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#motes { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

/* ───────── gate ───────── */
/* The gate is always exactly one screen — no page scroll while it is shown. */
body:has(#gate:not([hidden])) { overflow: hidden; }
.gate {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; /* the box area takes whatever height is left */
  justify-items: center;
  padding:
    calc(7vh + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    calc(4vh + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 45% at 50% 55%, rgba(60, 120, 90, .13), transparent 70%),
    radial-gradient(ellipse 90% 70% at 50% 120%, rgba(70, 30, 120, .22), transparent 70%),
    radial-gradient(ellipse at 50% 50%, #0b0f0e 0%, #050607 70%);
}
.gate::after { /* vignette + grain */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    url(/img/grain.svg) 0 0 / 220px 220px,
    radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.85) 100%);
}

/* The clearing: dead trees stand at both edges, three depths of them, barely told from the dark —
   until the lightning lights the sky behind them and the whole wood shows for an instant. */
.woods { position: absolute; inset: 0; justify-self: stretch; z-index: 0; pointer-events: none; }
.woods .sky {
  position: absolute; inset: 0;
  /* a little haze of light up in the canopy, just enough to find the branches against */
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(44, 64, 57, .32), transparent 75%);
}
.woods .sky::after {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background:
    radial-gradient(ellipse 70% 55% at var(--fx, 50%) 6%, rgba(170, 205, 192, .55), rgba(80, 110, 100, .28) 45%, transparent 80%),
    linear-gradient(rgba(60, 85, 78, .25), transparent 70%);
}
.woods.flash .sky::after { animation: flash 1.2s ease-out; --peak: .75; }
.woods.strike .sky::after { animation: flash 1.1s ease-out; --peak: 1; }
.woods .grove {
  position: absolute; top: 0; bottom: 0;
  width: min(46vw, 62vh);
  background: url(/img/forest-l.svg) left bottom / auto 100% no-repeat;
  /* the inner edge melts into the clearing rather than ending in a line */
  -webkit-mask-image: linear-gradient(to right, #000 50%, transparent);
  mask-image: linear-gradient(to right, #000 50%, transparent);
}
.woods .grove.r {
  right: 0;
  background-image: url(/img/forest-r.svg); background-position: right bottom;
  -webkit-mask-image: linear-gradient(to left, #000 50%, transparent);
  mask-image: linear-gradient(to left, #000 50%, transparent);
}
.woods .grove.l { left: 0; }
/* bats (js/bats.js) fly between the far trees and the nearest trunks */
.woods .bats { position: absolute; inset: 0; width: 100%; height: 100%; }
.woods .grove.l.near { background-image: url(/img/forest-l-near.svg); }
.woods .grove.r.near { background-image: url(/img/forest-r-near.svg); }
@media (max-width: 560px) { .woods .grove { width: 34vw; } }

/* Eyes in the wood: now and then a pair opens among the trees, looks, blinks and is gone. Every
   wrong incantation brings more of them, nearer; late in the count they turn red. */
.eyes { position: absolute; inset: 0; justify-self: stretch; z-index: 0; pointer-events: none; }
.eyes .pair {
  position: absolute; display: flex; gap: calc(var(--e) * 1.4);
  translate: -50% -50%; rotate: var(--r, 0deg);
  animation: peer 4.2s ease-in-out forwards;
}
.eyes .pair.stay { animation: appear 1.6s ease-out forwards; }
.eyes .pair i {
  width: var(--e); height: calc(var(--e) * .55); border-radius: 50%;
  background: radial-gradient(#f2ffd8 0%, #b9e47a 40%, rgba(150, 205, 90, 0) 72%);
  box-shadow: 0 0 calc(var(--e) * 1.6) rgba(170, 225, 110, .45);
  animation: blinkE var(--b, 5s) ease-in-out var(--bd, 0s) infinite;
}
.eyes .pair.red i {
  background: radial-gradient(#ffe0d4 0%, #ff4a34 40%, rgba(255, 50, 30, 0) 72%);
  box-shadow: 0 0 calc(var(--e) * 1.8) rgba(255, 60, 40, .5);
}
@keyframes peer { 0% { opacity: 0; } 18%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
@keyframes blinkE { 0%, 46%, 54%, 100% { scale: 1 1; } 50% { scale: 1 .08; } }

/* The flash lights the whole clearing, not only the sky: the fog and the mist on the ground glow
   all through (fog scatters light most), the box and the blade catch it, the gold glints — and the
   name, lit from behind, goes dark against it. --p is how hard: a far flash, or the strike. */
.gate.flashing { --p: .55; }
.gate.striking { --p: 1; }
.mistlight {
  position: absolute; inset: 0; justify-self: stretch; z-index: 0; pointer-events: none; opacity: 0;
  background:
    radial-gradient(ellipse 70% 32% at 50% 72%, rgba(190, 216, 206, .2), transparent 70%),
    radial-gradient(ellipse 90% 45% at 50% 30%, rgba(170, 200, 190, .13), transparent 75%);
}
.gate.flashing .mistlight, .gate.flashing .ground-mist::after { animation: flash 1.2s ease-out; --peak: .7; }
.gate.striking .mistlight, .gate.striking .ground-mist::after { animation: flash 1.1s ease-out; --peak: 1; }
/* (the box itself is not lit by the flash: nothing that moves may lie over it, see .scene) */
/* the lightning catches the carving: for that instant the light inside the name flares up */
.gate.flashing .title .letters > .glow { animation: flash 1.2s ease-out; --peak: .9; }
.gate.striking .title .letters > .glow { animation: flash 1.1s ease-out; --peak: 1; }

/* one wind blows through the clearing, from left to right: the fog banks are carried across
   (two copies side by side, so they come round again without a seam). No blur: the banks are soft
   gradients already, and a blurred layer this big is more than a phone's graphics chip can keep */
.fog { position: absolute; top: -5%; bottom: -5%; left: -100vw; width: 200vw; justify-self: start; pointer-events: none; z-index: 0; opacity: .5; background-size: 100vw 100% !important; background-repeat: repeat-x !important; }
.fog-a {
  background:
    radial-gradient(ellipse 35% 18% at 30% 70%, rgba(140, 170, 160, .12), transparent 70%),
    radial-gradient(ellipse 30% 15% at 75% 62%, rgba(120, 150, 140, .10), transparent 70%);
  animation: wind 95s linear infinite;
}
.fog-b {
  background:
    radial-gradient(ellipse 40% 14% at 60% 80%, rgba(110, 80, 160, .10), transparent 70%),
    radial-gradient(ellipse 25% 12% at 20% 40%, rgba(120, 150, 140, .07), transparent 70%);
  animation: wind 140s linear -40s infinite;
}
@keyframes wind { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(100vw, 0, 0); } }

.gate-head { position: relative; z-index: 4; text-align: center; }
/* Far off, behind the name, a storm: now and then the fog is lit from inside, twice, and
   goes dark; once in a while the bolt itself shows through, thin and far away. A wrong
   incantation late in the count brings it down close — the whole wood flashes. */
.storm {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: 150%; height: 340%; translate: -50% -58%;
  background: radial-gradient(ellipse 46% 38% at var(--fx, 50%) 46%, rgba(200, 236, 222, .22), rgba(120, 170, 155, .08) 48%, transparent 72%);
  opacity: 0; pointer-events: none;
}
.bolt {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: 130%; height: 300%; translate: -50% -62%;
  opacity: 0; pointer-events: none; overflow: visible;
}
/* a far flash is far: its bolt stands behind the trees, cut by their branches; only the strike
   comes down in front of everything */
.woods .bolt.far { left: 0; top: 0; width: 100%; height: 62%; translate: none; z-index: auto; }
.bolt path { fill: none; stroke-linejoin: miter; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.bolt .glow { stroke: rgba(170, 235, 210, .22); stroke-width: 5; } /* a soft halo by width, not by a blur filter */
.bolt .stroke { stroke: #f4fffa; stroke-width: 1.1; }
.bolt .fork { stroke: rgba(225, 250, 238, .55); stroke-width: .7; }
.storm.flash { animation: flash 1.2s ease-out; }
.bolt.flash { animation: flash 1.2s ease-out; --peak: .4; }
.bolt.strike { animation: flash 1.1s ease-out; --peak: 1; }
.bolt.strike .stroke { stroke-width: 2.2; }
.bolt.strike .fork { stroke-width: 1.1; stroke: rgba(225, 250, 238, .8); }
.bolt.strike .glow { stroke-width: 8; stroke: rgba(190, 245, 225, .32); }
@keyframes flash {
  0% { opacity: 0; }
  4% { opacity: var(--peak, 1); }
  9% { opacity: calc(var(--peak, 1) * .15); }
  15% { opacity: var(--peak, 1); }
  24% { opacity: calc(var(--peak, 1) * .3); }
  32% { opacity: calc(var(--peak, 1) * .55); }
  60% { opacity: calc(var(--peak, 1) * .06); }
  100% { opacity: 0; }
}
.thunder {
  position: absolute; inset: 0; justify-self: stretch; z-index: 2; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 20%, rgba(205, 240, 228, .22), rgba(150, 200, 185, .08) 60%, transparent 90%);
}
.thunder.strike { animation: flash 1.1s ease-out; }

/* The name is cut into the dark like letters in black stone: moon-silver, a shadow along the top
   of each stroke and a thin catch of light along the bottom, so it reads clearly without shining.
   It surfaces slowly, each letter guttering on its own like something lit by a dying candle; a
   faint phosphor light breathes inside it with the box; it shrinks back a little when you reach
   for the box. */
.title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: .32em;
  padding-left: .32em;
  color: #c3cfca;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .95), 0 1px 0 rgba(230, 242, 236, .32), 0 2px 3px rgba(0, 0, 0, .8), 0 0 18px rgba(143, 227, 176, .14);
  animation: emerge 1.2s cubic-bezier(.16, 1, .3, 1) .05s backwards;
  transition: opacity 1.4s ease, filter 1.4s ease, color 1.2s ease;
}
@keyframes emerge { from { opacity: 0; filter: blur(3px); } }
.title .letters > span { position: relative; display: inline-block; animation: gutter 9s ease-in-out infinite; }
/* the P has no flourish and only half a bowl, so it reads small beside A, N and R: it is set
   larger, like the first letter of an old manuscript */
.title .letters > span:nth-child(1) { font-size: 1.14em; animation-duration: 8.3s; animation-delay: -1.2s; }
.title .letters > span:nth-child(2) { animation-duration: 11.7s; animation-delay: -6.5s; }
.title .letters > span:nth-child(3) { animation-duration: 9.4s; animation-delay: -3.1s; }
.title .letters > span:nth-child(4) { animation-duration: 13.1s; animation-delay: -9.8s; }
.title .letters > span:nth-child(5) { animation-duration: 10.2s; animation-delay: -4.4s; }
.title .letters > span:nth-child(6) { animation-duration: 7.6s; animation-delay: -2.7s; }
.title .letters > span:nth-child(7) { animation-duration: 12.4s; animation-delay: -7.9s; }
@keyframes gutter {
  0%, 100% { opacity: .86; }
  38% { opacity: .76; }
  44% { opacity: .9; }
  47% { opacity: .42; }
  49% { opacity: .8; }
  51% { opacity: .55; }
  54% { opacity: .86; }
  80% { opacity: .94; }
}
/* the light inside the letters: a glow-only copy laid over them, breathing with the box's sign
   (opacity only, so it costs nothing to draw); the lightning flares it */
.title .letters { position: relative; }
.title .letters > .glow {
  position: absolute; inset: 0; display: block; white-space: nowrap; pointer-events: none;
  color: transparent; text-shadow: 0 0 6px rgba(143, 227, 176, .55), 0 0 16px rgba(143, 227, 176, .3);
  opacity: .15; animation: titleGlow 4.5s ease-in-out infinite;
}
.title .letters > .glow > span { display: inline-block; }
.title .letters > .glow > span:first-child { font-size: 1.14em; }
@keyframes titleGlow { 0%, 100% { opacity: .12; } 50% { opacity: .6; } }
.gate[data-dread] .title .letters > .glow { animation: none; opacity: 0; }
/* reaching for the box, the name withdraws */
.gate:has(.scene:hover) .title, .gate.awake .title { opacity: .75; filter: blur(.4px); }
.gate.unsealing .title { opacity: 0; filter: blur(4px); transition-duration: .7s; }
/* now and then something in it stirs: a letter twitches, or the O opens an eye */
.title .letters > span.twitch { translate: 1.5px -1px; skew: -8deg; opacity: .9; animation: none; }
.title .o { color: inherit; }
.title .eye {
  /* centred on the ring itself: the letter's box also holds the letter-spacing (.32em) after
     the glyph, and Cinzel's O sits a touch above the middle of the line */
  position: absolute; left: calc(50% - .16em); top: calc(50% - .05em); width: .42em; height: .42em;
  translate: -50% -50%;
  fill: none; stroke: currentColor; stroke-width: 2.8;
  opacity: 0; scale: 1 0;
  pointer-events: none;
}
.title .eye .pupil { fill: #b3241f; stroke: none; filter: drop-shadow(0 0 1.5px #ff3b2e); }
/* the O stays; inside its ring an eye slowly opens, blinks once, and closes again */
.title .o.watch { animation: none; opacity: .8; }
.title .o.watch .eye { color: #a9bbb1; animation: eyeOpen 3.6s ease-in-out forwards; }
@keyframes eyeOpen {
  0% { opacity: 0; scale: 1 0; }
  15% { opacity: 1; scale: 1 1; }
  45% { scale: 1 1; }
  54% { scale: 1 .06; }
  65% { scale: 1 1; }
  84% { opacity: 1; scale: 1 1; }
  100% { opacity: 0; scale: 1 0; }
}
/* every wrong incantation wakes it a little more, and it reddens */
.gate[data-dread="1"] .title { color: #8d8a80; filter: none; opacity: .8; }
.gate[data-dread="2"] .title { color: #9a6a5f; filter: none; opacity: .9; text-shadow: 0 0 14px rgba(160, 30, 20, .3); }
.gate[data-dread="3"] .title { color: #a8453b; filter: none; opacity: 1; text-shadow: 0 0 16px rgba(190, 30, 20, .45); }
.gate[data-dread="4"] .title { color: #bd2f28; filter: none; opacity: 1; text-shadow: 0 0 20px rgba(220, 30, 20, .6); }
.whisper {
  /* the sword's length: never longer than PANDORA above it (its letters span about 7.15 times the
     title's font size) */
  --sword: min(437px, 94vw, clamp(34px, 7vw, 64px) * 7.15);
  position: relative; z-index: 0;
  margin: 14px 0 0;
  --ls: .22em; /* close set, as an inscription is: the words fit the short blade */
  /* the words stand in the middle of the page, in line with the box */
  padding: .7em 0 .7em var(--ls);
  font-family: var(--cn);
  font-weight: 300;
  font-size: 15px;
  letter-spacing: var(--ls);
  /* old gold, inlaid in the dark blade like the inscription on an ancient sword; it answers the
     gold of the burnt strip at the foot */
  color: #c9a96a;
  text-shadow: 0 0 6px rgba(214, 178, 105, .35), 0 0 2px #000, 0 1px 1px #000;
  transition: color 1.2s ease, text-shadow 1.2s ease;
}
/* from the third wrong incantation the gold darkens to blood, with the name above */
.gate[data-dread="3"] .whisper, .gate[data-dread="4"] .whisper { color: #b0483c; text-shadow: 0 0 7px rgba(200, 50, 30, .4), 0 0 2px #000; }
@media (max-width: 1100px) { .whisper { --ls: .18em; } }
/* The sword follows the incantation: one character of the inscription brightens for each one
   spoken (app.js sets .lit). Refused, the lit ones and the serpent's eyes turn to blood, and it
   flicks its tongue at you. */
.whisper .ch { transition: color .25s, text-shadow .25s, opacity .25s; }
/* while the box listens, the words not yet spoken sink back, so the spoken ones stand out */
.gate.awake .whisper .ch:not(.lit) { opacity: .5; }
.whisper .ch.lit { color: #fff4d6; text-shadow: 0 0 4px #ffd98a, 0 0 10px rgba(255, 200, 100, .9), 0 0 20px rgba(230, 160, 60, .6), 0 1px 1px #000; }
.gate.refused .whisper .ch.lit { color: #ff8a74; text-shadow: 0 0 7px rgba(255, 60, 40, .85), 0 0 16px rgba(200, 20, 10, .5), 0 1px 1px #000; }
.gate.refused .whisper .glint .pulse.r { animation: none; opacity: 1; }
.gate.refused .whisper .glint .tongue { animation: tongueFlick .7s linear; }
@keyframes tongueFlick { 0%, 30%, 60%, 100% { opacity: 0; } 15%, 45% { opacity: 1; } }
/* now and then the blade catches the light: a cold gleam flicks along the front of its edge to the
   point (under a second) and bursts there into a small four-rayed star — 寒芒. When the
   lightning flashes, the whole edge flares with it. Drawn over the sword rather than in it,
   because a sword image that animates is repainted on every frame and flickers on phones. */
.whisper .glint {
  position: absolute; z-index: -1; left: 50%; top: 50%;
  width: var(--sword); aspect-ratio: 470 / 80; translate: -50% -50%;
  overflow: visible; pointer-events: none;
}
.whisper .glint .edge, .whisper .glint .flare {
  fill: none; stroke: #f2fffa; stroke-linecap: round; vector-effect: non-scaling-stroke;
}
.whisper .glint .edge {
  stroke-width: 1.5;
  stroke-dasharray: 14 200; stroke-dashoffset: -45; opacity: 0;
  filter: drop-shadow(0 0 2px rgba(220, 255, 240, .95));
  animation: gleam 13s cubic-bezier(.4, 0, .6, 1) 4s infinite;
}
.whisper .glint .flare { stroke-width: 1.1; opacity: 0; filter: drop-shadow(0 0 3px rgba(220, 255, 240, .8)); }
.gate.flashing .whisper .glint .flare { animation: flash 1.2s ease-out; --peak: .7; }
.gate.striking .whisper .glint .flare { animation: flash 1.1s ease-out; --peak: 1; }
.whisper .glint .star {
  fill: #fff; opacity: 0; transform-box: fill-box; transform-origin: center; scale: 0;
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px rgba(200, 255, 230, .8));
  animation: gleamStar 13s ease-out 4s infinite;
}
/* when the key turns in the lock the gleam runs the blade once: the sword lets you in */
.gate.unsealing .whisper .glint .edge { animation: gleamOnce .75s .3s ease-in-out both; }
.gate.unsealing .whisper .glint .star { animation: starOnce .9s .95s ease-out both; }
/* sealed again: once the lock has snapped shut, the gleam runs again — the guard is back */
.gate.resealing .whisper .glint .edge { animation: gleamOnce .75s 2.3s ease-in-out both; }
.gate.resealing .whisper .glint .star { animation: starOnce .9s 2.95s ease-out both; }
@keyframes gleamOnce { 0% { stroke-dashoffset: -100; opacity: 0; } 8% { opacity: 1; } 88% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 14; opacity: 0; } }
@keyframes starOnce { 0% { opacity: 0; scale: 0; rotate: 0deg; } 18% { opacity: 1; scale: 1.5; rotate: 12deg; } 55% { opacity: .75; scale: 1; rotate: 30deg; } 100% { opacity: 0; scale: .2; rotate: 45deg; } }
/* the guard steps aside: as the box opens the sword sinks into the mist; it rises again from it
   when the box is sealed */
.gate.opening .whisper { translate: 0 26px; opacity: 0; filter: blur(3px); transition: translate .9s ease-in, opacity .9s ease-in, filter .9s ease-in; }
.gate.resealing .whisper { animation: swordRise 1s 1.25s cubic-bezier(.2, .7, .3, 1) backwards; }
@keyframes swordRise { from { translate: 0 26px; opacity: 0; filter: blur(3px); } }
@keyframes gleam {
  0%, 83.6% { stroke-dashoffset: -45; opacity: 0; }
  84.4% { opacity: 1; }
  90% { stroke-dashoffset: 0; opacity: 1; }
  91%, 100% { stroke-dashoffset: 14; opacity: 0; }
}
@keyframes gleamStar {
  0%, 89.6% { opacity: 0; scale: 0; rotate: 0deg; }
  91% { opacity: 1; scale: 1.3; rotate: 12deg; }
  94% { opacity: .75; scale: .95; rotate: 30deg; }
  97.5%, 100% { opacity: 0; scale: .2; rotate: 45deg; }
}
/* the sword's living parts, drawn over it for the same reason: the stones breathe on the embers'
   beat as the box's sign (5s), the serpent's eyes now and then close, and its tongue flickers out */
.whisper .glint .pulse { opacity: 0; animation: stoneBreath 5s ease-in-out infinite; } /* one heartbeat with the box's sign */
@keyframes stoneBreath { 50% { opacity: .85; } }
.whisper .glint .lid {
  fill: #2c3734; transform-box: fill-box; transform-origin: center; scale: 1 0;
  animation: lidBlink 9s ease-in-out infinite;
}
@keyframes lidBlink { 0%, 90%, 98%, 100% { scale: 1 0; } 93%, 95% { scale: 1 1; } }
.whisper .glint .tongue {
  fill: none; stroke: #b42a1c; stroke-width: .9; stroke-linecap: round; vector-effect: non-scaling-stroke;
  opacity: 0; animation: tongue 13s linear 5s infinite;
}
@keyframes tongue { 0%, 60%, 63%, 66%, 100% { opacity: 0; } 61.5%, 64.5% { opacity: 1; } }
/* an inscription has no punctuation: its two halves are parted by a looped knot (the ⌘ figure,
   four rings bound round a square, an old warding sign) in the same gold — and the same red,
   later. Drawn as a mask over the text colour. */
.whisper .sep {
  display: inline-block; vertical-align: middle;
  width: .95em; height: .95em; margin: -.12em var(--ls) 0 0;
  background: currentColor;
  -webkit-mask: url(/img/knot.svg) center / contain no-repeat;
  mask: url(/img/knot.svg) center / contain no-repeat;
  filter: drop-shadow(0 0 3px rgba(214, 178, 105, .35));
}
/* a sword in the mist laid across the screen behind the words: little more than its shape */
.whisper::before {
  content: ""; position: absolute; z-index: -1;
  left: 50%; top: 50%;
  width: var(--sword); aspect-ratio: 470 / 80;
  /* the blade runs as far left of the words as the hilt runs right, so the sword's middle is the
     words' middle, and both are the middle of the page */
  translate: -50% -50%;
  background: url(/img/sword.svg) center / contain no-repeat;
  pointer-events: none;
}

/* ───────── stage / box ───────── */
/* mist lying on the ground of the clearing, rolling slowly; the foot of the box stands in it */
.ground-mist {
  position: absolute; z-index: 1; left: 50%; top: calc(50% + var(--s) * .04);
  width: calc(var(--s) * 3.6); max-width: 115vw; height: calc(var(--s) * .9);
  translate: -50% 0; pointer-events: none;
}
.ground-mist i {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(ellipse 48% 34% at 50% 55%, rgba(155, 182, 172, .28), rgba(120, 150, 140, .08) 50%, transparent 72%);
  animation: roll 26s linear infinite;
}
.ground-mist i:nth-child(1) { left: -30%; right: 25%; animation-duration: 31s; }
.ground-mist i:nth-child(2) { left: 20%; right: -25%; top: 12%; animation-duration: 24s; animation-direction: alternate-reverse; }
.ground-mist i:nth-child(3) { left: 5%; right: 5%; top: 28%; opacity: .8; animation-duration: 37s; animation-delay: -9s; }
.ground-mist i:nth-child(4) { left: -10%; right: 40%; top: -8%; opacity: .55; animation-duration: 29s; animation-delay: -15s; animation-direction: alternate-reverse; }
/* the ground mist goes with the wind too: each bank drifts across, thinning out at either end */
@keyframes roll {
  0% { translate: -18% 0; opacity: 0; }
  22% { opacity: .95; }
  78% { opacity: .9; }
  100% { translate: 18% -3%; opacity: 0; }
}
.ground-mist::after {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse 42% 32% at 50% 55%, rgba(215, 232, 225, .3), transparent 72%);
}

.stage {
  position: relative; z-index: 4;
  align-self: center;
  width: calc(var(--s) * 2.6);
  height: 100%;
  max-height: calc(var(--s) * 2.6);
  max-width: 92vw;
  display: grid; place-items: center;
}
.aura {
  position: absolute; inset: 12%; pointer-events: none; /* a light, never in the way of the incantation line */
  border-radius: 50%;
  /* soft by its gradient alone: a blur on this breathing layer right behind the box made one more
     full texture for the phone to redraw every frame */
  background: radial-gradient(circle, rgba(143, 227, 176, .18) 0%, rgba(122, 77, 255, .08) 42%, rgba(122, 77, 255, .03) 58%, transparent 74%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(.92); opacity: .7; } 50% { transform: scale(1.08); opacity: 1; } }
.gate.awake .aura { animation-duration: 3s; }


.scene {
  all: unset;
  /* above everything else in the stage. Phones draw this 3D box together with any layer that
     moves over it, and when they reshuffle those layers parts of the faces (the seals, the sign)
     can go undrawn for a frame — so nothing that moves may lie on top of it */
  position: relative; z-index: 3;
  cursor: grab;
  width: var(--s); height: var(--s);
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
}
.scene.dragging { cursor: grabbing; }
.scene:focus-visible .box { outline: 1px dashed rgba(143,227,176,.4); outline-offset: 30px; }
.box {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: scale .18s ease;
}
/* the box answers a touch: the glow leans in on hover, the box gives a little when pressed */
.stage:has(.scene:hover) .aura { opacity: 1; }
.scene:active .box { scale: .965; }
/* Each face is a plate of black bronze carved in the Egyptian manner (img/box-face.svg: a lotus
   frieze, cartouches of signs, a winged sun, an Eye of Horus; every line a chiselled groove with old
   gold laid in it). The light is baked per face: the lid catches most, the far sides least. */
.face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background:
    linear-gradient(rgba(255, 236, 200, var(--lift, 0)), rgba(255, 236, 200, var(--lift, 0))),
    linear-gradient(rgba(0, 0, 0, var(--shade, 0)), rgba(0, 0, 0, var(--shade, 0))),
    radial-gradient(ellipse at 50% 50%, rgba(143, 227, 176, .08), transparent 60%),
    url(/img/box-face.svg) 0 0 / 100% 100% no-repeat,
    #160f08;
  border: 1px solid #a9844a;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, .18), inset 0 0 26px rgba(0, 0, 0, .55);
  backface-visibility: visible;
}
.box .top { --lift: .12; } .box .front { --lift: .05; } .box .right { --shade: .16; }
.box .left { --shade: .26; } .box .back { --shade: .36; }
/* Every face of the box must stay exactly inside its own square. Anything drawn past its edge —
   an outer glow, a chain or seal running a pixel over, the light seeping under the lid — makes
   the faces cut into one another in 3D, and the phone then has to work out, frame by frame,
   which piece of which face is in front: the seals and the sign blink in and out as the box
   turns. So: no outer shadows on faces, and each face clips what it holds (except while the box
   is being broken open, when the lock and chains fly off it). */
.gate:not(.unsealing):not(.opening) .face { overflow: hidden; }
.front  { transform: translateZ(var(--h)); }
.back   { transform: rotateY(180deg) translateZ(var(--h)); }
.right  { transform: rotateY(90deg) translateZ(var(--h)); }
.left   { transform: rotateY(-90deg) translateZ(var(--h)); }
.top    { transform: rotateX(90deg) translateZ(var(--h)); }
.bottom { transform: rotateX(-90deg) translateZ(var(--h)); }
.box .bottom { --shade: .5; } /* the underside: the same carved bronze, in its own shadow */

.sig {
  width: 56%; height: 56%;
  color: var(--eerie);
  opacity: .5;
  filter: drop-shadow(0 0 4px rgba(143,227,176,.6));
}
.top .sig, .bottom .sig { width: 70%; height: 70%; } /* lid and underside carry the sign large */
/* The sign breathes: a brighter copy over it, haloed, fades slowly in and out — at its height it
   outshines the bronze and gold around it. Only its opacity changes, which the graphics chip does
   on its own: the faces are never repainted for it (repainting them is what made it flicker). */
.sig.glow {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  color: #d4ffe6;
  filter: drop-shadow(0 0 2px #b8ffd6) drop-shadow(0 0 7px rgba(143, 227, 176, .9)) drop-shadow(0 0 16px rgba(143, 227, 176, .55));
  opacity: 0;
  animation: sigBreath 5s ease-in-out infinite;
}
.top .sig.glow { animation-delay: -1.2s; }
.bottom .sig.glow { animation-delay: -1.2s; }
@keyframes sigBreath { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
/* The carvings answer the incantation. Over each face lie two lit copies of its carved lines
   (masks of img/box-face.svg's grooves, glowing gold): the columns of signs, revealed from the top
   one sign per character spoken (--g, set by app.js); and every line, which kindles from the lotus
   at the foot to the winged sun as the box is unsealed. The glow sits on the outer span (a filter
   is drawn before a mask, so it cannot sit on the masked one). */
.carve { position: absolute; inset: 0; pointer-events: none; opacity: 0; filter: drop-shadow(0 0 1.5px rgba(255, 206, 120, .8)) drop-shadow(0 0 5px rgba(230, 160, 60, .4)); }
.carve > span { position: absolute; inset: 0; background: linear-gradient(160deg, #ffe7b0, #d9a54c 55%, #f2c977); }
.carve.glyphs > span {
  -webkit-mask: url(/img/box-glyphs.svg) 0 0 / 100% 100% no-repeat; mask: url(/img/box-glyphs.svg) 0 0 / 100% 100% no-repeat;
  clip-path: inset(0 0 calc(100% - var(--g, 0%)) 0);
  transition: clip-path .35s ease-out, background .2s;
}
.carve.all > span { -webkit-mask: url(/img/box-lit.svg) 0 0 / 100% 100% no-repeat; mask: url(/img/box-lit.svg) 0 0 / 100% 100% no-repeat; }
.box.speaking .carve.glyphs { opacity: 1; transition: opacity .3s; }
/* a wrong incantation: the lit signs turn to blood before they go out */
.box.denied .carve.glyphs > span { background: linear-gradient(160deg, #ff9a86, #c0261b 55%, #ff5a40); }
.box.denied .carve.glyphs { filter: drop-shadow(0 0 2px rgba(255, 80, 60, .9)) drop-shadow(0 0 7px rgba(200, 30, 20, .6)); }
/* unsealing: every carved line kindles, from the foot up, before the box is broken open */
.gate.stirring .carve.all, .gate.unsealing .carve.all, .gate.opening .carve.all { opacity: .9; }
.gate.stirring .carve.all > span, .gate.unsealing .carve.all > span, .gate.opening .carve.all > span { animation: kindle .6s ease-out both; }
@keyframes kindle { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
/* the Eye of Horus at the foot of each face: on a wrong incantation its pupil burns red */
.horus {
  position: absolute; left: 50%; top: 77.8%; width: 13%; height: 9%; translate: -50% -50%; pointer-events: none;
  border-radius: 50%; background: radial-gradient(circle, #ffd2c4 0%, #ff3b2e 26%, rgba(200, 20, 10, .55) 52%, transparent 74%);
  opacity: 0;
}
.box.denied .horus { animation: horus 1.4s ease-out; }
@keyframes horus { 0% { opacity: 0; } 12%, 55% { opacity: 1; } 100% { opacity: 0; } }

/* beneath the floating box the mist is lit a little by the sign, breathing with it */
.underglow {
  position: absolute; z-index: 1; left: 50%; top: calc(50% + var(--s) * .62); width: calc(var(--s) * 1.9); height: calc(var(--s) * .5);
  translate: -50% -50%; pointer-events: none; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(170, 245, 205, .3), rgba(143, 227, 176, .12) 45%, rgba(143, 227, 176, .03) 65%, transparent 75%);
  opacity: 0; animation: sigBreath 5s ease-in-out infinite;
}
.gate[data-dread] .underglow, .gate.opening .underglow { animation: none; opacity: 0; transition: opacity .6s; }
/* now and then a few grains of gold sand sift from the box's lower seam into the mist (app.js) */
.sand { position: absolute; z-index: 1; left: 50%; top: calc(50% + var(--s) * .55); width: var(--s); height: calc(var(--s) * .7); translate: -50% 0; pointer-events: none; }
.sand i {
  position: absolute; top: 0; width: 2px; height: 2px; border-radius: 50%;
  background: #f3d68e; box-shadow: 0 0 3px rgba(255, 210, 130, .8);
  animation: sift var(--d, 2.6s) cubic-bezier(.45, 0, .8, .6) forwards;
}
@keyframes sift { 0% { opacity: 0; translate: 0 0; } 12% { opacity: 1; } 100% { opacity: 0; translate: var(--x, 0) calc(var(--s) * .62); } }

/* glowing seam under the lid, visible once the lid lifts */
.core {
  position: absolute; inset: 6%;
  transform: rotateX(90deg) translateZ(calc(var(--h) - 4px));
  background: radial-gradient(circle, #fff 0%, var(--eerie-hot) 25%, rgba(143,227,176,.5) 55%, transparent 75%);
  opacity: 0;
}

.box.listening .sig.glow { animation-duration: .9s; }
/* the pointer near: the sign quickens */
.box.near .sig.glow { animation-duration: 2.2s; }
/* the box can be taken hold of and turned */
.scene { touch-action: none; }
.box.denied .face { border-color: rgba(255, 59, 78, .6); box-shadow: inset 0 0 50px rgba(255, 59, 78, .35), 0 0 40px rgba(255, 59, 78, .3); }
.box.denied .sig { color: var(--blood); filter: drop-shadow(0 0 6px rgba(255,59,78,.9)); }
.box.denied .sig.glow { animation: none; opacity: 0; }
.scene.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); }
}

/* ───────── spell input ───────── */
.spell {
  position: absolute; left: 50%; top: calc(50% + var(--s) * .8 + 14px);
  width: min(calc(var(--s) * 1.35), 80vw);
  transform: translate(-50%, -50%) scale(.96);
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease .1s, transform .6s ease .1s;
  z-index: 5;
}
.gate.awake .spell { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.spell-wrap { position: relative; display: flex; align-items: center; }
.spell input {
  width: 100%;
  padding: 12px 34px 10px;
  background: radial-gradient(ellipse 70% 100% at 50% 100%, rgba(4, 7, 6, .7), transparent 75%);
  border: 0;
  border-radius: 0;
  color: var(--eerie-hot);
  caret-color: var(--eerie);
  font: 500 18px/1 var(--serif);
  letter-spacing: .35em;
  text-align: center;
  outline: none;
  text-shadow: 0 0 10px rgba(143, 227, 176, .45);
}
.spell-eye, .spell-go {
  all: unset; cursor: pointer; position: absolute; top: 50%; translate: 0 -50%;
  width: 28px; height: 28px; display: grid; place-items: center;
  color: rgba(176, 141, 87, .62); transition: color .25s ease, opacity .25s ease;
}
.spell-eye { left: 2px; }
.spell-eye::before {
  content: ""; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url(/img/eye-closed.svg) center / contain no-repeat;
  mask: url(/img/eye-closed.svg) center / contain no-repeat;
}
.spell-eye[aria-pressed="true"] { color: var(--eerie); }
.spell-eye[aria-pressed="true"]::before {
  -webkit-mask-image: url(/img/eye-open.svg); mask-image: url(/img/eye-open.svg);
}
.spell-eye:hover, .spell-go:hover { color: var(--eerie-hot); }
.spell-eye:focus-visible, .spell-go:focus-visible { outline: 1px solid rgba(143, 227, 176, .55); border-radius: 2px; }
.spell-go { right: 2px; color: var(--eerie); animation: goIn .2s ease-out; }
.spell-go[hidden] { display: none; }
.spell-go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(143, 227, 176, .5)); }
@keyframes goIn { from { opacity: 0; translate: -4px -50%; } }
.spell input::placeholder { color: rgba(143, 227, 176, .6); letter-spacing: .25em; font-family: var(--cn); font-size: 14px; text-shadow: none; }
.spell input:disabled { opacity: .6; }
/* the inscription line the incantation is written on, pinned by two brass studs */
.spell-line {
  position: relative; display: block; height: 1px; margin: 0 6px;
  background: linear-gradient(90deg, rgba(176, 141, 87, .5), rgba(143, 227, 176, .45) 50%, rgba(176, 141, 87, .5));
  transition: background .4s ease, box-shadow .4s ease;
}
.spell-flow {
  position: absolute; inset: -1px 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--eerie-hot) 50%, transparent);
  box-shadow: 0 0 10px rgba(143, 227, 176, .8);
  transform: scaleX(.12);
}
.gate.listening .spell-flow { opacity: 1; animation: spellFlow 1.15s ease-in-out infinite; }
@keyframes spellFlow {
  0% { transform: scaleX(.12); opacity: .35; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(.12); opacity: .35; }
}
.spell-line::before, .spell-line::after {
  content: ""; position: absolute; top: 50%; width: 6px; height: 6px;
  background: radial-gradient(circle at 35% 35%, #d9b77c, #6d532c 70%);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, .9);
  transform: translate(0, -50%);
}
.spell-line::before { left: -6px; }
.spell-line::after { right: -6px; }
.spell:focus-within .spell-line {
  background: linear-gradient(90deg, rgba(176, 141, 87, .7), var(--eerie-hot) 50%, rgba(176, 141, 87, .7));
  box-shadow: 0 0 10px rgba(143, 227, 176, .55);
}
.spell:focus-within input:focus-visible ~ .spell-line { box-shadow: 0 0 10px rgba(143, 227, 176, .55), 0 2px 0 rgba(143, 227, 176, .35); }

.omen {
  /* just under the incantation line (the spell is centred at 50% + .8s + 14px, ~44px tall) */
  position: absolute; z-index: 5; left: 50%; top: calc(50% + var(--s) * .8 + 14px + 34px);
  translate: -50% 0; width: max-content; max-width: 92vw;
  min-height: 1.6em; margin: 0;
  font-size: 13px; letter-spacing: .4em; padding-left: .4em;
  color: var(--ink-dim);
  text-align: center;
  transition: color .3s;
}
/* the resting hint is a warning in English, cut in old capitals */
.omen.hint { font: 600 12px/1.6 "Cinzel", serif; text-transform: uppercase; letter-spacing: .14em; padding-left: .14em; color: #8f9a93; }
/* no wider than three quarters of the burnt strip at the foot (about 225px); on phones, upright or
   sideways, where the strip is shorter, up to about 85% of it (about 189px) so it stays legible */
@media (max-width: 560px), (max-height: 520px) and (orientation: landscape) {
  .omen.hint { font-size: 10px; letter-spacing: .14em; padding-left: .14em; }
}
/* with the fingerprint button under the line (Android app) the hint sits below that too */
.stage:has(.finger:not([hidden])) .omen { top: calc(50% + var(--s) * .8 + 14px + 84px); }
.omen.bad { color: #ff6b7a; text-shadow: 0 0 10px rgba(255,59,78,.5); }
/* the hint comes and goes, like words seen through smoke; a warning or the opening stays
   steady so it is read */
.omen { animation: haunt 7.5s ease-in-out -3s infinite; }
.omen.bad, .omen.good { animation: none; }
@keyframes haunt {
  0%, 100% { opacity: .9; }
  22% { opacity: .55; }
  38% { opacity: .3; }
  52% { opacity: .75; }
  70% { opacity: .45; }
  84% { opacity: .95; }
}
.omen.good { color: var(--eerie-hot); text-shadow: 0 0 12px rgba(143,227,176,.7); }

/* ───────── opening sequence ───────── */
/* first the box is struck from inside, again and again, light flaring at the lid */
.gate.stirring .scene { animation: rattle .9s .55s ease-in-out; }
@keyframes rattle {
  0%, 22%, 46%, 66%, 100% { transform: none; }
  7% { transform: translate(-3px, 1px) rotate(-1.6deg); }
  14% { transform: translate(3px, -3px) rotate(1.3deg); }
  52% { transform: translate(2px, -5px) rotate(1.9deg); }
  58% { transform: translate(-3px, 2px) rotate(-1.2deg); }
  80% { transform: translate(-1px, -8px) scale(1.03); }
  88% { transform: translate(1px, 1px); }
}
/* the eyes in the wood go out: even they fear what is in the box */
.eyes.flee { opacity: 0; transition: opacity .6s ease-in; }
/* the gate dissolves over what has come out of the box */
.gate.leaving { position: fixed; inset: 0; z-index: 50; opacity: 0; transition: opacity .9s ease; pointer-events: none; }
/* a tap hurries the rite: the box's own animations jump to their end */
.gate.hurry .scene { animation: none !important; }
.gate.hurry .scene * { animation-duration: .01s !important; animation-delay: 0s !important; }

/* things glimpsed in the smoke (js/rite.js): pairs of eyes and clawed shadows */
.spirits { position: fixed; inset: 0; z-index: 61; pointer-events: none; overflow: hidden; }
.spirit { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.spirit.eyes2 { display: flex; gap: 7px; filter: drop-shadow(0 0 5px rgba(180, 230, 120, .7)); }
.spirit.eyes2::before {
  content: ""; position: absolute; inset: -16px -24px; z-index: -1;
  background: radial-gradient(ellipse, rgba(0, 0, 0, .8), transparent 70%); filter: blur(6px);
}
.spirit.eyes2 i { width: 7px; height: 3.6px; border-radius: 50%; background: radial-gradient(#f4ffd8 0%, #bfe67e 45%, rgba(150, 205, 90, 0) 78%); }
.spirit.eyes2.red { filter: drop-shadow(0 0 5px rgba(255, 70, 40, .8)); }
.spirit.eyes2.red i { background: radial-gradient(#ffe0d4 0%, #ff4a34 45%, rgba(255, 50, 30, 0) 78%); }
.spirit.bat svg { display: block; width: 40px; height: 24px; fill: #020303; filter: drop-shadow(0 0 6px rgba(0, 0, 0, .9)); animation: flap .11s ease-in-out infinite alternate; transform-origin: 50% 60%; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(-.55) translateY(-6px); } }
.spirit.claw svg { display: block; width: 52px; height: 52px; fill: #030404; opacity: .9; filter: blur(1.2px) drop-shadow(0 0 10px rgba(0, 0, 0, .95)); }

.gate.opening .box .top { animation: lidBurst .9s cubic-bezier(.2, .9, .3, 1) forwards; }
.gate.opening .box .core { animation: core 1.6s ease-in forwards; }
.gate.opening .aura { transition: opacity 1.2s ease; opacity: 0; }
.gate.opening .spell, .gate.opening .gate-head { opacity: 0; transition: opacity .5s; }
.gate.opening .scene { animation: tremble .08s linear infinite; }
@keyframes lidBurst {
  0% { transform: rotateX(90deg) translateZ(var(--h)); }
  12% { transform: translateY(-16px) rotateX(84deg) translateZ(var(--h)); }
  100% { transform: translateY(-460px) translateZ(-40px) rotateX(15deg) rotateZ(75deg) translateZ(var(--h)); opacity: 0; }
}
@keyframes core { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 1; transform: rotateX(90deg) translateZ(calc(var(--h) - 4px)) scale(1.6); } }
@keyframes tremble { 0% { transform: translate(1px, 0); } 50% { transform: translate(-1px, 1px); } 100% { transform: translate(0, -1px); } }


/* landscape phones: keep the box, title and input on one screen */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --s: 100px; }
  .gate { padding-top: calc(3vh + env(safe-area-inset-top)); padding-bottom: calc(2vh + env(safe-area-inset-bottom)); }
  .stage { max-height: calc(var(--s) * 2); width: calc(var(--s) * 3); }
  .title { font-size: 30px; }
  .whisper { margin-top: 6px; font-size: 13px; }
  .site-mark { margin-top: 8px; }
  .omen { top: calc(50% + var(--s) * .8 + 14px + 28px); }
}
@media (max-width: 560px) {
  :root { --s: 140px; }
  .gate { padding-top: calc(4vh + env(safe-area-inset-top)); padding-bottom: calc(2.5vh + env(safe-area-inset-bottom)); }
  .site-mark { margin-top: 18px; }
  .whisper { --ls: .06em; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .gate .site-mark .ash, .gate .site-mark .fume { display: none; }
  .gate .site-mark .flame, .gate .site-mark .flame i, .gate .site-mark .flame::before { animation: none; }
  .fog, .title, .title .letters > span, .gate .site-mark, .omen, .storm, .bolt, .thunder, .mistlight, .ground-mist::after, .whisper .glint .edge, .whisper .glint .flare, .whisper .glint .star, .whisper .glint .pulse, .whisper .glint .lid, .whisper, .whisper::before, .title .letters > .glow, .woods .sky::after, .eyes .pair, .eyes .pair i, .ground-mist i, .aura, .scene.shake, .sig.glow, .underglow { animation: none !important; }
}

/* site mark — shared by the gate and the ledger footers */
.site-mark {
  position: relative; z-index: 4;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 28px 0 0;
  font: 600 14px/1 "Cinzel", serif;
  letter-spacing: .42em; padding-left: .42em;
  color: rgba(185, 214, 198, .7);
  text-shadow: 0 0 14px rgba(143, 227, 176, .25);
}
.mark-line { width: 48px; height: 1px; background: linear-gradient(90deg, transparent, rgba(143, 227, 176, .6), transparent); }
/* on the gate the mark is what is left of a paper strip after the fire (img/burnt-paper.svg):
   charred, embers still breathing along its rim, the name in faded gold, drifting in the dark.
   Performance: the strip itself only drifts (a transform). The paper and its shadow lie on a still
   pseudo-element, painted once; everything that flickers on it — the name's glow, the flames, the
   smoke and ash — changes only its own opacity or transform. Nothing here animates a filter, a
   colour or a shadow: on a phone that repainted the whole strip, burnt paper and all, every frame. */
.gate .site-mark {
  gap: 0; padding: 16px 46px 15px;
  /* the name in faded gold leaf, catching a little of the fire's light */
  color: #8c713f; text-shadow: 0 0 1px rgba(230, 200, 140, .2), 0 0 3px rgba(210, 170, 90, .12);
  rotate: -2.5deg;
  animation: paperDrift 7s ease-in-out infinite;
}
.gate .site-mark::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url(/img/burnt-paper.svg) center / 100% 100% no-repeat;
  filter: drop-shadow(0 12px 7px rgba(0, 0, 0, .8)) drop-shadow(0 22px 18px rgba(0, 0, 0, .5));
}
/* the name brightens as the fire flares: a brighter copy over it fades in and out */
.gate .site-mark .mark-name { position: relative; }
.gate .site-mark .mark-name::after {
  content: attr(data-glow); position: absolute; inset: 0; pointer-events: none;
  color: #d6b878;
  text-shadow: 0 0 1px rgba(255, 225, 160, .65), 0 0 6px rgba(235, 190, 100, .55), 0 0 12px rgba(220, 150, 60, .3);
  opacity: 0;
  animation: smoulder 4.8s ease-in-out infinite;
}
.gate .site-mark .mark-line { display: none; }
/* Touch the strip and the fire takes hold for a moment: the flames leap up, the band of embers
   burns bright, and the whole name glows gold, then it all sinks back to its slow smoulder */
.gate .site-mark { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gate .site-mark.blaze .flame { animation: blazeUp 2.6s cubic-bezier(.2, .7, .3, 1), flutter .6s linear infinite; }
.gate .site-mark.blaze .flame::before { animation: none; opacity: 1; }
.gate .site-mark.blaze .mark-name::after { animation: nameBlaze 2.6s ease-out; }
@keyframes blazeUp {
  0% { scale: 1 .6; }
  12% { scale: 1.5 2.6; }
  30% { scale: 1.35 2.2; }
  55% { scale: 1.25 1.8; }
  100% { scale: 1 .6; }
}
@keyframes nameBlaze { 0% { opacity: 0; } 10%, 55% { opacity: 1; } 100% { opacity: 0; } }
/* phones: a shorter strip — tighter lettering, less paper either side */
@media (max-width: 560px) {
  .gate .site-mark { padding: 13px 30px 12px; font-size: 12px; letter-spacing: .3em; padding-left: calc(30px + .3em); }
}
/* the curled-up right edge is still burning: one small, low flame front along it (burnt-paper.svg
   puts the curl's tip at 91.7% across, 38% down; the edge runs from there down to the right).
   A glowing band hugs the edge and eight little tongues rise from it, low on the left and tallest
   at the right, overlapping and blending,
   each leaping and sinking, brightening and dimming on its own beat — like paper burning */
.site-mark .flame { display: none; }
.gate .site-mark .flame {
  display: block; position: absolute; inset: 0; pointer-events: none;
  /* the fire flares on the same beat as the name: low while the name is dark, leaping up as it brightens */
  transform-origin: 94% 46%;
  /* and on top of that slow swell, the quick restless flutter every real flame has */
  animation: flare 4.8s ease-in-out infinite, flutter 1.3s linear infinite;
}
@keyframes flutter {
  0%, 100% { opacity: .92; translate: 0 0; }
  9% { opacity: 1; translate: 0 -.4px; }
  17% { opacity: .82; translate: .2px 0; }
  26% { opacity: .97; translate: 0 -.3px; }
  38% { opacity: .86; }
  47% { opacity: 1; translate: -.2px -.5px; }
  55% { opacity: .8; translate: 0 0; }
  66% { opacity: .95; }
  74% { opacity: .85; translate: .2px -.2px; }
  86% { opacity: 1; translate: 0 -.4px; }
}
.gate .site-mark .flame::before {
  content: ""; position: absolute; left: 91.4%; top: 38.5%; width: 15px; height: 3.5px;
  transform-origin: 0 50%; rotate: 21deg; translate: 0 -50%;
  background: radial-gradient(ellipse 50% 50%, #ffd27a 0%, #ff8a32 40%, rgba(230, 70, 20, .5) 62%, rgba(255, 110, 40, .2) 80%, transparent 100%);
  box-shadow: 0 0 4px 1px rgba(255, 110, 40, .45);
  border-radius: 50%;
  animation: ember-band 4.8s ease-in-out infinite;
}
@keyframes ember-band { 0%, 58%, 86%, 100% { opacity: .55; } 72% { opacity: 1; } }
@keyframes flare { 0%, 58%, 86%, 100% { scale: 1 .6; } 72% { scale: 1.05 1.3; } }
.gate .site-mark .flame i {
  position: absolute;
  translate: -50% -88%;
  transform-origin: 50% 100%;
  background: radial-gradient(ellipse 50% 62% at 50% 80%, #fff1c4 0%, #ffbf5e 24%, #ff7424 52%, rgba(215, 55, 15, .45) 72%, transparent 82%);
  border-radius: 50% 50% 45% 45% / 72% 72% 28% 28%;
  animation: lick 3.4s ease-in-out infinite;
}
.gate .site-mark .flame i:nth-child(1) { left: 91.8%; top: 38.5%; width: 2.5px; height: 3px; rotate: -5deg; animation-duration: 3.34s; animation-delay: -0.91s; }
.gate .site-mark .flame i:nth-child(2) { left: 92.3%; top: 39.9%; width: 3px; height: 4px; rotate: 7deg; animation-duration: 2.58s; animation-delay: -1.82s; }
.gate .site-mark .flame i:nth-child(3) { left: 92.9%; top: 41.4%; width: 3px; height: 5px; rotate: -2deg; animation-duration: 3.95s; animation-delay: -3.04s; }
.gate .site-mark .flame i:nth-child(4) { left: 93.4%; top: 42.8%; width: 4px; height: 6px; rotate: 10deg; animation-duration: 2.88s; animation-delay: -0.61s; }
.gate .site-mark .flame i:nth-child(5) { left: 94.0%; top: 44.2%; width: 4px; height: 7px; rotate: -6deg; animation-duration: 3.49s; animation-delay: -2.43s; }
.gate .site-mark .flame i:nth-child(6) { left: 94.5%; top: 45.6%; width: 4px; height: 8px; rotate: 4deg; animation-duration: 2.43s; animation-delay: -1.52s; }
.gate .site-mark .flame i:nth-child(7) { left: 95.1%; top: 47.1%; width: 5px; height: 10px; rotate: 12deg; animation-duration: 3.04s; animation-delay: -0.30s; }
.gate .site-mark .flame i:nth-child(8) { left: 95.6%; top: 48.5%; width: 5px; height: 9px; rotate: 0deg; animation-duration: 2.13s; animation-delay: -1.22s; }
@keyframes lick {
  0%, 100% { scale: 1 1; skew: 0deg; opacity: .9; }
  18% { scale: .85 .5; skew: -8deg; opacity: .55; }
  34% { scale: 1.05 1.35; skew: 5deg; opacity: 1; }
  52% { scale: .9 .7; skew: -3deg; opacity: .7; }
  70% { scale: 1 1.2; skew: 9deg; opacity: .95; }
  86% { scale: .8 .6; skew: -6deg; opacity: .6; }
}
/* a little paper ash lifting off the strip and fading as it rises. Unlike the round glowing
   motes behind it, ash is a pale, flat, angular flake that does not glow, and it flutters —
   turning edge-on and over as it tumbles up */
.gate .site-mark { position: relative; }
.site-mark .ash { display: none; }
/* the ash rises off the flames at the right end */
.gate .site-mark .ash { display: block; position: absolute; left: 86%; right: 0; bottom: 70%; height: 80px; pointer-events: none; }
.gate .site-mark .ash i {
  position: absolute; bottom: 0; width: 7px; height: 5px;
  /* burnt paper: a dark flake, pale only at its thinnest edges */
  background: linear-gradient(135deg, #bdb5ab 0%, #6a625b 22%, #3a3532 55%, #26221f 78%, #8e867d 100%);
  clip-path: polygon(0 35%, 30% 0, 62% 12%, 100% 0, 86% 55%, 100% 100%, 45% 80%, 10% 100%);
  opacity: 0;
  animation: ash 9s linear infinite;
}
.gate .site-mark .ash i:nth-child(1) { left: 30%; animation-duration: 9.5s; animation-delay: -1s; }
.gate .site-mark .ash i:nth-child(2) { left: 55%; width: 5px; height: 4px; animation-duration: 11s; animation-delay: -6s; }
.gate .site-mark .ash i:nth-child(3) { left: 42%; width: 8px; height: 6px; animation-duration: 10s; animation-delay: -3.5s; }
.gate .site-mark .ash i:nth-child(4) { left: 68%; width: 5px; height: 3.5px; animation-duration: 12s; animation-delay: -8s; background: linear-gradient(135deg, #e07a3a, #7a3a1a); } /* still a spark at its edge */
.gate .site-mark .ash i:nth-child(5) { left: 20%; width: 6px; height: 4.5px; animation-duration: 13s; animation-delay: -10s; }
@keyframes ash {
  0% { opacity: 0; translate: 0 0; rotate: 0deg; scale: 1 1; }
  10% { opacity: .9; }
  25% { scale: .2 1; }
  40% { translate: 10px -26px; rotate: 120deg; scale: -1 .8; }
  55% { scale: .3 1; }
  75% { opacity: .55; scale: 1 .7; }
  100% { opacity: 0; translate: 22px -62px; rotate: 300deg; scale: -.6 1; }
}
/* and a thin thread of smoke curls up off the burning edge: black at the fire, grey as it rises, then gone */
.site-mark .fume { display: none; }
.gate .site-mark .fume { display: block; position: absolute; left: 89%; width: 9%; bottom: 40%; height: 100px; pointer-events: none; }
.gate .site-mark .fume::before {
  content: ""; position: absolute; left: 10%; right: 0; bottom: -6px; height: 16px;
  /* where the smoke leaves the fire: black, faintly lit from below */
  background: radial-gradient(ellipse 50% 45% at 50% 40%, rgba(8, 6, 5, .85), rgba(10, 8, 7, .4) 45%, transparent 72%), radial-gradient(ellipse at 50% 90%, rgba(255, 130, 60, .14), transparent 70%);
  height: 22px; bottom: -4px;
}
.gate .site-mark .fume i {
  position: absolute; bottom: 0; left: 35%; width: 11px; height: 11px; border-radius: 50%;
  /* grey smoke; it is black only at its root, where the static smudge below lies (::before) */
  background: radial-gradient(circle, rgba(120, 112, 105, .5), rgba(95, 88, 82, .24) 40%, rgba(95, 88, 82, .07) 58%, transparent 72%);
  opacity: 0;
  animation: fume 4.4s linear infinite;
}
.gate .site-mark .fume i:nth-child(2) { left: 50%; animation-duration: 5.2s; animation-delay: -1.1s; }
.gate .site-mark .fume i:nth-child(3) { left: 28%; animation-duration: 4.8s; animation-delay: -2.3s; }
.gate .site-mark .fume i:nth-child(4) { left: 44%; animation-duration: 5.6s; animation-delay: -3.4s; }
.gate .site-mark .fume i:nth-child(5) { left: 38%; animation-duration: 4.6s; animation-delay: -4.2s; }
/* the top-left rim, only just gone out: no flame, just the dying of one — the last flakes of ash
   lift off it slowly and drift, a couple still glowing at first and cooling to grey, and a thread
   of smoke so faint it is barely there */
.gate .site-mark .fume.l { left: 3%; width: 10%; bottom: 74%; height: 100px; scale: .5; transform-origin: 50% 100%; }
.gate .site-mark .fume.l::before { background: radial-gradient(ellipse, rgba(255, 140, 70, .08), transparent 70%); }
.gate .site-mark .fume.l i { animation-name: fumeOut; animation-duration: 7s; }
.gate .site-mark .fume.l i:nth-child(2) { animation-duration: 8.5s; animation-delay: -3s; }
@keyframes fumeOut {
  0% { opacity: 0; translate: 0 0; scale: .5; }
  20% { opacity: .5; }
  55% { translate: 6px -40px; scale: 1.2; }
  100% { opacity: 0; translate: 12px -84px; scale: 1.9; }
}
.gate .site-mark .ash.l { left: 2%; right: auto; width: 16%; bottom: 72%; height: 70px; scale: .75; transform-origin: 50% 100%; }
.gate .site-mark .ash.l i { animation-name: ashDrift; }
.gate .site-mark .ash.l i:nth-child(1) { left: 25%; animation-duration: 15s; animation-delay: -4s; }
.gate .site-mark .ash.l i:nth-child(2) { left: 55%; animation-duration: 18s; animation-delay: -11s; }
.gate .site-mark .ash.l i:nth-child(3) { left: 40%; animation-duration: 16.5s; animation-delay: -1.5s; }
/* a flake that leaves as a tiny ember and cools to ash as it floats off, turning over and over */
@keyframes ashDrift {
  0% { opacity: 0; translate: 0 0; rotate: 0deg; scale: 1 1; }
  8% { opacity: .95; }
  28% { scale: .3 1; }
  45% { translate: 14px -22px; rotate: 140deg; scale: -1 .8; }
  65% { translate: 6px -34px; scale: .4 1; }
  82% { opacity: .5; translate: 20px -44px; scale: 1 .7; }
  100% { opacity: 0; translate: 26px -58px; rotate: 330deg; scale: -.6 1; }
}
.gate .site-mark .ash.l i::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, #ffb060, #e0581e 60%, #7a2a0e);
  animation: emberCool 15s linear infinite; animation-duration: inherit; animation-delay: inherit;
}
@keyframes emberCool { 0% { opacity: 1; } 28%, 100% { opacity: 0; } }
/* black where it leaves the fire, turning grey as it rises and thins */
@keyframes fume {
  0% { opacity: 0; translate: 0 0; scale: .5; }
  18% { opacity: .55; }
  45% { opacity: .85; translate: 8px -36px; scale: 1.15; }
  75% { opacity: .4; translate: 15px -62px; scale: 1.6; }
  100% { opacity: 0; translate: 24px -88px; scale: 2; }
}
@keyframes paperDrift { 0%, 100% { translate: 0 0; rotate: -2.5deg; } 50% { translate: 0 -6px; rotate: -1deg; } }
/* a long dim stretch, then a brief brightening as the fire flares (in step with .flame) */
@keyframes smoulder { 0%, 58%, 86%, 100% { opacity: 0; } 72% { opacity: 1; } }

/* fingerprint unlock (Android app only) */
.finger {
  all: unset;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 14px auto 0;
  padding: 8px 14px;
  cursor: pointer;
  color: rgba(143, 227, 176, .8);
  font: 400 12px/1 var(--cn); letter-spacing: .3em;
  border: 1px solid rgba(143, 227, 176, .25);
  border-radius: 2px;
  background: rgba(4, 7, 6, .6);
}
.finger[hidden] { display: none; }
.finger svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(143,227,176,.6)); }
.finger:focus-visible { outline: 1px solid var(--eerie); }

/* ═════════ the seal ═════════ */
/* Paper seal strips, iron chains crossed round the box, and a round seal lock where they
   meet on the front. Typing lights its runes; the right incantation unlocks it and it opens. */
.strap {
  position: absolute; left: 24%; top: -1px; bottom: -1px; width: 15%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; justify-content: space-around;
  padding: 8% 0;
  /* old paper: dark, stained, edges burnt */
  background:
    radial-gradient(ellipse 60% 18% at 40% 30%, rgba(40, 20, 8, .35), transparent 70%),
    radial-gradient(ellipse 50% 14% at 65% 78%, rgba(60, 10, 8, .3), transparent 70%),
    repeating-linear-gradient(0deg, rgba(30, 18, 8, .1) 0 2px, transparent 2px 5px),
    linear-gradient(90deg, #2e2416 0%, #5e4d31 14%, #6f5b3b 50%, #5a482e 86%, #2a2013 100%);
  box-shadow: 0 0 0 1px rgba(15, 8, 3, .7), 0 0 14px rgba(0, 0, 0, .8);
  opacity: .88;
  transform-origin: 50% 100%;
  /* torn at both ends */
  clip-path: polygon(0 2.5%, 14% .4%, 27% 2.2%, 41% 0, 55% 2.8%, 70% .6%, 84% 2.4%, 100% .2%,
    100% 97.4%, 86% 99.6%, 71% 97.8%, 57% 100%, 43% 97.2%, 29% 99.4%, 15% 97.6%, 0 99.8%);
}
.face:not(.top):not(.bottom) > .strap { top: 3%; bottom: 3%; }
.strap b {
  writing-mode: vertical-rl;
  font: 700 calc(var(--s) * .085) / 1 var(--cn);
  letter-spacing: .25em;
  color: #9a1a14;
  text-shadow: 0 0 6px rgba(140, 10, 10, .45);
}
/* the first character is a red seal stamped across the strip, pressed in slightly askew */
.strap b:first-child, .strap b.seal {
  writing-mode: horizontal-tb;
  display: grid; place-items: center;
  width: calc(var(--s) * .13); height: calc(var(--s) * .13);
  border-radius: 50%;
  letter-spacing: 0;
  font-size: calc(var(--s) * .072);
  color: rgba(214, 186, 140, .85);
  text-shadow: none;
  background:
    radial-gradient(circle at 30% 70%, rgba(40, 0, 0, .35), transparent 35%),
    radial-gradient(circle at 70% 25%, rgba(255, 120, 100, .18), transparent 40%),
    #8a1510;
  box-shadow: 0 0 0 1px rgba(120, 10, 8, .7), inset 0 0 0 calc(var(--s) * .008) rgba(214, 186, 140, .45);
  rotate: 12deg;
}
/* 勿启 answers it with an upright oblong seal, older than the round one: a deeper red, grainy
   and pitted where the ink did not take, the two characters stacked top to bottom */
.strap b.sq {
  writing-mode: horizontal-tb;
  display: grid; place-items: center;
  width: calc(var(--s) * .125); height: calc(var(--s) * .2);
  border-radius: 5%;
  letter-spacing: 0;
  color: rgba(200, 170, 125, .8);
  text-shadow: none;
  background:
    url(/img/grain.svg) 0 0 / calc(var(--s) * .3),
    radial-gradient(circle at 72% 78%, rgba(20, 0, 0, .5), transparent 45%),
    radial-gradient(circle at 20% 30%, rgba(30, 2, 0, .4), transparent 35%),
    radial-gradient(circle at 60% 15%, rgba(150, 50, 30, .2), transparent 40%),
    #5c0c0a;
  box-shadow: 0 0 0 1px rgba(70, 6, 4, .75);
  -webkit-mask: url(/img/seal-wear.svg) 0 0 / calc(var(--s) * .2);
  mask: url(/img/seal-wear.svg) 0 0 / calc(var(--s) * .2);
}
.strap b.sq i {
  font-style: normal;
  writing-mode: vertical-rl;
  font-size: calc(var(--s) * .05);
  line-height: 1;
  letter-spacing: .4em;
  padding-top: .4em; /* letter-spacing also trails the last character: balance it above */
  scale: 1.4 1; /* broad seal-script characters filling the seal */
}
/* each spoken character makes the paper strips quiver */
/* on the lid the strips cross diagonally, clear of the chains */
.face.top { overflow: hidden; }
:is(.top, .bottom) .strap { top: 50%; bottom: auto; left: -12%; right: -12%; width: auto; height: 13%; transform: translateY(-50%) rotate(45deg); padding: 0; transform-origin: 50% 50%; }
:is(.top, .bottom) .strap.x { transform: translateY(-50%) rotate(-45deg); }
/* lid and underside are bound the same way: two strips crossed corner to corner, a round 封 seal
   stamped near each of the four corners */
:is(.top, .bottom) .strap { display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 17%; }
:is(.top, .bottom) .strap b { width: calc(var(--s) * .12); height: calc(var(--s) * .12); flex: none; }
/* each seal is written facing the middle of the face: the head of the character points to the
   centre (the strips lie at ±45°, so a quarter turn either way does it) */
:is(.top, .bottom) .strap b:first-child { rotate: 90deg; }
:is(.top, .bottom) .strap b.seal { rotate: -90deg; }

/* a thin dark-red light leaks from the crack under the lid, as if something inside is awake */
.face:not(.top):not(.bottom)::before {
  content: ""; position: absolute; left: 4%; right: 4%; top: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 120, 60, .75) 30%, rgba(255, 175, 95, .9) 50%, rgba(255, 120, 60, .75) 70%, transparent);
  box-shadow: 0 0 6px rgba(220, 70, 30, .8), 0 3px 14px rgba(180, 40, 20, .55);
  opacity: .75; /* steady, like the sign */
}
/* very rarely, for a breath, the light at the seam is not the fire's but warm gold — something
   else in there besides the evils (app.js sets .hope on the box) */
.box.hope .face:not(.top):not(.bottom)::before {
  background: linear-gradient(90deg, transparent, rgba(255, 210, 130, .8) 30%, rgba(255, 240, 200, .95) 50%, rgba(255, 210, 130, .8) 70%, transparent);
  box-shadow: 0 0 8px rgba(255, 200, 120, .9), 0 6px 22px 4px rgba(255, 190, 100, .55);
  height: 3px; opacity: 1;
}
.gate.stirring .face::before, .gate.unsealing .face::before { animation: none; opacity: 1; box-shadow: 0 0 10px rgba(255, 110, 50, .95), 0 4px 22px rgba(220, 60, 20, .8); }
.box.denied .face::before { background: linear-gradient(90deg, transparent, #ff3b2e 50%, transparent); }

/* chains: one round the middle, one over the top — they cross on every side */
.chain {
  position: absolute; left: -2px; right: -2px; top: 45.5%; height: 9%;
  background: url(/img/chain.svg) repeat-x 0 50% / auto 100%;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .9));
}
.chain.v {
  left: 50%; right: auto; top: -2px; bottom: -2px; width: 9%; height: auto;
  transform: translateX(-50%);
  background: url(/img/chain-v.svg) repeat-y 50% 0 / 100% auto;
}
/* the chains run right round the box: across the lid and across the underside too */
:is(.top, .bottom) .chain { top: 50%; transform: translateY(-50%); }
:is(.top, .bottom) .chain.v { top: -2px; transform: translateX(-50%); }

/* the round seal lock sits right where the chains cross on the front */
.lock {
  position: absolute; left: 50%; top: 50%; width: 42%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .95)) drop-shadow(0 0 14px rgba(170, 20, 30, .45));
}
.lock svg { display: block; width: 100%; height: auto; overflow: visible; }
.lock .rivet { fill: url(#lockStud); stroke: #241a0b; stroke-width: .4; }
/* runes light one by one as the incantation is spoken */
.lock .rune { fill: none; stroke: #5a1714; stroke-width: 1.3; stroke-linecap: round; transition: stroke .25s ease, filter .25s ease; }
.lock .rune.on { stroke: #ff6b4f; filter: drop-shadow(0 0 2px #ff4a3c) drop-shadow(0 0 5px #ff4a3c); }
.lock .seam { stroke: rgba(0, 0, 0, .55); stroke-width: .8; }
/* the lock is drawn twice, each copy showing one half — whole when still, parting when it opens */
.lock-half { position: relative; }
.lock-half.r { position: absolute; inset: 0; }
/* the halves reach past the disc so the shackle rings are cut in two with it */
.lock-half.l { clip-path: inset(-15% 50% -15% -15%); }
.lock-half.r { clip-path: inset(-15% -15% -15% 50%); }
.lock .core-g { transform-box: fill-box; transform-origin: 50% 50%; }
/* the sigil is pressed into the wax; an ember smoulders deep in the keyhole */
.lock .seal-sigil { color: #d2483a; opacity: .22; }
/* while awakening to type the incantation, dim distracting edge chrome so focus stays on box + line */
.woods .grove { transition: opacity .8s ease; }
.gate.awake .woods .grove { opacity: .55; }
.gate .site-mark { transition: opacity .6s ease; }
.gate.awake .site-mark { opacity: .3; }
.lock .ember { opacity: .65; transition: opacity .35s ease; }
.scene:hover .lock .ember, .gate.awake .lock .ember { opacity: .95; }
.lock .shackle { transform-box: fill-box; transform-origin: 50% 50%; }
.box.denied .lock .ember { opacity: 1; }

/* wrong incantation: the lock flares red and rattles, the chains bite */
.box.denied .lock .rune { stroke: #ff3b2e; filter: drop-shadow(0 0 4px #ff2a1e); }
.box.denied .lock { animation: lockRattle .5s ease-in-out; filter: drop-shadow(0 0 14px rgba(255, 40, 50, .95)) drop-shadow(0 0 4px rgba(255, 80, 80, .9)); }
.box.denied .chain { animation: tighten .5s ease-in-out 2; filter: drop-shadow(0 0 4px rgba(255, 40, 50, .8)); }
.box.denied .chain.v { animation-name: tightenV; }
.box.denied :is(.top, .bottom) .chain { animation: none; }
.box.denied .strap b:not(:first-child):not(.sq) { color: #c01818; text-shadow: 0 0 8px rgba(255, 40, 50, .8); }
@keyframes tighten { 50% { transform: scaleY(.72); } }
@keyframes tightenV { 50% { transform: translateX(-50%) scaleX(.72); } }
@keyframes lockRattle {
  20% { transform: translate(-50%, -50%) rotate(-14deg) scale(1.06); }
  45% { transform: translate(-50%, -50%) rotate(11deg); }
  70% { transform: translate(-50%, -50%) rotate(-6deg); }
  90% { transform: translate(-50%, -50%) rotate(2deg); }
}

/* breaking the seal (right incantation), before the lid opens */
.gate.unsealing .lock .rune { stroke: #ff8a6a; filter: drop-shadow(0 0 3px #ff4a3c) drop-shadow(0 0 7px #ff4a3c); }
.gate.unsealing .lock .core-g { animation: keyTurn .45s cubic-bezier(.5, 0, .3, 1) forwards; }
.gate.unsealing .lock { animation: lockClick .25s .45s ease-out; }
.gate.unsealing .lock .ember { opacity: 1; }
.gate.unsealing .lock .shackle { animation: shackleOpen .35s .45s ease-out forwards; }
.gate.unsealing .lock-half.l { animation: halfOpenL .75s .65s cubic-bezier(.4, 0, .6, 1) forwards; }
.gate.unsealing .lock-half.r { animation: halfOpenR .75s .65s cubic-bezier(.4, 0, .6, 1) forwards; }
.gate.unsealing .strap { animation: strapTear .8s .75s cubic-bezier(.5, 0, .7, .4) forwards; }
.gate.unsealing :is(.top, .bottom) .strap.x { animation-name: strapBurnX; }
.gate.unsealing .chain { animation: chainSnap .9s .62s cubic-bezier(.5, 0, .9, .5) forwards; }
.gate.unsealing .chain.v { animation-name: chainSnapV; }
.gate.unsealing :is(.top, .bottom) .chain { animation-name: chainFade; }
/* unlocking: the key turns, the lock clicks, its two halves swing apart */
@keyframes keyTurn { to { transform: rotate(90deg); } }
@keyframes shackleOpen { to { transform: scale(1.35); opacity: 0; } }
@keyframes lockClick {
  40% { transform: translate(-50%, -50%) scale(1.08); filter: brightness(1.9) drop-shadow(0 0 18px rgba(255, 90, 60, .95)); }
}
@keyframes halfOpenL { to { transform: translateX(-62%) rotate(-28deg); opacity: 0; } }
@keyframes halfOpenR { to { transform: translateX(62%) rotate(28deg); opacity: 0; } }
@keyframes strapBurnX { to { transform: translateY(-50%) rotate(-45deg) scaleX(0); opacity: 0; } }
.gate.unsealing :is(.top, .bottom) .strap:not(.x) { animation-name: strapBurnTop; }
@keyframes strapBurnTop { to { transform: translateY(-50%) rotate(45deg) scaleX(0); opacity: 0; filter: brightness(2) sepia(1) saturate(6); } }
/* something inside heaves: the chains go taut, flare, and snap */
@keyframes chainSnap {
  22% { transform: scaleX(1.05); filter: brightness(1.9); }
  30% { transform: translateY(-6%) rotate(-5deg); filter: brightness(1.4); }
  100% { transform: translateY(170%) rotate(12deg); opacity: 0; }
}
@keyframes chainSnapV {
  0% { transform: translateX(-50%); }
  22% { transform: translateX(-50%) scaleY(1.05); filter: brightness(1.9); }
  30% { transform: translateX(-50%) translateY(-6%) rotate(-4deg); }
  100% { transform: translateX(-50%) translateY(55%) rotate(7deg); opacity: 0; }
}
/* the seal strip strains, then rips across the middle; the two halves curl away */
@keyframes strapTear {
  0% { transform: translateX(-50%); clip-path: polygon(0 0, 100% 0, 100% 50%, 66% 50%, 33% 50%, 0 50%, 0 50%, 33% 50%, 66% 50%, 100% 50%, 100% 100%, 0 100%); }
  30% { transform: translateX(-50%) scaleX(1.07); filter: brightness(1.35); clip-path: polygon(0 0, 100% 0, 100% 50%, 66% 50%, 33% 50%, 0 50%, 0 50%, 33% 50%, 66% 50%, 100% 50%, 100% 100%, 0 100%); }
  42% { transform: translateX(-50%); clip-path: polygon(0 0, 100% 0, 100% 46%, 66% 52%, 33% 44%, 0 49%, 0 53%, 33% 49%, 66% 56%, 100% 51%, 100% 100%, 0 100%); }
  100% { transform: translateX(-50%) scaleX(.92); opacity: 0; clip-path: polygon(0 0, 100% 0, 100% 3%, 66% 9%, 33% 1%, 0 6%, 0 93%, 33% 98%, 66% 91%, 100% 97%, 100% 100%, 0 100%); }
}
@keyframes chainFade { to { opacity: 0; } }

/* each failed attempt deepens the dread: redder vignette, darker room */
.gate::before {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(120, 0, 10, .55) 100%);
  opacity: 0; transition: opacity 1.2s ease;
}
.gate[data-dread="1"]::before { opacity: .25; }
.gate[data-dread="2"]::before { opacity: .45; }
.gate[data-dread="3"]::before { opacity: .7; }
.gate[data-dread="4"]::before { opacity: .9; animation: dreadPulse 2.4s ease-in-out infinite; }
@keyframes dreadPulse { 50% { opacity: .55; } }

/* locked out: the box freezes over */
.gate.frozen .face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 20% 15%, rgba(220, 240, 255, .35), transparent 30%),
    radial-gradient(circle at 80% 85%, rgba(220, 240, 255, .3), transparent 35%),
    repeating-linear-gradient(60deg, rgba(220, 240, 255, .08) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-60deg, rgba(220, 240, 255, .06) 0 1px, transparent 1px 9px),
    linear-gradient(160deg, rgba(170, 210, 240, .28), rgba(120, 160, 200, .12));
  box-shadow: inset 0 0 30px rgba(200, 230, 255, .35);
}
.gate.frozen .sig { color: #bfe3ff; opacity: .35; animation: none; }
.gate.frozen .sig.glow { opacity: 0; }
.gate.frozen .aura { background: radial-gradient(circle, rgba(150, 200, 255, .18), transparent 70%); animation: none; }

/* back from the forest: the lid slams down on what was drawn in, the seals, chains and lock go
   straight back on, and only then does the box heave against them */
.gate.resealing .box .top { animation: lidSlam .45s 1.15s cubic-bezier(.7, 0, .9, .6) backwards; }
.gate.resealing .strap { animation: strapOn .45s 1.55s ease-out backwards; }
.gate.resealing :is(.top, .bottom) .strap { animation-name: strapOnTop; }
.gate.resealing :is(.top, .bottom) .strap.x { animation-name: strapOnX; }
.gate.resealing .chain { animation: chainOn .4s 1.65s ease-out backwards; }
.gate.resealing .chain.v { animation-name: chainOnV; }
.gate.resealing :is(.top, .bottom) .chain { animation-name: chainFadeIn; }
.gate.resealing .lock-half.l { animation: halfCloseL .35s 1.8s cubic-bezier(.3, 1.3, .5, 1) backwards; }
.gate.resealing .lock-half.r { animation: halfCloseR .35s 1.8s cubic-bezier(.3, 1.3, .5, 1) backwards; }
.gate.resealing .lock .core-g { animation: keyBack .3s 2.15s ease-in-out backwards; }
.gate.resealing .lock .shackle { animation: shackleOn .25s 2.05s ease-out backwards; }
@keyframes shackleOn { from { transform: scale(1.35); opacity: 0; } }
/* the stripped box never shows: it comes out of the last of the smoke as the lid slams on it */
.gate.resealing .scene { animation: boxIn .3s .95s ease-out backwards, thud .3s 1.55s ease-out, thud .3s 2.1s ease-out, rattle .7s 2.35s ease-in-out; }
@keyframes boxIn { from { opacity: 0; } }
@keyframes lidSlam {
  from { transform: translateY(-160px) rotateX(70deg) translateZ(var(--h)); opacity: 0; }
  to { transform: rotateX(90deg) translateZ(var(--h)); opacity: 1; }
}
@keyframes strapOn { from { transform: translateX(-50%) scaleY(0); } }
@keyframes strapOnTop { from { transform: translateY(-50%) rotate(45deg) scaleX(0); } }
@keyframes strapOnX { from { transform: translateY(-50%) rotate(-45deg) scaleX(0); } }
@keyframes chainOn { from { transform: translateY(-120%); opacity: 0; } }
@keyframes chainOnV { from { transform: translateX(-50%) translateY(-40%); opacity: 0; } }
@keyframes chainFadeIn { from { opacity: 0; } }
@keyframes halfCloseL { from { transform: translateX(-62%) rotate(-28deg); opacity: 0; } }
@keyframes halfCloseR { from { transform: translateX(62%) rotate(28deg); opacity: 0; } }
@keyframes keyBack { from { transform: rotate(90deg); } }
@keyframes thud { 30% { transform: translateY(5px); } }


@media (prefers-reduced-motion: reduce) {
  .gate.resealing *, .gate.unsealing * { animation-duration: .01s !important; animation-delay: 0s !important; }
}

/* smoke overlay (js/smoke.js) */
.smoke { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.smoke-veil { background: #030404; opacity: 0; }
/* reloading under the smoke after sealing: black from the first paint until the smoke draws again */
html.sealing::after { content: ""; position: fixed; inset: 0; z-index: 59; background: radial-gradient(ellipse at 50% 45%, #111314, #090a0b 75%); /* the smoke at full: about #0b0c0d */ pointer-events: none; transition: opacity .35s ease; animation: coverOff .4s 4s forwards; }
@keyframes coverOff { to { opacity: 0; } } /* never stays if the page script fails */
html.sealing.smoke-on::after { opacity: 0; }

/* landscape phones & soft-keyboard open: shrink box & hide bottom mark so passphrase input stays centered */
@media (max-height: 540px) {
  .gate { --s: 132px; --h: 66px; }
  .gate .site-mark { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .gate .site-mark { padding: 8px 30px 7px; font-size: 12px; letter-spacing: .3em; padding-left: calc(30px + .3em); }
}

/* without motion the sign simply glows, half way */
@media (prefers-reduced-motion: reduce) { .sig.glow { opacity: .55; } }

/* subtle skip cue during the opening ritual */
.skip-hint {
  position: fixed; z-index: 65; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%); margin: 0; pointer-events: none;
  font: 400 11px/1 var(--cn); letter-spacing: .28em; padding-left: .28em;
  color: rgba(201, 169, 106, .62); text-shadow: 0 1px 4px #000;
  animation: skipFade 1s ease-out both;
}
@keyframes skipFade { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }
