/* =========================================================
   Pika Interactive — "the burrow"
   A cross-section: a meadow on top, rooms dug into the earth below.
   Scrolling = walking deeper into the burrow. Things in the burrow
   are alive: lanterns swing, the cauldron bubbles, Pika reacts.
   ========================================================= */

:root {
  /* outside — sampled from the hero painting */
  --sky: #cad8cb;
  --sky-low: #d4dfd2;

  /* underground */
  --soil: #4a3223;
  --soil-deep: #2f1f16;
  --soil-rim: #3a271c;
  --lamp: #efd8a3;
  --lamp-hi: #f9ebc8;

  /* from the assets */
  --wood: #6b4329;
  --wood-dark: #48291a;
  --gold: #c99a3b;
  --gold-hi: #e2be6a;
  --plum: #4a3878;
  --plum-night: #2e2446;
  --lavender: #c9b6f0;
  --candle: #ffd98a;

  /* text */
  --ink: #2b1b12;
  --ink-soft: #4d3828;
  --parchment: #f6e7c4;

  --font-display: "Mochiy Pop One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "M PLUS Rounded 1c", "Nunito", system-ui, sans-serif;

  --wrap: 1240px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --hero-ratio: 2.4828;               /* 3168 / 1276 */
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
  background: var(--soil-deep);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--soil);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* paper grain over everything, so painted art and CSS share one surface */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .13;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

img, svg { display: block; max-width: 100%; }
picture { display: contents; }
.only-mobile { display: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 1.21rem + 3.37vw, 4.1rem); line-height: 1.08; letter-spacing: -.01em; }
h2 { font-size: clamp(1.9rem, 1.3rem + 1.9vw, 2.85rem); line-height: 1.12; }
h3 { font-size: 1.3rem; line-height: 1.25; }

p { margin: 0 0 1em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--plum);
  outline-offset: 3px;
  border-radius: 6px;
}

.nowrap { white-space: nowrap; }

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--parchment);
  color: var(--ink);
  font-weight: 700;
  border-radius: 10px;
}
.skip-link:focus { top: 16px; }

/* ---------- shared bits ---------- */
.sign-btn {
  display: inline-grid;
  place-items: center;
  width: 300px;
  max-width: 100%;
  aspect-ratio: 1218 / 408;
  padding: 0 0 1.5% 0;
  background: url("assets/web/sign-button.webp") center / contain no-repeat;
  color: var(--parchment);
  font-family: var(--font-display);
  font-size: 1.17rem;
  line-height: 1;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(36, 18, 8, .6);
  filter: drop-shadow(0 8px 10px rgba(47, 31, 22, .28));
  transform-origin: 50% 0;
  transition: transform .25s var(--spring), filter .2s ease;
}
.sign-btn span { transform: translateX(-4%); }
.sign-btn:hover { transform: translateY(-3px) rotate(-1.5deg); filter: drop-shadow(0 12px 14px rgba(47, 31, 22, .32)); }
.sign-btn:active { transform: translateY(2px) scale(.98); }
.sign-btn:focus-visible { outline-offset: 2px; border-radius: 22px; }
.sign-btn--small { width: 250px; font-size: 1rem; }

.text-link {
  font-weight: 700;
  color: var(--plum);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.text-link:hover { text-decoration-style: wavy; }
.text-link--light { color: var(--lavender); }

/* speech bubble, used by Pika in the meadow and at the cauldron */
.speech {
  position: absolute;
  z-index: 6;
  margin: 0;
  width: max-content;
  max-width: min(15em, 78vw);
  padding: 10px 16px 11px;
  background: #fdf3da;
  color: var(--ink);
  border: 2.5px solid var(--wood-dark);
  border-radius: 16px;
  font-weight: 700;
  font-size: .93rem;
  line-height: 1.35;
  box-shadow: 0 6px 0 rgba(47, 31, 22, .18);
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px) scale(.6);
  transform-origin: 20% 100%;
  transition: opacity .15s ease, transform .35s var(--spring);
}
.speech::after {
  content: "";
  position: absolute;
  left: 22%;
  bottom: -9px;
  width: 16px;
  height: 16px;
  background: inherit;
  border: inherit;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.speech.is-on { opacity: 1; transform: none; }
.speech:empty { visibility: hidden; }

/* little star bursts spawned by JS */
.spark {
  position: absolute;
  width: var(--s, 14px);
  height: var(--s, 14px);
  margin: calc(var(--s, 14px) / -2) 0 0 calc(var(--s, 14px) / -2);
  background: var(--c, var(--gold-hi));
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  pointer-events: none;
  z-index: 7;
  animation: spark-fly .8s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes spark-fly {
  0%   { transform: translate(0, 0) scale(.2) rotate(0); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--r, 90deg)); opacity: 0; }
}

/* ---------- nav ---------- */
.nav {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0 16px;
}
.nav__plank {
  max-width: var(--wrap);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 7px 12px 7px 8px;
  border-radius: 16px;
  background-color: var(--wood);
  background-image:
    repeating-linear-gradient(179deg, transparent 0 6px, rgba(40, 20, 10, .16) 6px 8px, transparent 8px 15px),
    linear-gradient(180deg, #7b4e31, #5e3922);
  box-shadow:
    inset 0 0 0 2px rgba(226, 190, 106, .55),
    inset 0 0 0 5px var(--wood-dark),
    0 5px 0 rgba(47, 31, 22, .35),
    0 14px 30px rgba(47, 31, 22, .22);
  color: var(--parchment);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--parchment);
}
.brand__emblem {
  width: 58px;
  height: 58px;
  flex: none;
  filter: drop-shadow(0 3px 2px rgba(20, 10, 4, .45));
  transition: transform .5s var(--spring);
}
.brand:hover .brand__emblem { transform: rotate(-14deg) scale(1.06); }
.brand__name {
  display: grid;
  font-family: var(--font-display);
  font-size: 1.43rem;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(36, 18, 8, .5);
}
.brand__name small {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--gold-hi);
  text-shadow: none;
  margin-top: 3px;
}

.nav__links { display: flex; gap: 4px; }
.nav__links a {
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .97rem;
  text-decoration: none;
  color: var(--parchment);
}
.nav__links a:hover { background: rgba(249, 235, 200, .12); }
.nav__links a[aria-current="true"] {
  text-decoration: underline wavy var(--gold-hi) 2px;
  text-underline-offset: 7px;
}
.nav :focus-visible { outline-color: var(--lavender); }

