/* =====================================================================
   for zenith: a tiny sanctuary, lit by one candle
   ===================================================================== */

/* ---------- fonts (self-hosted, latin subsets) ---------- */
@font-face {
  font-family: 'Fraunces';
  src: url('assets/fonts/fraunces.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('assets/fonts/fraunces-italic.woff2') format('woff2');
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Karla';
  src: url('assets/fonts/karla.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  src: url('assets/fonts/caveat.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Special Elite';
  src: url('assets/fonts/special-elite.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;

  /* the room: a quiet evening */
  --color-background: #1c1520;
  --color-background-deep: #150f19;
  --color-surface: #251c2a;
  --color-surface-raised: #2e2434;
  --color-line: rgba(247, 237, 220, 0.11);
  --color-line-strong: rgba(247, 237, 220, 0.22);

  /* paper and ink */
  --color-paper: #f7eddc;
  --color-paper-shade: #eadbc2;
  --color-ink: #3b2c35;
  --color-ink-soft: #6a5462;

  /* text on the dark */
  --color-text: #f7eddc;
  --color-muted: #b9a5b5;
  --color-faint: rgba(247, 237, 220, 0.38);

  /* accents, taken from the artwork */
  --color-accent: #f2b5c1;          /* her pink */
  --color-accent-deep: #e39aab;
  --color-accent-soft: rgba(242, 181, 193, 0.14);
  --color-glow: #ffc97a;            /* the candle */
  --color-glow-soft: rgba(255, 201, 122, 0.14);
  --color-sage: #a3bc9f;
  --color-blue: #b3c3f2;            /* his piece, softened */
  --color-blue-soft: rgba(179, 195, 242, 0.14);
  --color-navy: #1f2d5c;
  --color-coral: #e8846a;

  /* the case file */
  --color-manila: #ecd9b0;
  --color-manila-shade: #ddc490;
  --color-stamp: #9c3229;
  --color-stamp-progress: #7f4d0f;
  --ink-signature: #a2475f;
  --color-hazard: #e8c15a;
  --color-hazard-ink: #3a3325;

  /* note papers */
  --paper-secret: #fbe4ea;
  --ink-secret: #8e3f57;
  --paper-his: #e8edfb;
  --ink-his: #26366e;

  /* her candle holder, exactly as she painted it on may 29th (the studio can repaint it) */
  --glaze: #f5b8c4;
  --glaze-deep: #e39aab;
  --glaze-edge: #d4879b;
  --spots: rgba(197, 109, 131, 0.30);
  --rim-top: #fac9d3;
  --rim: #e39aab;
  --rim-dots: rgba(255, 246, 234, 0.85);

  /* type */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Karla', system-ui, -apple-system, sans-serif;
  --font-hand: 'Caveat', 'Bradley Hand', cursive;
  --font-case: 'Special Elite', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-h3: 1.2rem;
  --text-h2: clamp(2rem, 1.45rem + 2.3vw, 2.9rem);
  --text-display: clamp(3.2rem, 2.1rem + 5.6vw, 5.6rem);
  --text-note: clamp(1.65rem, 1.4rem + 0.9vw, 2.05rem);

  /* space */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: clamp(4.5rem, 3rem + 6vw, 8rem);

  --page-max: 1080px;
  --measure: 34rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);

  --radius-sm: 6px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-paper: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 22px 40px -22px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.22);
  --shadow-lift: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
  --focus: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-glow);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.45, 0.05, 0.35, 1);
  --dur-1: 0.18s;
  --dur-2: 0.45s;
  --dur-3: 0.9s;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--color-background);
  background-image:
    radial-gradient(70rem 40rem at 50% -8rem, rgba(255, 201, 122, 0.10), transparent 70%),
    radial-gradient(50rem 40rem at 100% 40%, rgba(242, 181, 193, 0.05), transparent 70%),
    radial-gradient(60rem 50rem at 0% 90%, rgba(179, 195, 242, 0.05), transparent 70%);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* a whisper of paper grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 0.95  0 0 0 0 0.9  0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; }
a { color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); }

::selection { background: var(--color-accent); color: var(--color-ink); }

/* ---------- type ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.eyebrow::before, .eyebrow::after {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--color-line-strong);
}

h1, h2, .cf-title {
  font-family: var(--font-display);
  font-weight: 380;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--color-text);
}
h1 em, h2 em {
  font-style: italic;
  font-weight: 360;
  color: var(--color-accent);
}
h2 { font-size: var(--text-h2); margin-top: var(--space-4); }

.lede {
  max-width: var(--measure);
  margin: var(--space-4) auto 0;
  color: var(--color-muted);
  text-wrap: pretty;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease, box-shadow var(--dur-1) ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: default; transform: none; }

.btn-primary {
  background: var(--color-accent);
  color: var(--color-ink);
  box-shadow: 0 10px 24px -14px rgba(242, 181, 193, 0.8);
}
.btn-primary:hover { background: #f6c4ce; transform: translateY(-1px); }
.btn-primary[aria-pressed="true"] { background: var(--color-blue); }

.btn-quiet {
  background: transparent;
  border-color: var(--color-line-strong);
  color: var(--color-text);
}
.btn-quiet:hover { background: rgba(247, 237, 220, 0.06); border-color: rgba(247, 237, 220, 0.34); }

.btn-lg { min-height: 54px; padding: 0 var(--space-6); font-size: 1rem; }
.btn-arrow { transition: transform var(--dur-2) var(--ease-out); }
.btn:hover .btn-arrow { transform: translateX(3px); }

.link-btn {
  background: none;
  border: 0;
  padding: var(--space-2) var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-line-strong);
  text-underline-offset: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--dur-1) ease, text-decoration-color var(--dur-1) ease;
}
.link-btn:hover { color: var(--color-text); text-decoration-color: currentColor; }

/* ---------- the cover ---------- */
.cover {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--gutter);
  transition: opacity 0.6s ease;
}
.cover.leaving { opacity: 0; }
.cover-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 36rem;
}
.cover-inner > * { animation: rise 1.1s var(--ease-out) both; }
.cover-inner > :nth-child(2) { animation-delay: 0.08s; }
.cover-inner > :nth-child(3) { animation-delay: 0.16s; }
.cover-inner > :nth-child(4) { animation-delay: 0.3s; }
.cover-inner > :nth-child(5) { animation-delay: 0.45s; }
@keyframes rise {
  from { opacity: 0; translate: 0 14px; }
  to   { opacity: 1; translate: 0 0; }
}

.cover-candle { overflow: visible; margin-bottom: var(--space-5); }
.cover-candle-flame { transform-box: fill-box; transform-origin: center bottom; animation: flickerSoft 2.6s ease-in-out infinite; }
.cover-candle-glow { animation: glowBreath 10s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes flickerSoft {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  40%      { transform: scale(0.95, 1.06) rotate(2deg); }
  70%      { transform: scale(1.03, 0.97) rotate(-1deg); }
}
@keyframes glowBreath {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  40%      { transform: scale(1.12); opacity: 1; }
}

.cover-title {
  margin-top: var(--space-3);
  font-size: var(--text-display);
}

.letter {
  position: relative;
  margin: var(--space-6) 0 var(--space-6);
  padding: var(--space-6) var(--space-6) var(--space-5);
  max-width: 30rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 30%),
    var(--color-paper);
  color: var(--color-ink);
  border-radius: 3px 4px 3px 5px;
  box-shadow: var(--shadow-paper);
  transform: rotate(-0.8deg);
  text-align: left;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14;
  font-size: 1.04rem;
  line-height: 1.65;
  text-wrap: pretty;
}
.letter p + p { margin-top: var(--space-3); }
.letter .letter-sign {
  margin-top: var(--space-4);
  font-family: var(--font-hand);
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--ink-signature);
}
/* a strip of tape holding the letter */
.letter::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 84px;
  height: 22px;
  transform: translateX(-50%) rotate(2deg);
  background: rgba(247, 205, 214, 0.72);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* ---------- the world ---------- */
