:root {
    --stage-blue: #08305f;
    --stage-ink: #13091f;
    --sun: #ffd45a;
    --gold: #ffbd2e;
    --coral: #ff5a6f;
    --rose: #d91f72;
    --teal: #18c8b8;
    --violet: #6d49ff;
    --paper: rgba(255, 255, 255, 0.92);
    --paper-border: rgba(255, 255, 255, 0.48);
    --text: #25101e;
    --muted: rgba(255, 255, 255, 0.76);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--text);
    background:
        linear-gradient(112deg, rgba(255, 212, 90, 0.5) 0 9%, transparent 9% 31%, rgba(24, 200, 184, 0.3) 31% 39%, transparent 39%),
        linear-gradient(248deg, transparent 0 30%, rgba(255, 90, 111, 0.38) 30% 39%, transparent 39% 100%),
        linear-gradient(145deg, #06172f 0%, var(--stage-blue) 45%, var(--stage-ink) 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    opacity: 0.34;
    background:
        repeating-conic-gradient(from 8deg at 50% 20%, rgba(255, 255, 255, 0.2) 0deg 8deg, transparent 8deg 18deg);
    mask-image: linear-gradient(to bottom, #000 0%, transparent 72%);
}

body::after {
    opacity: 0.5;
    background-image:
        linear-gradient(45deg, #fff 0 2px, transparent 2px),
        linear-gradient(90deg, var(--sun) 0 8px, transparent 8px),
        linear-gradient(135deg, var(--teal) 0 7px, transparent 7px),
        linear-gradient(30deg, var(--coral) 0 6px, transparent 6px);
    background-position: 8% 18%, 28% 72%, 75% 22%, 92% 66%;
    background-size: 76px 76px, 92px 92px, 68px 68px, 88px 88px;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1220px, calc(100vw - 28px));
    margin: 0 auto;
    padding: 22px 0 36px;
}

.hero {
    text-align: center;
    margin-bottom: 18px;
    color: #fff;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--sun);
    font-weight: 800;
}

.hero h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 58px);
    line-height: 1.08;
    color: #fff;
    text-shadow: 0 5px 0 rgba(0, 0, 0, 0.2), 0 0 28px rgba(255, 212, 90, 0.56);
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas:
        "wheel winners"
        "wheel controls";
    gap: 18px;
    align-items: start;
}

.panel {
    border: 1px solid var(--paper-border);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 225, 0.88));
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    padding: 18px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
    color: #8c123d;
}

.wheel-panel {
    grid-area: wheel;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 0;
    background: transparent;
}

.controls {
    grid-area: controls;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.winners {
    grid-area: winners;
}

textarea {
    width: 100%;
    min-height: 210px;
    resize: vertical;
    border: 2px solid rgba(217, 31, 114, 0.35);
    border-radius: 8px;
    padding: 12px;
    font: inherit;
    color: inherit;
    background: rgba(255, 255, 255, 0.95);
}

textarea:focus {
    outline: 3px solid rgba(255, 189, 46, 0.38);
    border-color: var(--rose);
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 900;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(92, 22, 40, 0.26);
    transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
    filter: none;
}

#updateNames,
.primary-action {
    background: linear-gradient(135deg, var(--coral), var(--rose));
}

.secondary-action {
    background: linear-gradient(135deg, var(--teal), #0876b8);
}

.wheel-container {
    position: relative;
    width: min(100%, 560px);
    aspect-ratio: 1 / 1;
    margin: 8px auto 18px;
    border-radius: 999px;
    filter: drop-shadow(0 30px 28px rgba(24, 9, 14, 0.45));
    perspective: 900px;
}

.wheel-container::before {
    content: "";
    position: absolute;
    inset: 7%;
    border-radius: 999px;
    transform: translateY(18px);
    background: radial-gradient(circle, rgba(0, 0, 0, 0.3), transparent 62%);
    z-index: 0;
}

.wheel-rim {
    position: absolute;
    inset: -4%;
    border-radius: 999px;
    background:
        radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.95), transparent 12%),
        conic-gradient(from -30deg, #fff4a8, #ffb21c, #b94a09, #ffde63, #fff4a8);
    box-shadow:
        inset 0 -22px 22px rgba(113, 44, 0, 0.34),
        inset 0 14px 16px rgba(255, 255, 255, 0.55),
        0 22px 0 #8d3f10;
    z-index: 0;
}

#wheel {
    position: absolute;
    inset: 3.6%;
    z-index: 1;
    width: auto;
    height: auto;
    border-radius: 999px;
    transform: rotateX(6deg) rotate(0deg);
    transform-origin: center;
    box-shadow:
        inset 0 18px 26px rgba(255, 255, 255, 0.38),
        inset 0 -18px 28px rgba(0, 0, 0, 0.24);
}

#wheel svg {
    border-radius: 999px;
    overflow: visible;
}

#pointer {
    position: absolute;
    top: -7%;
    left: 50%;
    width: 54px;
    height: 70px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #fff4a8, var(--gold) 48%, #c54d11);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.3));
    z-index: 4;
}

.wheel-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 24%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    border: 6px solid #fff3b0;
    color: #fff;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.92), transparent 22%),
        linear-gradient(145deg, var(--coral), var(--rose));
    box-shadow:
        inset 0 -12px 14px rgba(91, 8, 34, 0.38),
        0 12px 24px rgba(0, 0, 0, 0.32);
    font-size: clamp(13px, 2.4vw, 24px);
    font-weight: 900;
}

.wheel-text {
    font-weight: 900;
}

.draw-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 12px;
    width: min(100%, 560px);
}

.draw-actions button {
    min-height: 58px;
    font-size: 20px;
}

.winners-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.winners-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #61102e;
    background: linear-gradient(135deg, #fff0a8, #ffd7df);
    font-weight: 800;
}

.winners-list li::before {
    content: "★";
    color: var(--rose);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(5, 6, 16, 0.72);
    padding: 24px;
    z-index: 1000;
}

.modal.is-open {
    display: flex;
}

#fireworks {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.modal-content {
    position: relative;
    z-index: 1;
    width: min(700px, 100%);
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 232, 166, 0.94)),
        radial-gradient(circle at 50% 0%, rgba(255, 90, 111, 0.4), transparent 55%);
    text-align: center;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34);
}

.modal-content h2 {
    margin: 0;
    font-size: clamp(32px, 5vw, 56px);
    color: #8c123d;
}

.winner-name {
    max-width: 100%;
    padding: 16px 26px;
    border: 4px solid #fff3aa;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff5a6f, #d91f72);
    color: white;
    font-size: clamp(42px, 8vw, 78px);
    line-height: 1.08;
    overflow-wrap: anywhere;
    font-weight: 900;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    box-shadow: 0 18px 34px rgba(217, 31, 114, 0.28);
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "wheel"
            "winners"
            "controls";
    }

    .wheel-panel {
        padding: 16px;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100vw - 14px, 1220px);
        padding-top: 14px;
    }

    .hero {
        margin-bottom: 12px;
    }

    .hero h1 {
        font-size: 34px;
    }

    .subtitle {
        font-size: 14px;
    }

    .wheel-container {
        width: min(100%, 92vw);
        margin-bottom: 12px;
    }

    #pointer {
        width: 38px;
        height: 52px;
        top: -8%;
    }

    .draw-actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .draw-actions button {
        min-height: 54px;
        font-size: 18px;
    }

    .panel {
        padding: 14px;
    }

    textarea {
        min-height: 170px;
    }

    .modal {
        padding: 14px;
    }

    .modal-content {
        min-height: 250px;
        padding: 24px 16px;
    }
}
