/* ───────────────────────────────────────────────────────────────
   The Unbinding — 8-bit garden labyrinth astro zine
   Palette: readable pixel garden, mint, rose, canary, lavender
   ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #cfe8af;
  --bg-2:      #fff4c9;
  --ink:       #173c2b;
  --ink-mute:  #3f5a43;
  --teal:      #0f8f64;
  --fuchsia:   #d92786;
  --yellow:    #f5c928;
  --peri:      #5467c9;
  --soft:      #d9edbc;
  --panel:     #fff9df;
  --panel-hi:  #f3edc4;
  --readable:  #173c2b;
  --line:      rgba(39,103,73,.28);

  --shadow-teal:    0 2px 0 #b8f1d0, 0 0 10px rgba(15,143,100,.32);
  --shadow-fuchsia: 0 2px 0 #ffd1e9, 0 0 10px rgba(217,39,134,.30);
  --shadow-yellow:  0 2px 0 #fff5a8, 0 0 10px rgba(245,201,40,.42);
  --shadow-peri:    0 2px 0 #dce2ff, 0 0 10px rgba(84,103,201,.28);

  --font-pixel: "Press Start 2P", "VT323", monospace;
  --font-zine:  "VT323", "Press Start 2P", monospace;
  --font-ui:    "Space Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100%;
  overflow-x: hidden;
  scroll-padding-top: 96px;
}

body {
  background:
    radial-gradient(900px 520px at 22% 8%, rgba(255,249,223,.78) 0%, transparent 58%),
    radial-gradient(760px 500px at 80% 80%, rgba(255,214,235,.50) 0%, transparent 60%),
    repeating-linear-gradient(0deg, rgba(15,143,100,.12) 0 4px, transparent 4px 32px),
    repeating-linear-gradient(90deg, rgba(39,103,73,.12) 0 4px, transparent 4px 32px),
    var(--bg);
}

/* image rendering for crisp pixel art */
img { image-rendering: pixelated; image-rendering: crisp-edges; }
img.chart-img { image-rendering: auto; }

a { color: var(--teal); }
button { font-family: var(--font-pixel); }

/* ── starfield canvas ── */
#starfield {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
  opacity: .24;
  mix-blend-mode: multiply;
}

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
  background: linear-gradient(180deg, rgba(31,94,61,.96), rgba(31,94,61,.78) 78%, transparent);
  backdrop-filter: blur(6px);
}
.logo {
  display: flex; align-items: center; gap: 12px;
}
.logo-frame,
.cover-logo-frame {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 45% 42%, #fff9df 0 48%, #54d5d7 49% 58%, #173c2b 59% 64%, transparent 65%),
    #fff9df;
  border: 3px solid #54d5d7;
  box-shadow:
    0 0 0 3px rgba(255,249,223,.72),
    0 5px 0 rgba(11,45,30,.32),
    0 0 16px rgba(84,213,215,.28);
}
.logo-frame {
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
}
.logo-frame img,
.cover-logo-frame img {
  width: 112%;
  height: 112%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  display: block;
}
.logotype {
  display: flex; flex-direction: column; line-height: 1;
  font-family: var(--font-pixel);
}
.logotype .t1 { font-size: 9px; color: #fff9df; letter-spacing: 1px; }
.logotype .t2 { font-size: 11px; color: #fff9df; text-shadow: 0 2px 0 #0a4c33; margin-top: 4px; letter-spacing: 1px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── pixel buttons ── */
.pixel-btn {
  --c: var(--teal);
  background: transparent;
  color: var(--c);
  border: 2px solid var(--c);
  padding: 9px 14px;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--bg), 0 0 14px color-mix(in srgb, var(--c) 60%, transparent);
  transition: transform .12s, color .15s, background .15s, box-shadow .2s;
  text-transform: uppercase;
  min-height: 44px;
  touch-action: manipulation;
}
.pixel-btn:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }
.pixel-btn:active { transform: translateY(1px); }
.pixel-btn:focus-visible { outline: 2px dashed var(--yellow); outline-offset: 4px; }
.pixel-btn.ghost { --c: var(--peri); }
.pixel-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 25%, transparent); }

