/* NeverGrove — shared look for every page in the world. */

:root {
  --bg-a: #0a0b1e;
  --bg-b: #150a2e;
  --bg-c: #0b1a33;
  --ink: #eef1ff;
  --ink-soft: #b9c0e4;
  --ink-dim: #8a92bf;
  --cyan: #6fe3ec;
  --cyan-soft: #8ff0f6;
  --violet: #b98bff;
  --leaf: #8ee89a;
  --gold: #f0b95a;
  --rose: #ff9db0;
  --accent: var(--cyan);
  --panel: linear-gradient(160deg, rgba(38, 24, 74, 0.55), rgba(11, 16, 38, 0.68));
  --panel-border: rgba(150, 128, 255, 0.28);
  --field-bg: rgba(9, 12, 30, 0.6);
  --field-border: rgba(120, 160, 255, 0.26);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --r-hollow: #ffd27a;
  --r-woods: #8ee89a;
  --r-shore: #6fe3ec;
  --r-savanna: #ff9457;
  --r-frost: #d6f3ff;
  --r-canopy: #ff7ad9;
  --r-sands: #e3a8ff;
}
[data-realm="hollow"]  { --accent: var(--r-hollow); }
[data-realm="woods"]   { --accent: var(--r-woods); }
[data-realm="shore"]   { --accent: var(--r-shore); }
[data-realm="savanna"] { --accent: var(--r-savanna); }
[data-realm="frost"]   { --accent: var(--r-frost); }
[data-realm="canopy"]  { --accent: var(--r-canopy); }
[data-realm="sands"]   { --accent: var(--r-sands); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 700px at 12% -8%, rgba(120, 70, 200, 0.40) 0%, rgba(120, 70, 200, 0) 60%),
    radial-gradient(1000px 800px at 92% 112%, rgba(40, 150, 190, 0.32) 0%, rgba(40, 150, 190, 0) 60%),
    linear-gradient(180deg, var(--bg-a) 0%, var(--bg-b) 45%, var(--bg-c) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
body.no-scroll { overflow: hidden; }

a { color: var(--cyan-soft); }
button { font-family: inherit; }
::selection { background: rgba(185, 139, 255, 0.4); }

/* ─── Sky ─────────────────────────────────────────── */
/* Sky layers, back to front (negative z-index = behind all page content):
   stars → aurora → hills → fireflies and realm weather. */
#stars, #fireflies, #weather { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
#stars { z-index: -4; }

/* Hills — built by landscape() in grove.js. */
#scenery { position: fixed; left: 0; right: 0; bottom: 0; height: clamp(200px, 40vh, 420px); z-index: -2; pointer-events: none; overflow: hidden; }
#scenery .scene { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; }
#scenery .scene.on { opacity: 1; }
#scenery svg { width: 100%; height: 100%; display: block; }
#scenery .mist { position: absolute; left: -15%; width: 130%; height: 24%; bottom: 40%; animation: mist 46s ease-in-out infinite alternate; }
#scenery .mist.b { bottom: 16%; animation-duration: 63s; animation-direction: alternate-reverse; }
@keyframes mist { from { transform: translateX(-70px); } to { transform: translateX(70px); } }
/* Northern lights — a tiny canvas (see aurora() in grove.js) stretched over the sky, fading out toward the bottom. */
#aurora {
  position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -3; opacity: 0.8;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 0%, #000 50%, transparent 92%);
}
.star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; opacity: 0.7;
  animation: twinkle 5s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 0.14; } 50% { opacity: 0.9; } }
@keyframes drift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.shooting {
  position: fixed; z-index: 0; pointer-events: none;
  width: 140px; height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff 60%, rgba(255,255,255,0));
  transform-origin: left center;
  animation: shoot 1.1s ease-out forwards;
}
@keyframes shoot {
  0%   { opacity: 0; transform: rotate(var(--angle)) translateX(0) scaleX(0.3); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateX(var(--dist)) scaleX(1); }
}

.sparkle {
  position: fixed; z-index: 60; pointer-events: none;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sp, #fff);
  box-shadow: 0 0 8px var(--sp, #fff);
  transform: translate(-50%, -50%);
  animation: sparkle-fade 0.7s ease-out forwards;
}
@keyframes sparkle-fade {
  0%   { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 12px))) scale(0.2); }
}
.burst-spark {
  position: fixed; z-index: 70; pointer-events: none;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sp, #fff); box-shadow: 0 0 10px var(--sp, #fff);
  transform: translate(-50%, -50%);
  animation: burst 0.8s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
@keyframes burst {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1); }
}

