:root {
    --ink: #0A0711;
    --violet: #7C3AED;
    --mint: #84F5C4;
    --gold: #F6C445;
    --panel: #171421;
    --red: #FF5A5F;
    --blue: #243B6B;
    --paper: #F7E8BC;
    --plex: "IBM Plex Sans", "Inter", sans-serif;
    --body: "Atkinson Hyperlegible", "Inter", sans-serif;
    --display: "Bungee Shade", cursive;
    --serif: "Eczar", serif;
    --mono: "IBM Plex Mono", monospace;
    --font-note: "IBM Plex Mono sparingly for turn counters";
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: #0A0711;
    color: #F7E8BC;
    font-family: var(--body);
    overflow-x: hidden;
}

button { font: inherit; color: inherit; }

.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    opacity: .23;
    background-image:
        radial-gradient(circle at 18% 22%, rgba(247,232,188,.20) 0 1px, transparent 1.5px),
        radial-gradient(circle at 78% 62%, rgba(132,245,196,.13) 0 1px, transparent 1.5px),
        linear-gradient(135deg, rgba(255,255,255,.05), transparent 32%, rgba(0,0,0,.14));
    background-size: 17px 17px, 23px 23px, 100% 100%;
    mix-blend-mode: screen;
}

.turn-rail {
    position: fixed;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    display: grid;
    gap: 12px;
}

.turn-marker {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid #F7E8BC;
    background: #171421;
    color: #F7E8BC;
    font-family: var(--mono);
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(10,7,17,.5), inset 0 0 18px rgba(246,196,69,.12);
    transition: transform .3s ease, background .3s ease, color .3s ease;
}

.turn-marker.active {
    background: #84F5C4;
    color: #0A0711;
    transform: rotate(-12deg) scale(1.08);
}

.scene {
    min-height: 100vh;
    position: relative;
    display: grid;
    place-items: center;
    padding: 7vw;
    isolation: isolate;
    overflow: hidden;
}

