:root {
    color-scheme: light;
    --paper: #fff9f1;
    --ink: #251545;
    --muted: #605576;
    --pink: #a81b64;
    --plum: #6427af;
    --edge: #e4d6f4;
    --white: #fffdfd;
    font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 96% 0%, #ffdfef 0%, transparent 37rem),
        radial-gradient(ellipse at 0% 29%, #fff1af 0%, transparent 30rem),
        var(--paper);
}
[hidden] { display: none !important; }
button, select, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
a, button, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--plum); outline-offset: 4px; }
h1, h2, p { margin: 0; }
.shell { width: min(1152px, calc(100% - 64px)); margin-inline: auto; }
.site-header {
    min-height: 91px; display: flex; align-items: center; justify-content: space-between;
    gap: 14px; border-bottom: 1px solid #deccea;
}
.brand, .header-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { font-size: 1.11rem; font-weight: 850; letter-spacing: -.035em; overflow-wrap: anywhere; }
.brand-mark {
    background: #752cbe; color: #fff2a9; border-radius: 13px; display: grid;
    place-items: center; width: 40px; height: 40px; font-size: 26px; line-height: 1;
    flex: 0 0 40px; transform: rotate(-7deg); box-shadow: 2px 3px 0 #dcc2f4;
}
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 15px; border-radius: 12px; min-height: 44px;
    border: 1px solid transparent; cursor: pointer; color: var(--ink); font-weight: 750;
    transition: background .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.button:disabled { cursor: default; opacity: .58; }
