/* ============================================================
   SPIDERSPERTS — velvet night on the water
   ============================================================ */
:root {
  --ink:        #0A0B0D;   /* matte black base */
  --ink-2:      #0E1013;
  --silk:       #C9CFDA;   /* strand + secondary text */
  --paper:      #EFF1F5;   /* primary text */
  --faint:      #8B92A0;
  --ember:      #F6871F;
  --ember-deep: #D9720E;
  --navy:       #1C2A4D;
  --hairline:   rgba(201, 207, 218, 0.10);
  --card-bg:    rgba(255, 255, 255, 0.025);
  --serif: "Fraunces", Georgia, serif;
  --sans:  "Outfit", "Avenir Next", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* panning only — no pinch zoom and no double-tap zoom anywhere on the site.
   iOS ignores user-scalable=no in the viewport tag, so this (plus the gesture
   handlers in silk.js) is what actually holds. */
html { scroll-behavior: smooth; touch-action: pan-x pan-y; }
body { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

/* ---------------------------------------------- atmosphere */
#silk {
  /* the fixed box IS the viewport — 100vw/100vh were a second, competing
     measurement, and on iOS they disagree with it (100vh can exclude the
     home-indicator strip), which left an unpainted band along the bottom */
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.fuzz {
  position: fixed; inset: -50%;
  z-index: 1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: screen;
}
.vignette {
  position: fixed; inset: 0;
  z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(28, 42, 77, 0.16), transparent 60%),
    radial-gradient(140% 120% at 50% 55%, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
}

main, .nav, .footer { position: relative; z-index: 2; }

/* ---------------------------------------------- type */
h1, h2, h3 { font-family: var(--serif); font-weight: 380; letter-spacing: 0.005em; }
h1 em, h2 em { font-style: italic; font-weight: 340; color: var(--silk); }

h1 { font-size: clamp(2.6rem, 6.4vw, 4.9rem); line-height: 1.06; }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.12; }
h3 { font-size: 1.35rem; line-height: 1.25; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ember);
}
.lede { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--silk); max-width: 34em; }
.prose { color: var(--silk); max-width: 38em; }
.prose.pull {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.45;
  color: var(--paper);
  border-left: 1px solid var(--ember);
  padding-left: 1.4rem;
}
.ember-line { color: var(--ember); }
.mono-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  display: inline-block;
  min-width: 8.5em;
}

/* ---------------------------------------------- nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex; align-items: center; gap: 2rem;
  /* clear the notch where the platform still hands us an inset (Safari with
     viewport-fit=cover); the installed app reserves the status bar itself */
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) clamp(1.2rem, 4vw, 3rem) 0.9rem;
  background: rgba(10, 11, 13, 0.72);
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(201, 207, 218, 0.06);
}
.nav-brand img { display: block; height: 42px; width: auto; }
.nav-links { display: flex; gap: 1.8rem; margin-left: auto; }
.nav-links a {
  color: var(--silk); text-decoration: none;
  font-size: 0.86rem; font-weight: 400; letter-spacing: 0.05em;
  transition: color 0.25s;
}
.nav-links a:hover { color: var(--paper); }

/* ---------------------------------------------- buttons */
.btn {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 0.78rem 1.7rem;
  border-radius: 10px;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s, border-color 0.25s;
}
.btn-primary {
  background: var(--ember);
  color: #14100A;
  box-shadow: 0 2px 22px rgba(246, 135, 31, 0.18);
}
.btn-primary:hover {
  background: #FF9530;
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(246, 135, 31, 0.3);
}
.btn-ghost {
  color: var(--paper);
  border: 1px solid rgba(201, 207, 218, 0.22);
  background: rgba(255, 255, 255, 0.015);
}
.btn-ghost:hover { border-color: rgba(201, 207, 218, 0.5); transform: translateY(-2px); }
.btn-sm { padding: 0.55rem 1.2rem; font-size: 0.84rem; }
.btn-lg { padding: 0.95rem 2.3rem; font-size: 1rem; }
.btn-block { display: block; text-align: center; margin-top: auto; }

/* ---------------------------------------------- hero */
.hero {
  min-height: 92vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 9rem clamp(1.2rem, 6vw, 5rem) 4rem;
  max-width: 1180px; margin: 0 auto;
}
.hero h1 { margin: 1.3rem 0 1.6rem; }
.cta-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 2.4rem; }
.hero-foot {
  display: flex; align-items: center; gap: 0.55rem;
  margin-top: 4.2rem;
  font-size: 0.82rem; color: var(--faint); letter-spacing: 0.06em;
}
.hero-foot .foot-item { white-space: nowrap; }
.hero-foot .tick { color: var(--ember); font-size: 0.8rem; }
.hero-foot .dot { color: rgba(201, 207, 218, 0.25); margin: 0 0.5rem; }

/* reveal choreography */
.reveal { opacity: 0; transform: translateY(18px); animation: rise 0.9s cubic-bezier(0.2, 0.65, 0.25, 1) forwards; }
.d1 { animation-delay: 0.12s; }
.d2 { animation-delay: 0.26s; }
.d3 { animation-delay: 0.4s; }
.d4 { animation-delay: 0.62s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------------------------------------------- sections */
/* sections breathe: with no dividers between them, the gap is the only thing
   separating one idea from the next, so it has to be generous */
section { padding: clamp(6rem, 12.5vh, 9.5rem) clamp(1.2rem, 6vw, 5rem); }
.section-head { max-width: 1180px; margin: 0 auto 3.2rem; }
.section-head h2 { margin-top: 1.1rem; }
.section-head .sub { color: var(--faint); margin-top: 0.9rem; }

.problem { display: flex; justify-content: center; }
.problem-inner { max-width: 720px; }
.problem h2 { margin: 1.1rem 0 1.4rem; }
.problem .prose { margin-bottom: 1.8rem; }

/* ---------------------------------------------- field footage */
.footage {
  position: relative;
  padding: 0;
  margin: clamp(1.5rem, 5vh, 3.5rem) 0;
}
.footage-frame { position: relative; }
.footage video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 74vh;
  object-fit: cover;
  object-position: 74% 50%;   /* the weaver works the right side of frame */
}
.footage-frame::before,
.footage-frame::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
}
.footage-frame::before {   /* melt the band into the velvet, top and bottom */
  background:
    linear-gradient(180deg, var(--ink) 0%, transparent 12%, transparent 86%, var(--ink) 100%);
}
.footage-frame::after {    /* and at the sides */
  background:
    linear-gradient(90deg, var(--ink) 0%, transparent 9%, transparent 91%, var(--ink) 100%);
}
.footage-caption {
  position: absolute;
  left: clamp(1.2rem, 6vw, 5rem);
  bottom: clamp(1.2rem, 5vh, 2.6rem);
  z-index: 1;
}
.footage-caption p:last-child {
  margin-top: 0.4rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  color: var(--paper);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.8);
}
@media (max-width: 700px) {
  /* the 3.6:1 band collapses to a sliver on phones — crop taller,
     framed on the weaver at the hub, caption beneath */
  .footage video {
    height: 46vh;
    max-height: 380px;
    /* phone window shows ~28% of the wide frame; the spider lives at
       ~63-95% of frame width, so pin the window over 62-90% */
    object-position: 86% 50%;
  }
  .footage-caption {
    position: static;
    padding: 1rem 1.2rem 0;
  }
  .footage-caption p:last-child { text-shadow: none; }
}