.nav__toggle {
  display: none;
  font-weight: 700;
  font-size: .93rem;
  line-height: 1;
  color: var(--parchment);
  background: rgba(249, 235, 200, .1);
  border: 2px solid rgba(226, 190, 106, .6);
  border-radius: 10px;
  padding: 10px 16px;
}

/* ---------- depth gauge ---------- */
.depth {
  position: fixed;
  right: 22px;
  top: 50%;
  z-index: 40;
  width: 40px;
  height: 300px;
  translate: 0 -50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
.depth.is-on { opacity: 1; pointer-events: auto; }
.depth__rope {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 5px;
  margin-left: -2.5px;
  border-radius: 3px;
  background: repeating-linear-gradient(160deg, #b98d55 0 4px, #7a5532 4px 7px);
  box-shadow: 0 0 0 1.5px rgba(30, 15, 8, .35);
}
.depth__knot {
  position: absolute;
  left: 50%;
  top: calc(var(--at) * 100%);
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--wood);
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--wood-dark);
}
.depth__knot span {
  position: absolute;
  right: 26px;
  top: 50%;
  translate: 0 -50%;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--wood-dark);
  color: var(--parchment);
  font-weight: 700;
  font-size: .8rem;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity .15s ease, transform .2s ease;
  pointer-events: none;
}
.depth__knot:hover span { opacity: 1; transform: none; }
.depth__bead {
  position: absolute;
  left: 50%;
  top: calc(var(--p, 0) * 100%);
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(20, 10, 4, .45));
  transform: rotate(calc(var(--p, 0) * 360deg));
}

/* =========================================================
   SURFACE (hero)
   The painting sits on a "stage" that keeps its aspect ratio, so the
   door, Pika and the hotspots stay glued to the art at any width.
   ========================================================= */
.surface {
  --h: clamp(560px, 45vw, 860px);
  position: relative;
  height: var(--h);
  overflow: hidden;
  overflow: clip;           /* clip: cannot be scrolled by focus or scrollIntoView */
  background: var(--sky);
}

.surface__copy {
  position: relative;
  z-index: 5;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 128px 24px 0;
  pointer-events: none;
}
.surface__copy > * { max-width: min(44vw, 600px); pointer-events: auto; }

.lede {
  margin: 22px 0 26px;
  font-size: 1.13rem;
  color: var(--ink-soft);
  text-shadow: 0 0 18px rgba(212, 223, 210, .9), 0 0 4px rgba(212, 223, 210, .9);
}

.surface__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 28px;
}

.stage-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow: clip;           /* clip: cannot be scrolled by focus or scrollIntoView */
}
.stage {
  position: absolute;
  right: 0;
  bottom: 0;
  width: max(100%, calc(var(--h) * var(--hero-ratio)));
  aspect-ratio: 3168 / 1276;
}
.stage__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* pollen drifting over the meadow */
.motes i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fffbe8;
  box-shadow: 0 0 8px 2px rgba(255, 246, 210, .8);
  opacity: 0;
  animation: mote var(--d) linear var(--t) infinite;
}
@keyframes mote {
  0%   { transform: translate(0, 0); opacity: 0; }
  15%  { opacity: .9; }
  50%  { transform: translate(calc(var(--dx) * .5), -50px); }
  85%  { opacity: .7; }
  100% { transform: translate(var(--dx), -110px); opacity: 0; }
}

/* the door: hover/focus swings it open and lamplight spills out */
.doorway {
  position: absolute;
  left: 75.821%;
  top: 32.21%;
  width: 14.741%;
  height: 41.693%;
  z-index: 3;
  perspective: 900px;
  border-radius: 48% 48% 40% 40%;
}
.doorway:focus-visible { outline: 4px solid var(--plum); outline-offset: 6px; }
.doorway__inside,
.doorway__door {
  position: absolute;
  inset: 0;
}
.doorway__inside {
  background:
    radial-gradient(ellipse 55% 45% at 50% 62%, #fff0c2 0%, #ffcf7a 30%, #d9852f 62%, #5a2e14 100%);
  -webkit-mask: url("assets/web/hero-doorway-mask.png?v=3") center / 100% 100% no-repeat;
          mask: url("assets/web/hero-doorway-mask.png?v=3") center / 100% 100% no-repeat;
  animation: hearth-flicker 2.8s steps(1, end) infinite;
}
.doorway__door {
  transform-origin: 6% 50%;
  transition: transform .9s cubic-bezier(.25, 1.35, .5, 1);
}
.doorway__door img { width: 100%; height: 100%; }
.doorway__window {
  position: absolute;
  left: 50.5%;
  top: 26.5%;
  width: 34%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 140, .9) 0%, rgba(255, 190, 90, .35) 40%, transparent 70%);
  mix-blend-mode: screen;
  animation: window-flicker 3.2s ease-in-out infinite;
}
.doorway:hover .doorway__door,
.doorway:focus-visible .doorway__door { transform: rotateY(64deg); }

.doorway__tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 26px);
  translate: -50% 0;
  padding: 6px 16px 8px;
  border-radius: 10px;
  white-space: nowrap;
  background: linear-gradient(180deg, #7b4e31, #5e3922);
  box-shadow: inset 0 0 0 2px rgba(226, 190, 106, .6), 0 4px 0 rgba(47, 31, 22, .3);
  color: var(--parchment);
  font-family: var(--font-display);
  font-size: clamp(.82rem, .7rem + .43vw, 1.08rem);
  opacity: 0;
  transform: translateY(8px) rotate(-3deg) scale(.9);
  transition: opacity .2s ease, transform .35s var(--spring);
  pointer-events: none;
}
.doorway:hover .doorway__tag,
.doorway:focus-visible .doorway__tag { opacity: 1; transform: rotate(-3deg); }