.main { position: relative; z-index: 1; }
.main.hidden { display: none; }
.main.entering { animation: fadeIn 0.8s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* top bar: plain, out of the way */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(28, 21, 32, 0.72);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--color-line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--page-max);
  height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  text-decoration: none;
  color: var(--color-text);
  border-radius: var(--radius-sm);
}
.nav { display: flex; gap: clamp(0.5rem, 0.2rem + 1.5vw, 1.75rem); }
.nav a {
  position: relative;
  padding: var(--space-2) var(--space-1);
  font-size: var(--text-sm);
  text-decoration: none;
  color: var(--color-muted);
  border-radius: var(--radius-sm);
  transition: color var(--dur-1) ease;
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--color-text); }
.nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-glow);
  transform: translateX(-50%) scale(0);
  transition: transform var(--dur-2) var(--ease-out);
}
.nav a[aria-current="true"]::after { transform: translateX(-50%) scale(1); }

/* sections */
.sec {
  position: relative;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-9) var(--gutter) 0;
}
.sec-head { text-align: center; max-width: 40rem; margin: 0 auto; }

/* a small mark between sections, like a pause in a letter */
.sec + .sec::before, .ending::before {
  content: "";
  display: block;
  width: 40px;
  height: 6px;
  margin: 0 auto var(--space-7);
  background:
    radial-gradient(circle, var(--color-glow) 0 2px, transparent 2.5px) 0 50% / 14px 6px repeat-x;
  opacity: 0.45;
}

/* gentle entrances as things scroll in */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.9s ease, transform 0.9s var(--ease-out); }
.js .reveal.in-view { opacity: 1; transform: none; }

/* ---------- hello ---------- */
.welcome { padding-top: var(--space-8); }
.hello { font-size: var(--text-display); margin-top: var(--space-3); }
.name-tap {
  background: none;
  border: 0;
  padding: 0 0.04em;
  font: inherit;
  font-style: italic;
  font-weight: 360;
  color: var(--color-accent);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--dur-1) ease;
}
.name-tap:hover { color: var(--color-glow); }

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-7);
}
.choice {
  --choice-accent: var(--color-glow);
  --choice-soft: var(--color-glow-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-5) var(--space-4);
  min-height: 100%;
  text-align: left;
  background:
    radial-gradient(14rem 9rem at 0% 0%, var(--choice-soft), transparent 70%),
    var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 22px 18px 24px 16px;
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2) ease, box-shadow var(--dur-2) ease;
}
.choice:nth-child(even) { border-radius: 18px 24px 16px 22px; }
.choice:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--choice-accent) 45%, transparent);
  box-shadow: var(--shadow-lift);
}
.choice:active { transform: translateY(-1px) scale(0.99); }
.choice-art { margin-bottom: var(--space-2); transition: transform var(--dur-2) var(--ease-out); }
.choice:hover .choice-art { transform: rotate(-4deg) scale(1.06); }
.choice-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 36;
  font-size: var(--text-h3);
  line-height: 1.2;
  color: var(--color-text);
}
.choice-desc { font-size: var(--text-sm); line-height: 1.5; color: var(--color-muted); }
.choice-cta {
  margin-top: auto;
  padding-top: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--choice-accent);
}
.choice-breathe { --choice-accent: var(--color-accent); --choice-soft: var(--color-accent-soft); }
.choice-case { --choice-accent: var(--color-manila); --choice-soft: rgba(236, 217, 176, 0.12); }
.choice-rest { --choice-accent: var(--color-blue); --choice-soft: var(--color-blue-soft); }

/* ---------- the candle stage ---------- */
.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px minmax(0, 1fr);
  align-items: end;
  margin-top: var(--space-6);
}
.stage > .scene { grid-column: 2; }

.scene {
  position: relative;
  width: 240px;
  height: 300px;
  margin: 0 auto;
}

.glow {
  position: absolute;
  z-index: 0;
  left: 50%; top: 30%;
  width: 380px; height: 380px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 201, 122, 0.36) 0%, rgba(255, 201, 122, 0.12) 40%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
.lit .glow { opacity: 1; animation: breathe 10s ease-in-out infinite; }
@keyframes breathe {
  0%   { transform: translate(-50%, -50%) scale(0.9); }
  40%  { transform: translate(-50%, -50%) scale(1.08); }
  100% { transform: translate(-50%, -50%) scale(0.9); }
}

.flame {
  position: absolute;
  z-index: 5;
  left: 50%; bottom: 208px;
  width: 22px; height: 42px;
  transform: translateX(-50%) scale(0);
  transform-origin: bottom center;
  background: radial-gradient(ellipse at 50% 80%, #fff3d6 0%, var(--color-glow) 45%, #f08a3c 80%, transparent 100%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  filter: blur(0.5px);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.lit .flame { transform: translateX(-50%) scale(1); animation: flicker 2.4s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(-1.5deg); }
  25%      { transform: translateX(-52%) scale(1.05, 0.96) rotate(1deg); }
  50%      { transform: translateX(-49%) scale(0.97, 1.04) rotate(-1deg); }
  75%      { transform: translateX(-51%) scale(1.02) rotate(1.5deg); }
}

.wick {
  position: absolute;
  z-index: 4;
  left: 50%; bottom: 200px;
  width: 3px; height: 12px;
  transform: translateX(-50%);
  background: #4a3a45;
  border-radius: 2px;
}
.candle {
  position: absolute;
  z-index: 3;
  left: 50%; bottom: 110px;
  width: 58px; height: 92px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fdf3e3 0%, #f3e2cc 100%);
  border-radius: 8px 8px 4px 4px;
  box-shadow: inset -8px 0 14px rgba(0, 0, 0, 0.06);
}
.candle::before {
  content: "";
  position: absolute;
  top: -4px; left: 0; right: 0;
  height: 10px;
  background: #fff8ec;
  border-radius: 50%;
}
.holder {
  position: absolute;
  z-index: 2;
  left: 50%; bottom: 24px;
  width: 150px; height: 96px;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 11px 0px, var(--spots) 0 5px, transparent 6px) 0 0 / 22px 14px repeat,
    radial-gradient(circle at 11px 0px, var(--spots) 0 5px, transparent 6px) 11px 7px / 22px 14px repeat,
    linear-gradient(160deg, var(--glaze) 0%, var(--glaze-deep) 78%, var(--glaze-edge) 100%);
  border-radius: 14px 14px 60px 60px / 14px 14px 78px 78px;
  box-shadow: inset 0 -12px 24px rgba(0, 0, 0, 0.18), inset 8px 6px 14px rgba(255, 255, 255, 0.28), 0 24px 30px -18px rgba(0, 0, 0, 0.7);
}
.holder-rim {
  position: absolute;
  z-index: 4;
  left: 50%; bottom: 112px;
  width: 162px; height: 18px;
  transform: translateX(-50%);
  /* the rim: the part she spent forever on, small circles all the way round */
  background:
    radial-gradient(circle, var(--rim-dots) 0 2px, transparent 2.6px) 3px 50% / 11px 100% repeat-x,
    linear-gradient(180deg, var(--rim-top) 0%, var(--rim) 100%);
  border-radius: 50%;
}

/* the whole holder is one big button; the flame and his piece sit above it */
.candle-btn {
  position: absolute;
  z-index: 6;
  left: 30px; right: 30px;
  top: 70px; bottom: 6px;
  background: none;
  border: 0;
  border-radius: 40px 40px 70px 70px;
  cursor: pointer;
}
.flame-tap {
  position: absolute;
  z-index: 7;
  left: 50%; bottom: 196px;
  width: 76px; height: 84px;
  transform: translateX(-50%);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: none;
}
.lit .flame-tap { display: block; }

/* the candle's state, in light: unlit → lit → note revealed */
.scene::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 210px;
  height: 22px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.45), transparent 70%);
  z-index: 0;
  pointer-events: none;
}

