@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Cinzel+Decorative:wght@700;900&family=Space+Mono:wght@400;700&family=Spectral:wght@400;500;600;700&display=swap');
/* Space Mono used sparingly for formulas */

:root {
  --deep-inkwell: #11131F;
  --aged-vellum: #E8D7B0;
  --lantern-amber: #F0A33A;
  --verdigris-teal: #2AAE9F;
  --paradox-violet: #6E4CFF;
  --sealing-wax-red: #B83A2E;
  --chalk-white: #F7F0DF;
  --display: 'Cinzel Decorative', serif;
  --prose: 'Spectral', serif;
  --mono: 'Space Mono', monospace;
  --hand: 'Caveat', cursive;
}

* { box-sizing: border-box; }

html {
  background: var(--deep-inkwell);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--chalk-white);
  font-family: var(--prose);
  background:
    radial-gradient(circle at 20% 8%, rgba(110, 76, 255, 0.24), transparent 34rem),
    radial-gradient(circle at 78% 36%, rgba(42, 174, 159, 0.13), transparent 30rem),
    linear-gradient(180deg, #11131F 0%, #171728 48%, #11131F 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(232, 215, 176, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 215, 176, 0.026) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px;
  mix-blend-mode: screen;
  z-index: 1;
}

.ink-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: .34;
  background:
    radial-gradient(circle at 12% 17%, rgba(247, 240, 223, .12) 0 1px, transparent 2px),
    radial-gradient(circle at 74% 31%, rgba(232, 215, 176, .09) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 83%, rgba(240, 163, 58, .08) 0 1px, transparent 2px);
  background-size: 80px 70px, 110px 120px, 150px 90px;
}

.moon-spotlight {
  position: fixed;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(247, 240, 223, .10), rgba(42, 174, 159, .035) 35%, transparent 68%);
  filter: blur(8px);
}

.quest-ledger {
  position: fixed;
  top: 1.2rem;
  left: 1.2rem;
  width: 9.4rem;
  padding: .9rem .85rem;
  z-index: 10;
  color: var(--aged-vellum);
  border: 1px solid rgba(232, 215, 176, .36);
  border-radius: 1rem;
  background: rgba(17, 19, 31, .72);
  box-shadow: 0 0 30px rgba(17, 19, 31, .6), inset 0 0 0 1px rgba(240, 163, 58, .08);
  backdrop-filter: blur(8px);
}

.ledger-title, .coords, code, .tablet-label {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.ledger-title {
  font-size: .57rem;
  color: var(--verdigris-teal);
}

.completion-ring {
  margin: .55rem auto .7rem;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 163, 58, .68);
  box-shadow: inset 0 0 18px rgba(240, 163, 58, .12), 0 0 24px rgba(240, 163, 58, .16);
  font-family: var(--mono);
  color: var(--lantern-amber);
}

.completion-ring span { font-size: 1.45rem; }
.completion-ring small { margin-left: .15rem; color: var(--aged-vellum); }

.ledger-route {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  font-family: var(--mono);
  font-size: .68rem;
}

.ledger-route span {
  padding: .1rem .25rem;
  border: 1px solid rgba(232, 215, 176, .22);
  color: rgba(247, 240, 223, .72);
}

.route-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 600vh;
  z-index: 4;
  pointer-events: none;
}

.route-shadow, .route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-shadow {
  stroke: rgba(232, 215, 176, .13);
  stroke-width: 8;
  stroke-dasharray: 18 18;
}

.route-line {
  stroke: var(--lantern-amber);
  stroke-width: 5;
  filter: drop-shadow(0 0 9px rgba(240, 163, 58, .72));
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.proof-dungeon { position: relative; z-index: 5; }

.chamber {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 8rem min(8vw, 7rem);
  isolation: isolate;
  overflow: hidden;
}

.chamber::before {
  content: "";
  position: absolute;
  inset: 5vw;
  border: 1px solid rgba(232, 215, 176, .12);
  clip-path: polygon(3% 10%, 92% 3%, 98% 76%, 68% 98%, 7% 91%);
  pointer-events: none;
}

h1, h2 {
  font-family: var(--display);
  margin: 0;
  letter-spacing: .045em;
  text-shadow: 0 0 24px rgba(240, 163, 58, .2);
}

h1 {
  color: var(--chalk-white);
  font-size: clamp(3.3rem, 10vw, 9.5rem);
  line-height: .9;
}

h2 {
  color: var(--aged-vellum);
  font-size: clamp(2.15rem, 5.8vw, 5.8rem);
  line-height: .96;
}

p {
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  line-height: 1.55;
}

.stars {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 24%, var(--chalk-white) 0 1px, transparent 2px),
    radial-gradient(circle at 73% 16%, var(--aged-vellum) 0 1px, transparent 2px),
    radial-gradient(circle at 60% 72%, var(--paradox-violet) 0 1px, transparent 2px),
    radial-gradient(circle at 35% 80%, var(--verdigris-teal) 0 1px, transparent 2px);
  background-size: 220px 180px, 260px 240px, 310px 290px, 180px 250px;
  opacity: .45;
  animation: starDrift 14s linear infinite;
}