/* ── hero ── */
.hero {
  position: relative; z-index: 2;
  padding: 4vh 5vw 3vh; min-height: 82vh;
  display: flex; align-items: center; justify-content: center;
}
.hero-frame {
  text-align: center; max-width: 920px; width: 100%;
  border: 2px solid var(--teal);
  border-radius: 4px;
  padding: clamp(18px, 4vw, 42px) clamp(16px, 4vw, 50px);
  background:
    radial-gradient(420px 190px at 20% 70%, rgba(120,216,112,.35), transparent 68%),
    radial-gradient(360px 170px at 80% 30%, rgba(255,122,191,.20), transparent 70%),
    linear-gradient(180deg, rgba(255,249,223,.96), rgba(237,242,190,.92));
  box-shadow: 0 12px 0 rgba(39,103,73,.20), 0 0 0 6px rgba(255,249,223,.6);
}
.cover-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 18px;
  padding: 8px 14px 8px 8px;
  border: 2px solid rgba(39,103,73,.30);
  border-radius: 999px;
  background: rgba(255,249,223,.76);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 1.2px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 6px 0 rgba(39,103,73,.12);
}
.cover-logo-frame {
  width: 82px;
  height: 82px;
  flex: 0 0 82px;
}
.kicker {
  font-family: var(--font-pixel);
  font-size: 9px; letter-spacing: 2px;
  color: var(--peri); margin: 0 0 18px;
}
.title {
  font-family: var(--font-pixel);
  line-height: 1.25;
  margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.title .glow {
  font-size: clamp(16px, 4.1vw, 29px);
}
.t-teal    { color: var(--teal);    text-shadow: var(--shadow-teal); }
.t-fuchsia { color: var(--fuchsia); text-shadow: var(--shadow-fuchsia); }
.t-yellow  { color: var(--yellow);  text-shadow: var(--shadow-yellow); }
.t-peri    { color: var(--peri);    text-shadow: var(--shadow-peri); }

.title .subtitle { font-size: clamp(12px, 2.4vw, 18px); margin-top: 10px; }
.tagline {
  font-family: var(--font-zine);
  font-size: clamp(18px, 3.2vw, 26px);
  color: var(--ink);
  margin: 16px 0 18px;
  letter-spacing: 1px;
}

.hero-art {
  position: relative;
  height: clamp(150px, 22vw, 210px);
  width: min(100%, 760px);
  margin: 14px auto 18px;
  border: 3px solid #28734f;
  background:
    repeating-linear-gradient(0deg, rgba(39,103,73,.13) 0 8px, transparent 8px 16px),
    linear-gradient(180deg, #bdeaa5 0%, #eaf4bd 48%, #b9dd88 49%, #b9dd88 100%);
  overflow: hidden;
  box-shadow: inset 0 0 0 4px rgba(255,249,223,.55), 0 8px 0 rgba(39,103,73,.20);
}

.pixel-sun,
.pixel-cloud,
.pixel-serpent-gate,
.maze-tile,
.maze-path {
  position: absolute;
  display: block;
  image-rendering: pixelated;
}

.pixel-sun {
  width: 18px;
  height: 18px;
  right: 28px;
  top: 20px;
  background: var(--yellow);
  box-shadow:
    0 0 0 6px rgba(245,201,40,.18),
    -14px 0 0 -5px var(--yellow),
    14px 0 0 -5px var(--yellow),
    0 -14px 0 -5px var(--yellow),
    0 14px 0 -5px var(--yellow);
  animation: pixel-bob 4.8s steps(3, end) infinite;
}

.pixel-cloud {
  width: 58px;
  height: 18px;
  background: #fff9df;
  box-shadow: 18px -8px 0 #fff9df, 38px 0 0 #fff9df, 8px 10px 0 rgba(39,103,73,.10);
  opacity: .86;
}
.cloud-a { left: 38px; top: 28px; animation: cloud-drift 9s steps(6, end) infinite; }
.cloud-b { right: 120px; top: 46px; transform: scale(.75); animation: cloud-drift 11s steps(6, end) reverse infinite; }

.pixel-serpent-gate {
  left: 50%;
  bottom: 38px;
  width: 180px;
  height: 92px;
  transform: translateX(-50%);
  border: 10px solid #168653;
  border-bottom: 0;
  border-radius: 80px 80px 0 0;
  box-shadow:
    inset 0 0 0 8px #95d56e,
    0 0 0 4px #245b3c,
    0 10px 0 rgba(39,103,73,.18);
}

.pixel-serpent-gate::before,
.pixel-serpent-gate::after {
  content: "";
  position: absolute;
  bottom: -36px;
  width: 28px;
  height: 54px;
  background: #8a5b32;
  box-shadow: inset 0 0 0 6px #a7723b;
}
.pixel-serpent-gate::before { left: 8px; }
.pixel-serpent-gate::after { right: 8px; }

.maze-path {
  left: 50%;
  bottom: 0;
  width: 84px;
  height: 58px;
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, transparent 0 20%, #e2bd68 20% 80%, transparent 80%),
    linear-gradient(180deg, transparent, rgba(140,95,42,.18));
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
}

.maze-tile {
  width: 74px;
  height: 38px;
  background: #2f8b4f;
  border: 6px solid #1d6a3d;
  box-shadow:
    inset 0 0 0 5px #48ad62,
    0 7px 0 rgba(39,103,73,.18);
}
.tile-a { left: 9%; bottom: 26px; }
.tile-b { left: 26%; bottom: 64px; }
.tile-c { right: 26%; bottom: 64px; }
.tile-d { right: 9%; bottom: 26px; }

@keyframes pixel-bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(4px);} }
@keyframes cloud-drift { 0%,100% { translate: 0 0; } 50% { translate: 10px 0; } }