/* his piece, keeping hers company */
.his-piece {
  position: absolute;
  z-index: 7;
  right: -98px;
  bottom: 2px;
  padding: 4px;
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
  transition: transform var(--dur-2) var(--ease-out);
}
.his-piece:hover { transform: translateY(-2px) rotate(-2deg); }
.his-piece svg { overflow: visible; }
.his-piece .his-flame, .his-piece .his-glow {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: opacity 0.8s ease;
}
.his-piece.lit .his-flame { opacity: 1; animation: hisFlicker 2.1s ease-in-out infinite; }
.his-piece.lit .his-glow { opacity: 1; }
@keyframes hisFlicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50%      { transform: scale(0.94, 1.06) rotate(2deg); }
}

/* critters */
.critter, .snake { position: absolute; pointer-events: none; }
.tarantula {
  top: 0; right: 10px;
  display: flex; flex-direction: column; align-items: center;
  animation: hangbob 4s ease-in-out infinite;
}
.tarantula .thread { width: 1.5px; height: 64px; background: rgba(247, 237, 220, 0.22); }
@keyframes hangbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }
.dog { bottom: 2px; animation: dance 1.6s ease-in-out infinite; transform-origin: bottom center; }
.chihuahua { left: -6px; }
.corgi { right: -14px; animation-delay: 0.4s; }
@keyframes dance {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-9px) rotate(6deg); }
}
.corn { bottom: 118px; left: 50%; z-index: 5; transform: translateX(-50%); animation: sway 5s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: translateX(-52%); } 50% { transform: translateX(-48%); } }
.king { bottom: 16px; left: 28px; animation: coilbob 6s ease-in-out infinite; }
.ball { bottom: 14px; right: 30px; animation: coilbob 7s ease-in-out infinite reverse; }
@keyframes coilbob { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }

/* ---------- notes: small paper cards ---------- */
.note-area {
  display: flex;
  justify-content: center;
  min-height: 15rem;
  margin-top: var(--space-6);
  padding: 0 var(--space-2);
}
.note-card {
  --paper: var(--color-paper);
  --ink: var(--color-ink);
  position: relative;
  z-index: 16; /* the notes always outrank the dinosaurs */
  width: min(32rem, 100%);
  align-self: flex-start;
  padding: var(--space-5) var(--space-6) var(--space-4);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent 35%),
    var(--paper);
  color: var(--ink);
  border-radius: 3px 5px 4px 3px;
  box-shadow: var(--shadow-paper);
  transform: rotate(-1deg);
  transition: opacity 0.35s ease, transform 0.35s var(--ease-out);
}
.note-card.is-out { opacity: 0; transform: translateY(10px) rotate(-3deg); }
.note-card.is-in { animation: noteIn 0.7s var(--ease-out) both; }
@keyframes noteIn {
  from { opacity: 0; transform: translateY(14px) rotate(-3.5deg) scale(0.98); }
  to   { opacity: 1; transform: rotate(-1deg); }
}
.note {
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: var(--text-note);
  line-height: 1.3;
  text-wrap: pretty;
}
.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed color-mix(in srgb, var(--ink) 22%, transparent);
}
.note-card .link-btn { color: color-mix(in srgb, var(--ink) 70%, transparent); text-decoration-color: color-mix(in srgb, var(--ink) 25%, transparent); }
.note-card .link-btn:hover { color: var(--ink); }
.note-card :focus-visible { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }

.note-card.is-secret { --paper: var(--paper-secret); --ink: var(--ink-secret); }
.note-card.is-his { --paper: var(--paper-his); --ink: var(--ink-his); }
.note-card.is-case {
  --paper: var(--color-manila);
  --ink: var(--color-hazard-ink);
  transform: rotate(0.6deg);
}
.note-card.is-case .note {
  font-family: var(--font-case);
  font-size: 0.95rem;
  line-height: 1.75;
  white-space: pre-line;
}

/* ---------- the pond ---------- */
.pond-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  margin-top: var(--space-6);
}
.pond {
  position: relative;
  width: min(680px, 100%);
  height: 150px;
  container-type: inline-size;
  overflow: hidden;
  border-radius: 46% 54% 52% 48% / 58% 52% 48% 42%;
  background:
    radial-gradient(60% 80% at 30% 20%, rgba(179, 195, 242, 0.16), transparent 70%),
    linear-gradient(180deg, #2a3463 0%, #1d2447 70%, #1a1f3d 100%);
  box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(179, 195, 242, 0.12), 0 0 0 6px rgba(163, 188, 159, 0.08);
}
.ripple {
  position: absolute;
  border: 1px solid rgba(179, 195, 242, 0.22);
  border-radius: 50%;
  pointer-events: none;
  animation: ripple 7s ease-out infinite;
}
.ripple-a { left: 22%; top: 55%; width: 60px; height: 18px; }
.ripple-b { left: 70%; top: 30%; width: 44px; height: 14px; animation-delay: 3.5s; }
@keyframes ripple {
  0%   { transform: scale(0.4); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}
.swimmer {
  position: absolute;
  left: 0; top: 46px;
  animation: swim 18s ease-in-out infinite alternate;
}
@keyframes swim { from { transform: translateX(18px); } to { transform: translateX(calc(100cqw - 118px)); } }
.axo {
  display: block;
  padding: 6px;
  background: none;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  animation: flipdir 36s steps(1) infinite, bob 3s ease-in-out infinite;
}
.axo svg { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)); }
@keyframes flipdir { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }

/* ---------- case #003: the case file ---------- */
.casefile {
  position: relative;
  max-width: 46rem;
  margin: calc(var(--space-6) + 26px) auto 0;
  padding: var(--space-6) clamp(1.25rem, 0.8rem + 2.4vw, 2.5rem) var(--space-6);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 18%),
    var(--color-manila);
  color: var(--color-hazard-ink);
  border-radius: 4px 10px 6px 6px;
  box-shadow: var(--shadow-paper);
}
.casefile-tab {
  position: absolute;
  left: 0;
  bottom: 100%;
  padding: 6px 18px 4px;
  background: var(--color-manila-shade);
  border-radius: 8px 8px 0 0;
  font-family: var(--font-case);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.casefile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid rgba(58, 51, 37, 0.2);
}
.cf-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(58, 51, 37, 0.8);
}
.cf-title {
  margin-top: var(--space-1);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  font-style: italic;
  color: var(--color-hazard-ink);
}
.stamp {
  flex: none;
  padding: 4px 12px;
  border: 2.5px solid currentColor;
  border-radius: 6px;
  font-family: var(--font-case);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(58, 51, 37, 0.78);
  transform: rotate(6deg);
  mix-blend-mode: multiply;
}
.casefile[data-state="progress"] .stamp { color: var(--color-stamp-progress); }
.casefile[data-state="solved"] .stamp { color: var(--color-stamp); }
.stamp.thunk { animation: stampIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes stampIn {
  from { transform: rotate(-4deg) scale(1.9); opacity: 0; }
  to   { transform: rotate(6deg) scale(1); opacity: 1; }
}

.cf-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-4) 0 var(--space-6);
}
.cf-facts dt { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(58, 51, 37, 0.8); }
.cf-facts dd { margin-top: 2px; font-family: var(--font-case); font-size: 0.92rem; line-height: 1.4; }