.doorway__spill {
  position: absolute;
  left: 72%;
  top: 70%;
  width: 22%;
  height: 24%;
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(ellipse 50% 60% at 50% 20%, rgba(255, 214, 140, .85), rgba(255, 200, 110, 0) 70%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
.doorway:hover ~ .doorway__spill,
.doorway:focus-visible ~ .doorway__spill { opacity: 1; }

/* the old oaks framing the meadow; their roots continue in the soil below */
.hero-tree {
  position: absolute;
  bottom: 0;
  z-index: 2;
  width: auto;
  max-width: none;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(40, 25, 10, .4));
}
.hero-tree--left  { left: 0;  height: 118%; translate: -20% 0; }
.hero-tree--right { right: 0; height: 112%; translate: 16% 0; }

/* a few leaves let go of the oaks now and then */
.leaves i {
  position: absolute;
  top: -20px;
  left: var(--x);
  z-index: 2;
  width: 14px;
  height: 8px;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg, var(--c), #5f7a36);
  opacity: 0;
  pointer-events: none;
  animation: leaf-fall var(--d) linear var(--t) infinite;
}
@keyframes leaf-fall {
  0%   { transform: translate(0, 0) rotate(0); opacity: 0; }
  6%   { opacity: .95; }
  25%  { transform: translate(calc(var(--dx) * .3), 140px) rotate(160deg); }
  50%  { transform: translate(calc(var(--dx) * .5), 290px) rotate(320deg); }
  75%  { transform: translate(calc(var(--dx) * .8), 430px) rotate(480deg); }
  92%  { opacity: .9; }
  100% { transform: translate(var(--dx), 560px) rotate(640deg); opacity: 0; }
}

/* Pika in the meadow (click = hop + say something) */
.hero-pika {
  position: absolute;
  left: 57.4%;
  bottom: 7.5%;
  width: 12.6%;
  z-index: 4;
  transform-origin: 50% 100%;
  border-radius: 40%;
}
.hero-pika__body { display: block; transform-origin: 50% 100%; animation: breathe 3.6s ease-in-out infinite; }
.hero-pika__body img { width: 100%; height: auto; filter: drop-shadow(0 8px 5px rgba(40, 55, 20, .3)); }
.hero-pika:hover .hero-pika__body img { filter: drop-shadow(0 8px 5px rgba(40, 55, 20, .3)) brightness(1.05); }
.hero-pika__crystal {
  position: absolute;
  left: 23%;
  top: 21.7%;
  width: 62%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 230, 255, .95) 0%, rgba(201, 182, 240, .55) 28%, rgba(201, 182, 240, 0) 66%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: crystal 3.4s ease-in-out infinite;
}
.speech--hero { left: 63%; bottom: 49%; }

@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.012, 1.022); }
}
@keyframes hop {
  0%   { transform: none; }
  15%  { transform: scale(1.1, .86); }
  42%  { transform: translateY(-20%) scale(.94, 1.08); }
  70%  { transform: translateY(0) scale(1.08, .9); }
  85%  { transform: scale(.98, 1.03); }
  100% { transform: none; }
}
@keyframes crystal {
  0%, 100% { opacity: .45; transform: scale(.9); }
  50%      { opacity: .8;  transform: scale(1.08); }
}
@keyframes window-flicker {
  0%, 100% { opacity: .75; }
  30% { opacity: .95; }
  55% { opacity: .7; }
  75% { opacity: 1; }
}
@keyframes hearth-flicker {
  0%   { filter: brightness(1); }
  20%  { filter: brightness(1.12); }
  45%  { filter: brightness(.94); }
  70%  { filter: brightness(1.08); }
}

/* ---- the arrival sequence (only when JS is on, so no-JS never hides content) ---- */
.js .surface .w,
.js .surface .lede,
.js .surface .surface__actions,
.js .surface .hero-pika { opacity: 0; }

.surface.is-ready .w {
  display: inline-block;
  animation: word-pop .7s var(--spring) both;
  animation-delay: calc(.15s + var(--i, 0) * .09s);
}
.surface.is-ready .lede { animation: fade-in .8s ease .75s both; }
.surface.is-ready .surface__actions { animation: fade-in .4s ease 1s both; }
.surface.is-ready .surface__actions .sign-btn { animation: sign-swing 1.4s ease-out 1s backwards; }
.surface.is-ready .hero-pika:not(.is-in) { animation: hop-in .9s cubic-bezier(.3, .7, .4, 1) .45s both; }
.js .surface .hero-pika.is-in { opacity: 1; }
.surface .hero-pika.is-in.is-hopping { animation: hop .7s cubic-bezier(.3, .7, .4, 1); }