.gate-arch {
  width: min(72rem, 82vw);
  min-height: 34rem;
  border: 3px double rgba(232, 215, 176, .62);
  border-radius: 48% 48% 1.5rem 1.5rem / 27% 27% 1.5rem 1.5rem;
  display: grid;
  place-items: center;
  padding: 5rem 2rem;
  background: linear-gradient(180deg, rgba(17, 19, 31, .62), rgba(17, 19, 31, .92));
  box-shadow: inset 0 0 75px rgba(110, 76, 255, .16), 0 0 60px rgba(0,0,0,.45);
}

.inscription {
  margin: .8rem 0 1.6rem;
  color: var(--aged-vellum);
  font-style: italic;
}

.nested {
  position: absolute;
  font-family: var(--display);
  font-size: min(30vw, 21rem);
  color: rgba(232, 215, 176, .055);
  top: 14%;
}

.nested-one { left: 12%; }
.nested-two { right: 12%; transform: rotate(180deg); }

.gate-lock, .bridge-knot, .ring-core {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--mono);
  color: var(--lantern-amber);
  border: 1px solid rgba(240, 163, 58, .85);
  background: radial-gradient(circle, rgba(240, 163, 58, .22), rgba(17, 19, 31, .92));
  box-shadow: 0 0 28px rgba(240, 163, 58, .34);
}

.gate-lock { width: 6rem; height: 6rem; font-size: 2.7rem; animation: rotateKey 8s linear infinite; }

.gate-bars {
  position: absolute;
  bottom: 14%;
  width: min(38rem, 56vw);
  display: flex;
  justify-content: space-around;
}

.gate-bars span {
  width: 3px;
  height: 9rem;
  background: linear-gradient(var(--aged-vellum), transparent);
  opacity: .34;
}

.tablet {
  position: absolute;
  width: min(26rem, 32vw);
  padding: 1.2rem 1.35rem;
  color: var(--deep-inkwell);
  background:
    radial-gradient(circle at 20% 10%, rgba(247, 240, 223, .8), transparent 30%),
    var(--aged-vellum);
  border: 2px solid rgba(240, 163, 58, .55);
  clip-path: polygon(5% 0, 100% 8%, 94% 100%, 0 88%);
  box-shadow: 0 18px 45px rgba(0,0,0,.36);
  transform: translateY(36px);
  opacity: 0;
  transition: transform 1s ease, opacity 1s ease;
}

.active .tablet { transform: translateY(0); opacity: 1; }
.tablet-left { left: 7vw; bottom: 15vh; transition-delay: .2s; }
.tablet-right { right: 7vw; top: 18vh; transition-delay: .55s; }
.tablet strong { display: block; font-size: 1.3rem; line-height: 1.18; margin: .7rem 0; }
.tablet code { color: var(--paradox-violet); font-size: 1.1rem; }

.hand-note {
  position: absolute;
  margin: 0;
  font-family: var(--hand);
  color: var(--lantern-amber);
  font-size: clamp(1.8rem, 3.4vw, 3.2rem);
  transform: rotate(-7deg);
}

.note-one { right: 12vw; bottom: 8vh; }
.note-two { left: 13vw; bottom: 12vh; color: var(--sealing-wax-red); }
.note-three { right: 10vw; bottom: 11vh; color: var(--verdigris-teal); }
.note-four { left: 12vw; top: 15vh; color: var(--lantern-amber); }

.parchment-island {
  color: var(--deep-inkwell);
  background:
    linear-gradient(135deg, rgba(247, 240, 223, .9), rgba(232, 215, 176, .92)),
    var(--aged-vellum);
  padding: clamp(1.4rem, 3.4vw, 3rem);
  box-shadow: 0 25px 70px rgba(0,0,0,.42), inset 0 0 0 1px rgba(184, 58, 46, .18);
  clip-path: polygon(0 8%, 91% 0, 100% 84%, 72% 100%, 4% 94%);
}