.evidence {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.ev {
  padding: 10px 10px var(--space-3);
  background: #fbf6ec;
  border-radius: 2px;
  box-shadow: 0 10px 18px -12px rgba(58, 51, 37, 0.6), 0 1px 2px rgba(58, 51, 37, 0.18);
  transform: rotate(-1.5deg);
  transition: transform var(--dur-2) var(--ease-out);
}
.ev:nth-child(2) { transform: rotate(1.2deg); }
.ev:nth-child(3) { transform: rotate(-0.6deg); }
.ev-art {
  display: grid;
  place-items: center;
  height: 92px;
  border: 1.5px dashed rgba(58, 51, 37, 0.25);
  border-radius: 2px;
  background: rgba(58, 51, 37, 0.04);
  overflow: hidden;
}
.ev-q { font-family: var(--font-display); font-style: italic; font-size: 2rem; color: rgba(58, 51, 37, 0.3); }
.ev-name {
  margin-top: var(--space-2);
  font-family: var(--font-case);
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(58, 51, 37, 0.74);
}
.ev-hint { margin-top: 2px; font-size: var(--text-xs); line-height: 1.4; color: rgba(58, 51, 37, 0.72); font-style: italic; }
.ev.got .ev-art { border-style: solid; border-color: transparent; background: #2b2230; }
.ev.got .ev-name { color: var(--color-hazard-ink); }
.ev.got .ev-name::before { content: "\2713  "; color: var(--color-stamp); }
.ev.got .ev-hint { display: none; }
.ev.got.just-found { animation: evPop 0.6s var(--ease-out); }
@keyframes evPop {
  0%   { transform: translateY(-10px) rotate(-6deg) scale(1.06); }
  100% { transform: rotate(-1.5deg); }
}
/* the found clue, shown in the evidence photo */
.ev-art .clue-copy { transform: scale(0.9); pointer-events: none; }
.ev-art .clue-copy svg { display: block; }
.ev-art .scrap-paper { transform: rotate(-7deg) scale(1.15); }

.cf-status {
  margin-top: var(--space-6);
  font-family: var(--font-case);
  font-size: 0.9rem;
  line-height: 1.6;
}
.cf-verdict {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: #fbf6ec;
  border-left: 3px solid var(--color-stamp);
  font-family: var(--font-case);
  font-size: 0.9rem;
  line-height: 1.75;
  white-space: pre-line;
  box-shadow: 0 8px 16px -12px rgba(58, 51, 37, 0.6);
}
.keepsakes { margin-top: var(--space-6); }
.keepsakes.on { animation: rise 1s var(--ease-out) both; }
.keepsake-row { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
.keepsake {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4) 0 var(--space-3);
  background: #fbf6ec;
  border: 1px solid rgba(58, 51, 37, 0.18);
  border-radius: var(--radius-pill);
  color: var(--color-hazard-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1) ease;
}
.keepsake:hover { background: #fff; transform: translateY(-1px); }
.keepsake:focus-visible { box-shadow: 0 0 0 2px var(--color-manila), 0 0 0 4px var(--color-hazard-ink); }
.cf-reset { display: block; margin-top: var(--space-5); color: rgba(58, 51, 37, 0.7); text-decoration-color: rgba(58, 51, 37, 0.3); }
.cf-reset:hover { color: var(--color-hazard-ink); }
.cf-reset:focus-visible { box-shadow: 0 0 0 2px var(--color-manila), 0 0 0 4px var(--color-hazard-ink); }

/* ---------- the clues, hidden in the page ---------- */
.clue {
  position: absolute;
  z-index: 8;
  background: none;
  border: 0;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--dur-2) ease, transform var(--dur-2) var(--ease-out);
  touch-action: manipulation;
}
.clue:hover, .clue:focus-visible { opacity: 1; transform: scale(1.08) rotate(-2deg); }
.clue.found { opacity: 0; transform: scale(0.5); pointer-events: none; }
.scrap-paper {
  display: block;
  background: var(--color-paper);
  color: #4a3a45;
  font-family: var(--font-case);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding: 9px 12px 14px;
  transform: rotate(-7deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  clip-path: polygon(0 0, 100% 0, 100% 68%, 86% 82%, 72% 68%, 56% 86%, 40% 70%, 24% 88%, 10% 72%, 0 86%);
}
.chalk-label {
  display: block;
  margin-top: 2px;
  font-family: var(--font-case);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: rgba(247, 237, 220, 0.6);
  text-align: center;
}
.clue-scrap { left: calc(50% - 250px); bottom: 34px; }
.clue-tracks { right: max(0px, calc(50% - 370px)); top: -36px; }
.clue-chalk { right: var(--gutter); bottom: var(--space-6); }
.ev-art .chalk-label { color: rgba(247, 237, 220, 0.6); }

/* ---------- rest ---------- */
.rest-sec .btn { margin-top: var(--space-6); }

/* ---------- the end ---------- */
.ending {
  position: relative;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-9) var(--gutter) var(--space-8);
  text-align: center;
}
.ending-mark { margin: 0 auto var(--space-4); opacity: 0.9; }
.ending-line {
  max-width: 26rem;
  margin: 0 auto;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--color-text);
}
.ending-sign { margin-top: var(--space-3); font-size: var(--text-sm); color: var(--color-muted); }
.ending-top { display: inline-block; margin-top: var(--space-5); }

/* ---------- little chips that follow you ---------- */
.chip {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  min-height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  cursor: pointer;
  box-shadow: var(--shadow-lift);
  animation: rise 0.5s var(--ease-out) both;
}
.chip-case {
  left: 14px;
  max-width: min(22rem, calc(100vw - 28px));
  background: var(--color-manila);
  color: var(--color-hazard-ink);
  border: 0;
  font-family: var(--font-case);
  letter-spacing: 0.04em;
  text-align: left;
}
.chip-case.ping { animation: chipPing 0.6s var(--ease-out); }
.chip-case.quiet { padding: 0 var(--space-3); opacity: 0.85; }
.chip-case.quiet .chip-k { font-size: 0; }
.chip-case.quiet .chip-k::before { content: "#003"; font-size: var(--text-xs); }
.chip-case.quiet .chip-v { display: none; }
.chip-case.quiet:hover, .chip-case.quiet:focus-visible { opacity: 1; }
@keyframes chipPing { 30% { transform: scale(1.08) rotate(-2deg); } }
.chip-rest {
  right: 14px;
  background: var(--color-surface-raised);
  color: var(--color-blue);
  border: 1px solid rgba(179, 195, 242, 0.35);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.chip-rest span { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- the reveal ---------- */
.reveal-dim {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 18, 0);
  pointer-events: none;
  z-index: 11;
  transition: background 0.7s ease;
}
.reveal-dim.on { background: rgba(15, 10, 18, 0.6); }
.reveal-line {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  text-align: center;
  font-family: var(--font-case);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  color: var(--color-glow);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  transition: opacity 0.5s ease;
}
.reveal-line.on { opacity: 1; }

/* ---------- the culprits in hiding (--dir: -1 faces left, 1 faces right) ---------- */
.hideaway {
  --stalk-x: 0px;
  --stalk-y: 0px;
  --dir: 1;
  position: fixed;
  top: 76px;
  z-index: 13;
  width: 132px;
  height: 118px;
  pointer-events: none;
  overflow: visible;
  transform: translate(var(--stalk-x), var(--stalk-y));
  transition: transform 140ms ease-out, opacity 180ms ease;
}
.hideaway::before {
  content: "";
  position: absolute;
  border-radius: 55% 45% 58% 42% / 50% 44% 56% 50%;
  opacity: 0.9;
  pointer-events: none;
}
.hideaway-spino { --dir: -1; right: max(8px, 4vw); }
.hideaway-spino::before { inset: 8px 0 8px 4px; background: radial-gradient(circle at 60% 50%, rgba(242, 181, 193, 0.10) 0%, rgba(242, 181, 193, 0.05) 45%, transparent 72%); }
.hideaway-cerato { --dir: 1; left: max(8px, 4vw); }
.hideaway-cerato::before { inset: 8px 4px 8px 0; background: radial-gradient(circle at 40% 50%, rgba(242, 181, 193, 0.10) 0%, rgba(242, 181, 193, 0.05) 45%, transparent 72%); }
.hideaway.stalking { opacity: 1; }
.hideaway.undercover {
  opacity: 0 !important;
  transform: translate(0, -8px) !important;
  transition: opacity 900ms ease, transform 900ms ease;
}
.dino-pal {
  --peek-y: 0px;
  --peek-rot: 0deg;
  position: absolute;
  bottom: 2px;
  transform: translateY(var(--peek-y)) scaleX(var(--dir)) rotate(var(--peek-rot));
  transform-origin: center bottom;
  transition: transform 140ms ease-out, opacity 180ms ease, filter 180ms ease;
  pointer-events: none;
  opacity: 0.85;
  z-index: 2;
}
.hideaway-spino .dino-pal { right: 4px; }
.hideaway-cerato .dino-pal { left: 2px; bottom: 1px; }
.hideaway.stalking .dino-pal { opacity: 0.95; }
.dino-image {
  display: block;
  width: auto;
  height: 72px;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
}
.hideaway-cerato .dino-image { height: 74px; }
.feet-tap {
  position: absolute;
  bottom: -4px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  border-radius: 50%;
  z-index: 3;
}
.hideaway-spino .feet-tap { left: 36%; width: 38%; height: 46%; }
.hideaway-cerato .feet-tap { left: 28%; width: 45%; height: 44%; }
.hideaway.undercover .feet-tap { pointer-events: none !important; }
.dino-pal.scare {
  animation: dinoJumpscare 1.05s cubic-bezier(0.24, 0.9, 0.2, 1) forwards;
  transition: none;
  opacity: 1;
  z-index: 12;
}
@keyframes dinoJumpscare {
  0%   { transform: translate(0, 0) scaleX(var(--dir)) scale(1) rotate(0deg); }
  20%  { transform: translate(calc(var(--dir) * 4px), -4px) scaleX(var(--dir)) scale(1.04) rotate(calc(var(--dir) * 2deg)); }
  55%  { transform: translate(calc(var(--dir) * 42px), 40px) scaleX(var(--dir)) scale(1.60) rotate(calc(var(--dir) * 8deg)); }
  80%  { transform: translate(calc(var(--dir) * 34px), 34px) scaleX(var(--dir)) scale(1.46) rotate(calc(var(--dir) * 6deg)); }
  100% { transform: translate(0, 0) scaleX(var(--dir)) scale(1) rotate(0deg); }
}
.dino-rawr {
  position: absolute;
  bottom: 92px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-paper);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  z-index: 13;
}
.hideaway-spino .dino-rawr { right: 22px; }
.hideaway-cerato .dino-rawr { left: 20px; }
.dino-rawr.show { animation: rawrPop 0.9s ease forwards; }
@keyframes rawrPop {
  0%   { opacity: 0; transform: translateY(10px) scale(0.6); }
  30%  { opacity: 1; transform: translateY(-10px) scale(1.05); }
  65%  { opacity: 1; transform: translateY(-18px) scale(1); }
  100% { opacity: 0; transform: translateY(-24px) scale(0.92); }
}

/* ---------- culprits at large: the chase ---------- */
.chaser {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 15;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  will-change: transform;
  touch-action: manipulation;
}
.chaser.anchored { position: absolute; }
.chaser .flip { display: block; }
.chaser .body { display: block; transform-origin: center bottom; }
.chaser img {
  display: block;
  height: 66px;
  width: auto;
  max-width: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35));
}
.chaser.running .body { animation: chaseBob 0.38s ease-in-out infinite; }
@keyframes chaseBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-7px) rotate(3deg); }
}
.chaser.pop .body { animation: chaserPop 0.5s ease; }
@keyframes chaserPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28) rotate(-5deg); }
  100% { transform: scale(1); }
}
.chaser .crawr, .chaser .cbonk {
  position: absolute;
  left: 50%;
  top: -16px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  translate: -50% 0;
}
.chaser .crawr { color: var(--color-paper); }
.chaser .cbonk { color: var(--color-accent); }
.chaser .crawr.show { animation: rawrPop 0.9s ease forwards; }
.chaser .cbonk.show { animation: rawrPop 0.95s ease forwards; }
.chaser .cstars {
  position: absolute;
  left: 50%;
  top: -4px;
  font-size: 0.8rem;
  color: var(--color-glow);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
}
.chaser .cstars.show { animation: dizzyStars 0.95s ease forwards; }
@keyframes dizzyStars {
  0%   { opacity: 0; transform: translateX(-50%) translateY(6px) rotate(0deg); }
  25%  { opacity: 1; transform: translateX(-46%) translateY(-4px) rotate(8deg); }
  50%  { opacity: 1; transform: translateX(-54%) translateY(-7px) rotate(-8deg); }
  75%  { opacity: 1; transform: translateX(-47%) translateY(-9px) rotate(6deg); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-13px) rotate(0deg); }
}
.chaser.bonked .body { animation: bonkSquash 0.9s cubic-bezier(0.22, 0.9, 0.3, 1.1); }
@keyframes bonkSquash {
  0%   { transform: scale(1, 1); }
  14%  { transform: scale(1.18, 0.68) translateY(5px); }
  38%  { transform: scale(0.9, 1.1) translateY(-3px); }
  60%  { transform: scale(1.06, 0.95); }
  100% { transform: scale(1, 1); }
}
.chaser.chomp .body { animation: chompLunge 0.34s ease; }
@keyframes chompLunge {
  0%   { transform: none; }
  40%  { transform: translateY(-7px) rotate(-9deg) scale(1.07); }
  70%  { transform: translateY(2px) rotate(4deg) scale(0.97); }
  100% { transform: none; }
}
.chaser.caged { z-index: 14; }

