:root {
  /* Design typography tokens: inscriptions. Let the page feel discoverable with Fira Code operators embedded into the world rather than presented as terminal decoration. Fira Code** Cod should be reserved for code snippets */
  --violet: #9B7CFF;
  --copper: #C47A3B;
  --pine: #426A5A;
  --midnight: #130B24;
  --arcane: #6A4CFF;
  --parchment: #F2E8C9;
  --rose: #E85D75;
  --ink: #21142d;
  --font-title: "Cormorant Garamond", serif;
  --font-body: "Atkinson Hyperlegible", sans-serif;
  --font-code: "Fira Code", monospace;
  --font-space: "Space Grotesk", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--parchment);
  background: var(--midnight);
  font-family: var(--font-body);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .13;
  background-image: radial-gradient(circle at 20% 30%, #F2E8C9 0 1px, transparent 1px), radial-gradient(circle at 70% 80%, #C47A3B 0 1px, transparent 1px), radial-gradient(circle at 45% 55%, #9B7CFF 0 1px, transparent 1px);
  background-size: 37px 41px, 61px 53px, 97px 89px;
  mix-blend-mode: screen;
}

.cursor-rune {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 49;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--violet);
  border: 1px solid rgba(155, 124, 255, .32);
  border-radius: 50%;
  font-family: var(--font-title);
  font-size: 30px;
  transform: translate3d(-60px, -60px, 0);
  pointer-events: none;
  box-shadow: 0 0 24px rgba(106, 76, 255, .35);
}

.opening {
  min-height: 124vh;
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  background: radial-gradient(circle at 50% 30%, rgba(106, 76, 255, .22), transparent 28%), radial-gradient(circle at 20% 80%, rgba(66, 106, 90, .24), transparent 31%), linear-gradient(160deg, #130B24 0%, #090612 72%, #130B24 100%);
}

.night-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-image: radial-gradient(circle at 18% 24%, rgba(242, 232, 201, .68) 0 1px, transparent 2px), radial-gradient(circle at 76% 18%, rgba(155, 124, 255, .75) 0 1px, transparent 2px), radial-gradient(circle at 67% 71%, rgba(242, 232, 201, .43) 0 1px, transparent 2px), radial-gradient(circle at 37% 63%, rgba(232, 93, 117, .5) 0 1px, transparent 2px);
}

.lambda-constellation {
  position: absolute;
  width: min(74vw, 680px);
  aspect-ratio: 1;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%) scale(1);
  opacity: .85;
  transition: transform .9s ease, opacity .9s ease;
}

.opening.unfurled .lambda-constellation { transform: translate(-50%, -38%) scale(.72) rotate(-7deg); opacity: .38; }

.star-line {
  fill: none;
  stroke: var(--violet);
  stroke-width: 2;
  stroke-dasharray: 8 14;
  filter: drop-shadow(0 0 14px rgba(155, 124, 255, .9));
  animation: starPulse 4s ease-in-out infinite;
}

