:root {
    /* IBM Plex Sans Condensed* Condense* Condensed** for instrument labels */
    --obsidian: #080718;
    --indigo: #21134F;
    --gold: #D7A84A;
    --cyan: #3FF3D4;
    --lacquer: #9E2448;
    --ivory: #F3E8C7;
    --malachite: #2AC77F;
    --amethyst: #8B5CFF;
    --wordmark: 'Cinzel Decorative', serif;
    --poem: 'Fraunces', serif;
    --label: 'IBM Plex Sans Condensed', sans-serif;
    --mono: 'Azeret Mono', monospace;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ivory);
    background:
        radial-gradient(circle at 72% 12%, rgba(139, 92, 255, 0.22), transparent 31rem),
        radial-gradient(circle at 9% 39%, rgba(158, 36, 72, 0.18), transparent 26rem),
        linear-gradient(135deg, #080718 0%, #21134F 48%, #3FF3D4 130%);
    font-family: var(--poem);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

.instruments-of-xanadu {
    position: relative;
    isolation: isolate;
}

.chamber {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    padding: clamp(2rem, 5vw, 5.5rem);
    display: grid;
    align-items: center;
    border-bottom: 1px solid rgba(215, 168, 74, 0.18);
}

.chamber::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(243, 232, 199, 0.12) 0 1px, transparent 1.5px),
        repeating-linear-gradient(90deg, transparent 0 5.8rem, rgba(215, 168, 74, 0.035) 5.85rem 5.9rem);
    background-size: 8rem 8rem, 12rem 12rem;
    opacity: 0.25;
    pointer-events: none;
}