/* ---------- the paddocks flank the candle (it's the fence switch) ---------- */
.paddock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.paddock-left { grid-column: 1; justify-self: start; }
.paddock-right { grid-column: 3; justify-self: end; }
.stage.contained .paddock { visibility: visible; opacity: 1; transition: opacity 0.6s ease; }
.stage.contained .paddock .cage { animation: cageDrop 0.7s var(--ease-out) both; }
@keyframes cageDrop { from { translate: 0 -18px; } to { translate: 0 0; } }

.cage { position: relative; width: 180px; height: 124px; }
.cage-back, .cage-front { position: absolute; inset: 0; pointer-events: none; }
.cage-back { z-index: 13; }
.cage-front { z-index: 15; transition: opacity 0.5s ease, translate 0.5s ease; }
.cage-back svg, .cage-front svg { display: block; }
.cage-front.zap svg { animation: cageZap 0.55s ease; }
.cage-front.zap .zapbolt { animation: zapBolt 0.55s ease; }
@keyframes cageZap {
  0%, 100% { filter: none; }
  20%, 60% { filter: brightness(1.7) drop-shadow(0 0 8px rgba(232, 193, 90, 0.8)); }
  40%, 80% { filter: brightness(1.1); }
}
@keyframes zapBolt {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  55%  { opacity: 0.4; }
  75%  { opacity: 0.9; }
  100% { opacity: 0; }
}
.cage-front.rattle { animation: cageRattle 0.32s ease; }
@keyframes cageRattle {
  0%, 100% { translate: 0 0; }
  25% { translate: -2.5px 0; }
  50% { translate: 2.5px 0; }
  75% { translate: -1.5px 0; }
}
.cage-front.open { opacity: 0.22; translate: 0 -12px; }

/* the release buttons (two mistakes) */
.release-btn {
  position: relative;
  z-index: 16;
  min-height: 36px;
  font-family: var(--font-case);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--color-hazard-ink);
  background: var(--color-hazard);
  border: 2px solid var(--color-hazard-ink);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.release-btn.on { opacity: 1; pointer-events: auto; transform: translateY(0); }
.release-btn.on:hover { background: #f0cd6e; }
.release-btn:disabled { cursor: default; }
.release-btn:focus-visible { box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-hazard); }
#releaseBtn.bite1 { clip-path: polygon(0 0, 72% 0, 66% 18%, 74% 34%, 64% 52%, 72% 68%, 65% 84%, 70% 100%, 0 100%); }
#releaseBtn.bite2 { clip-path: polygon(0 0, 46% 0, 40% 16%, 48% 32%, 38% 50%, 46% 66%, 39% 82%, 44% 100%, 0 100%); }
#releaseBtn.bite3 { clip-path: polygon(0 0, 24% 0, 18% 20%, 25% 38%, 16% 56%, 23% 74%, 17% 100%, 0 100%); }
#releaseBtn2.bite1 { clip-path: polygon(100% 0, 28% 0, 34% 18%, 26% 34%, 36% 52%, 28% 68%, 35% 84%, 30% 100%, 100% 100%); }
#releaseBtn2.bite2 { clip-path: polygon(100% 0, 54% 0, 60% 16%, 52% 32%, 62% 50%, 54% 66%, 61% 82%, 56% 100%, 100% 100%); }
#releaseBtn2.bite3 { clip-path: polygon(100% 0, 76% 0, 82% 20%, 75% 38%, 84% 56%, 77% 74%, 83% 100%, 100% 100%); }
.release-btn.eaten { opacity: 0 !important; transform: translateY(2px) scale(0.7) rotate(-6deg); transition: opacity 0.28s ease, transform 0.28s ease; }