/* ---------------------------------------------- cards */
.card-grid {
  display: grid; gap: 1.6rem;
  max-width: 1180px; margin: 0 auto;
}
.card-grid.three { grid-template-columns: repeat(3, 1fr); }
.card-grid.two { grid-template-columns: repeat(2, 1fr); max-width: 900px; }

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 1.9rem 1.8rem 1.8rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 50px -28px rgba(0, 0, 0, 0.8);
  will-change: transform;
  transform-origin: 50% -60px;   /* hang from the silk threads above */
}
.card > p:last-of-type { color: var(--silk); font-size: 0.95rem; }
.card h3 { margin-bottom: 0.35rem; }

.pin {
  position: absolute; top: -4px; left: 50%;
  width: 7px; height: 7px; margin-left: -3.5px;
  border-radius: 50%;
  background: var(--silk);
  opacity: 0.55;
  box-shadow: 0 0 8px rgba(201, 207, 218, 0.5);
}

.card-num {
  font-family: var(--mono);
  font-size: 0.75rem; letter-spacing: 0.2em;
  color: var(--ember);
  margin-bottom: 1.2rem;
}
.card-tag {
  font-family: var(--mono);
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.9rem;
}

.badge {
  font-family: var(--mono);
  font-size: 0.66rem; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--silk);
  border: 1px solid rgba(201, 207, 218, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  align-self: flex-start;
  margin-bottom: 1.4rem;
}
.badge.ember { color: var(--ember); border-color: rgba(246, 135, 31, 0.45); }

.plan { padding-bottom: 2rem; }
.plan-body { color: var(--silk); margin-bottom: 1.4rem; }
.plan.flagship { border-color: rgba(246, 135, 31, 0.28); }
.features { list-style: none; margin-bottom: 2rem; }
.features li {
  position: relative;
  padding: 0.45rem 0 0.45rem 1.7rem;
  color: var(--silk); font-size: 0.95rem;
  border-bottom: 1px solid rgba(201, 207, 218, 0.05);
}
.features li:last-child { border-bottom: none; }
.features li::before {
  content: "✓";
  position: absolute; left: 0; top: 0.45rem;
  color: var(--ember);
  font-size: 0.85rem;
}

.note h3 { font-size: 1.18rem; }
.note p:last-of-type { font-size: 0.92rem; }

/* ---------------------------------------------- about */
.about { display: flex; justify-content: center; text-align: center; }
.about-inner { max-width: 640px; display: flex; flex-direction: column; align-items: center; }
.about-mark { margin-bottom: 1.6rem; filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.55)); }
.about h2 { margin: 1rem 0 1.3rem; }

/* ---------------------------------------------- closing */
.closing {
  text-align: center;
  padding-top: clamp(5rem, 12vh, 9rem);
  padding-bottom: clamp(5rem, 12vh, 9rem);
}
.closing h2 { font-size: clamp(2.3rem, 5vw, 3.8rem); }
.closing .lede { margin: 1.4rem auto 0; }
.closing .cta-row { justify-content: center; margin-top: 2.6rem; }
.contact-meta {
  margin: 3.4rem auto 0;
  display: inline-block;
  text-align: left;
  font-size: 0.95rem;
  color: var(--silk);
}
.contact-meta p { padding: 0.4rem 0; border-bottom: 1px solid rgba(201, 207, 218, 0.06); }
.contact-meta p:last-child { border-bottom: none; }

/* ---------------------------------------------- footer */
.footer {
  /* No rule above the footer, by design. The old full-width 1px border read
     as a stray line floating with nothing anchoring either end — the spacing
     alone separates the footer from the section above it. */
  padding: 2.6rem clamp(1.2rem, 6vw, 5rem);
  display: flex; align-items: center; gap: 1.2rem;
  color: var(--faint); font-size: 0.82rem; letter-spacing: 0.04em;
}
.footer img { opacity: 0.7; }
.footer .fine { margin-left: auto; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }

/* ---------------------------------------------- motion toggle */
#motion-toggle {
  position: fixed; bottom: 1rem; right: 1rem;
  z-index: 9;
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint);
  background: rgba(10, 11, 13, 0.7);
  border: 1px solid rgba(201, 207, 218, 0.14);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
#motion-toggle:hover { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }

/* ---------------------------------------------- responsive */
@media (max-width: 980px) {
  .card-grid.three { grid-template-columns: 1fr; max-width: 560px; }
  .card-grid.two { grid-template-columns: 1fr; max-width: 560px; }
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .nav { gap: 0.8rem; padding-left: 1rem; padding-right: 1rem; }
  /* the wordmark is a 7:1 lockup — at 36px tall it ate two thirds of a phone
     screen and left the bar looking oversized with nothing beside it */
  .nav-brand img { height: 30px; }
  .nav .btn-sm { display: none; }   /* hero CTA is immediately below */
  /* the nav is fixed and grows by the notch inset, so the hero's top padding
     has to include that inset or the eyebrow slides under the bar on a phone */
  .hero { min-height: 82vh; padding-top: calc(6.5rem + env(safe-area-inset-top, 0px)); }
  /* the headline set at 2.6rem forced "dock." onto its own line on a 390-440px
     screen; scaling with the viewport keeps the break where it was written */
  h1 { font-size: clamp(2.05rem, 8.6vw, 4.9rem); }
  /* the strip wrapped with "ONLY" orphaned on a line of its own — a little
     less tracking fits the whole line on any modern phone */
  .hero .eyebrow { font-size: 0.62rem; letter-spacing: 0.14em; }
  .hero-foot { flex-wrap: wrap; row-gap: 0.4rem; margin-top: 3rem; }
  .footer { flex-wrap: wrap; padding-bottom: 4.5rem; }   /* clear the motion pill */
  .footer .fine { margin-left: 0; }
  /* the pill is fixed over the page, so on a narrow screen it landed on top of
     section headings as they scrolled past — smaller and dimmer until touched */
  #motion-toggle {
    bottom: 0.6rem; right: 0.6rem;
    font-size: 0.55rem; padding: 0.34rem 0.7rem;
    opacity: 0.45;
  }
  #motion-toggle:active { opacity: 1; }
}