/* ─── Layout ──────────────────────────────────────── */
.wrap { position: relative; z-index: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }

.nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  background: rgba(8, 10, 28, 0.55);
  border-bottom: 1px solid rgba(150, 128, 255, 0.14);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.nav .brand {
  font-family: var(--display); font-size: 1.15rem; letter-spacing: 0.04em;
  color: var(--ink); text-decoration: none;
  text-shadow: 0 0 16px rgba(120, 200, 255, 0.45);
  display: flex; align-items: center; gap: 0.5rem; white-space: nowrap;
}
.nav .brand svg { width: 26px; height: 26px; filter: drop-shadow(0 0 6px rgba(120, 230, 150, 0.6)); }
.nav .links { display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: flex-end; }
.nav .links a, .nav .links button {
  color: var(--ink-soft); text-decoration: none; background: none; border: none; cursor: pointer;
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.45rem 0.7rem; border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.nav .links a:hover, .nav .links button:hover { color: var(--ink); background: rgba(120, 160, 255, 0.1); }
.nav .links a[aria-current="page"] { color: var(--cyan-soft); background: rgba(110, 227, 236, 0.1); }
@media (max-width: 560px) {
  .nav .wrap { flex-direction: column; gap: 0.2rem; padding-top: 0.5rem; padding-bottom: 0.4rem; }
  .nav .links { justify-content: center; gap: 0; }
  .nav .links a, .nav .links button { padding: 0.35rem 0.5rem; font-size: 0.68rem; letter-spacing: 0.08em; }
}

/* ─── Type ────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0; }
.glow-title {
  background: linear-gradient(100deg, var(--cyan) 0%, #d8ecff 42%, var(--violet) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 44px rgba(120, 180, 255, 0.25);
}
.eyebrow {
  font-size: 0.7rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 0.6rem;
}
.eyebrow.accent { color: var(--accent); }
.lede { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.7; max-width: 38rem; }
.italic { font-family: var(--display); }
.muted { color: var(--ink-dim); }
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); }
.section-head p { color: var(--ink-soft); margin: 0.5rem auto 0; max-width: 36rem; }

/* ─── Bits ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.4rem; border-radius: 999px; cursor: pointer;
  font-family: var(--display); font-size: 1rem; letter-spacing: 0.03em; text-decoration: none;
  color: var(--ink); background: rgba(20, 16, 44, 0.55);
  border: 1px solid rgba(150, 200, 255, 0.35);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 0 24px rgba(120, 200, 255, 0.25); border-color: rgba(150, 220, 255, 0.6); }
.btn.primary {
  background: linear-gradient(120deg, rgba(110, 227, 236, 0.22), rgba(185, 139, 255, 0.25));
  border-color: rgba(150, 220, 255, 0.55);
  box-shadow: 0 0 22px rgba(120, 200, 255, 0.2);
}
.btn.accent { border-color: var(--accent); color: var(--accent); }
.btn.accent.on { background: var(--accent); color: #0a0b1e; box-shadow: 0 0 26px var(--accent); }
.btn.small { padding: 0.5rem 0.95rem; font-size: 0.9rem; }
.btn.ghost { background: transparent; border-color: rgba(150, 200, 255, 0.2); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.38rem 0.8rem; border-radius: 999px; cursor: pointer;
  font-size: 0.8rem; letter-spacing: 0.04em;
  color: var(--ink-soft); background: rgba(12, 16, 34, 0.55);
  border: 1px solid rgba(120, 160, 255, 0.22);
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s, background 0.15s;
  text-decoration: none; white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: rgba(150, 200, 255, 0.5); }
.chip[aria-pressed="true"], .chip.on {
  color: #0a0b1e; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.chip.on .dot { background: #0a0b1e; box-shadow: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 1.5rem;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 46px rgba(90, 60, 180, 0.16), inset 0 0 40px rgba(80, 120, 255, 0.05);
}

.medallion {
  position: relative; flex-shrink: 0;
  width: var(--md, 66px); height: var(--md, 66px); border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--md, 66px) * 0.5); line-height: 1;
  background: radial-gradient(circle at 38% 34%, color-mix(in srgb, var(--accent) 28%, transparent), rgba(20, 24, 54, 0.75));
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 40%, transparent);
}
.medallion .sigil {
  position: absolute; right: -4px; bottom: -4px;
  width: calc(var(--md, 66px) * 0.36); height: calc(var(--md, 66px) * 0.36);
  border-radius: 50%; display: grid; place-items: center;
  font-size: calc(var(--md, 66px) * 0.19);
  background: #0c1026; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
}

.tag {
  display: inline-block; font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim); padding: 0.15rem 0.5rem; border-radius: 6px;
  border: 1px solid rgba(120, 160, 255, 0.18);
}
.tag.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ─── Creature cards ─────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.toolbar .search {
  flex: 1 1 220px; min-width: 0;
  padding: 0.7rem 1rem; border-radius: 999px;
  background: var(--field-bg); border: 1px solid var(--field-border);
  color: var(--ink); font-size: 0.95rem;
}
.toolbar .search:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(110, 227, 236, 0.4); }
.filters { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.4rem; }
.filters .group { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.filters .sep { width: 1px; background: rgba(120, 160, 255, 0.2); margin: 0 0.3rem; }
@media (max-width: 640px) { .filters .sep { display: none; } }

.count { font-size: 0.8rem; color: var(--ink-dim); letter-spacing: 0.06em; margin: 0 0 1rem; }

.creatures {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.ccard {
  position: relative; text-align: left; width: 100%;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 20px; padding: 1.1rem 1.1rem 1rem;
  color: inherit; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 10%, transparent);
  transition: transform 0.18s, box-shadow 0.2s, border-color 0.2s;
  animation: rise 0.5s ease both;
}
.ccard:hover, .ccard:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow: 0 0 34px color-mix(in srgb, var(--accent) 30%, transparent);
  outline: none;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ccard .top { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.7rem; }
.ccard .name { font-family: var(--display); font-size: 1.15rem; font-weight: 600; margin: 0; text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 40%, transparent); }
.ccard .epithet { font-family: var(--sans); font-size: 0.85rem; color: var(--accent); margin: 0.2rem 0 0; line-height: 1.35; }
.ccard .tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ccard .mark {
  position: absolute; top: 0.8rem; right: 0.8rem;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.8rem; color: #0a0b1e; background: var(--leaf);
  box-shadow: 0 0 12px var(--leaf);
}
.ccard .fav { position: absolute; top: 0.8rem; right: 2.6rem; font-size: 0.95rem; filter: drop-shadow(0 0 6px var(--gold)); }
.ccard.spotted { border-color: color-mix(in srgb, var(--leaf) 45%, transparent); }
.ccard.custom::after {
  content: "Your discovery"; position: absolute; left: 1rem; bottom: 0.55rem;
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold);
}
.ccard.custom { padding-bottom: 1.8rem; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-dim); }

/* ─── Realm banner (codex) ───────────────────────── */
.realm-banner {
  display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1.5rem; padding: 1.3rem 1.5rem;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 46px color-mix(in srgb, var(--accent) 16%, transparent);
}
/* The realm's line drawing (Grove.realmArt, drawn in by Anime.js): sits faintly behind the banner on the right. */
.realm-banner { position: relative; overflow: hidden; }
.realm-banner > :not(.realm-art) { position: relative; z-index: 1; }
.realm-art {
  position: absolute; right: 6.5rem; top: 50%; transform: translateY(-50%);             /* clear of the "spotted" counter */
  width: min(40%, 300px); height: auto; pointer-events: none; opacity: 0.5;
  fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  color: var(--accent); filter: drop-shadow(0 0 6px var(--accent));
}
.realm-art .live { transform-box: fill-box; transform-origin: center; }
.realm-art .spin, .realm-art .bloom { transform-box: view-box; transform-origin: 0 0; }   /* they turn about their own middle (0,0) */
.realm-art .sway, .realm-art .swing { transform-box: view-box; }                          /* turn from the point set in their style */
@media (max-width: 640px) { .realm-art { width: 70%; right: -6%; opacity: 0.3; } }
.realm-banner .sig { font-size: 2.6rem; line-height: 1; filter: drop-shadow(0 0 12px var(--accent)); }
.realm-banner h2 { font-size: clamp(1.5rem, 4vw, 2rem); color: var(--accent); text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 50%, transparent); }
.realm-banner p { margin: 0.3rem 0 0; color: var(--ink-soft); max-width: 40rem; }
.realm-banner .prog { margin-left: auto; text-align: right; font-size: 0.8rem; color: var(--ink-dim); letter-spacing: 0.06em; }
.realm-banner .prog strong { display: block; font-family: var(--display); font-size: 1.5rem; color: var(--ink); }