/* ---------- the detective is an ankylosaurus ---------- */
.anky-hide-cursor, .anky-hide-cursor * { cursor: none !important; }
#ankyCursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50; /* it's the cursor: always on top */
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}
#ankyCursor.on { opacity: 1; }
#ankyCursor .anky-flip { display: block; transform: translate(-50%, -56%) scaleX(1); }
#ankyCursor.left .anky-flip { transform: translate(-50%, -56%) scaleX(-1); }
#ankyCursor svg {
  display: block;
  width: 62px;
  height: auto;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
  transform-origin: center 70%;
}
#ankyCursor.waddle svg { animation: ankyWaddle 0.34s ease-in-out infinite; }
@keyframes ankyWaddle {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50%      { transform: rotate(4deg) translateY(-3px); }
}
#ankyCursor.bonk svg { animation: ankyBonk 0.32s ease; }
@keyframes ankyBonk {
  0%   { transform: rotate(0deg) scale(1); }
  38%  { transform: rotate(-26deg) scale(1.08); }
  100% { transform: rotate(0deg) scale(1); }
}
#ankyCursor .heart-svg { display: none; }
#ankyCursor.heart .anky-svg { display: none; }
#ankyCursor.heart .heart-svg {
  display: block;
  width: 42px;
  height: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
  animation: heartPulse 1.6s ease-in-out infinite;
  transform-origin: center center;
}
#ankyCursor.heart .anky-flip { transform: translate(-50%, -50%) !important; }
#ankyCursor.heart.waddle .heart-svg { animation: heartPulse 0.6s ease-in-out infinite; }
#ankyCursor.heart-pop .anky-flip { animation: heartPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
#ankyCursor.heart.bonk .heart-svg { animation: ankyBonk 0.32s ease; }
@keyframes heartPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes heartPop {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(-20deg); }
  60%  { transform: translate(-50%, -50%) scale(1.3) rotate(6deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
}

/* ---------- overlays: breathing, the pottery place, the studio ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30; /* above the fixed chips: nothing but the overlay */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: max(40px, 9vh) var(--gutter) var(--space-6);
  text-align: center;
  background:
    radial-gradient(40rem 30rem at 50% 30%, rgba(255, 201, 122, 0.08), transparent 70%),
    var(--color-background-deep);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.overlay.on { opacity: 1; pointer-events: auto; }
.overlay-exit { margin-top: var(--space-5); }

/* breathing: one clock drives the orb, the words and the count */
.breath { justify-content: center; }
.breath-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(300px, 78vw);
  aspect-ratio: 1;
  margin-top: var(--space-6);
}
.breath-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(242, 181, 193, 0.22);
}
.breath-orb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 201, 122, 0.55) 0%, rgba(242, 181, 193, 0.32) 45%, rgba(242, 181, 193, 0.05) 70%, transparent 72%);
  transform: scale(0.56);
  opacity: 0.75;
}
.breath-axo { overflow: visible; }
.breath-gills { transform-box: fill-box; transform-origin: right center; }
.breath-stage[data-phase="in"] .breath-orb { transform: scale(1); opacity: 1; transition: transform 4s var(--ease-soft), opacity 4s ease; }
.breath-stage[data-phase="out"] .breath-orb { transform: scale(0.56); opacity: 0.75; transition: transform 6s var(--ease-soft), opacity 6s ease; }
.breath-stage[data-phase="in"] .breath-gills { animation: gills 1.3s ease-in-out infinite; }
.breath-stage[data-phase="paused"] .breath-orb { transition: none; }
.breath-stage[data-phase="done"] .breath-orb { transform: scale(0.8); opacity: 0.9; transition: transform 2s var(--ease-soft); }
@keyframes gills { 50% { transform: rotate(-8deg); } }
.breath-text {
  margin-top: var(--space-5);
  min-height: 1.4em;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-style: italic;
  color: var(--color-text);
}
.breath-tick {
  min-height: 1.5em;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2em;
  color: var(--color-muted);
}
.breath-progress { display: flex; gap: 8px; margin-top: var(--space-4); }
.breath-progress span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(247, 237, 220, 0.16);
  transition: background-color 0.6s ease;
}
.breath-progress span.done { background: var(--color-accent); }
.breath-progress span.now { background: var(--color-glow); }
.breath-controls { display: flex; gap: var(--space-3); margin-top: var(--space-5); }

/* the pottery place */
.chapter-art {
  width: min(380px, 88vw);
  height: 220px;
  margin-top: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chapter-art svg { width: 100%; height: 100%; overflow: visible; }
.chapter-art.turn { animation: chapterTurn 0.7s ease; }
@keyframes chapterTurn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chapter-line {
  max-width: 26rem;
  min-height: 4em;
  margin-top: var(--space-4);
  font-family: var(--font-hand);
  font-size: 1.8rem;
  line-height: 1.3;
  color: var(--color-text);
  text-wrap: pretty;
}
.chapter-nav { display: flex; align-items: center; gap: var(--space-5); margin-top: var(--space-5); }
.chapter-nav .btn { min-width: 104px; }
.chapter-dots { display: flex; gap: 7px; }
.chapter-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(247, 237, 220, 0.18);
  transition: background-color 0.3s ease;
}
.chapter-dots span.on { background: var(--color-accent); }

/* the studio */
.studio-sub { margin-top: var(--space-2); font-family: var(--font-display); font-style: italic; font-size: 1.6rem; color: var(--color-accent); }
.studio-piece { position: relative; flex: none; width: 240px; height: 212px; margin-top: var(--space-3); }
.studio-parts { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-4); }
.studio-part {
  min-height: 36px;
  padding: 0 var(--space-4);
  background: none;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: color var(--dur-1) ease, border-color var(--dur-1) ease, background-color var(--dur-1) ease;
}
.studio-part:hover { color: var(--color-text); }
.studio-part[aria-checked="true"] { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-soft); }
.studio-swatches {
  display: grid;
  grid-template-columns: repeat(5, 42px);
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-5);
}
.swatch {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(247, 237, 220, 0.18);
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.18), inset 3px 3px 6px rgba(255, 255, 255, 0.22);
  transition: transform var(--dur-1) var(--ease-out);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { border-color: var(--color-paper); transform: scale(1.12); }
.swatch-name { min-height: 1.4em; margin-top: var(--space-3); font-size: var(--text-sm); color: var(--color-muted); }
.studio-actions { display: flex; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; justify-content: center; }

/* ---------- mobile: designed for the hand ---------- */
@media (max-width: 900px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "scene scene" "left right";
    row-gap: var(--space-5);
    column-gap: var(--space-3);
  }
  .stage > .scene { grid-area: scene; }
  .paddock-left { grid-area: left; justify-self: center; }
  .paddock-right { grid-area: right; justify-self: center; }
  .paddock { display: none; }
  .stage.contained .paddock { display: flex; }
  .clue-scrap { left: 0; top: -6px; bottom: auto; }
}

