:root {
    --court-midnight: #0B1020;
    --vellum-gold: #E8D7A2;
    --wax-verdict: #A6292E;
    --oxidized-brass: #8A6F2A;
    --lantern-flame: #F4A340;
    --robe-violet: #3A214A;
    --bone-chalk: #F7F0DA;
    --display: "Cormorant Garamond", serif;
    --body: "Alegreya Sans", sans-serif;
    --accent: "Unbounded", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    overflow-x: hidden;
    cursor: none;
    color: var(--bone-chalk);
    background:
        radial-gradient(circle at 15% 20%, rgba(58, 33, 74, .55), transparent 32rem),
        radial-gradient(circle at 85% 10%, rgba(138, 111, 42, .18), transparent 26rem),
        linear-gradient(135deg, var(--court-midnight), #080b17 48%, #120f1f);
    font-family: var(--body);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: .25;
    background-image:
        linear-gradient(rgba(247, 240, 218, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(247, 240, 218, .025) 1px, transparent 1px);
    background-size: 42px 42px, 42px 42px;
    mask-image: radial-gradient(circle, black, transparent 80%);
}

.cursor-seal {
    position: fixed;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    z-index: 200;
    pointer-events: none;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--lantern-flame), var(--wax-verdict) 58%, transparent 62%);
    box-shadow: 0 0 24px rgba(244, 163, 64, .45);
    mix-blend-mode: screen;
    opacity: .86;
    transition: width .25s ease, height .25s ease, opacity .25s ease;
}

.cursor-seal.is-lit { width: 54px; height: 54px; opacity: .55; }

.dust-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background-image:
        radial-gradient(circle, rgba(232, 215, 162, .55) 0 1px, transparent 1.6px),
        radial-gradient(circle, rgba(244, 163, 64, .34) 0 1px, transparent 1.4px);
    background-size: 170px 210px, 240px 180px;
    animation: dustDrift 20s linear infinite;
    opacity: .35;
}

@keyframes dustDrift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-90px, -130px, 0); }
}

.map-legend {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    display: grid;
    gap: .72rem;
    font-family: var(--accent);
    font-size: .58rem;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.map-legend a {
    color: rgba(247, 240, 218, .52);
    text-decoration: none;
    writing-mode: vertical-rl;
    padding: .55rem .35rem;
    border-left: 1px solid rgba(138, 111, 42, .35);
    background: rgba(11, 16, 32, .34);
    transition: color .3s ease, border-color .3s ease, text-shadow .3s ease;
}

.map-legend span { color: var(--oxidized-brass); }
.map-legend a.active { color: var(--lantern-flame); border-color: var(--lantern-flame); text-shadow: 0 0 12px rgba(244, 163, 64, .8); }

.verdict-map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
    opacity: .78;
}

.map-shadow, .map-path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.map-shadow { stroke: rgba(11, 16, 32, .8); stroke-width: 12; filter: blur(6px); }
.map-path { stroke: var(--vellum-gold); stroke-width: 4; stroke-dasharray: 10 16; filter: drop-shadow(0 0 8px rgba(244, 163, 64, .45)); }
.map-dots circle { fill: var(--wax-verdict); stroke: var(--vellum-gold); stroke-width: 3; filter: drop-shadow(0 0 12px rgba(166, 41, 46, .85)); }

.trial-path { position: relative; z-index: 10; }

.chamber {
    position: relative;
    min-height: 100vh;
    padding: clamp(2rem, 5vw, 5rem);
    display: grid;
    overflow: hidden;
    isolation: isolate;
}

.chamber::before {
    content: "";
    position: absolute;
    inset: 1.15rem;
    border: 1px solid rgba(232, 215, 162, .23);
    border-image: linear-gradient(135deg, transparent, rgba(232, 215, 162, .75), transparent, rgba(166, 41, 46, .5)) 1;
    pointer-events: none;
    z-index: -1;
}

.chamber::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--glow-x, 50%) var(--glow-y, 50%), rgba(244, 163, 64, .13), transparent 24rem);
    pointer-events: none;
    z-index: -1;
}

h1, h2 { font-family: var(--display); font-weight: 700; line-height: .88; margin: 0; }
h1 { font-size: clamp(4.8rem, 14vw, 14rem); letter-spacing: -.06em; color: var(--bone-chalk); text-shadow: 0 7px 0 rgba(58, 33, 74, .75), 0 0 22px rgba(232, 215, 162, .22); }
h2 { font-size: clamp(3rem, 7vw, 8rem); color: var(--bone-chalk); }
p { font-size: clamp(1.08rem, 1.6vw, 1.45rem); line-height: 1.45; }