/* ---------------------------------------------- feed the spiders */
#feed-btn {
  user-select: none;
  -webkit-user-select: none;
  position: fixed; right: 0; top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  writing-mode: vertical-rl;
  font-family: var(--mono); font-size: 0.6rem; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--faint);
  background: rgba(10, 11, 13, 0.6);
  border: 1px solid rgba(201, 207, 218, 0.12); border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 0.95rem 0.34rem;
  opacity: 0.25;
  cursor: pointer;
  transition: opacity 0.3s, color 0.3s;
}
#feed-btn:hover, #feed-btn:focus-visible { opacity: 1; color: var(--ember); }
body.feeding #feed-btn { opacity: 0.9; color: var(--ember); }

body.fade-out .nav, body.fade-out main, body.fade-out .footer, body.fade-out #motion-toggle {
  opacity: 0;
  transition: opacity 0.45s ease;
}
body.feeding .nav, body.feeding main, body.feeding .footer, body.feeding #motion-toggle { display: none; }
body.feeding { overflow: hidden; overscroll-behavior: none; }
/* The play field used to sit brighter than the site (#12151B against the
   site's #0A0B0D), on the theory that near-black made the game a squint. It
   did two bad things. It snapped — the swap is instant while the site is
   still fading out, so crossing into the game flashed. And it worked against
   itself: the silk is LIGHT on dark, so lifting the background closes the gap
   between strand and field rather than opening it. A mid ring arc composites
   to 25 on the old black against a base of 10, and to 32 on the lighter field
   against a base of 18 — the same strand, roughly half the relative contrast.
   The field stays the site's black, and the silk reads better for it.
   Brightness of the lace itself has its own dial: SILK_GAIN in silk.js. */
/* the edges lift a little so webs in the corners are not crushed by the
   vignette — eased over the same beat as the curtain, so nothing pops */
.vignette { transition: opacity 0.45s ease; }
body.feeding .vignette { opacity: 0.62; }

@media (hover: none) {
  /* no hover on touch — the door needs to be findable and tappable */
  #feed-btn { opacity: 0.55; padding: 1.1rem 0.6rem; }
}

#feeder {
  --stow-gap: 3.6rem;   /* clears the vertical "back to the site" tab */
  user-select: none;
  -webkit-user-select: none;
  position: fixed; left: 50%; bottom: calc(4vh + env(safe-area-inset-bottom, 0px));
  /* width is pinned to the jar so it never changes: the hint is taken out
     of flow (below), so removing it can't resize the box mid-stow. That is
     what used to make the jar lurch and shrink as it walked to the corner —
     the stow transform reads 100% (this width), so it must stay constant. */
  width: 96px;
  transform: translateX(-50%);
  z-index: 12;
  text-align: center;
  transition: transform 0.75s cubic-bezier(0.34, 0.8, 0.3, 1);
}
/* the first fly out of the jar teaches the whole trick — the words and
   the arrow go for good and the jar walks itself into the corner, out of
   the way of the webs it is being emptied onto */
#feeder.stowed {
  transform: translateX(calc(50vw - 100% - var(--stow-gap))) translateY(0.6rem);
}
#feeder.stowed-instant { transition: none; }
/* two ways out for the hint: the first fed fly, or the 7-second bell */
#feeder.open.stowed .feeder-hint,
#feeder.open .feeder-hint.fade { animation: hint-out 0.4s ease forwards; }
/* the explicit "from" matters: swapping animations drops hint-in's fill,
   so without it the fade would start at the base opacity of 0 — a blink,
   not a bow */
@keyframes hint-out { from { opacity: 1; } to { opacity: 0; } }
#jar {
  position: relative;
  width: 96px; height: 120px;
  margin: 0 auto;
  cursor: grab;
  touch-action: none;
}
#jar:active { cursor: grabbing; }
#jar-glass { position: absolute; inset: 0; width: 96px; height: 120px; }
/* the tip-power recharge: an ember outline that climbs the jar as it fills */
#jar-charge {
  position: absolute; inset: 0; width: 96px; height: 120px; z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(246, 135, 31, 0.6));
  opacity: 0.85;
}
#jar.tip-ready { cursor: pointer; }
#jar.tip-ready #jar-charge { animation: charge-pulse 1.1s ease-in-out infinite; }
@keyframes charge-pulse {
  0%, 100% { opacity: 0.7; filter: drop-shadow(0 0 4px rgba(246, 135, 31, 0.6)); }
  50%      { opacity: 1;   filter: drop-shadow(0 0 11px rgba(246, 135, 31, 0.95)); }
}
#jar.tipping { animation: jar-tip 0.8s ease; transform-origin: 50% 90%; }
@keyframes jar-tip {
  0% { transform: rotate(0); }
  35% { transform: rotate(-46deg); }
  62% { transform: rotate(-46deg); }
  100% { transform: rotate(0); }
}
#jar-lid {
  position: absolute; top: -10px; left: 0;
  width: 96px; height: 20px;
  z-index: 2;
}
#feeder.open #jar-lid {
  animation: lid-off 1.05s cubic-bezier(0.3, 0.6, 0.4, 1) forwards;
}
@keyframes lid-off {
  to { transform: translate(130px, -170px) rotate(900deg); opacity: 0; }
}
/* the hint floats above the jar, out of flow, so it never contributes to
   the feeder's width (see #feeder) — centred over the jar in either spot */
.feeder-hint {
  position: absolute;
  left: 50%; bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  width: max-content;
  opacity: 0;
}
#feeder.open .feeder-hint { animation: hint-in 0.6s ease 1s forwards; }
@keyframes hint-in { to { opacity: 1; } }
.feeder-label {
  font-family: var(--mono); font-size: 0.68rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--silk);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
  margin-bottom: 0.45rem;
}
.feeder-arrow { width: 32px; color: var(--ember); display: block; margin: 0 auto; }

/* ---------------------------------------------- the colony's ledger */
/* pinned to the top of the screen in feed mode (the nav is hidden there),
   clear of the jar, the webs, and the phone notch */
#tally {
  position: fixed; z-index: 12;
  left: clamp(1.2rem, 4vw, 3rem);
  top: calc(1.1rem + env(safe-area-inset-top, 0px));
  font-family: var(--mono);
  user-select: none; -webkit-user-select: none; pointer-events: none;
  opacity: 0;
}
body.feeding #tally { animation: hint-in 0.8s ease 1.2s forwards; }
.tally-row { display: flex; align-items: baseline; gap: 0.55rem; line-height: 1.5; }
.tally-n {
  min-width: 2.4ch; text-align: right;
  font-size: 1.05rem; font-weight: 500;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}