.pixel-garden {
  position: relative;
  height: 82px;
  width: min(100%, 760px);
  margin: -4px auto 18px;
  border: 3px solid #28734f;
  background:
    repeating-linear-gradient(0deg, rgba(40,115,79,.16) 0 8px, transparent 8px 16px),
    linear-gradient(180deg, #dff3b6, #b8df86);
  box-shadow: inset 0 0 0 4px rgba(255,249,223,.44), 0 8px 0 rgba(40,115,79,.20);
  overflow: hidden;
}

.pixel-garden::before {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 0;
  height: 38px;
  background:
    linear-gradient(90deg, transparent 0 10%, #e4c06b 10% 18%, transparent 18% 28%, #e4c06b 28% 36%, transparent 36% 46%, #e4c06b 46% 54%, transparent 54% 64%, #e4c06b 64% 72%, transparent 72% 82%, #e4c06b 82% 90%, transparent 90%),
    linear-gradient(180deg, transparent, rgba(140,95,42,.18));
  clip-path: polygon(44% 0, 56% 0, 76% 100%, 24% 100%);
}

.pixel-tree,
.flower-bush {
  position: absolute;
  display: block;
  image-rendering: pixelated;
}

.pixel-tree {
  width: 24px;
  height: 46px;
  bottom: 8px;
  background: #8a5b32;
  box-shadow:
    -21px -25px 0 7px #2f8b4f,
    0 -37px 0 13px #48ad62,
    21px -25px 0 7px #2f8b4f,
    0 -16px 0 8px #2f8b4f;
}
.tree-one { left: 9%; }
.tree-two { right: 10%; }
.grove-left { left: 6%; bottom: 18px; transform: scale(.82); }
.grove-right { right: 6%; bottom: 18px; transform: scale(.82); }

.flower-bush {
  width: 86px;
  height: 30px;
  bottom: 10px;
  background: #2f8b4f;
  border: 4px solid #1d6a3d;
  box-shadow: inset 0 0 0 4px #48ad62;
}
.flower-bush::before {
  content: "";
  position: absolute;
  left: 8px;
  top: -10px;
  width: 8px;
  height: 8px;
  background: #ff7abf;
  box-shadow:
    14px -6px 0 #fff44d,
    30px 0 0 #a6b8ff,
    46px -8px 0 #ff7abf,
    60px -2px 0 #fff44d;
}
.bush-one { left: 22%; }
.bush-two { left: 45%; }
.bush-three { right: 24%; }
.bush-left { left: 16%; bottom: 62px; transform: scale(.64); }
.bush-mid { left: 35%; bottom: 102px; transform: scale(.56); }
.bush-right { right: 17%; bottom: 102px; transform: scale(.56); }

.hero-names {
  font-family: var(--font-pixel);
  font-size: 9px; color: var(--peri);
  margin: 4px 0 22px; letter-spacing: 2px;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}
.hero-names span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(166,184,255,.28);
  background: rgba(10,24,17,.66);
  color: var(--readable);
  padding: 7px 9px;
  line-height: 1.45;
}

.press-start {
  font-family: var(--font-pixel);
  font-size: 14px;
  padding: 16px 22px;
  background: var(--bg-2);
  color: var(--yellow);
  border: 2px solid var(--yellow);
  cursor: pointer;
  text-shadow: var(--shadow-yellow);
  box-shadow: 0 0 0 4px var(--bg), 0 0 24px rgba(255,244,77,.45);
  animation: pressblink 1.4s steps(2,start) infinite;
  min-height: 52px;
  touch-action: manipulation;
}
.press-start:hover { transform: translateY(-1px); }
@keyframes pressblink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: .55; }
}
.hero-hint {
  margin-top: 16px;
  font-family: var(--font-pixel);
  font-size: 8px; letter-spacing: 1.5px;
  color: var(--ink-mute);
}