.stars circle { fill: var(--parchment); filter: drop-shadow(0 0 10px #9B7CFF); }

.opening-copy {
  position: relative;
  z-index: 2;
  width: min(980px, calc(100vw - 44px));
  text-align: center;
  padding-bottom: 16vh;
}

.eyebrow, .code-label {
  margin: 0 0 12px;
  color: var(--copper);
  font-family: var(--font-space);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .24em;
}

h1, h2, h3, blockquote {
  font-family: var(--font-title);
  font-weight: 600;
  margin: 0;
}

h1 {
  font-size: clamp(72px, 13vw, 180px);
  line-height: .82;
  color: var(--parchment);
  text-shadow: 0 0 40px rgba(155, 124, 255, .38), 0 12px 0 rgba(196, 122, 59, .12);
}

.hero-phrase {
  max-width: 720px;
  margin: 28px auto 0;
  font-size: clamp(19px, 2vw, 29px);
  line-height: 1.45;
  color: rgba(242, 232, 201, .82);
}

.scroll-sigil {
  position: absolute;
  bottom: 10vh;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-code);
  color: var(--violet);
  font-size: 13px;
  padding: 12px 18px;
  border: 1px solid rgba(155, 124, 255, .28);
  border-radius: 999px;
  background: rgba(19, 11, 36, .62);
}

.atlas {
  position: relative;
  background: linear-gradient(180deg, #090612 0%, #130B24 18%, #21142d 100%);
}

.compass {
  position: fixed;
  right: 26px;
  top: 28px;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(242, 232, 201, .24);
  border-radius: 50%;
  z-index: 30;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(242, 232, 201, .12), rgba(19, 11, 36, .76));
  box-shadow: 0 0 32px rgba(19, 11, 36, .8), inset 0 0 24px rgba(196, 122, 59, .12);
}

.compass span { color: var(--parchment); font-family: var(--font-title); font-size: 34px; }
.needle { position: absolute; width: 2px; height: 58px; background: linear-gradient(var(--rose) 0 50%, var(--pine) 50%); transform-origin: center; transition: transform .25s ease-out; }

.map-hero { min-height: 220vh; padding: 8vh 4vw 12vh; }

.parchment-map {
  position: relative;
  min-height: 1720px;
  max-width: 1320px;
  margin: 0 auto;
  border-radius: 42px;
  overflow: hidden;
  background: radial-gradient(circle at 22% 83%, rgba(66, 106, 90, .34), transparent 25%), radial-gradient(circle at 73% 22%, rgba(155, 124, 255, .2), transparent 28%), linear-gradient(135deg, rgba(242, 232, 201, .93), rgba(218, 191, 142, .86));
  color: var(--ink);
  box-shadow: 0 34px 100px rgba(0, 0, 0, .46), inset 0 0 0 2px rgba(196, 122, 59, .32), inset 0 0 120px rgba(19, 11, 36, .28);
  transform: rotate(-1.2deg);
}

.parchment-map::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(19, 11, 36, .28);
  border-radius: 32px;
  pointer-events: none;
}