.button-quiet { background: #fffdfd; border-color: #e5d4ee; font-size: .87rem; white-space: nowrap; }
.button-quiet:hover { background: #f5eafa; border-color: #c9a3e8; }
.button-primary {
    background: #7129b5; color: #fff;
    box-shadow: 0 4px 0 #4c1887, 0 7px 12px #6427af27;
}
.button-primary:hover:not(:disabled) { background: #60229d; transform: translateY(-2px); }
.button-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #4c1887; }
.button-secondary { background: #f1e2ff; border-color: #d8b7f2; color: #55238b; }
.button-secondary:hover { background: #e9d3fb; }
.sound-glyph { color: var(--pink); font-size: 1.04rem; }
.sound[aria-pressed=true] { background: #dcfaee; border-color: #8adac2; color: #155747; }

.stage-grid { display: grid; grid-template-columns: 1.17fr .83fr; gap: clamp(30px, 5vw, 77px); padding-block: 37px; align-items: center; }
.panel { border: 1px solid var(--edge); border-radius: 26px; background: var(--white); }
.wheel-panel {
    position: relative; isolation: isolate; padding: 19px clamp(15px, 3vw, 28px) 20px;
    border: 1px solid #d8baf2; border-radius: 31px;
    background:
        radial-gradient(circle, #9e68d165 1px, transparent 1.5px) 0 0 / 17px 17px,
        linear-gradient(147deg, #eee0ff, #f8e5ff 56%, #f9cced);
    box-shadow: 0 6px 0 #e4cef4, 0 22px 36px #7b369c20;
}
.wheel-panel::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; opacity: .59;
    background: repeating-conic-gradient(from -8deg at 50% 44%, #fff9 0deg 12deg, transparent 12deg 25deg);
    mask-image: radial-gradient(ellipse at 50% 50%, black, transparent 76%);
}
.wheel-meta { display: flex; justify-content: space-between; align-items: center; gap: 9px; font-size: .83rem; font-weight: 800; color: #5b3282; }
.live-tag, #participant-count {
    display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
    border-radius: 99px; background: #fffaff; border: 1px solid #e1bfee;
}
.live-tag i { width: 8px; height: 8px; border-radius: 50%; background: #16a279; box-shadow: 0 0 0 3px #cfefe4; margin-left: 2px; }
.wheel-scene { position: relative; padding-inline: 12px; }
.ribbon { position: absolute; pointer-events: none; font-size: clamp(1.35rem, 3.1vw, 2.6rem); line-height: 1; }
.ribbon-left { top: 20%; left: 3%; color: #a949c4; transform: rotate(-13deg); }
.ribbon-right { bottom: 18%; right: 1.5%; color: #bf378f; transform: rotate(13deg); }
.ribbon-top { top: 5%; right: 11%; color: #a86910; transform: rotate(12deg); font-size: 1.25rem; }
.ribbon-bottom { bottom: 4%; left: 11%; color: #168282; font-size: 1.35rem; }
.wheel-frame {
    position: relative; margin: 32px auto 21px; padding: 13px; width: min(100%, 455px);
    aspect-ratio: 1; border-radius: 50%; border: 2px solid #6326a5;
    background: #7c3cc2;
    box-shadow: 0 0 0 4px #fff7ff, 0 0 0 6px #a167cb, 0 9px 0 5px #7c41b2, 0 17px 25px 6px #52228445;
}
.wheel-frame::before {
    content: ""; pointer-events: none; position: absolute; inset: 2px; border-radius: 50%;
    background: repeating-conic-gradient(#fff7b8 0 1.4deg, transparent 1.4deg 10deg);
    mask-image: radial-gradient(circle farthest-side, transparent calc(100% - 4.5px), black calc(100% - 4px) calc(100% - 1px), transparent 100%);
}
#wheel { position: relative; display: block; width: 100%; height: auto; border-radius: 50%; }
.pointer {
    position: absolute; z-index: 2; top: -17px; left: 50%; translate: -50% 0;
    width: 44px; height: 43px; background: #5b229c;
    clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 9px; transform-origin: 50% 0;
}
.pointer::after {
    content: ""; position: absolute; inset: 4px 7px 9px; background: #ffdc60;
    clip-path: inherit; border-radius: 4px;
}
.wheel-hub {
    position: absolute; top: 50%; left: 50%; translate: -50% -50%;
    width: 16%; aspect-ratio: 1; display: grid; place-items: center;
    background: #ffe277; color: #60249b; border: 3px solid #fff8cf;
    border-radius: 50%; box-shadow: 0 0 0 3px #7a3ab5, 0 5px 13px #672d6e68;
}
.wheel-hub svg { width: 54%; height: auto; }
.wheel-panel.is-spinning .pointer { animation: pointer-tick .19s ease-in-out infinite alternate; }
.wheel-panel.is-spinning .wheel-frame::before { animation: rim-lights .75s linear infinite; }
@keyframes pointer-tick { to { transform: rotate(-8deg); } }
@keyframes rim-lights { to { rotate: 10deg; } }
.stage-controls { text-align: center; display: grid; gap: 9px; justify-items: center; margin-top: 23px; }
.spin-button { margin-bottom: 5px; min-height: 50px; padding-inline: 21px; }
.spin-button > span:first-child { font-size: 1.25rem; }
.stage-status {
    font-size: .88rem; font-weight: 760; color: #54277a; min-height: 1.4em;
    background: #fff9ffbb; border: 1px solid #e9d1f2; padding: 7px 12px; border-radius: 10px; overflow-wrap: anywhere;
    max-width: 100%;
}
.stage-error { color: #94224e; font-size: .87rem; }
.entry-details { border-top: 1px solid #dcbae9; padding-top: 11px; margin-top: 14px; font-size: .86rem; color: #50346b; }
.entry-details summary { cursor: pointer; width: fit-content; font-weight: 650; }
.entry-details ul { margin: 12px 0 0; padding-left: 20px; columns: 2; overflow-wrap: anywhere; }
.entry-details li { padding: 3px 0; break-inside: avoid; }

.results-panel { min-width: 0; position: relative; }
.title-spark { color: #b42c84; position: absolute; top: -4px; right: 7%; font-size: clamp(1.75rem, 4vw, 3.9rem); line-height: 1; rotate: 11deg; }
.results-panel h1 {
    font-size: clamp(4.1rem, 8vw, 7.55rem); font-weight: 925; letter-spacing: -.087em;
    line-height: .86; margin-left: -3px; color: #291549;
}
.results-panel h1 em { color: #a41965; font-style: normal; text-shadow: 2px 3px 0 #fac7e8; }
.intro { color: var(--muted); line-height: 1.56; max-width: 38ch; margin-top: 19px; }
.results-header {
    display: flex; justify-content: space-between; gap: 8px; align-items: center;
    margin: 23px 0 10px; color: #654b77; font-size: .81rem; font-weight: 750;
}
.results-header h2 { font-size: 1.14rem; color: var(--ink); letter-spacing: -.028em; }
#result-count { border: 1px solid #e3cfe9; background: #fffdfa; border-radius: 99px; padding: 4px 9px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.result {
    --medal: #ffdf69;
    --tint: #fff9e3;
    --rank-ink: #6b4606;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
    min-height: 72px; padding: 9px 14px;
    background: #fffdfd; border: 1px solid #e6d8e8; border-left: 4px solid var(--medal);
    border-radius: 13px; box-shadow: 0 3px 0 #e8dcf0;
}
.result-2 { --medal: #d8b5ff; --tint: #f8eeff; --rank-ink: #652992; }
.result-3 { --medal: #85e4cf; --tint: #e9fbf5; --rank-ink: #135b51; }
.result.is-active, .result.is-revealed { border-color: var(--medal); background: var(--tint); }
.result.is-revealed { animation: result-in .48s cubic-bezier(.2,.8,.3,1.4); }
@keyframes result-in { 35% { transform: translateY(-4px) scale(1.015); } }
.rank-badge {
    display: grid; place-items: center; width: 42px; height: 43px; border-radius: 10px;
    background: var(--medal); color: var(--rank-ink); font-weight: 900; font-variant-numeric: tabular-nums;
}
.rank-label { color: var(--rank-ink); display: block; font-size: .76rem; font-weight: 750; margin-bottom: 3px; }
.result strong { display: block; font-size: .92rem; color: var(--muted); overflow-wrap: anywhere; }
.result.is-revealed strong { color: var(--ink); font-size: 1.07rem; }
.result-star { color: #886e9b; font-size: 1.24rem; }
.result.is-revealed .result-star { color: var(--rank-ink); }
.site-footer {
    padding: 15px 0 22px; border-top: 1px solid #deccea; display: flex;
    justify-content: space-between; gap: 12px; color: var(--muted); font-size: .8rem;
}
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.confetti i {
    position: absolute; left: 50%; top: 31%; width: 9px; height: 14px; border-radius: 2px;
    animation: confetti-fall 1.32s ease-out both; translate: -50% -50%;
}
.confetti i:nth-child(3n) { border-radius: 50%; }
@keyframes confetti-fall {
    0% { transform: translate(0, 0) rotate(0); }
    35% { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--turn)); opacity: 0; }
}

.admin-main { padding-block: 34px 50px; }
.admin-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.admin-heading h1, .auth-card h1 { font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -.065em; margin-bottom: 7px; }
.admin-heading p, .muted, .empty { color: var(--muted); line-height: 1.55; }
.admin-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
.admin-side { display: grid; gap: 18px; }
.admin-card, .auth-card { padding: clamp(18px, 3vw, 27px); box-shadow: 0 4px 0 #ebd9f3, 0 10px 26px #6427af0b; }
.admin-card h2 { font-size: 1.27rem; margin-bottom: 12px; letter-spacing: -.025em; }
.admin-card h2 small { font-size: .78rem; color: var(--plum); margin-left: 6px; vertical-align: middle; }
.admin-card .muted { font-size: .92rem; margin-bottom: 14px; }
.auth-card { max-width: 490px; margin: 24px auto; }
.field-stack { display: grid; gap: 10px; padding-top: 10px; }
.field-stack button { justify-self: start; margin-top: 5px; }
.field-stack fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field-stack label { font-weight: 730; font-size: .91rem; }
.field-stack label span { color: var(--muted); margin-left: 5px; font-weight: 450; }
.field-stack input, .field-stack select, .field-stack textarea {
    width: 100%; color: var(--ink); background: #fffaff; border: 1px solid #d3b9e5;
    border-radius: 9px; padding: 10px 12px;
}
.field-stack textarea { resize: vertical; }
.admin-entries { list-style: none; margin: 14px 0 0; padding: 0; }
.admin-entries li {
    min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border-top: 1px solid var(--edge); padding-block: 6px; overflow-wrap: anywhere;
}
.admin-entries .button { min-height: 34px; padding-block: 4px; }
.empty { margin-top: 15px; }
.notice { background: #e5faec; border: 1px solid #a5d8bd; color: #214f39; border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; }
.notice-error { background: #ffedf4; color: #912357; border-color: #edb5cb; }

@media (max-width: 900px) {
    .shell { width: calc(100% - 40px); }
    .stage-grid { gap: 27px; }
    .title-spark { right: 3%; }
}
@media (min-width: 681px) and (max-width: 760px) {
    .stage-grid { grid-template-columns: 1fr 1fr; }
    .results-panel h1 { font-size: 3.85rem; }
}
@media (max-width: 680px) {
    .shell { width: calc(100% - 24px); }
    .site-header { min-height: 66px; gap: 8px; }
    .brand { font-size: .9rem; gap: 8px; }
    .brand-mark { width: 30px; height: 30px; flex-basis: 30px; font-size: 20px; border-radius: 9px; }
    .header-actions { gap: 5px; }
    .header-actions .button { padding-inline: 8px; font-size: .73rem; min-height: 39px; }
    .stage-grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
    .stage-grid { padding-block: 17px 25px; gap: 27px; }
    .wheel-panel { border-radius: 23px; }
    .wheel-scene { padding-inline: 4px; }
    .wheel-frame { padding: 9px; margin-top: 29px; }
    .wheel-frame::before { inset: 0; }
    .ribbon-left, .ribbon-right { display: none; }
    .ribbon-top { top: -5px; right: 3%; }
    .ribbon-bottom { bottom: -7px; left: 3%; }
    .desktop-break { display: none; }
    .title-spark { top: 1%; right: 2%; }
    .results-panel h1 { font-size: clamp(2.65rem, 10.8vw, 4.2rem); margin-left: 0; }
    .intro { margin-top: 11px; font-size: .94rem; }
    .results-header { margin-top: 18px; }
    .admin-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
}
@media (max-width: 350px) { .title-spark { display: none; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