/* ── TOC drawer ── */
.toc {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(39,103,73,.50);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.toc[hidden] { display: none; }
.toc-inner {
  width: min(640px, 100%);
  border: 2px solid var(--teal);
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 0 60px rgba(0,212,212,.35);
  max-height: 90vh; overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.toc h2 {
  font-family: var(--font-pixel);
  color: var(--teal);
  font-size: 14px; margin: 0 0 20px;
  text-shadow: var(--shadow-teal);
}
.toc ol {
  list-style: none; padding: 0; margin: 0 0 18px;
  display: grid; gap: 8px;
}
.toc li button {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.toc li button:hover, .toc li button:focus-visible {
  border-color: var(--fuchsia);
  background: rgba(255,95,177,.08);
  color: var(--fuchsia);
  outline: none;
}
.toc li .n { color: var(--yellow); flex: 0 0 24px; }

/* ── book / flipbook ── */
.book-wrap {
  position: relative; z-index: 2;
  padding: 4vh 16px 6vh;
  display: flex; flex-direction: column; align-items: center;
}
.book {
  position: relative;
  width: min(960px, 100%);
  /* aspect kept by .pages; relative for spine */
  perspective: 2200px;
  outline: none;
}
.book:focus-visible { box-shadow: 0 0 0 3px var(--yellow); }
.book-spine {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: linear-gradient(180deg, transparent, rgba(166,184,255,.35), transparent);
  pointer-events: none;
}
@media (max-width: 720px) { .book-spine { display: none; } }

.pages {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  transform-style: preserve-3d;
}
@media (max-width: 720px) {
  .pages { aspect-ratio: 3 / 4; }
}

.page {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 18px), rgba(39,103,73,.12) calc(100% - 18px) 100%),
    repeating-linear-gradient(0deg, rgba(15,143,100,.045) 0 4px, transparent 4px 28px),
    linear-gradient(180deg, #fff9df 0%, #f5efc9 100%);
  border: 2px solid var(--line);
  box-shadow: 0 12px 0 rgba(39,103,73,.18), 0 0 34px rgba(39,103,73,.18), inset 0 0 0 4px rgba(255,255,255,.44);
  padding: clamp(16px, 3vw, 36px);
  overflow: auto;
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform .8s cubic-bezier(.66,.04,.18,.99), opacity .4s;
  backface-visibility: hidden;
  opacity: 0;
  pointer-events: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@media (prefers-reduced-motion: reduce) {
  .page { transition: opacity .2s; transform: none !important; }
}
.page.is-current { opacity: 1; pointer-events: auto; z-index: 5; }
.page.is-prev    { transform: rotateY(-180deg); opacity: 0; z-index: 4; }
.page.is-next    { opacity: 0; z-index: 3; }

.page[aria-hidden="true"] {
  visibility: hidden;
}

.page.is-current {
  visibility: visible;
}

/* page interior */
.page header.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px dashed rgba(39,103,73,.30);
  padding-bottom: 10px; margin-bottom: 18px;
  gap: 10px;
}
.page-num {
  font-family: var(--font-pixel);
  font-size: 9px; color: var(--peri); letter-spacing: 2px;
}
.page-tag {
  font-family: var(--font-pixel);
  font-size: 9px; color: var(--yellow); letter-spacing: 2px;
}
.page h2.page-title {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 2.6vw, 22px);
  margin: 0 0 16px;
  letter-spacing: 1px;
  line-height: 1.3;
}
.page p, .page li {
  font-family: var(--font-ui);
  font-size: clamp(14px, 1.5vw, 16px);
  color: var(--ink-mute);
}
.page p strong { color: var(--ink); }
.page .lede {
  font-family: var(--font-zine);
  font-size: clamp(18px, 2.4vw, 24px);
  color: var(--ink);
  letter-spacing: .5px;
}
.page blockquote {
  border: 2px solid var(--fuchsia);
  border-left-width: 5px;
  margin: 18px 0;
  padding: 14px 16px;
  color: var(--readable);
  font-family: var(--font-zine);
  font-size: clamp(16px, 2vw, 20px);
  background: linear-gradient(180deg, #fff6d1, #ffe7f2);
  text-shadow: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.46), 0 8px 0 rgba(217,39,134,.12);
}
.page .footnote {
  margin-top: 18px;
  font-size: 12px; color: var(--peri);
  font-family: var(--font-ui);
}

.chart-img {
  display: block;
  width: min(100%, 620px);
  max-width: 100%;
  max-height: min(72vh, 720px);
  object-fit: contain;
  margin: 6px auto 14px;
  border: 4px solid #28734f;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #fff9df, #f1e8bf),
    var(--panel);
  box-shadow:
    0 0 0 5px rgba(255,249,223,.82),
    0 10px 0 rgba(39,103,73,.16),
    inset 0 0 0 1px rgba(255,255,255,.65);
}

.chart-scroll {
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.progressed-img {
  border-color: #d79c1e;
  box-shadow:
    0 0 0 5px rgba(255,249,223,.82),
    0 10px 0 rgba(215,156,30,.18),
    inset 0 0 0 1px rgba(255,255,255,.65);
}

.topbar .pixel-btn {
  color: #fff9df;
  background: rgba(15, 79, 51, .68);
  border-color: rgba(255, 249, 223, .58);
  box-shadow:
    0 0 0 2px rgba(255, 249, 223, .14),
    0 5px 0 rgba(11, 45, 30, .40);
}

.topbar .pixel-btn.ghost {
  color: #fff9df;
}

.topbar .pixel-btn:hover,
.topbar .pixel-btn:focus-visible {
  background: rgba(255, 249, 223, .18);
  color: #ffffff;
  border-color: #fff9df;
}

.chart-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}

.chart-key span {
  display: block;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf1, #e8f4c9);
  color: var(--readable);
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.35;
}

.chart-key strong {
  color: var(--yellow);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 1px;
}

.chart-help {
  border: 2px solid #28734f;
  background: #ddffd2;
  color: #173c2b !important;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 12px;
  font-weight: 700;
}

.reading-card,
.garden-note {
  border: 3px solid #28734f;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255,244,77,.32), transparent 42%),
    linear-gradient(180deg, #fffdf1, #e9f6c9);
  color: #173c2b;
  padding: 14px 16px;
  margin: 14px 0;
  box-shadow: 0 8px 0 rgba(39,103,73,.12);
}

.reading-card strong,
.garden-note strong {
  display: block;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 1px;
  color: #b0187a;
  margin-bottom: 8px;
}

.reading-card p,
.garden-note p {
  margin: 0;
  color: #173c2b;
}

.quest-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.quest-list li {
  border-left: 8px solid #f5c928;
  background: #fffdf1;
  color: #173c2b;
  padding: 10px 12px;
  box-shadow: inset 0 0 0 2px rgba(39,103,73,.12);
}

.mini-garden {
  height: 78px;
  border: 3px solid #28734f;
  background:
    linear-gradient(90deg, transparent 0 42%, #d9b469 42% 58%, transparent 58%),
    linear-gradient(180deg, #dff3b6, #b8df86);
  margin: 0 0 14px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 4px rgba(255,249,223,.45);
}

.mini-garden span {
  position: absolute;
  bottom: 8px;
  display: block;
  width: 50px;
  height: 28px;
  background: #2f8b4f;
  border: 3px solid #1d6a3d;
}

.mini-garden span::before {
  content: "";
  position: absolute;
  left: 6px;
  top: -8px;
  width: 8px;
  height: 8px;
  background: #ff7abf;
  box-shadow: 12px -4px 0 #fff44d, 26px 0 0 #a6b8ff, 38px -5px 0 #ff7abf;
}

.mini-garden span:nth-child(1) { left: 6%; }
.mini-garden span:nth-child(2) { left: 24%; bottom: 15px; }
.mini-garden span:nth-child(3) { left: 46%; }
.mini-garden span:nth-child(4) { right: 24%; bottom: 15px; }
.mini-garden span:nth-child(5) { right: 6%; }

.method-grid,
.practice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 14px 0 10px;
}

.method-grid > div,
.practice-grid > div,
.medicine p {
  border: 2px solid rgba(83,255,183,.34);
  background:
    linear-gradient(135deg, rgba(120,216,112,.28), transparent 46%),
    linear-gradient(180deg, var(--panel-hi), var(--panel));
  padding: 12px;
  color: var(--readable);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.45), 0 8px 0 rgba(39,103,73,.12);
}

.method-grid strong,
.practice-grid strong,
.medicine strong {
  display: block;
  color: var(--yellow);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.method-grid p,
.practice-grid p,
.medicine p {
  margin: 0;
}

.medicine {
  display: grid;
  gap: 10px;
}

/* cast cards (page 2) */
.cast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.cast-card {
  border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  padding: 14px;
  color: var(--readable);
}
.cast-card .role {
  font-family: var(--font-pixel);
  font-size: 9px; letter-spacing: 1.5px;
  color: var(--yellow); margin-bottom: 8px;
}
.cast-card .name {
  font-family: var(--font-pixel);
  font-size: 12px; color: var(--readable);
  margin: 4px 0 8px;
}
.cast-card.person-a { border-color: var(--teal);    box-shadow: inset 0 0 0 2px rgba(0,212,212,.18); }
.cast-card.person-b { border-color: var(--yellow);  box-shadow: inset 0 0 0 2px rgba(255,244,77,.18); }
.cast-card.person-c { border-color: var(--fuchsia); box-shadow: inset 0 0 0 2px rgba(255,95,177,.18); }
.cast-card .vibe {
  font-size: 13px; color: var(--readable); margin-top: 8px;
}
.cast-card .keywords {
  display: block; margin-top: 8px;
  font-size: 12px; color: var(--peri);
  font-style: italic;
}

/* progressed Sun bar */
.bars { display: grid; gap: 14px; margin-top: 14px; }
.bar-row { display: grid; gap: 6px; }
.bar-label {
  display: flex; justify-content: space-between;
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--ink); letter-spacing: 1px;
}
.bar-label .end { color: var(--peri); }
.bar {
  height: 14px; background: var(--soft);
  border: 2px solid var(--line);
  position: relative;
}
.bar .fill {
  position: absolute; inset: 0; right: auto;
  background-size: 8px 8px;
  background-image: linear-gradient(135deg, transparent 0 2px, currentColor 2px 6px, transparent 6px 8px);
  color: var(--teal);
  box-shadow: 0 0 12px currentColor;
  width: 0;
  transition: width 1s ease-out;
}
.bar.person-a .fill { color: var(--teal); }
.bar.person-b .fill { color: var(--yellow); }
.bar.person-c .fill { color: var(--fuchsia); }
.bar .marker {
  position: absolute; top: -6px; bottom: -6px;
  width: 2px; background: var(--ink);
  box-shadow: 0 0 6px var(--ink);
}

/* Scorpio stack diagram */
.scorpio-stack {
  display: grid; gap: 8px;
  margin-top: 14px;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.scorpio-stack .row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  text-shadow: none;
}
.scorpio-stack .row .dot {
  width: 12px; height: 12px; flex: 0 0 12px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}
.scorpio-stack .row.f { color: var(--fuchsia); }
.scorpio-stack .row.s { color: var(--yellow); }
.scorpio-stack .row.m { color: var(--teal); }
.scorpio-stack .label { color: var(--ink); font-size: 9px; }
.scorpio-stack .glyph { margin-left: auto; color: var(--peri); }

/* three-star family map (SVG sized) */
.family-map {
  margin: 18px auto 6px;
  display: block;
  width: 100%; max-width: 520px;
  height: auto;
}

/* audio visualizer */
.viz {
  margin-top: 16px;
  height: 60px;
  display: flex; align-items: flex-end; gap: 4px;
  padding: 8px;
  border: 2px dashed var(--line);
}
.viz span {
  display: block; flex: 1;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
  height: 20%;
  transition: height .2s ease-out;
}
.viz span:nth-child(3n)   { background: var(--fuchsia); box-shadow: 0 0 8px var(--fuchsia); }
.viz span:nth-child(5n+1) { background: var(--yellow);  box-shadow: 0 0 8px var(--yellow);  }
.viz span:nth-child(7n+2) { background: var(--peri);    box-shadow: 0 0 8px var(--peri);    }

/* blessing page */
.blessing {
  text-align: center;
  padding: 20px 4px;
}
.blessing p {
  font-family: var(--font-zine);
  font-size: clamp(18px, 2.6vw, 24px);
  color: var(--ink);
  letter-spacing: .5px;
  line-height: 1.7;
}
.blessing .sig {
  font-family: var(--font-pixel);
  font-size: 10px; color: var(--peri);
  margin-top: 24px; letter-spacing: 2px;
}
.blessing .start-again {
  margin-top: 22px;
}

/* controls */
.book-controls {
  display: flex; align-items: center; gap: 16px;
  margin-top: 20px;
}
.page-indicator {
  font-family: var(--font-pixel);
  font-size: 11px; color: var(--peri);
  letter-spacing: 2px;
}
.page-indicator .sep { margin: 0 4px; color: var(--line); }
.page-indicator #page-now { color: var(--yellow); text-shadow: var(--shadow-yellow); }

.dots {
  margin-top: 16px;
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
  max-width: 720px;
}
.dot {
  width: 12px; height: 12px;
  background: #fff9df;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
  padding: 0;
  touch-action: manipulation;
}
.dot[aria-current="true"] {
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 10px var(--yellow);
}
.dot:hover { border-color: var(--teal); }
.dot:focus-visible { outline: 2px dashed var(--yellow); outline-offset: 3px; }

/* footer */
.footer {
  position: relative; z-index: 2;
  text-align: center;
  padding: 30px 20px 50px;
  border-top: 1px dashed var(--line);
  margin-top: 30px;
}
.footer-line {
  font-family: var(--font-pixel);
  font-size: 11px; color: var(--ink);
  letter-spacing: 1.5px;
  text-shadow: var(--shadow-peri);
  margin: 0 0 8px;
}
.footer-tiny {
  font-family: var(--font-ui);
  font-size: 12px; color: var(--ink-mute);
  margin: 0;
}

/* utility */
.t-ink { color: var(--ink); }
.t-mute { color: var(--ink-mute); }

/* reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  .pixel-sun, .pixel-cloud { animation: none; }
  .press-start { animation: none; }
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  animation: none !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

html[data-motion="off"] .page {
  transform: none !important;
}

html[data-motion="off"] #starfield {
  display: none;
}

html[data-motion="off"] .viz span {
  height: 18% !important;
}

/* tablet/desktop niceties */
@media (min-width: 900px) {
  .topbar { padding: 16px 32px; }
  .book-wrap { padding-top: 6vh; }
}

/* mobile */
@media (max-width: 720px) {
  html, body { scroll-padding-top: 132px; }

  #starfield {
    opacity: .10;
    mix-blend-mode: normal;
  }

  .topbar {
    align-items: flex-start;
    padding: 10px max(12px, env(safe-area-inset-left)) 10px max(12px, env(safe-area-inset-right));
  }

  .logo-frame {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .top-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .pixel-btn {
    padding: 8px 10px;
    font-size: 9px;
    letter-spacing: .75px;
  }

  .hero {
    min-height: auto;
    padding: 20px 10px 26px;
    align-items: flex-start;
  }

  body.reading-mode .hero {
    display: none;
  }

  .hero-frame {
    padding: 22px 12px 20px;
    border-radius: 10px;
    box-shadow: 0 0 34px rgba(83,255,183,.16), inset 0 0 0 3px rgba(176,255,205,.06);
  }

  .cover-brand {
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 10px 12px;
    border-radius: 18px;
    font-size: 7px;
    line-height: 1.6;
  }

  .cover-logo-frame {
    width: 74px;
    height: 74px;
  }

  .kicker {
    font-size: 8px;
    line-height: 1.65;
    letter-spacing: 1px;
    margin-bottom: 14px;
  }

  .title { gap: 7px; }
  .title .glow { font-size: clamp(15px, 5.2vw, 21px); }
  .title .subtitle { font-size: clamp(11px, 4vw, 15px); }

  .tagline {
    font-size: clamp(18px, 6vw, 23px);
    margin: 14px 0 16px;
  }

  .hero-art {
    height: 142px;
    margin: 8px auto 14px;
  }

  .pixel-serpent-gate {
    width: 132px;
    height: 72px;
    border-width: 8px;
    bottom: 30px;
  }

  .maze-tile {
    width: 52px;
    height: 30px;
    border-width: 5px;
  }

  .tile-b,
  .tile-c {
    bottom: 50px;
  }

  .pixel-cloud {
    transform: scale(.72);
  }

  .grove-left,
  .grove-right {
    transform: scale(.58);
    bottom: 14px;
  }

  .grove-left { left: 4%; }
  .grove-right { right: 4%; }

  .hero-names {
    display: none;
    gap: 7px;
    margin: 2px auto 18px;
    font-size: 8px;
    letter-spacing: .8px;
    max-width: 370px;
  }

  .hero-names span {
    width: 100%;
    padding: 8px 10px;
    border-color: rgba(255,244,77,.34);
    background: linear-gradient(180deg, rgba(24,53,37,.92), rgba(16,32,24,.92));
  }

  .press-start {
    width: min(100%, 320px);
    font-size: 12px;
    padding: 14px 16px;
  }

  .hero-hint {
    font-size: 8px;
    line-height: 1.7;
    max-width: 280px;
    margin: 13px auto 0;
  }

  .book-wrap {
    padding: 10px 10px max(34px, env(safe-area-inset-bottom));
    min-height: calc(100svh - 92px);
  }

  .book {
    width: min(100%, 430px);
    perspective: 1200px;
  }

  .pages {
    aspect-ratio: auto;
    height: min(74svh, 680px);
    min-height: 560px;
  }

  .page {
    padding: 15px 14px 18px;
    border-radius: 12px;
    overflow-x: hidden;
    background:
      linear-gradient(90deg, transparent 0 calc(100% - 12px), rgba(39,103,73,.10) calc(100% - 12px) 100%),
      linear-gradient(180deg, #fffce8 0%, #f7f0c8 100%);
    box-shadow:
      0 8px 0 rgba(39,103,73,.18),
      0 0 0 3px rgba(255,255,255,.72) inset;
    transform: none !important;
    transition: opacity .18s ease;
  }

  .page.is-prev,
  .page.is-next {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }

  .page.is-current {
    opacity: 1;
    visibility: visible;
  }

  .page header.page-head {
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 14px;
    padding-bottom: 9px;
  }

  .page-num,
  .page-tag {
    font-size: 8px;
    letter-spacing: 1px;
    line-height: 1.45;
  }

  .page h2.page-title {
    font-size: clamp(14px, 4.8vw, 18px);
    line-height: 1.45;
    margin-bottom: 12px;
  }

  .page p,
  .page li {
    font-size: 14px;
    line-height: 1.62;
    color: #173c2b;
  }

  .page .lede {
    font-size: clamp(18px, 6vw, 22px);
    line-height: 1.45;
  }

  .page blockquote {
    margin: 14px 0;
    padding: 12px;
    font-size: 18px;
    line-height: 1.45;
  }

  .chart-img {
    width: min(680px, 100%);
    max-width: 100%;
    max-height: none;
    margin: 0;
    border-radius: 10px;
  }

  .progressed-img {
    width: min(720px, 100%);
  }

  .chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin: 4px 0 12px;
    padding: 8px 8px 12px;
    border: 2px solid rgba(39,103,73,.34);
    border-radius: 14px;
    background: #fff8d7;
    box-shadow: inset 0 -7px 0 rgba(15,143,100,.08);
  }

  .chart-scroll .chart-img {
    min-width: 620px;
  }

  .chart-help::after {
    content: " Swipe inside the chart box to inspect labels.";
  }

  .chart-key {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .chart-key span {
    padding: 8px;
    font-size: 11px;
  }

  .method-grid,
  .practice-grid,
  .cast {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .method-grid > div,
  .practice-grid > div,
  .medicine p,
  .cast-card {
    padding: 11px;
  }

  .book-controls {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 24;
    gap: 12px;
    margin-top: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(6,17,12,.84);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 24px rgba(0,0,0,.42);
  }

  .book-controls .pixel-btn {
    min-width: 48px;
    min-height: 48px;
    padding: 8px 12px;
  }

  .page-indicator {
    min-width: 72px;
    text-align: center;
    font-size: 10px;
    letter-spacing: 1px;
  }

  .dots {
    max-width: 360px;
    gap: 7px;
    margin-top: 12px;
  }

  .dot {
    width: 15px;
    height: 15px;
  }

  .footer {
    padding: 24px 14px 38px;
    margin-top: 18px;
  }
}

@media (max-width: 520px) {
  html, body { scroll-padding-top: 150px; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .logo {
    justify-content: center;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .top-actions .pixel-btn:first-child {
    grid-column: 1 / -1;
  }

  .top-actions .pixel-btn {
    width: 100%;
  }

  .hero {
    padding-top: 14px;
  }

  .hero-frame {
    padding-inline: 10px;
  }

  .toc {
    align-items: flex-end;
    padding: 10px;
  }

  .toc-inner {
    max-height: 86svh;
    border-radius: 16px 16px 8px 8px;
    padding: 18px 14px max(18px, env(safe-area-inset-bottom));
  }

  .toc h2 {
    font-size: 12px;
    line-height: 1.55;
  }

  .toc li button {
    min-height: 48px;
    font-size: 9px;
    line-height: 1.45;
    padding: 10px;
  }

  .pages {
    height: 68svh;
    min-height: 500px;
  }

  .page header.page-head {
    flex-direction: column;
  }

  .chart-key {
    grid-template-columns: 1fr;
  }

  .blessing {
    padding: 10px 0;
  }
}

@media (max-width: 380px) {
  .title .glow { font-size: 14px; }
  .hero-art { height: 128px; }
  .page { padding: 13px 12px 16px; }
  .pages { min-height: 490px; }
  .book-controls { gap: 8px; }
  .page-indicator { min-width: 58px; font-size: 9px; }
}