.quest-route { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-shadow, .route-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.route-shadow { stroke: rgba(19, 11, 36, .18); stroke-width: 21; }
.route-line { stroke: var(--arcane); stroke-width: 8; stroke-dasharray: 2400; stroke-dashoffset: 2400; filter: url(#routeGlow); transition: stroke-dashoffset .2s linear; }

.tablet, .chapter-card, .constellation-panel {
  background: rgba(19, 11, 36, .88);
  color: var(--parchment);
  border: 1px solid rgba(242, 232, 201, .2);
  box-shadow: 0 20px 55px rgba(19, 11, 36, .34), inset 0 0 26px rgba(155, 124, 255, .08);
}

.map-title {
  position: absolute;
  left: 7%;
  bottom: 7%;
  width: min(430px, 82vw);
  padding: 34px;
  border-radius: 26px;
  transform: rotate(1.4deg);
}

.map-title h2, .observatory h2 { font-size: clamp(44px, 6vw, 84px); line-height: .9; }
.map-title p:not(.code-label), .constellation-panel p, .chapter-card p { line-height: 1.55; color: rgba(242, 232, 201, .78); }

.chapter-card {
  position: absolute;
  width: min(390px, 78vw);
  padding: 25px;
  border-radius: 25px 25px 25px 9px;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .35s ease, box-shadow .35s ease, border-color .35s ease;
}

.chapter-card::after {
  content: attr(data-rune);
  position: absolute;
  right: 18px;
  top: 12px;
  color: rgba(155, 124, 255, .32);
  font-family: var(--font-code);
  font-size: 36px;
}

.chapter-card:hover { transform: rotate(0deg) translateY(-8px); border-color: rgba(155, 124, 255, .55); box-shadow: 0 30px 70px rgba(19, 11, 36, .44), 0 0 34px rgba(106, 76, 255, .23); }
.chapter-card h3 { font-size: 38px; color: var(--parchment); padding-right: 64px; }
.chapter-number { color: var(--copper); font-family: var(--font-space); letter-spacing: .2em; font-size: 13px; }
code { font-family: var(--font-code); color: var(--violet); font-size: 13px; }

.lazy-gate { left: 15%; bottom: 30%; --tilt: 2.3deg; }
.type-forest { left: 29%; top: 48%; --tilt: -2deg; }
.monad-ferry { right: 25%; top: 34%; --tilt: 1.5deg; }
.pattern-ruins { right: 8%; top: 18%; --tilt: -2.8deg; }
.repl-camp { right: 4%; top: 5%; --tilt: 1deg; }

.rune-button, .ruin-glyphs button {
  margin-top: 18px;
  border: 1px solid rgba(196, 122, 59, .7);
  background: rgba(196, 122, 59, .18);
  color: var(--parchment);
  border-radius: 999px;
  padding: 10px 14px;
  font-family: var(--font-code);
  cursor: pointer;
}

.lazy-river { display: flex; gap: 8px; height: 30px; align-items: center; opacity: .32; transition: opacity .35s ease; }
.lazy-river span { display: block; flex: 1; height: 6px; border-radius: 999px; background: var(--pine); transform: scaleX(.2); transform-origin: left; transition: transform .5s ease; box-shadow: 0 0 18px rgba(66, 106, 90, .7); }
.lazy-river.awake { opacity: 1; }
.lazy-river.awake span { transform: scaleX(1); }
.lazy-river.awake span:nth-child(2) { transition-delay: .16s; }
.lazy-river.awake span:nth-child(3) { transition-delay: .32s; }

.type-tree { position: relative; height: 120px; margin-top: 18px; }
.type-tree b { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); color: var(--copper); font-family: var(--font-code); }
.type-tree i { position: absolute; width: 2px; height: 88px; left: 50%; bottom: 22px; background: var(--pine); transform-origin: bottom; box-shadow: 0 0 14px rgba(66, 106, 90, .68); }
.type-tree i:nth-child(1){ transform: rotate(-44deg); }.type-tree i:nth-child(2){ transform: rotate(-18deg); }.type-tree i:nth-child(3){ transform: rotate(18deg); }.type-tree i:nth-child(4){ transform: rotate(44deg); }

.ferry-stage { height: 54px; margin-top: 16px; border-bottom: 2px dashed rgba(155, 124, 255, .4); position: relative; }
.boat { position: absolute; left: 0; top: 4px; width: 52px; height: 32px; display: grid; place-items: center; border-radius: 4px 4px 18px 18px; background: var(--copper); color: var(--midnight); font-family: var(--font-title); font-size: 25px; transition: left .8s cubic-bezier(.2,.8,.2,1); }
.boat.crossed { left: calc(100% - 52px); }

.ruin-glyphs { display: flex; flex-wrap: wrap; gap: 8px; }
.match-result { color: var(--rose) !important; font-family: var(--font-code); }
.repl-box { margin-top: 16px; display: grid; gap: 10px; padding: 16px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid rgba(155,124,255,.18); }

.observatory {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 540px);
  gap: 4vw;
  align-items: center;
  padding: 10vh 7vw;
  background: radial-gradient(circle at 70% 35%, rgba(155, 124, 255, .22), transparent 32%), linear-gradient(180deg, #21142d, #130B24);
}

.constellation-panel { border-radius: 34px; padding: clamp(28px, 5vw, 60px); }
.star-map { position: relative; height: 390px; margin-top: 26px; border-radius: 28px; overflow: hidden; background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(155, 124, 255, .24), transparent 23%), rgba(9, 6, 18, .7); border: 1px solid rgba(242,232,201,.16); }
.star-map span { position: absolute; left: var(--x); top: var(--y); color: var(--parchment); font-family: var(--font-code); transform: translate(-50%, -50%); text-shadow: 0 0 16px #9B7CFF; }
.star-map span::before { content: ""; display: block; width: 7px; height: 7px; margin: 0 auto 6px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 15px var(--violet); }
.moth { position: absolute; width: 16px; height: 10px; background: var(--rose); border-radius: 50% 50% 0 0; opacity: .7; animation: moth 7s ease-in-out infinite; }
.moth-a { left: 30%; top: 38%; }.moth-b { left: 72%; top: 28%; animation-delay: -2s; }.moth-c { left: 58%; top: 70%; animation-delay: -4s; }
blockquote { font-size: clamp(32px, 4vw, 64px); line-height: 1.02; color: var(--parchment); margin: 0; text-shadow: 0 0 35px rgba(155, 124, 255, .2); }

@keyframes starPulse { 50% { stroke-dashoffset: -44; opacity: .65; } }
@keyframes moth { 0%,100% { transform: translate(0,0) rotate(0); } 33% { transform: translate(28px,-18px) rotate(12deg); } 66% { transform: translate(-18px,22px) rotate(-18deg); } }

@media (max-width: 940px) {
  .parchment-map { min-height: 2150px; transform: none; }
  .chapter-card, .map-title { position: relative; left: auto; right: auto; top: auto; bottom: auto; width: calc(100% - 44px); margin: 42px auto; transform: none; }
  .map-title { padding: 28px; }
  .observatory { grid-template-columns: 1fr; }
  .compass { width: 62px; height: 62px; right: 14px; top: 14px; }
  .cursor-rune { display: none; }
}