/* a loss, not a bounty — a dimmer, cooler red sets it apart from "taken" */
.tally-row.loss .tally-n { color: #B5583C; }
.tally-k {
  font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--faint);
}
/* On a narrow screen four stacked rows ate a fifth of the field, so the
   ledger folds into a single row running along the top — counts reading
   left to right, stopped short of the gear's corner. (:not([hidden]) so
   the flex display never overrides the hidden attribute on the site.) */
@media (max-width: 740px) {
  #tally:not([hidden]) {
    display: flex; flex-wrap: wrap;
    align-items: baseline; column-gap: 1.1rem; row-gap: 0;
    left: 0.9rem; right: 4.6rem;
    top: calc(1rem + env(safe-area-inset-top, 0px));
  }
  .tally-row { gap: 0.4rem; line-height: 1.3; }
  .tally-n { min-width: 0; font-size: 0.82rem; }
  .tally-k { font-size: 0.5rem; letter-spacing: 0.12em; }
}
@media (max-width: 560px) {
  #tally:not([hidden]) { top: calc(0.9rem + env(safe-area-inset-top, 0px)); }
  .tally-n { font-size: 0.78rem; }
  .tally-k { font-size: 0.48rem; }
}

/* ---------------------------------------------- the level goal (feed mode) */
#goal {
  position: fixed; z-index: 12;
  top: calc(2.6vh + env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%);
  width: min(90vw, 30rem);
  text-align: center;
  font-family: var(--mono);
  user-select: none; -webkit-user-select: none; pointer-events: none;
  opacity: 0;
}
body.feeding #goal { animation: hint-in 0.8s ease 1.2s forwards; }
.goal-line {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--silk); line-height: 1.55;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85);
}
.goal-line #goal-need { color: var(--ember); font-weight: 500; }
.goal-bar {
  margin: 0.65rem auto 0; height: 3px; width: 100%;
  background: rgba(201, 207, 218, 0.12);
  border-radius: 2px; overflow: hidden;
}
.goal-bar > span {
  display: block; height: 100%; width: 0%;
  background: var(--ember);
  box-shadow: 0 0 10px rgba(246, 135, 31, 0.6);
  transition: width 0.5s ease;
}
.goal-sub {
  margin-top: 0.5rem;
  font-size: 0.56rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--faint);
}
.goal-sub #goal-have { color: var(--ember); font-variant-numeric: tabular-nums; }
/* On a narrow screen the goal is a strip, not a band: the quest line and
   its bar tuck directly under the one-row ledger, and the sub-line —
   whose facts the quest line and the bar already tell — stands down.
   The whole HUD is two short lines and a hairline of progress. */
@media (max-width: 740px) {
  #goal { top: calc(3.7rem + env(safe-area-inset-top, 0px)); }
  .goal-bar { margin-top: 0.45rem; }
  .goal-sub { display: none; }
}
@media (max-width: 560px) {
  .goal-line { font-size: 0.6rem; letter-spacing: 0.08em; }
  /* the ledger row is a touch shorter here — tuck the goal up with it */
  #goal { top: calc(3.3rem + env(safe-area-inset-top, 0px)); }
}

/* ---------------------------------------------- sound settings (feed mode) */
/* The gear mirrors the ledger across the top of the field. It has to sit
   above the game-over and win curtains (z 20) so the music can still be
   turned down while one of them is up. */
#settings-btn {
  position: fixed; z-index: 22;
  top: calc(1.1rem + env(safe-area-inset-top, 0px));
  right: clamp(1.2rem, 4vw, 3rem);
  width: 2.3rem; height: 2.3rem;
  display: grid; place-items: center;
  color: var(--faint);
  background: rgba(10, 11, 13, 0.7);
  border: 1px solid rgba(201, 207, 218, 0.14);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
#settings-btn[hidden] { display: none; }
#settings-btn:hover, #settings-btn:focus-visible { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }
#settings-btn[aria-expanded="true"] { color: var(--ember); border-color: rgba(246, 135, 31, 0.45); }
#settings-btn svg { width: 1.15rem; height: 1.15rem; display: block; }
#settings-btn .gear { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
/* the slash only appears once everything is off, so the button reads its
   own state from across the screen */
#settings-btn .gear-slash {
  stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
  opacity: 0; transition: opacity 0.2s;
}
#settings-btn.muted { color: #B5583C; }
#settings-btn.muted .gear-slash { opacity: 1; }

#settings {
  position: fixed; z-index: 22;
  top: calc(4.1rem + env(safe-area-inset-top, 0px));
  right: clamp(1.2rem, 4vw, 3rem);
  width: 15.5rem;
  padding: 1rem 1.05rem 0.9rem;
  font-family: var(--mono);
  background: rgba(10, 11, 13, 0.92);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid rgba(201, 207, 218, 0.16);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
#settings[hidden] { display: none; }
#settings.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.set-title {
  font-size: 0.58rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 0.85rem;
}
.set-row {
  display: grid; grid-template-columns: 4.1rem 1fr 2.6rem;
  align-items: center; gap: 0.55rem;
  margin-bottom: 0.7rem;
}
.set-row label {
  font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--silk);
}
.set-val {
  font-size: 0.6rem; text-align: right;
  color: var(--faint); font-variant-numeric: tabular-nums;
}
/* the slider is drawn by hand — the native control is a different shape and
   colour in every browser, and none of them are this one */
.set-row input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px;
  background: transparent; cursor: pointer;
}
.set-row input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: rgba(201, 207, 218, 0.16);
}
.set-row input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px;
  background: rgba(201, 207, 218, 0.16);
}
.set-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -4.5px;
  border-radius: 50%; border: none;
  background: var(--ember);
  box-shadow: 0 0 8px rgba(246, 135, 31, 0.55);
}
.set-row input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%; border: none;
  background: var(--ember);
  box-shadow: 0 0 8px rgba(246, 135, 31, 0.55);
}
.set-row input[type="range"]:focus-visible { outline: 1px solid rgba(246, 135, 31, 0.6); outline-offset: 4px; }
#mute-all, #howto-btn {
  width: 100%; margin-top: 0.35rem;
  font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--faint);
  background: transparent;
  border: 1px solid rgba(201, 207, 218, 0.14);
  border-radius: 8px; padding: 0.5rem 0.6rem;
  cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
#mute-all:hover, #mute-all:focus-visible,
#howto-btn:hover, #howto-btn:focus-visible { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }
#mute-all[aria-pressed="true"] { color: var(--ember); border-color: rgba(246, 135, 31, 0.45); }
/* the second shelf in the panel: the guide sits below the sound rows */
.howto-set-title { margin: 1.05rem 0 0.15rem; }
/* On a phone the goal has moved to its own band below the top row (see
   #goal), so the corner is free again — the gear sits in it, mirroring
   the ledger across the top of the screen. */