@media (max-width: 640px) {
  .topbar-inner { height: 52px; }
  .wordmark span { display: none; }
  .nav a { font-size: 0.95rem; padding: var(--space-2); }

  .sec { padding-top: var(--space-8); }
  .sec + .sec::before, .ending::before { margin-bottom: var(--space-6); }
  .welcome { padding-top: var(--space-7); }

  .choices { gap: var(--space-3); margin-top: var(--space-6); }
  .choice { padding: var(--space-4) var(--space-4) var(--space-3); }
  .choice-art { width: 40px; height: 40px; }
  .choice-title { font-size: 1.08rem; }
  .choice-desc { font-size: 0.84rem; }

  .letter { padding: var(--space-5) var(--space-5) var(--space-4); font-size: 1rem; }

  .his-piece { right: -66px; bottom: 6px; }
  .his-piece svg { width: 54px; height: auto; }

  .note-card { padding: var(--space-5) var(--space-5) var(--space-3); }

  .pond { height: 132px; }
  .swimmer { top: 38px; }
  .clue-tracks { right: 4px; top: -44px; }

  .cf-facts { grid-template-columns: 1fr; gap: var(--space-2); }
  .cf-facts > div { display: flex; gap: var(--space-3); align-items: baseline; }
  .cf-facts dt { min-width: 6.5rem; }
  .evidence { gap: var(--space-2); }
  .ev { padding: 6px 6px var(--space-2); }
  .ev-art { height: 70px; }
  .ev-name { font-size: 0.72rem; }
  .ev-hint { font-size: 0.68rem; }
  .ev-art .clue-copy { transform: scale(0.7); }

  .cage { width: 150px; height: 104px; }
  .cage-back svg, .cage-front svg { width: 150px; }
  .release-btn { max-width: 42vw; font-size: 0.66rem; line-height: 1.35; }
  .chaser img { height: 52px; }
  #ankyCursor svg { width: 52px; }
  #ankyCursor.heart .heart-svg { width: 36px; }

  .hideaway { top: 64px; width: 106px; height: 96px; }
  .hideaway-spino { right: 4px; }
  .hideaway-cerato { left: 4px; }
  .hideaway-spino .dino-image, .hideaway-cerato .dino-image { height: 58px; }
  .dino-rawr { bottom: 72px; font-size: 0.8rem; }

  .breath-text { font-size: 1.4rem; }
  .chapter-line { font-size: 1.6rem; }
}

@media (max-width: 380px) {
  .nav { gap: 0.25rem; }
  .nav a { font-size: 0.88rem; }
  .choice-desc { display: none; }
}

/* ---------- reduced motion: everything still works, nothing drifts ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .js .reveal { transform: none; transition: opacity 0.4s ease; }
  .choice, .choice:hover, .choice-art, .his-piece:hover, .clue:hover { transform: none; }
  .hideaway, .dino-pal { transition: none; }
  .note-card { transition: opacity 0.3s ease; }
  .note-card.is-out { transform: rotate(-1deg); }
  /* breathing without movement: the orb just brightens and dims */
  .breath-stage .breath-orb { transform: scale(0.8) !important; }
  .breath-stage[data-phase="in"] .breath-orb { transition: opacity 4s ease; }
  .breath-stage[data-phase="out"] .breath-orb { opacity: 0.45; transition: opacity 6s ease; }
}

/* =====================================================================
   the sketchbook: a little space to draw
   ===================================================================== */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.choice-draw { --choice-accent: var(--color-sage); --choice-soft: rgba(163, 188, 159, 0.12); }

/* ---- on the page: a notebook left open on the table ---- */
.sketch-shelf {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 1rem + 3vw, 3.5rem);
  margin-top: var(--space-7);
}
.sketch-book {
  position: relative;
  flex: none;
  width: 210px;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  border-radius: 4px 8px 8px 4px;
  background: var(--sb-paper, #fbf6ec);
  box-shadow: var(--shadow-paper), -6px 0 0 -2px #e9dcc6, -10px 2px 0 -4px #dccfb8;
  transform: rotate(-2.5deg);
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) ease;
}
.sketch-book:hover { transform: rotate(-1deg) translateY(-4px); }
.sketch-leaf {
  position: absolute;
  inset: 18px 10px 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 2px;
  background-image: radial-gradient(rgba(59, 44, 53, 0.09) 1px, transparent 1.2px);
  background-size: 14px 14px;
}
.sketch-thumb { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; }
.sketch-rings {
  position: absolute;
  top: -9px;
  left: 18px;
  right: 18px;
  height: 20px;
  background: radial-gradient(circle at 50% 50%, transparent 4px, #b9a6b5 4.5px, #b9a6b5 6px, transparent 6.5px) 0 0 / 22px 20px repeat-x;
  pointer-events: none;
}
.sketch-side { max-width: 22rem; text-align: left; }
.sketch-state { font-family: var(--font-hand); font-size: 1.6rem; line-height: 1.25; color: var(--color-text); }
.sketch-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.sketch-note { margin-top: var(--space-4); font-size: var(--text-sm); color: var(--color-muted); }

/* the cursor is a real cursor while drawing (the ankylosaurus would cover the line) */
body.sb-open #ankyCursor { opacity: 0 !important; }
.anky-hide-cursor .sb-overlay.on, .anky-hide-cursor .sb-overlay.on *,
.anky-hide-cursor .sb-dialog, .anky-hide-cursor .sb-dialog * { cursor: auto !important; }
.anky-hide-cursor .sb-overlay.on button, .anky-hide-cursor .sb-dialog button { cursor: pointer !important; }
.anky-hide-cursor .sb-overlay.on .sb-canvas, .sb-canvas { cursor: crosshair !important; }
.anky-hide-cursor .sb-overlay.on .sb-page.erasing .sb-canvas, .sb-page.erasing .sb-canvas { cursor: cell !important; }

/* ---- the sketchbook overlay ---- */
.sketchbook { padding-top: max(24px, 4vh); }
.sb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  max-width: 980px;
}
.sb-head { position: relative; width: 100%; text-align: center; }
/* a close button always within thumb's reach at the top */
.sb-x {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-line-strong);
  border-radius: 50%;
  background: rgba(37, 28, 42, 0.85);
  color: var(--color-text);
  cursor: pointer;
  transition: background-color var(--dur-1) ease;
}
.sb-x:hover { background: var(--color-surface-raised); }
.sb-state { margin-top: var(--space-2); min-height: 1.5em; font-size: var(--text-sm); color: var(--color-muted); }

.sb-page {
  --page-w: min(100%, 540px, calc((100dvh - 360px) * 0.8));
  position: relative;
  width: var(--page-w);
  min-width: 250px;
  aspect-ratio: 4 / 5;
  border-radius: 4px 6px 6px 4px;
  background-color: #fbf6ec;
  background-image: radial-gradient(rgba(59, 44, 53, 0.08) 1.1px, transparent 1.3px);
  background-size: 22px 22px;
  background-position: 11px 11px;
  box-shadow: var(--shadow-paper);
}
.sb-rings {
  position: absolute;
  top: -10px;
  left: 22px;
  right: 22px;
  height: 22px;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, transparent 4.5px, #b9a6b5 5px, #b9a6b5 6.5px, transparent 7px) 0 0 / 26px 22px repeat-x;
  pointer-events: none;
}
.sb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  touch-action: none; /* only the page itself stops scrolling, and only so a finger can draw */
  -webkit-user-select: none;
  user-select: none;
}
.sb-canvas:focus-visible { box-shadow: 0 0 0 3px var(--color-glow); }
.sb-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-hand);
  font-size: 1.9rem;
  color: rgba(59, 44, 53, 0.28);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.sb-empty.gone { opacity: 0; }

.sb-side { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); width: 100%; }

.sb-tools { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.sb-colours { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sb-swatch {
  position: relative;
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(247, 237, 220, 0.16);
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.18), inset 2px 2px 4px rgba(255, 255, 255, 0.22);
  transition: transform var(--dur-1) var(--ease-out);
}
.sb-swatch:hover { transform: scale(1.08); }
.sb-swatch[aria-checked="true"] { border-color: var(--color-paper); transform: scale(1.12); }
/* a tick, so the chosen colour never depends on colour alone */
.sb-swatch[aria-checked="true"]::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 5px;
  border-left: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: translate(-50%, -65%) rotate(-45deg);
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.6));
}
.sb-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.sb-sizes { display: flex; gap: 4px; }
.sb-size {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: none;
  cursor: pointer;
}
.sb-size::before { content: ""; width: var(--d); height: var(--d); border-radius: 50%; background: var(--color-text); }
.sb-size[aria-checked="true"] { border-color: var(--color-line-strong); background: rgba(247, 237, 220, 0.08); }
.sb-divider { width: 1px; height: 26px; margin: 0 var(--space-1); background: var(--color-line-strong); }
.sb-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
}
.sb-tool:hover { background: rgba(247, 237, 220, 0.06); }
.sb-tool[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-soft); }
.sb-tool:disabled { opacity: 0.35; cursor: default; background: none; }