/* ─── Detail sheet ───────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: rgba(5, 6, 20, 0.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 3vh 1rem 4vh;
  animation: fade 0.25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: relative; max-width: 900px; margin: 0 auto;
  background: linear-gradient(160deg, rgba(38, 24, 74, 0.92), rgba(11, 16, 38, 0.96));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 28px; padding: clamp(1.4rem, 4vw, 2.4rem);
  box-shadow: 0 0 80px color-mix(in srgb, var(--accent) 22%, transparent), 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: sheet-in 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
.sheet .close {
  position: absolute; top: 1rem; right: 1rem;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgba(12, 16, 34, 0.7); border: 1px solid rgba(150, 200, 255, 0.3);
  color: var(--ink); font-size: 1.1rem;
}
.sheet .close:hover { border-color: var(--accent); color: var(--accent); }
.sheet-head { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.5rem; padding-right: 2.5rem; }
.sheet-head h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 50%, transparent); }
.sheet-head .epithet { font-family: var(--sans); font-size: 1.05rem; color: var(--accent); margin: 0.25rem 0 0.7rem; }
.sheet-head .realm-link { display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; }

.quick {
  display: grid; gap: 0.7rem; margin-bottom: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.quick div {
  padding: 0.7rem 0.9rem; border-radius: 14px;
  background: rgba(9, 12, 30, 0.5); border: 1px solid rgba(120, 160, 255, 0.16);
}
.quick dt { font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.25rem; }
.quick dd { margin: 0; font-size: 0.9rem; color: var(--ink); line-height: 1.4; }

.stats { display: grid; gap: 0.55rem; margin-bottom: 1.6rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.pips { display: flex; gap: 4px; }
.pips span {
  width: 18px; height: 9px; border-radius: 3px;
  background: rgba(120, 160, 255, 0.14); border: 1px solid rgba(120, 160, 255, 0.2);
  transition: background 0.3s, box-shadow 0.3s;
}
.pips span.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }
.pips span:nth-child(1) { transition-delay: 0.05s; } .pips span:nth-child(2) { transition-delay: 0.12s; }
.pips span:nth-child(3) { transition-delay: 0.19s; } .pips span:nth-child(4) { transition-delay: 0.26s; }
.pips span:nth-child(5) { transition-delay: 0.33s; }

.lore { display: grid; gap: 1.2rem; grid-template-columns: 1fr 1fr; margin-bottom: 1.4rem; }
@media (max-width: 640px) { .lore { grid-template-columns: 1fr; } }
.lore .wide { grid-column: 1 / -1; }
.lore h3 { font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.4rem; font-family: var(--sans); font-weight: 600; }
.lore h3 .spark { color: var(--leaf); margin-right: 0.35rem; }
.lore p { margin: 0; color: var(--ink); line-height: 1.65; font-size: 0.97rem; }
.lore ul { margin: 0; padding: 0; list-style: none; }
.lore li { position: relative; padding-left: 1.4rem; margin-bottom: 0.6rem; line-height: 1.6; }
.lore li::before { content: "✦"; position: absolute; left: 0; color: var(--accent); }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.4rem; }
.notes label { display: block; font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.4rem; }
textarea, input[type="text"], select {
  width: 100%; font-family: var(--sans); font-size: 0.95rem; line-height: 1.55;
  color: var(--ink); background: var(--field-bg);
  border: 1px solid var(--field-border); border-radius: 12px; padding: 0.7rem 0.8rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 4rem; resize: vertical; }
textarea::placeholder, input::placeholder { color: rgba(180, 160, 230, 0.5); }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 20%, transparent); }
select option { background: #12142e; }

.sheet-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid rgba(120, 160, 255, 0.14); }
.sheet-nav button { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-family: var(--display); font-size: 0.95rem; padding: 0.4rem 0.2rem; }
.sheet-nav button:hover { color: var(--accent); }

/* ─── Journal ────────────────────────────────────── */
.journal-grid { display: grid; gap: 1.2rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .journal-grid { grid-template-columns: 1fr; } }
.journal-grid .full { grid-column: 1 / -1; }
.panel h3.ph { font-size: 1.25rem; margin-bottom: 1rem; }