@keyframes word-pop {
  0%   { opacity: 0; transform: translateY(45%) scale(.5) rotate(-8deg); }
  60%  { opacity: 1; transform: translateY(-6%) scale(1.06) rotate(2deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sign-swing {
  0%   { transform: rotate(-16deg); opacity: 0; }
  20%  { opacity: 1; }
  35%  { transform: rotate(10deg); }
  55%  { transform: rotate(-5deg); }
  75%  { transform: rotate(2deg); }
  100% { transform: rotate(0); opacity: 1; }
}
@keyframes hop-in {
  0%   { opacity: 0; transform: translateY(18%) scale(1.1, .8); }
  35%  { opacity: 1; transform: translateY(-22%) scale(.92, 1.1); }
  65%  { transform: translateY(0) scale(1.1, .88); }
  82%  { transform: scale(.97, 1.04); }
  100% { opacity: 1; transform: none; }
}

/* =========================================================
   BURROW
   Painted rooms, joined by a shaft through painted soil.
   Each room's painting sits on a "stage" that keeps its aspect
   ratio and covers the section, so sprites and glows positioned
   in stage-% stay glued to the art at any size.
   ========================================================= */
.burrow { background: var(--soil-deep); }

/* ---- soil bands: a cutaway of the earth with the shaft down the middle ---- */
.soil {
  position: relative;
  z-index: 0;
  height: clamp(150px, 15vw, 240px);
  background: #3c2e25 center / cover no-repeat;
}
.soil--top { height: clamp(170px, 19vw, 300px); background-image: url("assets/web/soil-top-2400.webp");
  background-image: -webkit-image-set(url("assets/web/soil-top-2400.webp") 1x, url("assets/web/soil-top-3168.webp") 2x);
  background-image: image-set(url("assets/web/soil-top-2400.webp") 1x, url("assets/web/soil-top-3168.webp") 2x); background-position: center top; }
.soil--mid { background-image: url("assets/web/soil-mid-2400.webp");
  background-image: -webkit-image-set(url("assets/web/soil-mid-2400.webp") 1x, url("assets/web/soil-mid-3168.webp") 2x);
  background-image: image-set(url("assets/web/soil-mid-2400.webp") 1x, url("assets/web/soil-mid-3168.webp") 2x); }
.soil--low { background-image: url("assets/web/soil-low-2400.webp");
  background-image: -webkit-image-set(url("assets/web/soil-low-2400.webp") 1x, url("assets/web/soil-low-3168.webp") 2x);
  background-image: image-set(url("assets/web/soil-low-2400.webp") 1x, url("assets/web/soil-low-3168.webp") 2x); background-position: center 30%; }
.soil--flip { transform: scaleX(-1); }

.trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.trail path { fill: none; stroke: none; }
.paw {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  fill: #f0d9a8;
  opacity: 0;
  transform: rotate(var(--a)) scale(.3);
  transition: opacity .25s ease, transform .35s var(--spring);
  transition-delay: calc(var(--i) * .12s);
}
.soil.is-walked .paw { opacity: .55; transform: rotate(var(--a)) scale(1); }

/* ---- scenes ---- */
.scene {
  --r: 1.791;                                              /* painting aspect ratio */
  --h: clamp(640px, calc(100vw / var(--r)), 1000px);
  position: relative;
  z-index: 1;
  min-height: var(--h);
  margin: -34px 0;
  overflow: hidden;
  overflow: clip;           /* clip: cannot be scrolled by focus or scrollIntoView */
  background: var(--floor, #4a3223);
  /* a hand-dug, uneven edge where the room meets the soil */
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0 22C70 8 120 30 190 18C260 6 320 12 380 22C450 34 520 30 590 16C660 4 730 8 800 20C870 32 940 30 1010 16C1080 4 1140 10 1200 22L1200 40L0 40Z'/%3E%3C/svg%3E") left top / 1200px 40px repeat-x,
    linear-gradient(#000 0 0) left 39px / 100% calc(100% - 78px) no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0 0L1200 0L1200 18C1140 30 1080 36 1010 24C940 10 870 8 800 20C730 32 660 36 590 24C520 10 450 6 380 18C320 28 260 34 190 22C120 10 70 32 0 18Z'/%3E%3C/svg%3E") left bottom / 1200px 40px repeat-x;
          mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0 22C70 8 120 30 190 18C260 6 320 12 380 22C450 34 520 30 590 16C660 4 730 8 800 20C870 32 940 30 1010 16C1080 4 1140 10 1200 22L1200 40L0 40Z'/%3E%3C/svg%3E") left top / 1200px 40px repeat-x,
    linear-gradient(#000 0 0) left 39px / 100% calc(100% - 78px) no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0 0L1200 0L1200 18C1140 30 1080 36 1010 24C940 10 870 8 800 20C730 32 660 36 590 24C520 10 450 6 380 18C320 28 260 34 190 22C120 10 70 32 0 18Z'/%3E%3C/svg%3E") left bottom / 1200px 40px repeat-x;
}
.scene__stage {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: max(100%, calc(var(--sh, var(--h)) * var(--r)));
  aspect-ratio: var(--r);
  translate: -50% 0;
}
.scene__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* lights off until you walk in (JS adds .is-lit) */
.scene__dim {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #140b06;
  opacity: 0;
  transition: opacity 1.2s ease .1s;
  pointer-events: none;
}
.js .scene:not(.is-lit) .scene__dim { opacity: .62; }

.scene__content {
  position: relative;
  z-index: 2;
  pointer-events: none;          /* empty parts let clicks reach Pika and the cauldron in the painting below */
  min-height: var(--h);
  max-width: 1480px;
  margin: 0 auto;
  padding: 100px clamp(24px, 4vw, 64px) 76px;
  display: grid;
  align-items: center;
  gap: 32px;
}

.scene__content > * { pointer-events: auto; }

/* ---- parchment notes hung on the walls ----
   Each note is a painted panel used as a 9-slice border-image:
   the ornate corners keep their size, the edges and parchment stretch
   to fit the text. Slice numbers are pixels in the exported .webp. */
.note,
.rules {
  position: relative;
  color: var(--ink);
  border-style: solid;
  border-color: transparent;
  filter: drop-shadow(0 14px 16px rgba(30, 15, 8, .38));
}
.note h2 {
  font-size: clamp(1.73rem, 1.12rem + 1.3vw, 2.38rem);
  margin-bottom: 16px;
}
.note p { font-size: 1.01rem; max-width: 34em; }
.note .text-link { display: inline-block; margin-top: 4px; }

.note--scroll {      /* parchment scroll with turned wooden rods */
  border-width: 72px 64px;
  border-image: url("assets/web/panel-scroll.webp") 200 186 fill / 92px 86px / 0 stretch;
  background: linear-gradient(#fbf3e1, #fbf3e1) center / calc(100% - 124px) calc(100% - 140px) no-repeat;
  background-origin: border-box;
  padding: 4px 14px 0;
}

.note--card {        /* a potion-book page pinned to the wall */
  border-width: 72px 48px 48px 78px;   /* clear of the curled corner and the lavender sprig */
  border-image: url("assets/web/panel-card.webp") 200 180 154 220 fill / 84px 76px 65px 92px / 0 stretch;
  background: linear-gradient(#fbeedc, #fbeedc) left 42px top 40px / calc(100% - 82px) calc(100% - 78px) no-repeat;
  background-origin: border-box;
  padding: 4px 8px 4px 4px;
  transform: rotate(-1.2deg);
}
.note--card::before {  /* brass nail */
  content: "";
  position: absolute;
  top: -48px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #f3d98c, #c99a3b 45%, #7a5a1c);
  box-shadow: 0 3px 2px rgba(30, 15, 8, .45);
}

.note--board {       /* the hall's notice board: wood, gold filigree, purple gems */
  border-width: 38px;
  border-image: url("assets/web/panel-board.webp") 260 fill / 92px / 0 stretch;
  background:
    linear-gradient(#f8ebd6, #f8ebd6) center / calc(100% - 68px) calc(100% - 68px) no-repeat,
    linear-gradient(#674534, #674534) center / calc(100% - 6px) calc(100% - 6px) no-repeat;
  background-origin: border-box;
  padding: 28px 30px 22px;
  text-align: center;
}
.note--board::after { /* the four gems sit on the middle of each side */
  content: "";
  position: absolute;
  inset: -38px;
  pointer-events: none;
  background:
    url("assets/web/panel-gem.webp") center top 0 / 30px auto no-repeat,
    url("assets/web/panel-gem.webp") center bottom -1px / 30px auto no-repeat,
    url("assets/web/panel-gem.webp") left 1px center / 30px auto no-repeat,
    url("assets/web/panel-gem.webp") right -1px center / 30px auto no-repeat;
}
.note--board h2 { font-size: clamp(2rem, 1.3rem + 1.64vw, 2.85rem); }
.note--board .sign-btn--small { width: 220px; font-size: .92rem; }

/* ---- Burrow rules: a rustic sign, with Pika peeking over its top plank ---- */
.rules {
  margin-top: 130px;
  border-width: 56px 60px 54px;
  border-image: url("assets/web/panel-sign.webp") 17% fill / 61px 73px / 0 stretch;
  background:
    linear-gradient(#f2e6cc, #f2e6cc) center / calc(100% - 112px) calc(100% - 88px) no-repeat,
    linear-gradient(#8f6342, #8f6342) center / calc(100% - 8px) calc(100% - 8px) no-repeat;
  background-origin: border-box;
  padding: 2px 4px 0;
  transform: rotate(1.2deg);
}
.rules h3 { margin-bottom: 12px; color: var(--wood-dark); }
.rules ul { margin: 0; padding: 0; list-style: none; }
.rules li {
  position: relative;
  padding-left: 32px;
  margin-top: 12px;
  font-size: .95rem;
  line-height: 1.5;
}
.rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .2em;
  width: 20px;
  height: 20px;
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.rules strong { color: var(--ink); }

.peek {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 56px - 8px);   /* paws rest on the sign's top plank */
  width: min(250px, 72%);
  aspect-ratio: 620 / 346;
  translate: -50% 0;
  overflow: hidden;
  overflow: clip;           /* clip: cannot be scrolled by focus or scrollIntoView */
}
.peek__pika {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 40% 40% 0 0;
  transform: translateY(102%);
  transition: transform .6s var(--spring);
}
.peek__pika img { width: 100%; height: 100%; }
.scene.is-lit .peek__pika,
html:not(.js) .peek__pika { transform: none; transition-delay: .55s; }
.scene.is-lit .peek__pika:hover { transform: translateY(-4%) rotate(-3deg); transition-delay: 0s; }
.scene.is-lit .peek__pika.is-ducking { transform: translateY(78%); transition: transform .18s ease-in; }

/* ---- shared light sources painted over the art ---- */
.lantern {
  position: absolute;
  top: -1%;
  left: 50%;
  z-index: 3;
  width: 4.2%;
  margin-left: -2.1%;
  transform-origin: 50% 0;
  animation: swing 3.8s ease-in-out infinite alternate;
}
.lantern img { position: relative; width: 100%; height: auto; filter: drop-shadow(0 6px 4px rgba(40, 20, 8, .35)); }
.lantern i {
  position: absolute;
  left: 50%;
  top: 65%;
  width: 420%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 130, .7) 0%, rgba(255, 190, 90, .25) 35%, rgba(255, 190, 90, 0) 68%);
  mix-blend-mode: screen;
  animation: flicker 2.6s linear infinite;
}
@keyframes swing {
  from { transform: rotate(-2.4deg); }
  to   { transform: rotate(2.4deg); }
}
@keyframes flicker {
  0%   { opacity: .85; }
  12%  { opacity: 1; }
  24%  { opacity: .78; }
  38%  { opacity: .96; }
  52%  { opacity: .82; }
  66%  { opacity: 1; }
  80%  { opacity: .86; }
  100% { opacity: .9; }
}

.glow {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: var(--gs, 9%);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  mix-blend-mode: screen;
  pointer-events: none;
}
.glow--candle {
  background: radial-gradient(circle, rgba(255, 222, 150, .75) 0%, rgba(255, 190, 90, .25) 32%, rgba(255, 190, 90, 0) 66%);
  animation: flicker 2.3s linear infinite;
}
.glow--big { --gs: 30%; }
.glow--fire {
  --gs: 22%;
  background: radial-gradient(circle, rgba(255, 196, 110, .75) 0%, rgba(255, 140, 50, .28) 38%, rgba(255, 140, 50, 0) 68%);
  animation: flicker 1.7s linear infinite, breathe-glow 3.4s ease-in-out infinite;
}
.glow--shroom {
  --gs: 12%;
  background: radial-gradient(circle, rgba(214, 196, 255, .7) 0%, rgba(160, 130, 230, .22) 38%, rgba(160, 130, 230, 0) 68%);
  animation: shroom 4.2s ease-in-out infinite;
}
@keyframes breathe-glow {
  0%, 100% { scale: 1; }
  50%      { scale: 1.08; }
}
@keyframes shroom {
  0%, 100% { opacity: .55; scale: .92; }
  50%      { opacity: 1;   scale: 1.06; }
}

/* the kettle is on (of course it is) */
.steam {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: 3.2%;
  aspect-ratio: 1 / 3;
  translate: -50% -100%;
  pointer-events: none;
}
.steam i {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 70%;
  aspect-ratio: 1;
  margin-left: -35%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 240, .75), rgba(255, 250, 240, 0) 70%);
  filter: blur(2px);
  opacity: 0;
  animation: steam 3.6s ease-out infinite;
}
.steam i:nth-child(2) { animation-delay: 1.2s; }
.steam i:nth-child(3) { animation-delay: 2.4s; }
@keyframes steam {
  0%   { transform: translate(0, 0) scale(.5); opacity: 0; }
  20%  { opacity: .85; }
  100% { transform: translate(-40%, -330%) scale(1.9); opacity: 0; }
}

/* ---- Room 1: study ---- */
.scene--study { --floor: #9f7858; --fx: .5; }
.scene--study .scene__content { grid-template-columns: minmax(330px, 30%) 1fr minmax(330px, 29%); }
.scene--study .note--scroll { grid-column: 1; }
.scene--study .rules { grid-column: 3; }

/* ---- Room 2: brewing ---- */
.scene--brewing { --floor: #714b3e; --fx: .37; }
.scene--brewing .scene__content { grid-template-columns: 1fr minmax(340px, 33%); }
.scene--brewing .note--card { grid-column: 2; }

.brew {
  position: absolute;
  left: 20.5%;
  bottom: 11%;
  z-index: 3;
  width: 33%;
}
.brew__pot {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 30%;
}
.brew__pot img { position: relative; width: 100%; height: auto; }
.brew__glow {
  position: absolute;
  left: 35%;
  top: 58%;
  width: 90%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(205, 180, 255, .55) 0%, rgba(160, 130, 230, .2) 35%, rgba(160, 130, 230, 0) 65%);
  animation: brew-glow 3s ease-in-out infinite;
}
.brew__pot.is-bloop .brew__glow { animation: bloop .6s ease-out; }
.bubbles i {
  position: absolute;
  left: var(--x);
  top: 59%;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, #dccbff 30%, #b39ae8 75%);
  box-shadow: 0 0 10px rgba(205, 180, 255, .7);
  opacity: 0;
  animation: bubble var(--d) ease-in var(--t) infinite;
}
.speech--brew { left: 46%; top: -6%; transform-origin: 30% 100%; }

@keyframes brew-glow {
  0%, 100% { opacity: .7; transform: scale(.95); }
  50%      { opacity: 1;  transform: scale(1.06); }
}
@keyframes bloop {
  0%   { opacity: 1; transform: scale(1); filter: brightness(1); }
  30%  { opacity: 1; transform: scale(1.35); filter: brightness(1.6); }
  100% { opacity: .8; transform: scale(1); filter: brightness(1); }
}
@keyframes bubble {
  0%   { transform: translateY(0) scale(.3); opacity: 0; }
  15%  { opacity: .95; }
  80%  { transform: translateY(-110px) scale(1); opacity: .8; }
  90%  { transform: translateY(-122px) scale(1.4); opacity: .3; }
  100% { transform: translateY(-126px) scale(1.6); opacity: 0; }
}

/* ---- Room 3: hearth ---- */
.scene--hearth { --floor: #a87a54; --fx: .72; }
.scene--hearth .scene__content { grid-template-columns: minmax(480px, 47%) 1fr; }

.hearth__intro {
  max-width: 30em;
  margin: 16px auto 26px;
  font-size: 1.01rem;
  color: var(--ink-soft);
}

.letter-form {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  text-align: left;
}
.letter-form label {
  display: block;
  margin: 0 0 8px 6px;
  font-weight: 700;
  font-size: .93rem;
}
.letter-form__row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.letter-form input {
  flex: 1 1 240px;
  min-width: 0;
  height: 58px;
  padding: 0 18px;
  font: 400 1.01rem var(--font-body);
  color: var(--ink);
  background: #fffaf0;
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
  box-shadow: inset 0 3px 0 rgba(72, 41, 26, .12);
}
.letter-form input::placeholder { color: #9b8569; }
.letter-form input:focus-visible { outline-offset: 2px; }
.letter-form input[aria-invalid="true"] { border-color: #8a2f2a; animation: shake .35s ease; }
.letter-form__status {
  min-height: 1.6em;
  margin: 8px 0 0 6px;
  font-weight: 700;
  font-size: .9rem;
}
.letter-form__status.is-error { color: #8a2f2a; }
.letter-form__status.is-ok { color: #3f5a24; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.village { margin-top: 26px; }
.village h3 { font-size: 1.08rem; color: var(--wood-dark); }

.tokens {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 14px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.token {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 70px;
  text-decoration: none;
  font-weight: 700;
  font-size: .82rem;
  color: var(--ink);
  perspective: 400px;
}
.token__coin {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #8d5c38, #5a3721 72%);
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 0 6px var(--wood-dark),
    0 7px 0 3px rgba(47, 31, 22, .25);
}
.token__coin svg { width: 30px; height: 30px; fill: var(--parchment); }
.token:hover .token__coin,
.token:focus-visible .token__coin { animation: coin-flip .8s cubic-bezier(.3, .7, .4, 1); }
.token:focus-visible { outline: none; }
.token:focus-visible .token__coin { outline: 3px solid var(--plum); outline-offset: 8px; }
@keyframes coin-flip {
  0%   { transform: translateY(0) rotateY(0); }
  40%  { transform: translateY(-14px) rotateY(200deg); }
  100% { transform: translateY(0) rotateY(360deg); }
}

/* opt-in crackle of the hearth fire */
.fire-toggle {
  position: absolute;
  right: 4%;
  bottom: 70px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 9px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #7b4e31, #5e3922);
  box-shadow: inset 0 0 0 2px rgba(226, 190, 106, .6), 0 4px 0 rgba(47, 31, 22, .35), 0 10px 18px rgba(30, 15, 8, .35);
  color: var(--parchment);
  font-family: var(--font-display);
  font-size: .92rem;
  line-height: 1;
  transition: transform .2s var(--spring);
}
.fire-toggle[hidden] { display: none; }
.fire-toggle:hover { transform: translateY(-2px) rotate(-1.5deg); }
.fire-toggle:focus-visible { outline: 3px solid var(--lavender); outline-offset: 3px; }
.fire-toggle__icon { width: 22px; height: 22px; fill: currentColor; }
.fire-toggle__icon .fire-toggle__waves,
.fire-toggle__icon .fire-toggle__mute { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fire-toggle__waves { display: none; }
.fire-toggle[aria-pressed="true"] .fire-toggle__waves { display: inline; }
.fire-toggle[aria-pressed="true"] .fire-toggle__mute { display: none; }
.fire-toggle__state {
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(20, 10, 4, .35);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .72rem;
}
.fire-toggle[aria-pressed="true"] .fire-toggle__state { background: var(--gold); color: var(--ink); }
/* on, but the browser is waiting for a first tap before it allows sound: invite it */
.fire-toggle.is-waiting .fire-toggle__state { background: var(--lavender); color: var(--ink); animation: tap-pulse 1.6s ease-in-out infinite; }
.fire-toggle.is-waiting .fire-toggle__waves { display: inline; }
.fire-toggle.is-waiting .fire-toggle__mute { display: none; }
@keyframes tap-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.fire-toggle__bars { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.fire-toggle[aria-pressed="true"] .fire-toggle__bars { display: inline-flex; }
.fire-toggle__bars i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--gold-hi);
  transform-origin: 50% 100%;
  animation: crackle-bar .9s ease-in-out infinite;
}
.fire-toggle__bars i:nth-child(2) { animation-delay: -.3s; animation-duration: .7s; }
.fire-toggle__bars i:nth-child(3) { animation-delay: -.6s; animation-duration: 1.1s; }
@keyframes crackle-bar {
  0%, 100% { transform: scaleY(.3); }
  50%      { transform: scaleY(1); }
}

/* ---- Room 4: Pika's bedroom ---- */
.scene--nook {
  --r: 2.358;
  --h: clamp(460px, calc(100vw / var(--r)), 760px);
  --floor: #573d32;
  --fx: .66;
  margin-bottom: -34px;
}
.scene--nook .scene__content {
  align-items: end;
  justify-items: center;
  padding-bottom: 54px;
}
.bed {
  position: absolute;
  left: 55%;
  bottom: 6%;
  z-index: 3;
  width: 29%;
}
.bed img { position: relative; width: 100%; height: auto; }
.bed__candle {
  position: absolute;
  left: 73.8%;
  top: 65.1%;
  width: 70%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 140, .65) 0%, rgba(255, 190, 90, .2) 30%, rgba(255, 190, 90, 0) 62%);
  mix-blend-mode: screen;
  animation: flicker 2.2s linear infinite;
  pointer-events: none;
}
.bed__z {
  position: absolute;
  left: 38%;
  top: 18%;
  pointer-events: none;
}
.bed__z i {
  position: absolute;
  left: 0;
  top: 0;
  font-style: normal;
  font-family: var(--font-display);
  color: var(--lavender);
  opacity: 0;
  animation: snore 4.5s ease-out infinite;
}
.bed__z i:nth-child(1) { font-size: 1.1rem; animation-delay: 0s; }
.bed__z i:nth-child(2) { font-size: 1.5rem; animation-delay: 1.5s; }
.bed__z i:nth-child(3) { font-size: 2rem;   animation-delay: 3s; }
@keyframes snore {
  0%   { transform: translate(0, 0) scale(.5) rotate(-10deg); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(46px, -86px) scale(1.1) rotate(8deg); opacity: 0; }
}
.bed__note {
  margin: 0;
  font-size: 1.01rem;
  color: #f0dfbb;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
}

/* ---------- footer: the crystal bedrock ---------- */
.footer {
  --r: 2.357;
  --h: clamp(440px, calc(100vw / var(--r)), 660px);
  position: relative;
  z-index: 0;
  height: var(--h);
  overflow: hidden;
  overflow: clip;
  background: #251516;
  color: var(--parchment);
}
.footer__stage {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: max(100%, calc(var(--h) * var(--r)));
  aspect-ratio: var(--r);
  translate: -50% 0;
}
.footer__art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.glow--crystal {
  --gs: 10%;
  background: radial-gradient(circle, rgba(214, 190, 255, .6) 0%, rgba(170, 130, 240, .2) 38%, rgba(170, 130, 240, 0) 68%);
  animation: crystal-glow 4.6s ease-in-out var(--t, 0s) infinite;
}
@keyframes crystal-glow {
  0%, 100% { opacity: .45; scale: .94; }
  50%      { opacity: 1;   scale: 1.06; }
}
.glowworms i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffe7a8;
  box-shadow: 0 0 8px 3px rgba(255, 214, 120, .6);
  opacity: 0;
  animation: glowworm 3.8s ease-in-out var(--t) infinite;
}
@keyframes glowworm {
  0%, 100% { opacity: 0; transform: translateY(0); }
  45%      { opacity: .95; }
  60%      { opacity: .8; transform: translateY(-4px); }
}

/* a little secret: Pika's spare key */
.footer__key {
  position: absolute;
  left: 17%;
  top: 80%;
  z-index: 3;
  width: 5.5%;
  height: 8%;
  border-radius: 40%;
}
.footer__key::after {      /* a glint so curious people notice it */
  content: "";
  position: absolute;
  left: 45%;
  top: 35%;
  width: 10px;
  height: 10px;
  background: #fff3c9;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  opacity: 0;
  animation: glint 5s ease-in-out 1.5s infinite;
}
.footer__key:hover::after,
.footer__key:focus-visible::after { animation-duration: 1.2s; }
.footer__key:focus-visible { outline: 3px solid var(--lavender); outline-offset: 2px; }
@keyframes glint {
  0%, 70%, 100% { opacity: 0; transform: scale(.4) rotate(0); }
  80%           { opacity: 1; transform: scale(1.2) rotate(45deg); }
}
.speech--key { left: 14%; bottom: 25%; transform-origin: 20% 100%; }

.footer__inner {
  position: relative;
  z-index: 2;
  pointer-events: none;          /* the hidden key below must stay clickable */
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 80px 24px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  text-shadow: 0 2px 10px rgba(10, 4, 4, .7);
}
.footer__inner > * { pointer-events: auto; }
.brand--footer { flex-direction: column; gap: 10px; }
.brand--footer .brand__emblem { width: 86px; height: 86px; }
.brand--footer .brand__name { justify-items: center; font-size: 1.6rem; }
.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 26px;
}
.footer__links a { font-weight: 700; text-decoration: none; }
.footer__links a:hover { text-decoration: underline wavy var(--gold-hi) 2px; text-underline-offset: 6px; }
.footer :focus-visible { outline-color: var(--lavender); }
.footer__legal {
  margin: 6px 0 0;
  font-size: .85rem;
  color: #d9c3a0;
}

/* pause everything that isn't on screen */
.js .zone:not(.is-live) *,
.js .zone:not(.is-live) *::before,
.js .zone:not(.is-live) *::after { animation-play-state: paused !important; }
/* …except the one-time arrival sequence, which must always finish */
.js .zone:not(.is-live) :is(.w, .lede, .surface__actions, .sign-btn, .hero-pika) { animation-play-state: running !important; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1199px) {
  .depth { display: none; }
}

/* stacked hero: copy on the sky, then a window onto the painting */
@media (max-width: 1100px) {
  .surface { height: auto; }
  .surface__copy { padding-top: 124px; }
  .surface__copy > * { max-width: 640px; }
  .lede { text-shadow: none; }
  .stage-wrap {
    --f: .6;          /* share of the painting that fits the screen */
    --x0: .4;         /* where that window starts */
    position: relative;
    inset: auto;
    margin-top: -40px;
  }
  .stage {
    position: relative;
    right: auto;
    bottom: auto;
    width: calc(100% / var(--f));
    translate: calc(var(--x0) * -100%) 0;
  }
  .stage-wrap::before {   /* melt the sky into the painting */
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 30%;
    z-index: 1;
    background: linear-gradient(var(--sky), rgba(202, 216, 203, 0));
    pointer-events: none;
  }
  .speech--hero { left: 52%; bottom: 52%; font-size: .85rem; }
  .hero-tree, .leaves { display: none; }
}

/* stacked rooms: a window onto the painting, then the notes on the room's floor colour */
@media (max-width: 900px) {
  .soil--top { background-image: url("assets/web/soil-top-1200.webp"); }
  .soil--mid { background-image: url("assets/web/soil-mid-1200.webp"); }
  .soil--low { background-image: url("assets/web/soil-low-1200.webp"); }
  .soil { height: 130px; }
  .soil--top { height: 160px; }

  .scene {
    --mh: clamp(280px, 74vw, 500px);
    --sw: calc(var(--mh) * var(--r));
    min-height: 0;
  }
  .scene--nook { --mh: clamp(260px, 72vw, 420px); }
  .scene--brewing { --mh: clamp(320px, 86vw, 520px); }
  .scene__stage {
    position: relative;
    left: clamp(calc(100% - var(--sw)), calc(50% - var(--sw) * var(--fx)), 0px);
    bottom: auto;
    width: var(--sw);
    height: var(--mh);
    translate: none;
  }
  .scene::before {        /* the painting's floor melts into the notes below */
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--mh) - 120px);
    height: 122px;
    z-index: 1;
    background: linear-gradient(rgba(0, 0, 0, 0), var(--floor));
    pointer-events: none;
  }
  .scene__content,
  .scene--study .scene__content,
  .scene--brewing .scene__content,
  .scene--hearth .scene__content {
    display: block;
    min-height: 0;
    margin-top: -56px;
    padding: 0 18px 78px;
  }
  .scene__content > * { max-width: 620px; margin-left: auto; margin-right: auto; }
  .scene__content > * + * { margin-top: 28px; }
  .rules { margin-top: 150px !important; }
  .scene--brewing .scene__content { margin-top: -12px; }
  .fire-toggle { top: calc(var(--mh) - 108px); bottom: auto; right: 14px; font-size: .85rem; }
  .scene--nook .scene__content { margin-top: 4px; padding-bottom: 64px; text-align: center; }
}

@media (max-width: 760px) {
  body { font-size: 1.01rem; }

  .nav { top: 10px; padding: 0 10px; }
  .nav__plank { flex-wrap: wrap; gap: 0; }
  .nav__toggle { display: inline-block; }
  .nav__links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    padding: 10px 0 6px;
  }
  .nav__plank.is-open .nav__links { display: flex; }
  .nav__links a { padding: 12px 10px; font-size: 1.01rem; }
  .brand__emblem { width: 48px; height: 48px; }
  .brand__name { font-size: 1.21rem; }

  .surface__copy { padding: 112px 16px 0; }
  .lede { font-size: 1.01rem; margin: 16px 0 22px; }
  .sign-btn { width: 270px; }
  .surface { background: #c0d1c7; }                 /* the portrait painting's sky */
  .stage-wrap { --f: 1; --x0: 0; margin-top: calc(-100vw * 2584 / 1536 * .42); }
  .stage-wrap::before { display: none; }
  .stage { aspect-ratio: 1536 / 2584; }
  .hero-pika { left: 25.4%; bottom: 10.5%; width: 25%; }
  .speech--hero { left: 30%; bottom: 29%; max-width: 12em; }
  .doorway { left: 61.979%; top: 63.777%; width: 27.018%; height: 18.073%; }
  .doorway__inside {
    -webkit-mask-image: url("assets/web/hero-doorway-mask-mobile.png?v=2");
            mask-image: url("assets/web/hero-doorway-mask-mobile.png?v=2");
  }
  .doorway__window { display: none; }               /* the phone door has no window */
  .doorway__spill { left: 58%; top: 79%; width: 34%; height: 13%; }

  .note--scroll {
    border-width: 58px 50px;
    border-image-width: 74px 69px;
    background-size: calc(100% - 100px) calc(100% - 112px);
    padding: 6px 18px 2px;          /* text sits well inside the paper, not on its edge */
  }
  .note--card { border-width: 66px 40px 44px 66px; padding: 2px 4px 0 2px; }
  .note--board { padding: 20px 6px 14px; }
  .rules { padding: 0; transform: rotate(.8deg); }
  .peek { width: 200px; }
  .speech--brew { left: auto; right: 2%; top: -8%; transform-origin: 70% 100%; }
  .speech--brew::after { left: 58%; }

  .letter-form__row { flex-direction: column; align-items: stretch; }
  .letter-form input { flex: 0 0 auto; }   /* in a column, flex-basis would become height */
  .letter-form__row .sign-btn { align-self: center; }
  .tokens { gap: 16px 20px; }
  .token__coin { width: 58px; height: 58px; }
  .token__coin svg { width: 26px; height: 26px; }

  .scene { --r: .5581; --mh: calc(100vw / var(--r)); }
  .scene--study   { --overlap: .48; --floor: #a17d63; }
  .scene--brewing { --overlap: .24; --floor: #33272f; }
  .scene--hearth  { --overlap: .45; --floor: #a46843; }
  .scene--nook    { --overlap: .1;  --floor: #3b2c27; }
  .scene__content,
  .scene--study .scene__content,
  .scene--brewing .scene__content,
  .scene--hearth .scene__content,
  .scene--nook .scene__content { margin-top: calc(var(--mh) * var(--overlap) * -1); }
  .scene--brewing .scene__content { color: inherit; }

  .glow, .steam { left: var(--mx, var(--x)); top: var(--my, var(--y)); }
  .scene .glow { width: calc(var(--gs, 9%) * 2.2); }
  .footer .glow { width: calc(var(--gs, 10%) * 2); }
  .steam { width: 8%; }
  .only-mobile { display: block; }
  .only-desktop { display: none; }

  .lantern { width: 10%; margin-left: -5%; }
  .brew { left: 30.7%; bottom: 23%; width: 62%; }
  .bed { left: 19%; bottom: 18%; width: 62%; }
  .fire-toggle { top: calc(var(--mh) * .44); }

  .footer { --r: .7467; --h: calc(100vw / var(--r)); }
  .footer__key { left: 30%; top: 85%; width: 10%; height: 7%; }
  .speech--key { left: 16%; bottom: 20%; }
  .footer__inner { padding: 24px 24px 52%; gap: 10px; }   /* keep the text in the dark middle of the cave, clear of the crystals */
  .brand--footer .brand__emblem { width: 62px; height: 62px; }
  .footer__links { gap: 6px 18px; }
}

/* touch screens can't hover: keep the door's tag visible so people know to tap it */
@media (hover: none) {
  .doorway__tag { opacity: 1; transform: rotate(-3deg); animation: tag-bob 2.6s ease-in-out infinite; }
}
@keyframes tag-bob {
  0%, 100% { translate: -50% 0; }
  50%      { translate: -50% -5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
  .motes, .bubbles, .bed__z, .steam, .leaves, .glowworms { display: none; }
}
