:root {
    color-scheme: light;
    --evergreen: #112e26;
    --fir: #194837;
    --cream: #fffaf0;
    --gold: #efcc8a;
    --pale-gold: #ffe8b8;
    --berry: #93283d;
    --ink: #23362c;
    --quiet: #526359;
    --line: #d9d3c6;
    --serif: Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    min-width: 280px;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    color: var(--cream);
    background:
        radial-gradient(ellipse at 78% 36%, #28614a 0, transparent 41%),
        radial-gradient(ellipse at 6% 120%, #325a43 0, transparent 57%),
        var(--evergreen);
    font: 1rem/1.57 var(--sans);
}

a { color: inherit; }
input, button, textarea { font: inherit; }

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

.panel :is(button, input, textarea, a):focus-visible {
    outline-color: #8e2e43;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.frame {
    width: min(100% - 3.5rem, 72rem);
    margin-inline: auto;
}

.site-header {
    border-bottom: 1px solid #f5ddab48;
    background: #0d231d69;
}

.header-inner {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: .65rem 1.5rem;
}

.brand, .nav-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    text-decoration: none;
}

.brand {
    gap: .6rem;
    color: var(--cream);
    font-size: .95rem;
    font-weight: 750;
    letter-spacing: -.025em;
}

.brand-icon {
    display: inline-grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    border: 1px solid var(--gold);
    border-radius: 8px;
    color: var(--pale-gold);
    font: 1.04rem/1 var(--serif);
}

.nav-link {
    color: #f4e5c8;
    font-size: .82rem;
    text-underline-offset: .23rem;
}
.nav-link:hover { text-decoration: underline; }

.scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, .93fr);
    grid-template-areas:
        "intro stage"
        "panel stage"
        "logout stage";
    gap: 1.45rem clamp(1.1rem, 5vw, 5rem);
    align-items: start;
    padding-block: clamp(3.6rem, 8vw, 7.5rem) 3.3rem;
}

.intro { grid-area: intro; }