.chapter-sigil, .margin-note, .threshold-runes, .evidence-ribbons span, .summons-link {
    font-family: var(--accent);
    text-transform: uppercase;
    letter-spacing: .13em;
}

.chapter-sigil { color: var(--lantern-flame); font-size: .66rem; margin: 0 0 1rem; }
.margin-note { color: var(--oxidized-brass); font-size: .64rem; line-height: 1.55; }

.summons-gate { place-items: center; background: radial-gradient(ellipse at 50% 100%, rgba(58, 33, 74, .42), transparent 54%); }
.stone-arch {
    position: absolute;
    width: min(78vw, 760px);
    height: min(86vh, 820px);
    bottom: -8vh;
    border: clamp(2rem, 5vw, 4.4rem) solid rgba(247, 240, 218, .06);
    border-bottom: 0;
    border-radius: 50% 50% 0 0;
    box-shadow: inset 0 0 70px rgba(0, 0, 0, .75), 0 0 0 1px rgba(232, 215, 162, .12);
}

.sealed-parchment, .parchment-plaque, .final-scroll {
    position: relative;
    color: var(--court-midnight);
    background:
        linear-gradient(135deg, rgba(247, 240, 218, .9), rgba(232, 215, 162, .88)),
        repeating-linear-gradient(0deg, rgba(138, 111, 42, .06), rgba(138, 111, 42, .06) 2px, transparent 2px, transparent 8px);
    box-shadow: 0 35px 80px rgba(0, 0, 0, .42), inset 0 0 0 1px rgba(138, 111, 42, .38);
}

.sealed-parchment {
    width: min(88vw, 980px);
    min-height: 54vh;
    padding: clamp(2rem, 6vw, 5rem);
    display: grid;
    align-content: center;
    transform: rotate(-2deg);
    clip-path: polygon(2% 4%, 98% 0, 96% 94%, 4% 100%);
}