@media (max-width: 560px) {
  #settings-btn {
    top: calc(0.9rem + env(safe-area-inset-top, 0px));
    right: 0.9rem;
    width: 2.1rem; height: 2.1rem;
  }
  #settings {
    top: calc(3.6rem + env(safe-area-inset-top, 0px));
    right: 0.9rem;
    width: min(15.5rem, calc(100vw - 1.8rem));
  }
}
/* the first-visit arrow to the gear — the jar hint's twin, aimed up.
   Fixed beneath the gear and right-aligned to it, in both gear homes. */
#gear-hint {
  position: fixed; z-index: 22;
  top: calc(1.1rem + env(safe-area-inset-top, 0px) + 2.7rem);
  right: clamp(1.2rem, 4vw, 3rem);
  width: max-content;
  text-align: right;
  opacity: 0;
  pointer-events: none;
}
#gear-hint[hidden] { display: none; }
#gear-hint.show { animation: hint-in 0.6s ease 1.4s forwards; }
/* the lesson has a clock: after a dozen seconds it bows out on its own
   (hint-out itself lives with the jar hint, up by #feeder) */
#gear-hint.fade { animation: hint-out 0.7s ease forwards; }
.gear-hint-arrow {
  width: 32px; color: var(--ember);
  display: block; margin: 0 0.15rem 0.45rem auto;
}
.gear-hint-label {
  font-family: var(--mono); font-size: 0.68rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--silk);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}
@media (max-width: 560px) {
  /* the narrow-screen gear moved up into the corner (top 0.9rem — see
     #settings-btn above); this offset still pointed at its OLD home below
     the HUD, so the arrow floated mid-field aiming at nothing. Beneath
     the gear means beneath the gear in both homes. */
  #gear-hint {
    top: calc(3.2rem + env(safe-area-inset-top, 0px));
    right: 0.9rem;
  }
  .gear-hint-arrow { margin-right: 0.05rem; }
}
/* the panel is a menu, not scenery — it stays put when motion is off */
@media (prefers-reduced-motion: reduce) {
  #settings { transition: opacity 0.01s, visibility 0.01s; transform: none; }
  #gear-hint.show { animation: none; opacity: 1; }
  #gear-hint.fade { animation: none; opacity: 0; }
}

/* ---------------------------------------------- fleeting notices */
#toast {
  position: fixed; z-index: 13;
  top: calc(13vh + env(safe-area-inset-top, 0px));
  left: 50%;
  font-family: var(--mono); font-size: 0.68rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ember);
  background: rgba(10, 11, 13, 0.82);
  border: 1px solid rgba(246, 135, 31, 0.35);
  border-radius: 10px; padding: 0.55rem 1rem;
  pointer-events: none; opacity: 0;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
  transform: translateX(-50%);
}
#toast.show { animation: toast-pop 2.6s ease forwards; }
/* on narrow screens the toast pops just under the compact HUD strip
   (see #goal) rather than into it */
@media (max-width: 740px) {
  #toast { top: calc(6.2rem + env(safe-area-inset-top, 0px)); }
}
@keyframes toast-pop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  82%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* ---------------------------------------------- game over */
#gameover {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(6, 7, 9, 0.88);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0;
}
/* an explicit display overrides the hidden attribute — restore it so the
   overlay never covers the screen (and eats taps) while it is hidden */
#gameover[hidden] { display: none; }
#gameover.show { animation: hint-in 0.6s ease forwards; }
.go-panel { text-align: center; max-width: 27rem; padding: 2rem 1.6rem; }
.go-eyebrow {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 0.9rem;
}
.go-title {
  font-family: var(--serif); font-style: italic; font-weight: 340;
  font-size: clamp(2.4rem, 9vw, 3.6rem); color: var(--ember);
  letter-spacing: 0.01em; line-height: 1; margin-bottom: 1.1rem;
}
.go-msg {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.7;
  color: var(--silk); margin: 0 auto 1.9rem; max-width: 24rem;
}
#restart-btn {
  font-family: var(--mono); font-size: 0.72rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink); background: var(--ember);
  border: none; border-radius: 10px; padding: 0.9rem 1.7rem;
  cursor: pointer; transition: background 0.25s, transform 0.15s;
}
#restart-btn:hover, #restart-btn:focus-visible {
  background: var(--ember-deep); transform: translateY(-1px);
}

/* ---------------------------------------------- victory */
#win {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(6, 7, 9, 0.9);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0;
}
#win[hidden] { display: none; }
#win.show { animation: hint-in 0.6s ease forwards; }
.win-eyebrow { color: var(--ember); }
.win-title { color: var(--silk); }
#winagain-btn, #hamlet-btn {
  font-family: var(--mono); font-size: 0.72rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink); background: var(--ember);
  border: none; border-radius: 10px; padding: 0.9rem 1.7rem;
  cursor: pointer; transition: background 0.25s, transform 0.15s;
}
#winagain-btn:hover, #winagain-btn:focus-visible,
#hamlet-btn:hover, #hamlet-btn:focus-visible {
  background: var(--ember-deep); transform: translateY(-1px);
}
/* the playbill button leads; Play again waits beneath it, quieter */
#hamlet-btn { display: block; margin: 0 auto 0.8rem; }
#winagain-btn {
  background: transparent; color: var(--silk);
  border: 1px solid rgba(201, 207, 218, 0.35);
}
#winagain-btn:hover, #winagain-btn:focus-visible {
  background: rgba(201, 207, 218, 0.12); color: var(--silk);
}

/* ---------------------------------------------- the field guide */
/* A deck of flash cards, dealt from the gear. It sits above the game-over
   and win curtains (z 20) and above the gear itself (z 22): while the
   guide is open the pointer belongs to the guide, not the field. */
#howto {
  position: fixed; inset: 0; z-index: 23;
  display: grid; place-items: center;
  padding: calc(1.2rem + env(safe-area-inset-top, 0px)) 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 7, 9, 0.9);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0;
}
#howto[hidden] { display: none; }
#howto.show { animation: hint-in 0.45s ease forwards; }
.howto-frame {
  width: min(33rem, 100%);
  /* a short viewport (a phone on its side) must never put Next out of
     reach — the frame caps at the padded screen and scrolls inside */
  max-height: 100%;
  overflow-y: auto;
  background: rgba(10, 11, 13, 0.92);
  border: 1px solid rgba(201, 207, 218, 0.16);
  border-radius: 14px;
  padding: 1rem 1.15rem 0.9rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.howto-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.8rem;
}
.howto-eyebrow {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--faint);
}
#howto-count { color: var(--silk); font-variant-numeric: tabular-nums; }
#howto-close {
  width: 2rem; height: 2rem; flex: 0 0 auto;
  display: grid; place-items: center;
  color: var(--faint); background: transparent;
  border: 1px solid rgba(201, 207, 218, 0.14);
  border-radius: 999px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#howto-close svg { width: 0.85rem; height: 0.85rem; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#howto-close:hover, #howto-close:focus-visible { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }
.howto-card { display: none; }
.howto-card.current { display: block; animation: card-turn 0.4s ease; }
@keyframes card-turn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
/* the photograph: letterboxed on near-black, so every aspect fits without
   a visible seam against the frame */
.howto-shot {
  height: clamp(190px, 34vh, 320px);
  border: 1px solid var(--hairline);
  border-radius: 10px; overflow: hidden;
  background: #060709;
}
.howto-shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.howto-kicker {
  font-family: var(--serif); font-style: italic; font-weight: 340;
  font-size: clamp(1.4rem, 4.6vw, 1.8rem); color: var(--ember);
  line-height: 1.1; margin: 0.95rem 0 0.55rem;
}
.howto-text {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.75;
  color: var(--silk);
  min-height: 6.4rem;   /* five lines — the controls hold still card to card */
}
.howto-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; margin-top: 0.9rem;
}
#howto-prev, #howto-pause, #howto-next {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  border-radius: 8px; padding: 0.55rem 1rem; cursor: pointer;
}
#howto-prev, #howto-pause {
  color: var(--faint); background: transparent;
  border: 1px solid rgba(201, 207, 218, 0.14);
  transition: color 0.2s, border-color 0.2s;
}
#howto-prev:hover, #howto-prev:focus-visible,
#howto-pause:hover, #howto-pause:focus-visible { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }
#howto-prev[disabled] { opacity: 0.35; pointer-events: none; }
/* the pause is a held breath, not a setting — ember while it holds. The
   fixed width keeps the deck's center still when the label flips */
#howto-pause { min-width: 6.2rem; }
#howto-pause[aria-pressed="true"] { color: var(--ember); border-color: rgba(246, 135, 31, 0.45); }
/* focus rings in the house ember, like the sound sliders — not UA blue */
#howto-close:focus-visible, #howto-prev:focus-visible,
#howto-pause:focus-visible, #howto-next:focus-visible {
  outline: 1px solid rgba(246, 135, 31, 0.6); outline-offset: 3px;
}
#howto-next {
  color: var(--ink); background: var(--ember);
  border: 1px solid transparent;
  transition: background 0.25s, transform 0.15s;
}
#howto-next:hover, #howto-next:focus-visible { background: var(--ember-deep); transform: translateY(-1px); }
.howto-dots { display: flex; gap: 0.38rem; flex-wrap: wrap; justify-content: center; margin-top: 0.7rem; }
.howto-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(201, 207, 218, 0.22);
}
.howto-dots span.on { background: var(--ember); box-shadow: 0 0 6px rgba(246, 135, 31, 0.6); }
/* the slow clock: a thread of ember filling while the card is held */
.howto-timer {
  height: 2px; border-radius: 2px; overflow: hidden;
  margin-top: 0.85rem;
  background: rgba(201, 207, 218, 0.1);
}
#howto-timer-fill {
  display: block; height: 100%; width: 0%;
  background: var(--ember);
  transition: width 0.14s linear;
}
.howto-timer.done { opacity: 0; }  /* the last card waits for no one */
@media (max-width: 560px) {
  #howto { padding: calc(0.8rem + env(safe-area-inset-top, 0px)) 0.8rem calc(0.8rem + env(safe-area-inset-bottom, 0px)); }
  .howto-frame { padding: 0.85rem 0.9rem 0.8rem; }
  .howto-shot { height: clamp(150px, 26vh, 240px); }
  .howto-text { font-size: 0.68rem; min-height: 7rem; }
}
/* a phone on its side: shrink the photograph and let the text run free so
   the card mostly fits, with the frame's own scroll catching the rest */
@media (max-height: 540px) {
  .howto-shot { height: max(110px, 30vh); }
  .howto-text { min-height: 0; }
}
/* cards are read, not watched — motion off stills the deck and its clock,
   and with no clock there is nothing for a pause button to hold */
@media (prefers-reduced-motion: reduce) {
  #howto.show { animation-duration: 0.01s; }
  .howto-card.current { animation: none; }
  .howto-timer, #howto-pause { display: none; }
}

/* ---------------------------------------------- first visit */
/* One card, once, above everything but the Lurker: the browser is the
   large world, the installed dock the small one. z 24 clears the guide. */
#firstrun {
  position: fixed; inset: 0; z-index: 24;
  display: grid; place-items: center;
  padding: calc(1.2rem + env(safe-area-inset-top, 0px)) 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 7, 9, 0.92);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0;
}
#firstrun[hidden] { display: none; }
#firstrun.show { animation: hint-in 0.45s ease forwards; }
.firstrun-frame {
  width: min(30rem, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: rgba(10, 11, 13, 0.92);
  border: 1px solid rgba(201, 207, 218, 0.16);
  border-radius: 14px;
  padding: 1.2rem 1.3rem 1.15rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.firstrun-title {
  font-family: var(--serif); font-style: italic; font-weight: 340;
  font-size: clamp(1.6rem, 5vw, 2.1rem); color: var(--ember);
  line-height: 1.1; margin: 0.6rem 0 0.8rem;
}
.firstrun-text {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.75;
  color: var(--silk); margin-bottom: 0.85rem;
}
.firstrun-text em { font-style: normal; color: var(--paper); }
.firstrun-controls { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.35rem; }
#firstrun-install, #firstrun-continue {
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  border-radius: 8px; padding: 0.6rem 1.1rem; cursor: pointer;
}
#firstrun-install {
  color: var(--ink); background: var(--ember); border: 1px solid transparent;
  transition: background 0.25s, transform 0.15s;
}
#firstrun-install:hover, #firstrun-install:focus-visible { background: var(--ember-deep); transform: translateY(-1px); }
#firstrun-continue {
  color: var(--faint); background: transparent;
  border: 1px solid rgba(201, 207, 218, 0.14);
  transition: color 0.2s, border-color 0.2s;
}
#firstrun-continue:hover, #firstrun-continue:focus-visible { color: var(--paper); border-color: rgba(201, 207, 218, 0.4); }
/* with no live install prompt, Continue is the only door — dress it ember */
#firstrun-install[hidden] + #firstrun-continue {
  color: var(--ink); background: var(--ember); border-color: transparent;
  transition: background 0.25s, transform 0.15s;
}
#firstrun-install[hidden] + #firstrun-continue:hover,
#firstrun-install[hidden] + #firstrun-continue:focus-visible {
  background: var(--ember-deep); color: var(--ink); transform: translateY(-1px);
}
#firstrun-install:focus-visible, #firstrun-continue:focus-visible {
  outline: 1px solid rgba(246, 135, 31, 0.6); outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  #firstrun.show { animation-duration: 0.01s; }
}