.palace-map {
    position: fixed;
    z-index: 20;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3.1rem;
    padding: 0.65rem 0.45rem;
    border: 1px solid rgba(215, 168, 74, 0.42);
    border-radius: 5rem;
    background: rgba(8, 7, 24, 0.76);
    box-shadow: 0 0 2rem rgba(63, 243, 212, 0.12), inset 0 0 1.8rem rgba(139, 92, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.map-node {
    height: 2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: rgba(243, 232, 199, 0.58);
    border: 1px solid rgba(243, 232, 199, 0.16);
    font-family: var(--mono);
    font-size: 0.62rem;
    transition: background 500ms ease, color 500ms ease, box-shadow 500ms ease, border-color 500ms ease;
}

.map-node.active {
    color: var(--obsidian);
    background: radial-gradient(circle, var(--cyan), var(--gold));
    border-color: var(--gold);
    box-shadow: 0 0 1.1rem rgba(63, 243, 212, 0.55);
}

.river-thread {
    position: fixed;
    z-index: 5;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.9;
    mix-blend-mode: screen;
}

.river-thread path {
    fill: none;
    stroke: url(#riverGradient);
    stroke-width: 0.58;
    stroke-linecap: round;
    filter: url(#riverGlow);
    stroke-dasharray: 5 10;
    animation: riverPulse 10s linear infinite;
}

.instrument-label {
    margin: 0 0 1rem;
    color: var(--cyan);
    font-family: var(--label);
    font-size: clamp(0.86rem, 1.6vw, 1.1rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.gilded-rule {
    width: min(25rem, 58vw);
    height: 1px;
    margin: 1.2rem 0;
    background: linear-gradient(90deg, transparent, #D7A84A, #3FF3D4, transparent);
    box-shadow: 0 0 1rem rgba(215, 168, 74, 0.52);
}

.arch-frame {
    position: relative;
    padding: clamp(1.5rem, 4vw, 4rem);
    border: 1px solid rgba(215, 168, 74, 0.48);
    border-radius: 48% 48% 1.6rem 1.6rem / 20% 20% 1.6rem 1.6rem;
    background: linear-gradient(160deg, rgba(33, 19, 79, 0.84), rgba(8, 7, 24, 0.72));
    box-shadow: inset 0 0 4rem rgba(63, 243, 212, 0.08), 0 2rem 4rem rgba(0, 0, 0, 0.35);
}

.arch-frame::before {
    content: "";
    position: absolute;
    inset: 0.7rem;
    border: 1px solid rgba(63, 243, 212, 0.2);
    border-radius: inherit;
    pointer-events: none;
}

h1, h2 {
    margin: 0;
    line-height: 0.94;
    font-weight: 700;
}

h1 {
    font-family: var(--wordmark);
    font-size: clamp(3rem, 12vw, 12.5rem);
    color: transparent;
    background: linear-gradient(100deg, rgba(215,168,74,0.05), #D7A84A 30%, #F3E8C7 52%, #3FF3D4 68%, #D7A84A 80%);
    -webkit-background-clip: text;
    background-clip: text;
    letter-spacing: -0.07em;
    text-shadow: 0 0 3rem rgba(215, 168, 74, 0.24);
    animation: titleGild 5.6s ease both;
}

h2 {
    font-family: var(--wordmark);
    font-size: clamp(2.45rem, 6vw, 6.9rem);
    color: var(--ivory);
    text-shadow: 0 0 2.2rem rgba(139, 92, 255, 0.3);
}

p {
    font-size: clamp(1.05rem, 1.55vw, 1.45rem);
    line-height: 1.55;
    color: rgba(243, 232, 199, 0.82);
}

.observatory {
    background:
        radial-gradient(circle at 50% 76%, rgba(63, 243, 212, 0.16), transparent 25rem),
        radial-gradient(circle at 50% 45%, rgba(33, 19, 79, 0.86), transparent 36rem),
        #080718;
    grid-template-rows: 1fr auto;
}

.star-dust,
.star-dust::before {
    position: absolute;
    inset: 0;
    content: "";
    background-image: radial-gradient(circle, rgba(243,232,199,.5) 0 1px, transparent 1.4px);
    background-size: 7.7rem 6.2rem;
    opacity: 0.16;
    animation: dustDrift 23s linear infinite;
}

.star-dust::before {
    transform: rotate(37deg) scale(1.2);
    opacity: 0.2;
    animation-duration: 31s;
}

.dome-silhouette {
    position: absolute;
    left: 50%;
    bottom: -18vh;
    transform: translateX(-50%);
    width: min(82rem, 112vw);
    height: 72vh;
    border-radius: 50% 50% 0 0 / 72% 72% 0 0;
    background:
        radial-gradient(circle at 50% 24%, rgba(63,243,212,0.08), transparent 10rem),
        linear-gradient(180deg, rgba(33, 19, 79, 0.82), #080718 78%);
    border: 1px solid rgba(215, 168, 74, 0.22);
    box-shadow: inset 0 2rem 8rem rgba(0,0,0,.65), 0 -2rem 5rem rgba(139, 92, 255, 0.15);
}

.dome-window {
    position: absolute;
    bottom: 39%;
    width: 5.2rem;
    height: 10rem;
    border: 1px solid rgba(215, 168, 74, 0.38);
    border-radius: 50% 50% 0.8rem 0.8rem;
    background: linear-gradient(180deg, rgba(63,243,212,.18), rgba(8,7,24,.5));
    box-shadow: inset 0 0 2rem rgba(63, 243, 212, 0.12);
}
.window-a { left: 23%; transform: rotate(-10deg); }
.window-b { left: 47%; bottom: 48%; }
.window-c { right: 23%; transform: rotate(10deg); }

.dome-orbit {
    position: absolute;
    left: 50%;
    bottom: 16vh;
    width: min(86rem, 120vw);
    height: 17rem;
    border: 1px solid rgba(215, 168, 74, 0.42);
    border-radius: 50%;
    transform: translateX(-50%) rotate(-8deg);
}
.orbit-two { transform: translateX(-50%) rotate(13deg); border-color: rgba(63, 243, 212, 0.22); width: min(70rem, 100vw); }

.title-curve {
    align-self: end;
    position: relative;
    z-index: 3;
    margin-bottom: 16vh;
}

.opening-inscription {
    position: absolute;
    z-index: 4;
    right: clamp(3rem, 13vw, 14rem);
    bottom: 10vh;
    max-width: 26rem;
    font-family: var(--poem);
    color: rgba(243, 232, 199, 0.76);
}

.entrance-seal {
    position: absolute;
    z-index: 6;
    left: clamp(2rem, 8vw, 8rem);
    bottom: 11vh;
    color: var(--ivory);
    background: radial-gradient(circle at 30% 20%, rgba(215,168,74,.3), rgba(158,36,72,.66));
    border: 1px solid rgba(215, 168, 74, 0.72);
    border-radius: 999px;
    padding: 0.95rem 1.4rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-family: var(--label);
    cursor: pointer;
    box-shadow: 0 0 2rem rgba(158, 36, 72, 0.35), inset 0 0 1.5rem rgba(8,7,24,.42);
}

.river-lab {
    grid-template-columns: minmax(18rem, 0.72fr) minmax(25rem, 1fr);
    gap: 5vw;
    background: radial-gradient(circle at 18% 44%, rgba(63,243,212,.1), transparent 22rem), #080718;
}

.river-arch { max-width: 45rem; }
.river-arch p:last-child, .garden-arch p:last-child, .measurement-scroll p { max-width: 36rem; }

.current-belt {
    position: absolute;
    left: -6rem;
    right: -6rem;
    top: 54%;
    height: 7rem;
    display: flex;
    gap: 2rem;
    align-items: center;
    color: var(--cyan);
    font-family: var(--mono);
    white-space: nowrap;
    transform: rotate(-4deg);
    background: linear-gradient(90deg, transparent, rgba(63, 243, 212, 0.08), rgba(33, 19, 79, 0.65), transparent);
    border-block: 1px solid rgba(63, 243, 212, 0.2);
    overflow: hidden;
}
.current-belt span { display: inline-block; min-width: max-content; animation: currentDrift 18s linear infinite; }

.alcove {
    position: absolute;
    z-index: 4;
    width: 14rem;
    min-height: 9rem;
    padding: 1.2rem;
    border: 1px solid rgba(215, 168, 74, 0.43);
    border-radius: 50% 50% 1rem 1rem / 27% 27% 1rem 1rem;
    background: rgba(33, 19, 79, 0.72);
    font-family: var(--label);
    box-shadow: 0 0 2.5rem rgba(63, 243, 212, 0.1);
}
.alcove b { display: block; color: var(--gold); letter-spacing: 0.12em; text-transform: uppercase; }
.alcove em { display: block; margin-top: 0.8rem; color: rgba(243, 232, 199, 0.78); font-style: normal; }
.alcove-a { right: 23vw; top: 17vh; }
.alcove-b { right: 9vw; bottom: 12vh; }

.astrolabe {
    justify-self: end;
    width: min(36rem, 45vw);
    opacity: 0.78;
    stroke: var(--gold);
    fill: none;
    stroke-width: 1.2;
    filter: drop-shadow(0 0 1.5rem rgba(215, 168, 74, 0.28));
    animation: astrolabeSpin 48s linear infinite;
}
.astrolabe path { fill: rgba(63, 243, 212, 0.08); stroke: var(--cyan); }

.measurements {
    background: linear-gradient(180deg, #080718 0%, #120b35 47%, #080718 100%);
    align-items: end;
}

.stalactites {
    position: absolute;
    top: 0;
    left: 4vw;
    right: 4vw;
    height: 47vh;
    display: flex;
    justify-content: space-around;
    align-items: start;
    opacity: 0.8;
}
.stalactites i {
    display: block;
    width: 1px;
    height: var(--h, 18rem);
    background: linear-gradient(#D7A84A, #8B5CFF, transparent);
    transform: rotate(var(--r, 0deg));
    box-shadow: 0 0 1.4rem rgba(139, 92, 255, 0.45);
}
.stalactites i:nth-child(2) { --h: 25rem; --r: 5deg; }
.stalactites i:nth-child(3) { --h: 14rem; --r: -8deg; }
.stalactites i:nth-child(4) { --h: 31rem; --r: 3deg; }
.stalactites i:nth-child(5) { --h: 19rem; --r: -4deg; }
.stalactites i:nth-child(6) { --h: 27rem; --r: 7deg; }
.stalactites i:nth-child(7) { --h: 16rem; --r: -5deg; }

.pendulum-field { position: absolute; inset: 0; }
.pendulum {
    position: absolute;
    top: 0;
    width: 2px;
    height: 48vh;
    background: linear-gradient(rgba(215,168,74,.62), rgba(63,243,212,.08));
    transform-origin: top center;
    animation: pendulumSwing 6.4s ease-in-out infinite;
}
.pendulum span {
    position: absolute;
    left: 50%;
    bottom: -1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, #F3E8C7, #3FF3D4 32%, rgba(63,243,212,.08) 68%);
    box-shadow: 0 0 2rem rgba(63, 243, 212, 0.5);
}
.p1 { left: 18%; animation-delay: -1s; height: 38vh; }
.p2 { left: 48%; animation-delay: -2.4s; height: 55vh; }
.p3 { left: 74%; animation-delay: -3.3s; height: 42vh; }

.measurement-scroll {
    position: relative;
    z-index: 3;
    max-width: 53rem;
    margin-left: 10vw;
    margin-bottom: 10vh;
}
.readout-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 2rem;
}
.readout-grid span {
    color: var(--cyan);
    border: 1px solid rgba(63, 243, 212, 0.24);
    padding: 0.55rem 0.75rem;
    font-family: var(--mono);
    font-size: 0.82rem;
    background: rgba(8, 7, 24, 0.62);
}

.garden {
    grid-template-columns: 1fr minmax(20rem, 0.82fr);
    gap: 4vw;
    background:
        radial-gradient(circle at 33% 56%, rgba(42, 199, 127, 0.17), transparent 29rem),
        radial-gradient(circle at 77% 27%, rgba(158, 36, 72, 0.22), transparent 22rem),
        #080718;
}

.garden-map {
    position: relative;
    height: min(42rem, 74vh);
    border-radius: 49% 51% 45% 55%;
    border: 1px solid rgba(42, 199, 127, 0.25);
    background:
        radial-gradient(circle at 40% 50%, rgba(42,199,127,.14), transparent 20rem),
        repeating-radial-gradient(circle at 50% 55%, transparent 0 2rem, rgba(215,168,74,.07) 2.08rem 2.12rem);
}

.theorem-flower {
    position: absolute;
    width: 11rem;
    height: 11rem;
    animation: bloomPulse 7s ease-in-out infinite;
}
.theorem-flower span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4.5rem;
    height: 8.5rem;
    transform-origin: 50% 100%;
    border-radius: 100% 0 100% 0;
    background: linear-gradient(160deg, rgba(42,199,127,.62), rgba(63,243,212,.12));
    border: 1px solid rgba(243, 232, 199, 0.18);
}
.theorem-flower span:nth-child(1) { transform: translate(-50%, -100%) rotate(0deg); }
.theorem-flower span:nth-child(2) { transform: translate(-50%, -100%) rotate(90deg); background: linear-gradient(160deg, rgba(158,36,72,.7), rgba(215,168,74,.14)); }
.theorem-flower span:nth-child(3) { transform: translate(-50%, -100%) rotate(180deg); }
.theorem-flower span:nth-child(4) { transform: translate(-50%, -100%) rotate(270deg); background: linear-gradient(160deg, rgba(139,92,255,.62), rgba(63,243,212,.14)); }
.theorem-flower b {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--gold);
    font-family: var(--mono);
}
.flower-a { left: 8%; top: 12%; }
.flower-b { right: 12%; top: 35%; animation-delay: -2s; transform: scale(1.2); }
.flower-c { left: 32%; bottom: 5%; animation-delay: -4s; transform: scale(.86); }

.leaf-trace {
    position: absolute;
    color: var(--malachite);
    border: 1px solid rgba(42,199,127,.34);
    border-radius: 100% 0 100% 0;
    padding: 1rem 1.2rem;
    font-family: var(--label);
    letter-spacing: 0.08em;
    background: rgba(8,7,24,.62);
}
.trace-a { left: 48%; top: 12%; transform: rotate(-18deg); }
.trace-b { left: 12%; bottom: 20%; transform: rotate(13deg); }
.garden-arch { align-self: center; }

.returning-light {
    place-items: center;
    text-align: center;
    background:
        radial-gradient(circle at 50% 50%, rgba(63,243,212,.22), transparent 24rem),
        radial-gradient(circle at 50% 50%, rgba(215,168,74,.13), transparent 42rem),
        #080718;
}

.mandala {
    position: absolute;
    width: min(52rem, 84vw);
    aspect-ratio: 1;
    opacity: 0.86;
}
.mandala-ring {
    position: absolute;
    inset: var(--inset, 4%);
    border-radius: 50%;
    border: 1px solid rgba(215, 168, 74, 0.52);
    box-shadow: 0 0 2rem rgba(215, 168, 74, 0.18), inset 0 0 2rem rgba(63, 243, 212, 0.12);
    animation: astrolabeSpin 42s linear infinite;
}
.r2 { --inset: 18%; border-style: dashed; border-color: rgba(63, 243, 212, 0.5); animation-duration: 34s; animation-direction: reverse; }
.r3 { --inset: 32%; border-color: rgba(139, 92, 255, 0.64); animation-duration: 24s; }
.mandala-prism {
    position: absolute;
    inset: 38%;
    clip-path: polygon(50% 0, 100% 80%, 0 80%);
    background: linear-gradient(135deg, #D7A84A, #3FF3D4, #8B5CFF);
    filter: drop-shadow(0 0 2rem rgba(63, 243, 212, 0.58));
    opacity: 0.72;
}
.mandala-equation {
    position: absolute;
    color: var(--gold);
    font-family: var(--mono);
    font-size: clamp(1.2rem, 3vw, 2rem);
    text-shadow: 0 0 1.3rem rgba(215, 168, 74, 0.8);
}
.e1 { left: 50%; top: 3%; }
.e2 { right: 8%; top: 48%; }
.e3 { left: 8%; top: 48%; }
.e4 { left: 50%; bottom: 3%; }
.final-inscription {
    position: relative;
    z-index: 3;
    max-width: 58rem;
    padding: 2rem;
    background: radial-gradient(circle, rgba(8,7,24,.72), rgba(8,7,24,.18), transparent 72%);
}
.final-inscription .gilded-rule { margin-inline: auto; }

.reveal {
    opacity: 0;
    transform: translateY(2.5rem) scale(0.98);
    transition: opacity 1000ms ease, transform 1000ms ease;
}
.reveal.visible {
    opacity: 1;
    transform: none;
}

@keyframes titleGild {
    0% { opacity: 0.12; filter: brightness(0.35); letter-spacing: -0.03em; }
    100% { opacity: 1; filter: brightness(1.08); letter-spacing: -0.07em; }
}
@keyframes riverPulse { to { stroke-dashoffset: -90; } }
@keyframes dustDrift { to { background-position: 11rem 8rem; } }
@keyframes currentDrift { from { transform: translateX(0); } to { transform: translateX(-34rem); } }
@keyframes astrolabeSpin { to { transform: rotate(360deg); } }
@keyframes pendulumSwing { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes bloomPulse { 0%,100% { filter: brightness(.8); } 50% { filter: brightness(1.3); } }

@media (max-width: 860px) {
    .palace-map { right: 0.55rem; transform: translateY(-50%) scale(.82); transform-origin: right center; }
    .chamber { padding: 2rem 1.4rem 5rem; }
    .river-lab, .garden { grid-template-columns: 1fr; }
    .astrolabe { width: 72vw; justify-self: center; opacity: 0.42; }
    .alcove { position: relative; inset: auto; margin: 1rem 0; }
    .current-belt { top: 74%; }
    .opening-inscription, .entrance-seal { left: 1.4rem; right: 4rem; }
    .opening-inscription { bottom: 22vh; }
    .garden-map { min-height: 34rem; }
    .measurement-scroll { margin-left: 0; }
}