.parchment-island h2 { color: var(--deep-inkwell); text-shadow: none; }
.coords { color: var(--sealing-wax-red); font-size: .76rem; }

.fork-scroll {
  position: absolute;
  top: 14vh;
  left: 12vw;
  width: min(33rem, 72vw);
}

.implication-bridge {
  position: relative;
  width: min(64rem, 86vw);
  height: 34rem;
  margin-top: 8rem;
}

.implication-bridge::before, .implication-bridge::after {
  content: "";
  position: absolute;
  top: 48%;
  width: 46%;
  height: 1.4rem;
  border: 1px solid rgba(232, 215, 176, .42);
  background: repeating-linear-gradient(90deg, rgba(232, 215, 176, .18) 0 22px, rgba(17,19,31,.6) 22px 36px);
}

.implication-bridge::before { left: 6%; transform: rotate(-20deg); box-shadow: 0 0 26px rgba(42,174,159,.16); }
.implication-bridge::after { right: 6%; transform: rotate(20deg); box-shadow: 0 0 26px rgba(184,58,46,.18); }

.path-choice {
  position: absolute;
  width: 16rem;
  min-height: 9rem;
  border: 1px solid currentColor;
  font-family: var(--mono);
  color: var(--aged-vellum);
  background: rgba(17, 19, 31, .78);
  cursor: pointer;
  transition: transform .35s ease, box-shadow .35s ease, color .35s ease;
}

.path-choice.valid { left: 3%; top: 6%; color: var(--verdigris-teal); clip-path: polygon(8% 0, 100% 8%, 91% 100%, 0 90%); }
.path-choice.false { right: 3%; bottom: 6%; color: var(--sealing-wax-red); clip-path: polygon(0 10%, 94% 0, 100% 88%, 10% 100%); }
.path-choice small { color: var(--aged-vellum); }
.path-choice:hover, .path-choice.chosen { transform: translateY(-8px) rotate(-2deg); box-shadow: 0 0 30px currentColor; }
.path-choice.false.crumble { animation: crumble .8s ease both; }

.bridge-knot {
  position: absolute;
  left: calc(50% - 3rem);
  top: calc(50% - 3rem);
  width: 6rem;
  height: 6rem;
  font-size: 2.5rem;
}

.contradiction-well { background: radial-gradient(circle at 50% 48%, rgba(184,58,46,.19), transparent 33rem); }

.well-mouth {
  width: min(44rem, 78vw);
  aspect-ratio: 1.6;
  display: grid;
  place-items: center;
  padding: 3rem;
  text-align: center;
  border-radius: 50%;
  border: 3px double rgba(184, 58, 46, .75);
  background: radial-gradient(ellipse at center, rgba(17,19,31,.96) 0 34%, rgba(184,58,46,.18) 35%, rgba(17,19,31,.5) 68%, transparent 70%);
  box-shadow: inset 0 -30px 80px rgba(0,0,0,.72), 0 0 65px rgba(184,58,46,.24);
}

.well-mouth p { max-width: 28rem; color: var(--aged-vellum); }
.raven { position: absolute; font-family: var(--display); font-size: 5rem; color: var(--sealing-wax-red); filter: drop-shadow(0 0 16px rgba(184,58,46,.45)); }
.raven-left { left: 18vw; top: 23vh; transform: rotate(-18deg); }
.raven-right { right: 18vw; bottom: 23vh; transform: rotate(17deg); }

.falling-claims span {
  position: absolute;
  top: -5rem;
  font-family: var(--mono);
  color: var(--sealing-wax-red);
  animation: fallClaim 5.5s linear infinite;
  opacity: .76;
}
.falling-claims span:nth-child(1) { left: 18%; animation-delay: .2s; }
.falling-claims span:nth-child(2) { left: 28%; animation-delay: 1.4s; }
.falling-claims span:nth-child(3) { left: 62%; animation-delay: .8s; }
.falling-claims span:nth-child(4) { left: 70%; animation-delay: 2.2s; }
.falling-claims span:nth-child(5) { left: 48%; animation-delay: 3s; }
.falling-claims span:nth-child(6) { left: 82%; animation-delay: 4s; }