.sealed-parchment h1, .sealed-parchment h2, .parchment-plaque h2, .final-scroll h2 { color: var(--court-midnight); text-shadow: 0 2px rgba(138, 111, 42, .24); }
.ceremonial-line { max-width: 44rem; color: #3A214A; }
.vellum-border { position: absolute; inset: 1.3rem; border: 2px double rgba(138, 111, 42, .65); pointer-events: none; }
.wax-seal, .cracked-seal {
    position: absolute;
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    right: clamp(1rem, 5vw, 4rem);
    bottom: -2rem;
    background: radial-gradient(circle at 35% 28%, #d05a4f, var(--wax-verdict) 56%, #65151a);
    box-shadow: 0 14px 30px rgba(0,0,0,.38), inset 0 0 0 .55rem rgba(101, 21, 26, .28);
    transition: transform .8s ease;
}
.wax-seal span, .cracked-seal span { position: absolute; inset: 18%; border: 2px solid rgba(247, 240, 218, .55); border-radius: 50%; }
.wax-seal.is-cracked { transform: rotate(18deg) scale(.92); clip-path: polygon(0 0, 48% 0, 42% 36%, 55% 52%, 40% 100%, 0 100%); }
.summons-link { color: var(--wax-verdict); font-size: .72rem; text-decoration: none; border-bottom: 1px solid currentColor; width: max-content; padding-bottom: .35rem; }
.threshold-runes { position: absolute; left: 3rem; bottom: 2rem; color: rgba(232, 215, 162, .56); font-size: .6rem; }

.evidence-causeway { align-items: center; grid-template-columns: 1fr 1fr; background: linear-gradient(120deg, transparent 45%, rgba(58, 33, 74, .42)); }
.gavel-shadow { position: absolute; right: -15vw; top: 8vh; width: 58vw; height: 18vw; background: rgba(0,0,0,.45); transform: rotate(39deg); border-radius: 10vw; filter: blur(3px); }
.gavel-shadow::before { content: ""; position: absolute; width: 19vw; height: 26vw; right: 8vw; top: -4vw; border-radius: 3vw; background: rgba(0,0,0,.5); }
.parchment-plaque { padding: clamp(1.7rem, 4vw, 3.5rem); max-width: 560px; clip-path: polygon(0 5%, 94% 0, 100% 92%, 6% 100%); }
.pinned-left { margin-left: 3vw; transform: rotate(1.5deg); }
.evidence-ribbons { align-self: end; display: grid; gap: 1.2rem; justify-self: center; transform: rotate(-7deg); }
.evidence-ribbons span { color: var(--court-midnight); background: var(--vellum-gold); padding: .9rem 2rem; box-shadow: 0 14px 26px rgba(0,0,0,.34); font-size: .62rem; }
.evidence-ribbons span:nth-child(even) { background: var(--wax-verdict); color: var(--bone-chalk); margin-left: 4rem; }
.thread-knot { position: absolute; width: 24vw; height: 24vw; right: 18vw; top: 18vh; border: 3px solid var(--wax-verdict); border-radius: 45% 55% 40% 60%; opacity: .58; animation: slowTurn 18s linear infinite; }
@keyframes slowTurn { to { transform: rotate(360deg); } }

.witness-lanterns { grid-template-columns: .8fr 1.2fr; align-items: center; gap: 4vw; background: radial-gradient(circle at 26% 50%, rgba(244, 163, 64, .18), transparent 26rem); }
.lantern-row { display: grid; grid-template-columns: repeat(2, minmax(110px, 180px)); gap: 2rem; justify-content: center; }
.lantern { border: 0; min-height: 210px; background: transparent; position: relative; cursor: none; }
.lantern::before { content: ""; position: absolute; left: 50%; top: 0; width: 44%; height: 100%; transform: translateX(-50%); border: 3px solid var(--oxidized-brass); border-radius: 50% 50% 36% 36%; background: rgba(11, 16, 32, .6); box-shadow: inset 0 0 30px rgba(0,0,0,.8); }
.lantern span { position: absolute; left: 50%; top: 38%; width: 34px; height: 54px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--lantern-flame); box-shadow: 0 0 18px 8px rgba(244, 163, 64, .35); opacity: .35; animation: flicker 1.6s infinite alternate; }
.lantern.active span, .lantern:hover span { opacity: 1; box-shadow: 0 0 60px 28px rgba(244, 163, 64, .44); }
@keyframes flicker { 0% { transform: translate(-50%, -50%) scale(.85); } 100% { transform: translate(-50%, -53%) scale(1.12); } }
.shadow-testimony { max-width: 760px; padding: 4rem; background: linear-gradient(100deg, rgba(11,16,32,.88), rgba(58,33,74,.74)); border-left: 8px solid var(--lantern-flame); clip-path: polygon(0 0, 100% 8%, 92% 100%, 4% 92%); }
.shadow-testimony h2 { color: var(--bone-chalk); }
.chess-witnesses { position: absolute; right: 7vw; bottom: 5vh; display: flex; gap: 1rem; opacity: .35; }
.chess-witnesses i { width: 45px; height: 120px; background: #000; border-radius: 50% 50% 12px 12px; transform: skew(-10deg); }

.maze-precedent { grid-template-columns: 1.25fr .75fr; align-items: center; background: radial-gradient(circle at 70% 70%, rgba(138, 111, 42, .14), transparent 24rem); }
.maze-floor { position: relative; width: min(58vw, 760px); aspect-ratio: 1; border: 3px solid rgba(232, 215, 162, .36); transform: rotate(-10deg); background: repeating-linear-gradient(90deg, rgba(232,215,162,.1) 0 4px, transparent 4px 74px), repeating-linear-gradient(0deg, rgba(232,215,162,.08) 0 4px, transparent 4px 74px); box-shadow: inset 0 0 70px rgba(0,0,0,.55); }
.maze-line { position: absolute; background: var(--oxidized-brass); box-shadow: 0 0 12px rgba(232,215,162,.25); }
.m1 { left: 12%; top: 14%; width: 70%; height: 5px; }.m2 { left: 24%; top: 28%; width: 5px; height: 58%; }.m3 { right: 14%; top: 28%; width: 5px; height: 50%; }.m4 { left: 24%; bottom: 16%; width: 62%; height: 5px; }
.footsteps span { position: absolute; width: 16px; height: 28px; border-radius: 50%; background: var(--wax-verdict); opacity: .75; animation: stepGlow 2.8s infinite; }
.footsteps span:nth-child(1) { left: 15%; top: 70%; }.footsteps span:nth-child(2) { left: 28%; top: 61%; animation-delay: .25s; }.footsteps span:nth-child(3) { left: 42%; top: 48%; animation-delay: .5s; }.footsteps span:nth-child(4) { left: 55%; top: 34%; animation-delay: .75s; }.footsteps span:nth-child(5) { left: 73%; top: 23%; animation-delay: 1s; }
@keyframes stepGlow { 50% { box-shadow: 0 0 18px var(--wax-verdict); transform: scale(1.2); } }
.narrow-plaque { transform: rotate(4deg); }
.marginal-creature { position: absolute; right: 12vw; top: 12vh; color: var(--court-midnight); background: var(--vellum-gold); border-radius: 40% 60% 50% 50%; padding: 2rem 1.1rem; font-family: var(--accent); font-size: .55rem; text-transform: uppercase; transform: rotate(16deg); }

.scales-chamber { place-items: center; background: radial-gradient(circle at 50% 30%, rgba(244, 163, 64, .12), transparent 25rem), linear-gradient(180deg, rgba(58,33,74,.34), transparent); }
.scale-machine { position: relative; width: min(86vw, 900px); height: 56vh; transition: transform .8s ease; }
.scale-machine.tipped { transform: rotate(.8deg); }
.scale-beam { position: absolute; left: 10%; top: 18%; width: 80%; height: 12px; background: var(--oxidized-brass); box-shadow: 0 0 18px rgba(232,215,162,.25); }
.scale-spire { position: absolute; left: 50%; top: 15%; width: 12px; height: 62%; background: var(--oxidized-brass); transform: translateX(-50%); }
.scale-chain { position: absolute; top: 20%; width: 3px; height: 22%; background: var(--vellum-gold); }
.scale-chain.left { left: 20%; }.scale-chain.right { right: 20%; }
.scale-pan { position: absolute; top: 42%; width: 27%; aspect-ratio: 2.8 / 1; border-radius: 0 0 50% 50%; border: 5px solid var(--oxidized-brass); border-top: 0; background: rgba(232,215,162,.13); display: grid; place-items: center; }
.scale-pan.left { left: 6%; transform: translateY(18px); }.scale-pan.right { right: 6%; transform: translateY(-18px); }
.scale-pan p { font-family: var(--accent); color: var(--lantern-flame); text-transform: uppercase; font-size: .75rem; }
.circular-decree { position: absolute; width: min(43vw, 520px); aspect-ratio: 1; border-radius: 50%; display: grid; align-content: center; text-align: center; padding: 4rem; background: rgba(11,16,32,.72); border: 1px solid rgba(232,215,162,.28); box-shadow: inset 0 0 60px rgba(58,33,74,.7); }
.circular-decree h2 { font-size: clamp(2.6rem, 5vw, 5.3rem); }
.celestial-jury span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--bone-chalk); box-shadow: 0 0 18px var(--bone-chalk); }
.celestial-jury span:nth-child(1){ left: 17%; top: 16%; }.celestial-jury span:nth-child(2){ left: 31%; top: 8%; }.celestial-jury span:nth-child(3){ right: 24%; top: 18%; }.celestial-jury span:nth-child(4){ right: 13%; bottom: 24%; }.celestial-jury span:nth-child(5){ left: 21%; bottom: 18%; }