.table-scene {
    background:
        radial-gradient(circle at 50% 42%, rgba(124,58,237,.28), transparent 38%),
        radial-gradient(circle at 15% 85%, rgba(132,245,196,.16), transparent 30%),
        linear-gradient(140deg, #0A0711 0%, #171421 54%, #243B6B 100%);
}

.felt-grid, .diagonal-path {
    position: absolute;
    inset: -12%;
    transform: rotate(-8deg);
    background-image: linear-gradient(rgba(247,232,188,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(247,232,188,.08) 1px, transparent 1px);
    background-size: 76px 76px;
    mask-image: radial-gradient(circle, #000 10%, transparent 74%);
}

.dilemma-card, .principle-card, .witness-card, .final-board {
    transform-style: preserve-3d;
    transition: transform .22s ease, box-shadow .3s ease;
}

.dilemma-card {
    width: min(780px, 82vw);
    min-height: 540px;
    padding: 44px;
    position: relative;
    border: 5px solid #0A0711;
    border-radius: 28px;
    background:
        linear-gradient(90deg, transparent 0 92%, rgba(255,90,95,.26) 92% 95%, transparent 95%),
        radial-gradient(circle at 20% 10%, rgba(246,196,69,.32), transparent 26%),
        #F7E8BC;
    color: #0A0711;
    box-shadow: 0 34px 90px rgba(0,0,0,.55), 18px 18px 0 #7C3AED, -18px -18px 0 rgba(132,245,196,.72);
    rotate: -4deg;
}

.dilemma-card h1 {
    font-family: var(--display);
    font-size: clamp(4rem, 12vw, 9.5rem);
    line-height: .88;
    margin: 34px 0 24px;
    color: #7C3AED;
    text-shadow: 4px 4px 0 #0A0711;
}

.dilemma-card h2, .chapter-gate h2, .ledger h3, .witness-card h3, .final-board h2 {
    font-family: var(--serif);
    font-weight: 800;
}

.dilemma-card h2 { font-size: clamp(1.7rem, 4vw, 3.2rem); line-height: 1; max-width: 680px; }
.chapter { font-family: var(--mono); text-transform: uppercase; letter-spacing: .14em; color: #243B6B; font-weight: 700; }
.rule-note { max-width: 420px; font-size: 1.08rem; line-height: 1.55; }

.prompt-button {
    position: absolute;
    right: -34px;
    top: 52px;
    padding: 14px 22px;
    background: #84F5C4;
    color: #0A0711;
    border: 3px solid #0A0711;
    border-radius: 0 16px 16px 0;
    font-family: var(--mono);
    text-transform: uppercase;
    box-shadow: 7px 7px 0 #FF5A5F;
}

.tabs { display: flex; gap: 14px; position: absolute; bottom: -22px; left: 90px; }
.tabs span { width: 86px; height: 44px; background: #F6C445; border: 4px solid #0A0711; border-radius: 0 0 18px 18px; }
.tabs span:nth-child(2) { background: #FF5A5F; transform: translateY(8px) rotate(2deg); }
.tabs span:nth-child(3) { background: #84F5C4; transform: rotate(-5deg); }

.token {
    position: absolute;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #171421;
    border: 4px solid #F6C445;
    color: #84F5C4;
    font-family: var(--serif);
    font-weight: 800;
    box-shadow: inset 0 0 0 8px #0A0711, 0 16px 24px rgba(0,0,0,.35);
    animation: floatToken 6s ease-in-out infinite;
}
.orbit-a { left: 12vw; top: 18vh; }
.orbit-b { right: 12vw; bottom: 16vh; animation-delay: -2s; }
.orbit-c { left: 18vw; bottom: 13vh; animation-delay: -4s; }

.candle { position: absolute; width: 42px; height: 130px; border-radius: 16px 16px 6px 6px; background: #F7E8BC; box-shadow: 0 0 72px #F6C445; }
.candle::before { content: ""; position: absolute; top: -42px; left: 8px; width: 25px; height: 48px; border-radius: 50% 50% 45% 45%; background: #F6C445; box-shadow: 0 0 32px #FF5A5F; animation: flicker 1.6s infinite alternate; }
.candle-left { left: 7vw; bottom: 9vh; rotate: 6deg; }
.candle-right { right: 9vw; top: 12vh; rotate: -8deg; }
.compass-rose { position: absolute; right: 18vw; top: 18vh; width: 180px; height: 180px; border: 2px dashed #84F5C4; border-radius: 50%; opacity: .65; display: grid; place-items: center; font-family: var(--display); color: #F6C445; }
.compass-rose::before, .compass-rose::after { content: ""; position: absolute; width: 150%; height: 4px; background: #84F5C4; transform: rotate(28deg); }
.compass-rose::after { transform: rotate(118deg); }
.compass-rose span { position: relative; z-index: 1; background: #0A0711; padding: 8px; }

.draft-scene { background: linear-gradient(160deg, #171421, #0A0711 60%, #243B6B); }
.diagonal-path { transform: rotate(18deg); background-size: 54px 54px; opacity: .8; }
.chapter-gate { position: absolute; top: 8vh; left: 8vw; max-width: 760px; transform: rotate(-3deg); }
.chapter-gate span { font-family: var(--mono); text-transform: uppercase; color: #84F5C4; letter-spacing: .18em; }
.chapter-gate h2 { margin: 0; font-size: clamp(3rem, 8vw, 7rem); line-height: .86; color: #F7E8BC; text-shadow: 5px 5px 0 #7C3AED; }
.draft-table { display: flex; gap: 34px; margin-top: 14vh; perspective: 1200px; }
.principle-card { width: min(310px, 27vw); min-height: 380px; padding: 30px; background: #F7E8BC; color: #0A0711; border: 4px solid #0A0711; border-radius: 22px; box-shadow: 12px 12px 0 #F6C445; }
.principle-card:nth-child(1) { rotate: -8deg; }
.principle-card:nth-child(2) { translate: 0 40px; box-shadow: 12px 12px 0 #84F5C4; }
.principle-card:nth-child(3) { rotate: 7deg; box-shadow: 12px 12px 0 #FF5A5F; }
.principle-card h3 { font-family: var(--serif); font-size: 2.05rem; line-height: .95; margin: 52px 0 18px; }
.wax { position: absolute; top: 22px; right: 22px; width: 74px; height: 74px; border-radius: 50%; background: #FF5A5F; color: #F7E8BC; display: grid; place-items: center; font-family: var(--display); font-size: .82rem; rotate: 9deg; }
.principle-string { position: absolute; height: 4px; background: #84F5C4; transform-origin: left center; box-shadow: 0 0 16px #84F5C4; transition: transform .45s ease; }
.string-one { width: 48vw; left: 11vw; top: 52vh; rotate: 18deg; }
.string-two { width: 52vw; right: 14vw; bottom: 24vh; rotate: -22deg; background: #F6C445; }
.draft-scene.tight .principle-string { transform: scaleX(.76); }
.dice-tray { position: absolute; right: 9vw; bottom: 8vh; display: flex; gap: 16px; transform: rotate(7deg); }
.die { width: 70px; height: 70px; border: 4px solid #0A0711; background: #84F5C4; color: #0A0711; font-size: 2rem; box-shadow: 8px 8px 0 #7C3AED; cursor: pointer; transition: transform .25s ease; }
.die.rolled { transform: rotate(360deg) scale(1.12); background: #F6C445; }

.orchard-scene { background: radial-gradient(circle at 45% 38%, rgba(246,196,69,.18), transparent 34%), linear-gradient(135deg, #243B6B, #0A0711 72%); }
.tilted { right: 8vw; left: auto; transform: rotate(4deg); text-align: right; }
.orchard-board { position: relative; width: min(900px, 82vw); height: 620px; margin-top: 12vh; }
.branch { position: absolute; height: 8px; background: #F7E8BC; border-radius: 99px; transform-origin: left; box-shadow: 0 0 0 3px #0A0711; }
.branch-a { width: 650px; left: 90px; top: 290px; rotate: -18deg; }
.branch-b { width: 520px; left: 220px; top: 330px; rotate: 24deg; background: #84F5C4; }
.branch-c { width: 420px; left: 150px; top: 380px; rotate: 70deg; background: #F6C445; }
.outcome-bead { position: absolute; border: 4px solid #0A0711; border-radius: 50%; width: 112px; height: 112px; background: #FF5A5F; color: #F7E8BC; font-family: var(--serif); font-weight: 800; cursor: pointer; box-shadow: inset 0 0 0 9px rgba(10,7,17,.28), 0 18px 28px rgba(0,0,0,.34); transition: transform .3s ease, background .3s ease; }
.outcome-bead:hover, .outcome-bead.active { transform: scale(1.12) rotate(-8deg); background: #84F5C4; color: #0A0711; }
.bead-a { left: 60px; top: 200px; }
.bead-b { right: 90px; top: 130px; }
.bead-c { right: 170px; bottom: 95px; }
.bead-d { left: 260px; bottom: 30px; }
.ledger { position: absolute; left: 50%; top: 50%; width: min(430px, 82vw); transform: translate(-50%, -50%) rotate(-4deg); background: #F7E8BC; color: #0A0711; border: 4px solid #0A0711; border-radius: 20px; padding: 32px; box-shadow: 14px 14px 0 #7C3AED; }
.stamp { display: inline-block; font-family: var(--display); color: #FF5A5F; border: 3px solid #FF5A5F; padding: 4px 10px; transform: rotate(-7deg); }

.masks-scene { background: linear-gradient(150deg, #0A0711, #171421 45%, #7C3AED 150%); }
.mask-stage { display: flex; gap: 34px; margin-right: 420px; margin-top: 80px; }
.mask { width: 170px; height: 230px; border: 4px solid #F7E8BC; border-radius: 50% 50% 42% 42%; background: #243B6B; cursor: pointer; position: relative; box-shadow: 11px 11px 0 #0A0711; transition: transform .3s ease, background .3s ease; }
.mask span::before, .mask span::after { content: ""; position: absolute; width: 30px; height: 18px; border-radius: 50%; background: #0A0711; top: 82px; }
.mask span::before { left: 43px; } .mask span::after { right: 43px; }
.mask em { position: absolute; left: 0; right: 0; bottom: 34px; font-family: var(--mono); font-style: normal; color: #F7E8BC; }
.mask.active { background: #FF5A5F; transform: translateY(-18px) rotate(-5deg); }
.witness-card { position: absolute; right: 9vw; bottom: 14vh; width: min(480px, 40vw); padding: 34px; background: #F7E8BC; color: #0A0711; border: 4px solid #0A0711; border-radius: 22px; box-shadow: -12px 12px 0 #84F5C4; rotate: 5deg; }
.witness-card h3 { font-size: 2.2rem; line-height: 1; }
.scratch { position: absolute; width: 280px; height: 2px; background: #F6C445; opacity: .7; transform: rotate(-20deg); }
.scratch::before, .scratch::after { content: ""; position: absolute; inset: 10px 0 auto; height: 2px; background: inherit; }
.scratch-one { left: 12vw; bottom: 18vh; } .scratch-two { right: 18vw; top: 24vh; transform: rotate(34deg); }

.ending-scene { background: radial-gradient(circle, rgba(255,90,95,.18), transparent 42%), linear-gradient(180deg, #171421, #0A0711); }
.final-board { width: min(880px, 84vw); padding: 48px; border-radius: 34px; border: 5px double #F7E8BC; background: #171421; color: #F7E8BC; box-shadow: 0 0 0 18px rgba(124,58,237,.3), 0 42px 90px rgba(0,0,0,.55); text-align: center; }
.final-board h2 { font-size: clamp(3rem, 8vw, 7.4rem); line-height: .86; margin: 12px 0 28px; color: #F6C445; text-shadow: 5px 5px 0 #FF5A5F; }
.ending-copy { max-width: 660px; margin: 0 auto 34px; font-size: 1.2rem; line-height: 1.55; }
.verdict-row { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin-bottom: 36px; }
.verdict-token { border: 3px solid #0A0711; border-radius: 999px; padding: 14px 24px; background: #F7E8BC; color: #0A0711; font-family: var(--display); cursor: pointer; transition: transform .25s ease, background .25s ease; }
.verdict-token.selected { background: #84F5C4; transform: rotate(-4deg) scale(1.06); }
.blank-card { margin: auto; max-width: 560px; background: #F7E8BC; color: #0A0711; border: 4px solid #0A0711; border-radius: 18px; padding: 24px; box-shadow: 10px 10px 0 #243B6B; transform: rotate(2deg); }
.blank-card span { display: block; font-family: var(--mono); text-transform: uppercase; color: #7C3AED; margin-bottom: 12px; }
.blank-card strong { font-family: var(--serif); font-size: 1.7rem; line-height: 1.05; }

.marginal { position: absolute; font-family: var(--mono); color: #84F5C4; border-left: 3px solid #84F5C4; padding-left: 12px; opacity: .85; }
.marginal-one { left: 8vw; top: 42vh; rotate: -12deg; }
.marginal-two { right: 16vw; top: 36vh; rotate: 8deg; }

@keyframes floatToken { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-18px) rotate(9deg); } }
@keyframes flicker { from { transform: scaleY(.82) rotate(-3deg); } to { transform: scaleY(1.08) rotate(5deg); } }

@media (max-width: 820px) {
    .scene { padding: 88px 22px; }
    .turn-rail { right: 8px; }
    .dilemma-card { width: 86vw; padding: 28px; min-height: 500px; }
    .prompt-button { right: -18px; top: 22px; font-size: .75rem; }
    .draft-table, .mask-stage { flex-direction: column; margin: 180px 0 0; gap: 20px; }
    .principle-card { width: 76vw; min-height: 260px; }
    .chapter-gate { top: 44px; left: 24px; right: 24px; }
    .chapter-gate h2 { font-size: 3.2rem; }
    .dice-tray { right: 28px; bottom: 28px; }
    .orchard-board { height: 720px; }
    .witness-card { position: relative; right: auto; bottom: auto; width: 82vw; margin-top: 26px; }
    .mask { width: 132px; height: 178px; }
    .mask-stage { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .token, .candle, .compass-rose, .marginal, .principle-string { display: none; }
}