#jar-flies { position: absolute; inset: 0; z-index: 1; }
.jfly {
  position: absolute;
  width: 5px; height: 4px;
  border-radius: 50%;
  background: #78808F;
  animation: jfly-jig 1.1s ease-in-out infinite alternate, jfly-drift 3.2s ease-in-out infinite alternate;
}
.jfly::before, .jfly::after {
  content: "";
  position: absolute; top: -2px;
  width: 4px; height: 2.5px;
  border-radius: 50%;
  background: rgba(190, 196, 210, 0.4);
}
.jfly::before { left: -2.5px; transform: rotate(-30deg); }
.jfly::after { right: -2.5px; transform: rotate(30deg); }
@keyframes jfly-jig { from { transform: translate(-1.5px, 1px); } to { transform: translate(1.5px, -2px); } }
@keyframes jfly-drift { from { margin-left: -5px; } to { margin-left: 5px; } }

#drag-fly {
  position: fixed; left: 0; top: 0;
  width: 12px; height: 10px;
  z-index: 13;
  pointer-events: none;
}
#drag-fly::before {
  content: "";
  position: absolute; left: 3px; top: 4px;
  width: 6px; height: 4.5px;
  border-radius: 50%;
  background: #838B9B;
}
#drag-fly .wing {
  position: absolute; top: 1px;
  width: 6px; height: 3.5px;
  border-radius: 50%;
  background: rgba(200, 206, 220, 0.5);
  transform-origin: 100% 100%;
  animation: wing-buzz 0.09s linear infinite alternate;
}
#drag-fly .wing.w1 { left: -1px; }
#drag-fly .wing.w2 { right: -1px; transform-origin: 0% 100%; animation-delay: 0.045s; }
@keyframes wing-buzz { from { transform: rotate(-24deg); } to { transform: rotate(20deg); } }

@media (max-width: 560px) {
  #feed-btn { font-size: 0.55rem; padding: 0.7rem 0.28rem; }
  #feeder { bottom: 3vh; --stow-gap: 2.8rem; }
}

/* ---------------------------------------------- power-ups: gold, dew, moth */
/* the golden fly — an ember jewel among the six in the glass */
.jfly.gold {
  background: var(--ember);
  box-shadow: 0 0 6px 2px rgba(246, 135, 31, 0.45);
}
.jfly.gold::before, .jfly.gold::after { background: rgba(255, 205, 150, 0.55); }
#drag-fly.gold::before {
  background: var(--ember);
  box-shadow: 0 0 8px 2px rgba(246, 135, 31, 0.5);
}
#drag-fly.gold .wing { background: rgba(255, 205, 150, 0.6); }

/* the dew — a droplet gathering at the foot of the screen. The water level
   IS the meter: every fly the colony takes runs down into it, and a full
   drop can be lifted off and hung on a web. */
#dewdrop {
  position: fixed;
  left: calc(2.6rem + env(safe-area-inset-left, 0px));
  bottom: calc(4vh + env(safe-area-inset-bottom, 0px));
  width: 44px; height: 60px;
  z-index: 12;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.55s ease;
}
#dewdrop.open { opacity: 1; }
.dew-shape {
  display: block;
  width: 44px; height: 60px;
  overflow: visible;
  transform-origin: 50% 70%;
}
/* a full drop is heavy and lit — and it says so */
#dewdrop.full { cursor: grab; }
#dewdrop.full:active { cursor: grabbing; }
#dewdrop.full .dew-shape {
  filter: drop-shadow(0 0 8px rgba(174, 208, 246, 0.5));
  animation: dew-swell 2.8s ease-in-out infinite;
}
@keyframes dew-swell {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.075); }
}
/* while it is in hand the drop is gone from the sill */
#dewdrop.carrying { opacity: 0.25; }
#dewdrop.carrying .dew-shape { animation: none; filter: none; }
.dew-glint { opacity: 0; transition: opacity 0.9s ease; }
#dewdrop.full .dew-glint { opacity: 1; }
#dew-fill-rect { transition: y 0.6s ease, height 0.6s ease; }
/* the lesson, and only once it can actually be acted on */
.dew-hint {
  position: absolute;
  left: 50%; bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  width: max-content;
  font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: #B9D3EF;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition: opacity 0.55s ease;
  pointer-events: none;
}
#dewdrop.full .dew-hint { opacity: 1; }
#dewdrop.carrying .dew-hint { opacity: 0; }
/* small screens: the drop tucks into the corner and shrinks with the rest.
   This has to sit AFTER the rules above — same specificity, later wins. */
@media (max-width: 560px) {
  #dewdrop {
    bottom: 3vh;
    left: calc(1.1rem + env(safe-area-inset-left, 0px));
    width: 34px; height: 46px;
  }
  .dew-shape { width: 34px; height: 46px; }
  .dew-hint { font-size: 0.52rem; letter-spacing: 0.12em; }
}

/* the drop in hand — a real bead of water, big enough to aim with */
#drag-fly.dew::before {
  left: 0; top: -3px;
  width: 13px; height: 16px;
  border-radius: 50% 50% 52% 52% / 62% 62% 40% 40%;
  background: radial-gradient(circle at 34% 62%, rgba(255, 255, 255, 0.95), rgba(156, 192, 228, 0.75) 52%, rgba(94, 130, 180, 0.7));
  box-shadow: 0 0 8px rgba(174, 208, 246, 0.5);
}
#drag-fly.dew .wing { display: none; }

/* the refill timer: an emptied jar glows warmer until it tips new flies in */
.jar-glow {
  position: absolute;
  inset: -8px -6px -6px;
  border-radius: 18px 18px 24px 24px;
  background: radial-gradient(ellipse at 50% 60%, rgba(246, 135, 31, 0.5), rgba(246, 135, 31, 0.12) 60%, transparent 78%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s linear;
  z-index: 0;
  filter: blur(2px);
}

/* the moth alarm: the flies in the jar feel it coming and panic */
#jar-flies.panic .jfly { animation-duration: 0.35s, 1.1s; }

@media (prefers-reduced-motion: reduce) {
  #dewdrop.full .dew-shape { animation: none; }
  #dew-fill-rect { transition: none; }
  #jar-flies.panic .jfly { animation: none; }
}

/* ---------------------------------------------- the lurker */
/* A hand rises from below, winds up, and HURLS a golden orb-weaver
   straight at the viewer — it tumbles in, fills the screen at impact
   (with the shake + shriek), then drops away. Two animated layers:
   .scare-arm (the thrower) and .scare-spider (the projectile). */
#scare {
  position: fixed; inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
  background: rgba(0, 0, 0, 0);
}
#scare.on { animation: scare-dark 2.4s ease-out forwards; }
@keyframes scare-dark {
  0%   { background: rgba(0, 0, 0, 0); }
  10%  { background: rgba(0, 0, 0, 0.15); }
  30%  { background: rgba(0, 0, 0, 0.55); }
  52%  { background: rgba(0, 0, 0, 0.82); }
  72%  { background: rgba(0, 0, 0, 0.62); }
  100% { background: rgba(0, 0, 0, 0); }
}

