:root {
  --night: #1A1218;
  --dusk: #6B6FA8;
  --moss: #8FBF9A;
  --mist: #8EC4C8;
  --rose: #E8A0B4;
  --violet: #B08CC8;
  --honey: #E8C070;
  --parchment: #F0E4EE;
  --shadow: #4A3848;
  --lilac: #D4B4E8;
  --gold: #F0D8A0;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: #0B080B; }
body {
  margin: 0;
  background: transparent;
  color: var(--parchment);
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  line-height: 1.6;
}
/* outer-space layer: content scrolls on top of it, not with it */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
header, nav, main, footer { position: relative; z-index: 1; }
h1, h2, h3 {
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  color: var(--lilac);
  line-height: 1.2;
}
h2 { font-size: 2rem; letter-spacing: -0.02em; }
h3 { font-size: 1.35rem; }
.lede { max-width: 44rem; margin: 0 auto; color: var(--parchment); }
a { color: var(--rose); }
code, pre {
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  background: #241a22;
}
pre { padding: 1rem; overflow-x: auto; border-left: 3px solid var(--violet); }

/* splash */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.splash .hero { max-width: min(720px, 92vw); height: auto; }
.tag { color: var(--dusk); font-size: 1.25rem; }
.descend {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--rose);
  border-radius: 999px;
  text-decoration: none;
}

/* sticky index */
.index {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  justify-content: center;
  padding: 0.6rem;
  background: rgba(26, 18, 24, 0.95);
  border-bottom: 1px solid var(--shadow);
}
.index a { text-decoration: none; color: var(--mist); font-size: 0.95rem; }
.index a.active { color: var(--gold); text-decoration: underline; }

/* chapters */
main { max-width: 860px; margin: 0 auto; padding: 0 1.2rem 4rem; }
.chapter {
  padding: 3.5rem 0;
  border-top: 1px solid var(--shadow);
}
/* rise is progressive enhancement: hidden only when JS arms it */
html.fx .chapter {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
html.fx .chapter.risen { opacity: 1; transform: none; }
.chapter:first-of-type { border-top: none; }
.cellar { min-height: auto; }
.law strong { color: var(--gold); }
.app {
  border: 1px solid var(--shadow);
  border-radius: 12px;
  padding: 1.2rem;
  margin: 1.6rem 0;
}
.app h3 { margin-top: 0.4rem; color: var(--app, var(--lilac)); }
.app { border-top: 2px solid var(--app, var(--shadow)); }
/* shelf grid */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
  margin: 1.6rem 0;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.8rem;
  border: 1px solid var(--shadow);
  border-top: 2px solid var(--app, var(--lilac));
  border-radius: 10px;
  text-decoration: none;
}
.tile img { width: 100%; height: auto; border-radius: 6px; }
.tile strong { color: var(--app, var(--parchment)); font-size: 1rem; }
.tile span { color: var(--dusk); font-size: 0.8rem; line-height: 1.4; }
.tile:hover { border-color: var(--app, var(--rose)); }
.shot {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--shadow);
  margin: 1rem 0;
}
.clip {
  display: block;
  width: min(240px, 60vw);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--shadow);
  margin: 1rem 0;
  background: var(--night);
}
/* live text sigils — no images, no backgrounds to strip */
.sigil {
  color: var(--app, var(--parchment));
  text-shadow: 0 0 14px var(--app, transparent);
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
  margin: 1rem auto;
  padding: 0;
  background: none;
  border: none;
}
.tile .sigil { font-size: 0.8rem; }
figure { margin: 1.6rem 0; }
figcaption { color: var(--dusk); font-size: 0.9rem; }
footer { text-align: center; padding: 3rem 1rem; color: var(--dusk); }

/* up button */
#up {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  background: var(--night);
  color: var(--rose);
  border: 1px solid var(--rose);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  font-size: 1rem;
}
#up:hover { background: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.fx .chapter { opacity: 1; transform: none; transition: none; }
  html.fx main .chapter h2::before, html.fx main .chapter h2::after { animation: none; opacity: 0; }
}
/* glitch titles — same language as the story clips, zero downloads */
main .chapter h2 {
  position: relative;
  display: inline-block;
  text-shadow: 0 0 22px rgba(176, 140, 200, 0.3);
}
html.fx main .chapter h2::before, html.fx main .chapter h2::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  white-space: nowrap;
}
html.fx main .chapter h2::before {
  color: #8EC4C8;
  transform: translate(-2px, 0);
  clip-path: inset(12% 0 62% 0);
  animation: gl1 4.2s infinite steps(1);
}
html.fx main .chapter h2::after {
  color: #E8A0B4;
  transform: translate(2px, 0);
  clip-path: inset(58% 0 8% 0);
  animation: gl2 3.7s infinite steps(1);
}
@keyframes gl1 { 0%, 92%, 100% { opacity: 0; } 93%, 97% { opacity: 0.6; } }
@keyframes gl2 { 0%, 88%, 100% { opacity: 0; } 89%, 95% { opacity: 0.6; } }
@media (max-width: 640px) {
  .app img[width] { width: 100%; height: auto; }
}