.eyebrow {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 0 0 1.16rem;
    color: var(--pale-gold);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.eyebrow span { width: 20px; height: 1px; background: currentColor; }

h1, h2, p { margin: 0; }
h1 {
    font: 400 clamp(3.35rem, 6.7vw, 6.35rem)/.99 var(--serif);
    letter-spacing: -.065em;
}
h1 em {
    display: inline-block;
    color: var(--gold);
    font-weight: inherit;
    letter-spacing: -.08em;
}

.lede {
    max-width: 36ch;
    margin-top: 1.05rem;
    color: #e7eadd;
    font-size: clamp(1rem, 1.6vw, 1.16rem);
}

.panel {
    grid-area: panel;
    min-width: 0;
    padding: clamp(1.15rem, 3.4vw, 1.7rem);
    border: 1px solid #fff8e7;
    border-radius: 18px;
    background: var(--cream);
    color: var(--ink);
    box-shadow: 0 16px 40px -23px #020e09e6;
}

.panel h2 {
    margin-bottom: 1rem;
    font: 400 clamp(1.4rem, 2.5vw, 1.85rem)/1.1 var(--serif);
    letter-spacing: -.046em;
}

.action-form { display: grid; gap: .55rem; }
.action-form > label:not(.confirm) { font-size: .89rem; font-weight: 740; }

.action-form :is(input[type="password"], input[type="text"], textarea) {
    width: 100%;
    min-width: 0;
    min-height: 49px;
    padding: .62rem .74rem;
    border: 1px solid #a79887;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 1rem;
}

.action-form textarea { resize: vertical; }
.hint { color: var(--quiet); font-size: .86rem; }
.panel > .hint { margin-bottom: .7rem; }

.button {
    display: inline-flex;
    min-height: 51px;
    justify-content: space-between;
    align-items: center;
    gap: .85rem;
    padding: .65rem .92rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 745;
    line-height: 1.28;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}
.button-primary {
    border-color: #7b2438;
    background: var(--berry);
    color: #fff7ed;
}
.button-primary:hover { background: #752036; }
.action-form > .button { margin-top: .4rem; }

.button-arrow {
    position: relative;
    width: 18px;
    height: 16px;
    flex: 0 0 18px;
}
.button-arrow::before {
    position: absolute;
    right: 2px;
    top: 4px;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
    content: "";
}
.button-arrow::after {
    position: absolute;
    top: 7px;
    left: 1px;
    width: 15px;
    border-top: 2px solid currentColor;
    content: "";
}

.confirm {
    display: flex;
    min-height: 44px;
    align-items: flex-start;
    gap: .65rem;
    margin: .3rem 0 .1rem;
    padding: .63rem .7rem;
    border: 1px solid #ddd0a9;
    border-radius: 8px;
    background: #f8efdb;
    font-size: .87rem;
    font-weight: 650;
    cursor: pointer;
}

.confirm input {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin: .12rem 0 0;
    accent-color: var(--berry);
}

.notice {
    margin-bottom: .85rem;
    padding: .54rem .69rem;
    border-left: 3px solid #527c58;
    border-radius: 0 5px 5px 0;
    background: #edf5e7;
    color: #21432d;
    font-size: .88rem;
    font-weight: 640;
}

.notice-error {
    border-color: #a33b51;
    background: #fae6e8;
    color: #772239;
}

.result-wrap { position: relative; }
.reveal-progress { display: none; }
.recipient {
    max-width: 100%;
    margin: -.45rem 0 .65rem;
    color: var(--berry);
    font: italic 400 clamp(2.45rem, 5.4vw, 4.2rem)/1.04 var(--serif);
    letter-spacing: -.073em;
    overflow-wrap: anywhere;
}

.logout { grid-area: logout; }
.logout button {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #f2e4c6;
    font-size: .88rem;
    text-decoration: underline;
    text-underline-offset: .2rem;
    cursor: pointer;
    touch-action: manipulation;
}

.stage {
    position: relative;
    display: grid;
    grid-area: stage;
    width: min(100%, 32rem);
    aspect-ratio: 1;
    align-self: center;
    justify-self: center;
    place-items: center;
    isolation: isolate;
}

.stage::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(circle, #f4d98434 0, transparent 67%);
    content: "";
}
.orbit {
    position: absolute;
    inset: 2.5%;
    z-index: -1;
    border: 1px solid #eee5b745;
    border-radius: 50%;
}
.orbit-inner {
    inset: 7.8%;
    border-style: dashed;
    border-color: #e9d68b70;
}
.spark {
    position: absolute;
    z-index: 1;
    color: var(--pale-gold);
    font: clamp(.95rem, 2vw, 1.55rem)/1 var(--serif);
}
.spark-top { top: 6%; left: 21%; }
.spark-right { top: 27%; right: 4.3%; }
.spark-bottom { right: 15.5%; bottom: 11%; }
.spark-left { bottom: 24%; left: 4.35%; }

.wheel {
    position: relative;
    width: 71%;
    aspect-ratio: 1;
}
.wheel-rotor {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    padding: 4%;
    border: 1px solid #ffe7ad;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, #d2ad68 0 59%, transparent 60%),
        repeating-conic-gradient(from 0deg, #f5dc9c 0deg 7deg, #a66e43 7deg 8deg);
    box-shadow: 0 12px 28px -8px #081e15c7, inset 0 0 0 4px #b4844b;
}

.wheel-disc {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid #6c4b32;
    border-radius: 50%;
    background:
        repeating-conic-gradient(from -30deg, transparent 0 58deg, #efcf867f 58deg 60deg),
        conic-gradient(from -30deg, #a83c51 0 60deg, #34725b 60deg 120deg, #9c3046 120deg 180deg,
            #265545 180deg 240deg, #a83c51 240deg 300deg, #34725b 300deg 360deg);
    box-shadow: inset 0 0 22px #1e1f1b60;
}

.wheel-star {
    position: absolute;
    top: 6.2%;
    bottom: 6.2%;
    left: 50%;
    width: 1.2em;
    transform: translateX(-50%) rotate(var(--angle, 0deg));
    color: #ffebbd;
    font: clamp(.92rem, 2.25vw, 2.15rem)/1 var(--serif);
    text-align: center;
    text-shadow: 0 2px 3px #2510218c;
}

.wheel-star:nth-child(2) { --angle: 60deg; }
.wheel-star:nth-child(3) { --angle: 120deg; }
.wheel-star:nth-child(4) { --angle: 180deg; }
.wheel-star:nth-child(5) { --angle: 240deg; }
.wheel-star:nth-child(6) { --angle: 300deg; }

.wheel-hub {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    display: grid;
    width: 24%;
    aspect-ratio: 1;
    place-items: center;
    transform: translate(-50%, -50%);
    border: 1px solid #996447;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #fff0c8, #dcaf65 72%);
    box-shadow: 0 4px 15px #321e1e79, inset 0 0 0 2px #f6dc9c;
}

.gift-icon {
    position: relative;
    width: 42%;
    height: 35%;
    margin-top: 12%;
    border: 1px solid #6d2c3a;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--berry) 0 41%, #fbda9a 41% 59%, var(--berry) 59%);
}
.gift-icon::before, .gift-icon::after {
    position: absolute;
    bottom: 100%;
    width: 37%;
    height: 48%;
    border: 2px solid var(--berry);
    content: "";
}
.gift-icon::before { right: 49%; border-radius: 62% 42% 0 62%; transform: rotate(22deg); }
.gift-icon::after { left: 49%; border-radius: 42% 62% 62% 0; transform: rotate(-22deg); }

.wheel-pointer {
    position: absolute;
    z-index: 2;
    top: -3.1%;
    left: 50%;
    width: 10%;
    aspect-ratio: .87;
    transform: translateX(-50%);
    clip-path: polygon(3% 3%, 97% 3%, 50% 100%);
    background: linear-gradient(100deg, #f4d697, #fff0c8 47%, #b9814b);
}

.footer {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding-block: 1.15rem 2rem;
    border-top: 1px solid #f5ddab43;
    color: #eee4cb;
    font-size: .82rem;
}
.footer span { color: var(--gold); }

@media (prefers-reduced-motion: no-preference) {
    .scene[data-reveal="true"] .wheel-rotor {
        animation: spin 1.2s cubic-bezier(.17, .68, .21, .99) both;
    }
    .scene[data-reveal="true"] .result-content {
        animation: reveal .28s 1.15s ease-out both;
    }
    .scene[data-reveal="true"] .reveal-progress {
        position: absolute;
        inset: 0;
        display: grid;
        place-content: center;
        color: var(--berry);
        font: italic 500 1.35rem/1.2 var(--serif);
        animation: hide-progress 1.15s step-end both;
    }
}
@keyframes spin { to { transform: rotate(1110deg); } }
@keyframes reveal {
    from { visibility: hidden; opacity: 0; transform: translateY(6px); }
    to { visibility: visible; opacity: 1; transform: none; }
}
@keyframes hide-progress { to { visibility: hidden; } }

@media (max-width: 700px) {
    .frame { width: min(100% - 2rem, 32rem); }
    .header-inner { min-height: 59px; }
    .scene {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "intro" "panel" "stage" "logout";
        gap: .95rem;
        padding-block: 2rem 1.65rem;
    }
    .scene--draw, .scene--result { grid-template-areas: "intro" "stage" "panel" "logout"; }
    .scene--organizer_login, .scene--setup, .scene--locked {
        grid-template-areas: "intro" "panel" "logout";
    }
    .scene--organizer_login .stage, .scene--setup .stage, .scene--locked .stage { display: none; }
    .eyebrow { margin-bottom: .9rem; }
    h1 { font-size: clamp(2.67rem, 11vw, 4.5rem); }
    .lede { margin-top: .7rem; }
    .stage { width: min(63%, 15rem); }
    .scene--draw .stage, .scene--result .stage { width: min(53%, 11.5rem); }
    .panel { border-radius: 14px; }
}

@media (max-width: 370px) {
    .scene--draw {
        grid-template-areas: "intro" "panel" "stage" "logout";
    }
}