.sb-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.sb-minor { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-4); }

.sb-drafts { width: 100%; max-width: 32rem; }
.sb-drafts-note { font-size: var(--text-sm); color: var(--color-muted); text-align: center; }
.sb-draft-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.sb-draft { position: relative; }
.sb-draft-open {
  display: block;
  width: 100%;
  padding: 4px 4px 6px;
  border: 0;
  border-radius: 3px;
  background: #fbf6ec;
  color: var(--color-ink-soft);
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: 0 8px 14px -10px rgba(0, 0, 0, 0.7);
}
.sb-draft-open img { display: block; width: 100%; aspect-ratio: 4 / 5; }
.sb-draft.current .sb-draft-open { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.sb-draft-del {
  position: absolute;
  top: -8px; right: -8px;
  width: 26px; height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.sb-draft-empty { grid-column: 1 / -1; text-align: center; font-size: var(--text-sm); color: var(--color-muted); }

/* desktop: the tools sit beside the page, so the page can be big */
@media (min-width: 900px) {
  .sb-wrap {
    display: grid;
    grid-template-columns: auto 250px;
    grid-template-areas: "head head" "page side" "close close";
    column-gap: var(--space-7);
    row-gap: var(--space-5);
    align-items: start;
    justify-content: center;
  }
  .sb-head { grid-area: head; }
  .sb-page { grid-area: page; --page-w: min(600px, calc((100dvh - 190px) * 0.8)); }
  .sb-side { grid-area: side; align-items: stretch; padding-top: var(--space-4); }
  .sb-colours { display: grid; grid-template-columns: repeat(4, 34px); gap: 12px; justify-content: start; }
  .sb-tools, .sb-row { align-items: flex-start; justify-content: flex-start; }
  .sb-row { flex-direction: column; align-items: stretch; }
  .sb-divider { display: none; }
  .sb-actions { flex-direction: column; align-items: stretch; }
  .sb-minor { flex-direction: column; align-items: flex-start; }
  .sb-wrap > .overlay-exit { grid-area: close; justify-self: center; }
}

/* ---- dialogs ---- */
.sb-dialog {
  margin: auto;
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: var(--space-6) var(--space-5) var(--space-5);
  border: 1px solid var(--color-line-strong);
  border-radius: 20px 16px 22px 18px;
  background: var(--color-surface-raised);
  color: var(--color-text);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}
.sb-dialog::backdrop { background: rgba(15, 10, 18, 0.62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sb-dialog[open] { animation: dialogIn 0.35s var(--ease-out); }
@keyframes dialogIn { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
.sb-dialog h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.2;
}
.sb-dialog p { margin-top: var(--space-3); color: var(--color-muted); font-size: 0.97rem; line-height: 1.55; }
.sb-dialog p strong { color: var(--color-text); font-weight: 500; word-break: break-all; }
.sb-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }
.sb-field { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.sb-field span { font-size: var(--text-sm); color: var(--color-muted); }
.sb-field em { font-style: normal; opacity: 0.8; }
.sb-field input {
  min-height: 46px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-line-strong);
  border-radius: 12px;
  background: var(--color-background-deep);
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
}
#sbAuthCode { font-size: 1.4rem; letter-spacing: 0.4em; font-variant-numeric: tabular-nums; }
.sb-field input:focus-visible { border-color: var(--color-glow); }
.sb-error { min-height: 1.2em; color: #f4a4a4 !important; font-size: var(--text-sm) !important; }
.sb-muted { color: var(--color-muted); }
.sb-share-preview {
  display: block;
  width: 120px;
  aspect-ratio: 4 / 5;
  margin: var(--space-4) auto 0;
  border-radius: 3px;
  box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.8);
  transform: rotate(-2deg);
}
.sb-progress { height: 8px; margin-top: var(--space-5); border-radius: 99px; background: rgba(247, 237, 220, 0.1); overflow: hidden; }
.sb-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--color-accent); transition: width 0.25s ease; }

.sb-viewer { width: min(560px, calc(100vw - 24px)); padding: var(--space-4); }
.sb-viewer-img {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 220px);
  aspect-ratio: 4 / 5;
  object-fit: contain;
  border-radius: 4px;
  background: #fbf6ec;
}
.sb-viewer-meta { margin-top: var(--space-3); }
.sb-viewer-meta p { margin-top: var(--space-1); }

/* ---- the shared gallery ---- */
.gal-wrap { width: 100%; max-width: 900px; display: flex; flex-direction: column; align-items: center; }
.gal-heading { font-size: var(--text-h2); margin-top: var(--space-3); }
.gal-body { width: 100%; margin-top: var(--space-6); min-height: 30vh; }
.gal-message { max-width: 26rem; margin: var(--space-6) auto 0; text-align: center; }
.gal-message-title { font-family: var(--font-display); font-style: italic; font-size: 1.4rem; color: var(--color-text); }
.gal-message-text { margin-top: var(--space-2); color: var(--color-muted); }
.gal-message .btn { margin-top: var(--space-5); }
.gal-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-6) var(--space-5); }
.gal-item {
  padding: 10px 10px 12px;
  background: #fbf6ec;
  border-radius: 3px;
  box-shadow: 0 16px 26px -18px rgba(0, 0, 0, 0.9), 0 2px 4px rgba(0, 0, 0, 0.25);
  transform: rotate(var(--tilt, 0deg));
  transition: transform var(--dur-2) var(--ease-out);
}
.gal-item:hover { transform: rotate(0deg) translateY(-3px); }
.gal-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 2px; }
.gal-open img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: rgba(59, 44, 53, 0.05); }
.gal-open:focus-visible { box-shadow: 0 0 0 2px #fbf6ec, 0 0 0 4px var(--color-ink); }
.gal-missing { display: grid; place-items: center; aspect-ratio: 4 / 5; font-size: var(--text-sm); color: var(--color-ink-soft); }
.gal-cap { margin-top: var(--space-2); color: var(--color-ink); }
.gal-title { display: block; font-family: var(--font-hand); font-size: 1.35rem; line-height: 1.15; }
.gal-meta { display: block; font-size: 0.75rem; color: var(--color-ink-soft); }
.gal-flash { margin-bottom: var(--space-4); text-align: center; color: var(--color-accent); }
.gal-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-5); margin-top: var(--space-7); }
.gal-foot .overlay-exit { margin-top: 0; }

/* ---- five ways in ---- */
.choices { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) and (min-width: 901px) {
  .choice { padding: var(--space-4); }
  .choice-desc { font-size: 0.82rem; }
}
@media (max-width: 900px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices .choice:last-child { grid-column: 1 / -1; }
  .sketch-shelf { flex-direction: column; text-align: center; }
  .sketch-side { text-align: center; }
  .sketch-actions { justify-content: center; }
}
@media (max-width: 640px) {
  .nav { gap: 0.15rem; }
  .nav a { padding: var(--space-2) 6px; font-size: 0.92rem; }
  .sketch-book { width: 180px; }
  .sb-page { --page-w: min(100%, calc((100dvh - 330px) * 0.8)); }
  .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-3); }
  .gal-title { font-size: 1.15rem; }
}
@media (max-width: 460px) {
  .sb-tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sb-tool { padding: 0 10px; }
  .sb-swatch { width: 32px; height: 32px; }
}
@media (max-width: 380px) {
  .nav a { font-size: 0.84rem; padding: var(--space-2) 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .sketch-book, .sketch-book:hover, .gal-item, .gal-item:hover { transform: none; transition: none; }
  .sb-dialog[open] { animation: none; }
  .sb-swatch, .sb-swatch:hover, .sb-swatch[aria-checked="true"] { transform: none; }
}