.ring-wrap { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.ring { width: 130px; height: 130px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: rgba(120, 160, 255, 0.14); }
.ring .bar { stroke: var(--leaf); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.8s ease; filter: drop-shadow(0 0 6px var(--leaf)); }
.ring text { fill: var(--ink); font-family: var(--display); font-size: 26px; font-weight: 600; text-anchor: middle; }
.ring .sub { font-size: 9px; fill: var(--ink-dim); letter-spacing: 1px; text-transform: uppercase; font-family: var(--sans); }

.realm-bars { display: grid; gap: 0.6rem; }
.rbar { display: grid; grid-template-columns: 1.6rem 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.85rem; text-decoration: none; color: var(--ink); }
.rbar .track { height: 8px; border-radius: 4px; background: rgba(120, 160, 255, 0.12); overflow: hidden; }
.rbar .fill { height: 100%; background: var(--accent); box-shadow: 0 0 8px var(--accent); border-radius: 4px; transition: width 0.6s ease; }
.rbar .n { color: var(--ink-dim); font-size: 0.75rem; min-width: 3rem; text-align: right; }
.rbar .lbl { font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0.04em; margin-bottom: 0.2rem; }

.badges { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.badge { text-align: center; }
.badge .ring-ic {
  width: 66px; height: 66px; margin: 0 auto 0.5rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.8rem;
  background: radial-gradient(circle at 38% 34%, rgba(240, 185, 90, 0.3), rgba(20, 24, 54, 0.75));
  border: 1px solid rgba(240, 185, 90, 0.6);
  box-shadow: 0 0 22px rgba(240, 185, 90, 0.35);
}
.badge .bn { font-family: var(--display); font-size: 0.92rem; }
.badge .bh { font-size: 0.7rem; color: var(--ink-dim); line-height: 1.35; margin-top: 0.15rem; }
.badge.locked .ring-ic { filter: grayscale(1); opacity: 0.4; box-shadow: none; border-color: rgba(120, 160, 255, 0.2); }
.badge.locked .bn { color: var(--ink-dim); }

.note-list { display: grid; gap: 0.6rem; }
.note-item { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-radius: 14px; background: rgba(9, 12, 30, 0.5); border: 1px solid rgba(120, 160, 255, 0.14); text-decoration: none; color: inherit; }
.note-item .em { font-size: 1.4rem; line-height: 1; }
.note-item .nn { font-family: var(--display); font-size: 0.95rem; }
.note-item .nt { font-size: 0.85rem; color: var(--ink-soft); white-space: pre-wrap; margin-top: 0.15rem; }
.note-item:hover { border-color: rgba(150, 200, 255, 0.4); }

.explorer-name { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.explorer-name input { max-width: 16rem; }

/* ─── Quest ───────────────────────────────────────── */
.quest { max-width: 680px; margin: 0 auto; }
.q-meta { display: flex; justify-content: space-between; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 1rem; }
.q-meta strong { color: var(--gold); }
.q-prompt { font-family: var(--display); font-size: clamp(1.25rem, 3.5vw, 1.6rem); line-height: 1.35; margin-bottom: 1.4rem; }
.q-prompt .em { font-size: 2.2rem; display: block; margin-bottom: 0.5rem; }
.opts { display: grid; gap: 0.7rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .opts { grid-template-columns: 1fr; } }
.opt {
  text-align: left; padding: 0.9rem 1.1rem; border-radius: 16px; cursor: pointer;
  color: var(--ink); background: rgba(9, 12, 30, 0.55); border: 1px solid rgba(120, 160, 255, 0.22);
  font-size: 1rem; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.opt:hover:not(:disabled) { border-color: var(--cyan); transform: translateY(-2px); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--leaf); box-shadow: 0 0 20px rgba(142, 232, 154, 0.4); background: rgba(142, 232, 154, 0.12); }
.opt.wrong { border-color: var(--rose); background: rgba(255, 157, 176, 0.1); }
.q-feedback { margin: 1.2rem 0; padding: 0.9rem 1.1rem; border-radius: 14px; background: rgba(9, 12, 30, 0.5); border: 1px solid rgba(120, 160, 255, 0.16); color: var(--ink-soft); line-height: 1.55; min-height: 3rem; }
.q-feedback strong { color: var(--ink); }
.q-result { text-align: center; }
.q-result .big { font-family: var(--display); font-size: clamp(2.4rem, 8vw, 4rem); color: var(--gold); text-shadow: 0 0 30px rgba(240, 185, 90, 0.5); }
.q-result .stars { font-size: 2rem; letter-spacing: 0.2rem; margin: 0.4rem 0 1rem; }
.progress-dots { display: flex; gap: 6px; margin-bottom: 1.2rem; }
.progress-dots span { flex: 1; height: 5px; border-radius: 3px; background: rgba(120, 160, 255, 0.14); }
.progress-dots span.ok { background: var(--leaf); box-shadow: 0 0 6px var(--leaf); }
.progress-dots span.no { background: var(--rose); }
.progress-dots span.now { background: var(--cyan); }

/* ─── Forms (new creature) ───────────────────────── */
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .wide { grid-column: 1 / -1; }
.field label { display: block; font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan-soft); margin-bottom: 0.4rem; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.emoji-pick button {
  font-size: 1.2rem; line-height: 1; width: 2.3rem; height: 2.3rem; border-radius: 10px; cursor: pointer;
  background: rgba(12, 16, 34, 0.6); border: 1px solid rgba(120, 160, 255, 0.22);
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.emoji-pick button:hover { transform: translateY(-2px); }
.emoji-pick button[aria-pressed="true"] { border-color: var(--cyan); box-shadow: 0 0 14px rgba(110, 227, 236, 0.5); }
.range-row { display: flex; align-items: center; gap: 0.8rem; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.range-row input[type="range"] { flex: 1; accent-color: var(--cyan); }

/* ─── Map ─────────────────────────────────────────── */
.map-wrap { padding: 0.6rem; overflow: hidden; }
.map-wrap svg { width: 100%; height: auto; display: block; border-radius: 18px; }
.realm-g { cursor: pointer; }
.realm-g .halo { fill: var(--accent); fill-opacity: 0.05; transition: fill-opacity 0.3s; }
.realm-g:hover .halo, .realm-g.active .halo, .realm-g:focus .halo { fill-opacity: 0.2; }
.realm-g .decor { opacity: 0.92; transition: opacity 0.25s; }
.realm-g:hover .decor, .realm-g.active .decor, .realm-g:focus .decor { opacity: 1; filter: url(#glow); }
.realm-g .plate rect { transition: stroke-opacity 0.25s; }
.realm-g:hover .plate rect, .realm-g.active .plate rect, .realm-g:focus .plate rect { stroke-opacity: 1; filter: url(#glow); }
.realm-g:focus { outline: none; }
.realm-g .lbl { fill: #fff; font-family: var(--display); font-size: 23px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.realm-g .tag-t { fill: var(--accent); font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 2.5px; text-anchor: middle; pointer-events: none; text-transform: uppercase; }
.trail { fill: none; stroke: rgba(240, 185, 90, 0.35); stroke-width: 1.6; stroke-dasharray: 3 8; stroke-linecap: round; animation: trail 30s linear infinite; }
@keyframes trail { to { stroke-dashoffset: -220; } }
.map-info { display: grid; gap: 1.2rem; grid-template-columns: 1.9fr 1fr; align-items: start; }
@media (max-width: 800px) { .map-info { grid-template-columns: 1fr; } }
.realm-card { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 16%, transparent); transition: border-color 0.3s, box-shadow 0.3s; }
.realm-card .sig { font-size: 2.4rem; line-height: 1; filter: drop-shadow(0 0 12px var(--accent)); }
.realm-card h3 { font-size: 1.5rem; color: var(--accent); margin: 0.4rem 0 0.15rem; }
.realm-card .tl { font-family: var(--display); color: var(--ink-soft); margin: 0 0 0.8rem; }
.realm-card p { margin: 0 0 1rem; color: var(--ink-soft); line-height: 1.6; }
.realm-card .who { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem; font-size: 1.3rem; }
.realm-card .who span { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 60%, transparent)); }
.realm-list { display: grid; gap: 0.45rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 1rem; }

/* ─── Animated illustrations (Grove.lottie) ───────── */
/* The still picture shows first; the animation sits on top, invisible, and fades in once it has loaded. */
.lottie-box > dotlottie-wc { position: absolute; inset: var(--lottie-inset, 0); display: block; opacity: 0; transition: opacity 0.7s ease; pointer-events: none; }
.lottie-box > :not(dotlottie-wc) { transition: opacity 0.7s ease; }
.lottie-box.alive > dotlottie-wc { opacity: 1; }
.lottie-box.alive > :not(dotlottie-wc) { opacity: 0; }
/* a realm sigil: the emoji, with its animated version on top (Grove.sigil) */
.sig-anim { position: relative; display: inline-block; width: 1.3em; height: 1.3em; line-height: 1.3em; text-align: center; --lottie-inset: -28%; }
/* the little picture above a page's title (the Codex's book, Grove Run's Gloomling) */
.page-art { position: relative; width: 96px; height: 96px; margin: 0 auto 0.3rem; font-size: 3.4rem; line-height: 96px; text-align: center; --lottie-inset: -12%; filter: drop-shadow(0 0 18px rgba(185, 139, 255, 0.45)); }
.page-art > svg { width: 100%; height: 100%; display: block; }
@media (max-width: 640px) { .page-art { width: 72px; height: 72px; line-height: 72px; font-size: 2.6rem; } }
/* a one-shot celebration burst (Grove.burst) */
.lottie-burst { position: fixed; z-index: 75; width: 170px; height: 170px; margin: -85px 0 0 -85px; pointer-events: none; }

/* ─── Toast ───────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 1.4rem; z-index: 80;
  transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: 0.6rem;
  background: rgba(14, 22, 40, 0.92);
  border: 1px solid rgba(120, 235, 200, 0.5);
  color: #dffcf1; padding: 0.65rem 1.1rem; border-radius: 999px;
  font-size: 0.9rem; letter-spacing: 0.03em; white-space: nowrap; max-width: 92vw;
  opacity: 0; pointer-events: none;
  box-shadow: 0 0 30px rgba(120, 235, 200, 0.25);
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .em { font-size: 1.2rem; }
#toast.gold { border-color: rgba(240, 185, 90, 0.6); color: #fff1d6; box-shadow: 0 0 30px rgba(240, 185, 90, 0.35); }

/* ─── Footer ──────────────────────────────────────── */
footer.site {
  position: relative; z-index: 1; text-align: center;
  padding: 2.5rem 1rem 1.6rem; color: rgba(185, 192, 228, 0.55);
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase;
}
footer.site .crew { margin-bottom: 0.6rem; color: var(--ink-soft); }
footer.site .crew strong { color: var(--ink); }
footer.site .crew .dot { color: var(--cyan); margin: 0 0.5rem; }
footer.site .spark { color: var(--leaf); }

/* ─── Page transitions (the browser's own View Transitions, no library) ───
   Moving between the Grove, the Codex and Grove Run, the old page drifts
   forward and dissolves while the new one rises out of the mist, like stepping
   through a portal. The menu bar has its own name, so it stays put while the
   page behind it changes. Browsers that don't know this simply load the page
   as before. Hash links inside the Codex aren't page loads, so they're untouched. */
@view-transition { navigation: auto; }
.nav { view-transition-name: grove-nav; }
html.gate-on .nav { view-transition-name: none; } /* would float above the Gate */
::view-transition-old(root) { animation: portal-out 0.32s ease-in both; }
::view-transition-new(root) { animation: portal-in 0.38s ease-out both; }
::view-transition-group(grove-nav) { animation-duration: 0.32s; }
@keyframes portal-out { to { opacity: 0; transform: scale(1.03); filter: blur(6px) brightness(1.3); } }
@keyframes portal-in { from { opacity: 0; transform: scale(0.98); filter: blur(4px); } }

/* ─── Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  html { scroll-behavior: auto; }
  .star, .trail, .ccard, .overlay, .sheet, .shooting, .sparkle, .burst-spark, #scenery .mist { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}