/* the throwing arm — rises from the bottom, cocks back, whips forward */
.scare-arm {
  position: absolute;
  left: 50%; bottom: 0;
  width: auto; height: 116vh;
  transform-origin: 50% 100%;
  transform: translate(calc(-50% + var(--ax, 0px)), 116%) rotate(-6deg);
  opacity: 0;
  filter: drop-shadow(0 8px 40px rgba(0, 0, 0, 0.85));
}
#scare.on .scare-arm { animation: scare-throw-arm 2.4s cubic-bezier(0.22, 0.9, 0.25, 1) forwards; }
@keyframes scare-throw-arm {
  0%   { transform: translate(calc(-50% + var(--ax,0px)), 116%) rotate(-6deg); opacity: 0; }
  6%   { opacity: 1; }
  16%  { transform: translate(calc(-50% + var(--ax,0px)), 40%) rotate(-16deg); opacity: 1; }
  26%  { transform: translate(calc(-50% + var(--ax,0px)), 44%) rotate(-24deg); opacity: 1; }  /* full cock */
  37%  { transform: translate(calc(-50% + var(--ax,0px)), 20%) rotate(26deg); opacity: 1; }   /* WHIP / release */
  48%  { transform: translate(calc(-50% + var(--ax,0px)), 34%) rotate(15deg); opacity: 1; }   /* follow-through */
  70%  { transform: translate(calc(-50% + var(--ax,0px)), 78%) rotate(4deg); opacity: 0.9; }
  100% { transform: translate(calc(-50% + var(--ax,0px)), 120%) rotate(-4deg); opacity: 0; }
}
/* the perched spider vanishes at the instant of release */
#scare.on .scare-arm #perched { animation: perched-release 2.4s linear forwards; }
@keyframes perched-release { 0%, 30% { opacity: 1; } 36%, 100% { opacity: 0; } }

/* the hurled spider — launches from the hand, tumbles across, fills the
   screen fangs-first at impact, then drops away below */
.scare-spider {
  position: absolute;
  left: 50%; top: 50%;
  width: min(150vmin, 1100px);
  height: auto;
  transform-origin: 50% 50%;
  transform: translate(calc(-50% + 24vw), calc(-50% + 20vh)) scale(0.12) rotate(-14deg);
  opacity: 0;
  filter: drop-shadow(0 0 50px rgba(0, 0, 0, 0.85));
}
#scare.on .scare-spider { animation: scare-hurl 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
@keyframes scare-hurl {
  0%, 30% { transform: translate(calc(-50% + 24vw), calc(-50% + 20vh)) scale(0.12) rotate(-14deg); opacity: 0; }
  35%     { transform: translate(calc(-50% + 22vw), calc(-50% + 8vh)) scale(0.22) rotate(20deg); opacity: 1; }  /* leaves the hand */
  45%     { transform: translate(calc(-50% + 9vw),  calc(-50% - 2vh)) scale(0.58) rotate(212deg); opacity: 1; } /* tumbling across */
  56%     { transform: translate(-50%, calc(-50% - 2vh)) scale(1.24) rotate(374deg); opacity: 1; }             /* IMPACT — fills the screen */
  64%     { transform: translate(-50%, calc(-50% + 0vh)) scale(1.00) rotate(380deg); opacity: 1; }             /* recoil, whole spider in view */
  72%     { transform: translate(-50%, calc(-50% - 1vh)) scale(1.08) rotate(385deg); opacity: 1; }
  100%    { transform: translate(-50%, calc(-50% + 84vh)) scale(0.42) rotate(414deg); opacity: 0; }            /* drops away */
}
body.scare-shake { animation: scare-shake 0.55s linear; }
@keyframes scare-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-12px, 8px); }
  20% { transform: translate(11px, -6px); }
  30% { transform: translate(-9px, -9px); }
  40% { transform: translate(9px, 7px); }
  50% { transform: translate(-7px, 5px); }
  60% { transform: translate(6px, -5px); }
  70% { transform: translate(-5px, 3px); }
  80% { transform: translate(4px, -3px); }
  90% { transform: translate(-2px, 2px); }
}
@media (prefers-reduced-motion: reduce) {
  /* no lunge, no shake, no tumble — the spider just looms and fades,
     centred and still, so the scare still reads without motion */
  #scare.on { animation: scare-dark-soft 2s ease-out forwards; }
  @keyframes scare-dark-soft { 0% { background: rgba(0,0,0,0); } 25% { background: rgba(0,0,0,0.5); } 100% { background: rgba(0,0,0,0); } }
  .scare-arm { display: none; }
  .scare-spider {
    transform: translate(-50%, -50%) scale(0.82) rotate(0deg);
  }
  #scare.on .scare-spider { animation: scare-fade 2s ease-out forwards; }
  @keyframes scare-fade {
    0%   { transform: translate(-50%, -50%) scale(0.82); opacity: 0; }
    20%  { transform: translate(-50%, -50%) scale(0.82); opacity: 1; }
    75%  { transform: translate(-50%, -50%) scale(0.82); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.82); opacity: 0; }
  }
  #scare.on .scare-arm { animation: none; }
  body.scare-shake { animation: none; }
}

/* ---------------------------------------------- print */
@media print {
  :root {
    --ink: #fff; --ink-2: #fff;
    --paper: #000; --silk: #333; --faint: #555;
    --ember: #B35D00; --navy: #1C2A4D;
    --card-bg: transparent;
    --hairline: rgba(0, 0, 0, 0.25);
  }
  body { background: #fff; color: #000; }
  #silk, .fuzz, .vignette, .nav, #motion-toggle { display: none; }
  .card { box-shadow: none; backdrop-filter: none; }
  .btn-primary { box-shadow: none; color: #000; }
  .hero { min-height: 0; padding-top: 2rem; }
  .reveal { animation: none; opacity: 1; transform: none; }
}

/* ---------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { animation: none; opacity: 1; transform: none; }
  .btn, .nav-links a { transition: none; }
  #feeder { transition: none; }
  #feeder.open #jar-lid { animation: none; opacity: 0; }
  #feeder.open .feeder-hint { animation: none; opacity: 1; }
  #feeder.open.stowed .feeder-hint { animation: none; opacity: 0; }
  body.feeding #tally { animation: none; opacity: 1; }
  .jfly, #drag-fly .wing { animation: none; }
}