.unsealed-verdict { place-items: center; background: radial-gradient(ellipse at 50% 60%, rgba(232,215,162,.17), transparent 38rem); }
.final-scroll { width: min(90vw, 1120px); min-height: 78vh; padding: clamp(2rem, 7vw, 6rem); display: grid; align-content: center; clip-path: polygon(4% 0, 98% 4%, 94% 100%, 0 94%); transform-origin: center top; transform: scaleY(.82); opacity: .78; transition: transform 1s ease, opacity 1s ease; }
.final-scroll.unfurled { transform: scaleY(1); opacity: 1; }
.final-scroll h2 { font-size: clamp(4rem, 10vw, 11rem); }
.final-scroll p { max-width: 52rem; color: var(--robe-violet); }
.summons-link.final { margin-top: 1.5rem; }
.cracked-seal { left: 6vw; right: auto; top: 10vh; bottom: auto; transform: rotate(-18deg); }

.is-visible .parchment-plaque, .is-visible .shadow-testimony, .is-visible .circular-decree { animation: chamberReveal .9s ease both; }
@keyframes chamberReveal { from { opacity: .35; transform: translateY(34px) rotate(var(--tilt, 0deg)); } to { opacity: 1; } }

@media (max-width: 820px) {
    body { cursor: auto; }
    .cursor-seal { display: none; }
    .map-legend { display: none; }
    .chamber, .evidence-causeway, .witness-lanterns, .maze-precedent { grid-template-columns: 1fr; }
    .verdict-map { opacity: .35; }
    .sealed-parchment { transform: none; }
    .evidence-ribbons { justify-self: start; }
    .lantern-row { grid-template-columns: repeat(4, 1fr); gap: .6rem; }
    .lantern { min-height: 130px; }
    .maze-floor { width: 84vw; }
    .circular-decree { position: relative; width: 82vw; }
}