.wax-seal {
  position: absolute;
  right: 13vw;
  top: 15vh;
  width: 7rem;
  height: 7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--display);
  color: var(--chalk-white);
  background: var(--sealing-wax-red);
  box-shadow: inset -8px -10px 0 rgba(17,19,31,.18), 0 0 35px rgba(184,58,46,.45);
}

.margin-proof { position: absolute; left: 10vw; bottom: 15vh; color: var(--aged-vellum); }

.lemma-lanterns { grid-template-columns: 1.05fr .95fr; gap: 4vw; }
.lemma-ring {
  position: relative;
  width: min(36rem, 78vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed rgba(232,215,176,.3);
  animation: slowSpin 28s linear infinite;
}

.lantern {
  position: absolute;
  width: 5.3rem;
  height: 5.3rem;
  border-radius: 45% 45% 50% 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  color: var(--deep-inkwell);
  background: radial-gradient(circle at 50% 35%, var(--chalk-white), var(--lantern-amber) 58%, rgba(240,163,58,.4));
  box-shadow: 0 0 18px rgba(240,163,58,.35);
  transform: translate(-50%, -50%);
  transition: box-shadow .4s ease, filter .4s ease;
}

.lantern.lit { box-shadow: 0 0 42px rgba(240,163,58,.82), 0 0 70px rgba(42,174,159,.32); filter: saturate(1.25); }
.lantern:nth-child(1) { left: 50%; top: 2%; }
.lantern:nth-child(2) { left: 91%; top: 27%; }
.lantern:nth-child(3) { left: 91%; top: 73%; }
.lantern:nth-child(4) { left: 50%; top: 98%; }
.lantern:nth-child(5) { left: 9%; top: 73%; }
.lantern:nth-child(6) { left: 9%; top: 27%; }
.ring-core { position: absolute; inset: calc(50% - 3.2rem); font-size: 2rem; animation: counterSpin 28s linear infinite; }
.lemma-copy { width: min(34rem, 78vw); }

.quantifier-garden { background: radial-gradient(circle at 65% 52%, rgba(42,174,159,.17), transparent 34rem); }
.garden-copy { position: absolute; left: 10vw; top: 13vh; width: min(34rem, 74vw); z-index: 2; }
.symbol-vines { position: relative; width: min(58rem, 88vw); height: 36rem; margin-top: 10rem; }
.symbol-vines::before {
  content: "";
  position: absolute;
  inset: 7rem 4rem 2rem;
  border: 2px solid rgba(42,174,159,.45);
  border-radius: 50% 50% 1rem 1rem;
  box-shadow: 0 0 34px rgba(42,174,159,.22);
}

.quantifier-key {
  position: absolute;
  width: 7rem;
  height: 7rem;
  border-radius: 50% 50% 50% 0;
  border: 1px solid var(--verdigris-teal);
  background: rgba(17,19,31,.82);
  color: var(--verdigris-teal);
  font-family: var(--display);
  font-size: 3rem;
  cursor: pointer;
  transition: transform .35s ease, box-shadow .35s ease, color .35s ease;
}
.quantifier-key:first-child { right: 24%; top: 1rem; }
.quantifier-key:nth-child(2) { right: 8%; top: 9rem; color: var(--paradox-violet); border-color: var(--paradox-violet); }
.quantifier-key.turned { transform: rotate(45deg) scale(1.08); box-shadow: 0 0 35px currentColor; }

.vine {
  position: absolute;
  padding: .65rem .9rem;
  font-family: var(--mono);
  color: var(--verdigris-teal);
  border: 1px solid rgba(42,174,159,.35);
  background: rgba(17,19,31,.7);
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(42,174,159,.12);
}
.vine-one { left: 8%; top: 45%; transform: rotate(-17deg); }
.vine-two { left: 36%; top: 70%; transform: rotate(9deg); color: var(--paradox-violet); }
.vine-three { right: 10%; top: 52%; transform: rotate(-5deg); }

.conclusion-door { background: radial-gradient(circle at 50% 50%, rgba(240,163,58,.18), rgba(110,76,255,.12) 32rem, transparent 48rem); }
.final-door {
  width: min(45rem, 80vw);
  min-height: 42rem;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 5rem 3rem 3rem;
  border: 3px double rgba(240,163,58,.75);
  border-radius: 50% 50% 1.2rem 1.2rem / 25% 25% 1.2rem 1.2rem;
  background: linear-gradient(180deg, rgba(17,19,31,.62), rgba(17,19,31,.95));
  box-shadow: inset 0 0 95px rgba(240,163,58,.12), 0 0 90px rgba(240,163,58,.18);
}
.door-formula { color: var(--verdigris-teal); margin: .3rem 0; }
.qed-seal {
  width: 10rem;
  height: 10rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin: 1.4rem;
  font-family: var(--display);
  color: var(--chalk-white);
  background: var(--sealing-wax-red);
  box-shadow: inset -12px -14px 0 rgba(17,19,31,.2), 0 0 45px rgba(184,58,46,.5);
  transform: scale(.82) rotate(-12deg);
  transition: transform .7s ease, box-shadow .7s ease;
}
.qed-seal.complete { transform: scale(1.1) rotate(0deg); box-shadow: inset -12px -14px 0 rgba(17,19,31,.15), 0 0 80px rgba(240,163,58,.7); }

.orbit {
  position: absolute;
  width: min(54rem, 88vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed rgba(232,215,176,.22);
  animation: slowSpin 36s linear infinite;
}
.orbit span {
  position: absolute;
  left: 50%;
  top: 50%;
  font-family: var(--mono);
  color: var(--lantern-amber);
  text-shadow: 0 0 14px rgba(240,163,58,.9);
}
.orbit span:nth-child(1) { transform: rotate(0deg) translateX(27rem); }
.orbit span:nth-child(2) { transform: rotate(45deg) translateX(27rem); }
.orbit span:nth-child(3) { transform: rotate(90deg) translateX(27rem); }
.orbit span:nth-child(4) { transform: rotate(135deg) translateX(27rem); color: var(--sealing-wax-red); }
.orbit span:nth-child(5) { transform: rotate(180deg) translateX(27rem); }
.orbit span:nth-child(6) { transform: rotate(225deg) translateX(27rem); color: var(--verdigris-teal); }
.orbit span:nth-child(7) { transform: rotate(270deg) translateX(27rem); color: var(--paradox-violet); }
.orbit span:nth-child(8) { transform: rotate(315deg) translateX(27rem); }

.note-popup {
  position: fixed;
  max-width: 18rem;
  padding: .7rem .9rem;
  border: 1px solid rgba(240,163,58,.55);
  background: rgba(232,215,176,.95);
  color: var(--deep-inkwell);
  font-family: var(--hand);
  font-size: 1.55rem;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transform: translate(12px, 12px) rotate(-3deg);
  transition: opacity .2s ease;
  box-shadow: 0 14px 34px rgba(0,0,0,.32);
}
.note-popup.visible { opacity: 1; }

.chamber:not(.active) .parchment-island, .chamber:not(.active) .well-mouth, .chamber:not(.active) .lemma-ring, .chamber:not(.active) .symbol-vines, .chamber:not(.active) .final-door {
  transform: translateY(28px) scale(.98);
  opacity: .72;
}
.parchment-island, .well-mouth, .lemma-ring, .symbol-vines, .final-door { transition: transform .8s ease, opacity .8s ease; }

@keyframes starDrift { to { background-position: 220px 180px, -260px 240px, 310px -290px, -180px -250px; } }
@keyframes rotateKey { to { transform: rotate(360deg); } }
@keyframes slowSpin { to { transform: rotate(360deg); } }
@keyframes counterSpin { to { transform: rotate(-360deg); } }
@keyframes fallClaim { 0% { transform: translateY(-4rem) rotate(0deg); opacity: 0; } 18% { opacity: .8; } 100% { transform: translateY(110vh) rotate(260deg); opacity: 0; } }
@keyframes crumble { 0% { clip-path: polygon(0 10%, 94% 0, 100% 88%, 10% 100%); } 100% { clip-path: polygon(8% 14%, 22% 6%, 29% 50%, 43% 36%, 56% 96%, 61% 44%, 78% 66%, 90% 12%, 100% 88%, 10% 100%); transform: translateY(16px) rotate(5deg); opacity: .55; } }

@media (max-width: 820px) {
  .quest-ledger { width: 7.8rem; transform: scale(.88); transform-origin: top left; }
  .chamber { padding: 7rem 1.2rem; }
  .tablet { position: relative; inset: auto; width: min(22rem, 82vw); margin: .8rem; }
  .gate-arch { width: 92vw; min-height: 28rem; }
  .lemma-lanterns { grid-template-columns: 1fr; }
  .fork-scroll, .garden-copy { position: relative; inset: auto; width: 88vw; }
  .implication-bridge { height: 30rem; }
  .path-choice { width: 12.5rem; }
  .orbit span:nth-child(n) { transform: translate(-50%, -50%); }
}
