:root {
    --red: #dd0015;
    --deep-red: #9f0615;
    --green: #109900;
    --deep-green: #004836;
    --cream: #fbfbef;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow-x: hidden; background: #a20815; }
button, input { font: inherit; }
button { cursor: pointer; }

.lucky-page {
    position: relative;
    min-height: 100vh;
    min-height: max(100dvh, calc(min(720px, 51vw) + 230px));
    overflow: hidden;
    background: #a20815 url('../images/xmas_desktop.webp') center / cover no-repeat;
}

.snow-canvas, .confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.snow-canvas { z-index: 2; }
.confetti-canvas { z-index: 40; }

.site-logo {
    position: fixed;
    z-index: 9;
    top: max(16px, env(safe-area-inset-top));
    left: 18px;
    display: flex;
    width: 246px;
    min-height: 68px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
}
.site-logo img { display: block; width: 100%; height: auto; max-height: 76px; object-fit: contain; filter: drop-shadow(0 0 5px rgba(255,255,255,.9)); }

.info-button {
    position: fixed;
    z-index: 8;
    top: max(94px, calc(env(safe-area-inset-top) + 80px));
    left: 18px;
    display: grid;
    width: 32px;
    height: 32px;
    padding: 4px;
    place-items: center;
    border: 0;
    background: transparent;
    color: #090909;
}
.info-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }

.package-badge {
    position: fixed;
    z-index: 8;
    top: max(16px, env(safe-area-inset-top));
    right: 18px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 999px;
    background: rgba(255, 255, 255, .9);
    color: #24372e;
    box-shadow: 0 8px 28px rgba(67, 0, 8, .18);
    backdrop-filter: blur(8px);
}
.package-badge span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .65; }
.package-badge strong { font-size: 13px; }

.festive-gifts {
    position: absolute;
    z-index: 3;
    left: 100px;
    display: block;
    height: auto;
    object-fit: contain;
    pointer-events: none;
}
.festive-gifts { top: 55%; width: 632px; transform: translateY(-50%); animation: gifts-in .85s ease-out both; }
@keyframes gifts-in { from { opacity: 0; transform: translate(-35px, -50%); } to { opacity: 1; transform: translate(0, -50%); } }

.wheel-stage {
    position: absolute;
    z-index: 4;
    top: 24px;
    right: 24px;
    width: min(720px, 51vw);
}
.wheel-wrap { position: relative; width: 100%; aspect-ratio: 1; filter: drop-shadow(0 18px 22px rgba(25, 0, 0, .28)); }
.wheel-controls { display: grid; gap: 12px; margin-bottom: 12px; justify-items: center; }
.wheel-rules { padding: 9px 18px; border: 1px solid rgba(255,255,255,.65); border-radius: 999px; background: #fff; color: #164d38; font-size: 14px; font-weight: 750; box-shadow: 0 5px 18px rgba(0,0,0,.12); }
.wheel-packages { display: flex; gap: 8px; width: 100%; justify-content: center; flex-wrap: wrap; }
.wheel-package { flex: 1 1 100px; max-width: 190px; min-height: 44px; padding: 10px 12px; border: 2px solid rgba(255,255,255,.65); border-radius: 12px; background: rgba(255,255,255,.9); color: #234534; font-size: 14px; font-weight: 800; transition: background .16s ease, color .16s ease, box-shadow .16s ease; }
.wheel-package[aria-pressed="true"] { border-color: #ffe58e; background: #ffdf75; color: #493d13; box-shadow: 0 0 0 3px rgba(255,229,142,.22); }
.wheel-package:not([disabled]):hover { background: #fff2bd; }
.wheel-package:focus-visible, .wheel-rules:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.wheel-package[disabled] { cursor: wait; opacity: .7; }
.wheel-preview { margin: 0; padding: 5px 12px; border-radius: 999px; background: rgba(0,56,43,.7); color: #fff; font-size: 12px; }
#wheelCanvas { display: block; width: 100%; height: 100%; transition: transform 6.2s cubic-bezier(.12,.62,.12,1); will-change: transform; }
#wheelCanvas.is-idle { transition: none; }
.wheel-pointer {
    position: absolute;
    z-index: 5;
    top: 2.3%;
    left: 50%;
    width: 9%;
    height: 12%;
    transform: translate(-50%, -8%);
    background: var(--cream);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    filter: drop-shadow(0 3px 0 var(--deep-green));
}
.spin-button {
    position: absolute;
    z-index: 6;
    top: 50%;
    left: 50%;
    width: 24%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    background: transparent url('../images/quay.png') center / contain no-repeat;
    filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .22));
    transition: scale .18s ease;
}
.spin-button:hover { scale: 1.04; }
.spin-button:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
.spin-button[disabled] { cursor: wait; filter: grayscale(.3); }

.terms-bar {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 62px;
    padding: 11px max(18px, env(safe-area-inset-right)) calc(11px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    border-top: 1px solid #ddd;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .12);
    color: #222;
}
.terms-bar p { margin: 0; font-size: 14px; line-height: 1.45; text-align: center; }
.terms-bar button {
    flex: 0 0 auto;
    padding: 7px 17px;
    border: 1px solid #6c757d;
    border-radius: 999px;
    background: #fff;
    color: #50565b;
    font-size: 14px;
    font-weight: 600;
}
.terms-bar.is-hidden { display: none; }

.modal-layer {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: grid;
    padding: 22px;
    place-items: center;
    overflow-y: auto;
    background: rgba(0, 24, 18, .72);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.modal-layer.is-open { opacity: 1; visibility: visible; }
.modal-card {
    position: relative;
    width: min(500px, 100%);
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
    color: #1d2a25;
    transform: translateY(10px) scale(.98);
    transition: transform .2s ease;
}
.modal-layer.is-open .modal-card { transform: translateY(0) scale(1); }
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #f2f4f3;
    color: #38443f;
    font-size: 24px;
    line-height: 1;
}
.modal-heading { display: flex; align-items: center; gap: 12px; padding-right: 34px; }
.modal-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: #eef8ed; font-size: 25px; }
.modal-heading small { color: #0b8e38; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.modal-heading h1 { margin: 3px 0 0; font-size: clamp(22px, 4vw, 28px); line-height: 1.15; }
.modal-intro { margin: 16px 0 18px; color: #5e6b65; font-size: 14px; line-height: 1.55; }

.package-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
.package-options legend { grid-column: 1 / -1; margin-bottom: 4px; color: #36453e; font-size: 13px; font-weight: 750; }
.package-option { position: relative; min-width: 0; }
.package-option input { position: absolute; opacity: 0; pointer-events: none; }
.package-option span { display: flex; height: 100%; min-height: 72px; padding: 10px 8px; border: 1px solid #dce5df; border-radius: 13px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; transition: .16s ease; }
.package-option b { font-size: 13px; line-height: 1.2; }
.package-option small { display: none; }
.package-option input:checked + span { border-color: var(--package-color); background: color-mix(in srgb, var(--package-color) 10%, white); box-shadow: 0 0 0 2px color-mix(in srgb, var(--package-color) 25%, transparent); color: color-mix(in srgb, var(--package-color) 72%, #17271f); }
.package-option input:focus-visible + span { outline: 3px solid #badfc4; outline-offset: 2px; }

.form-field { display: block; margin-top: 13px; }
.form-field span { display: block; margin-bottom: 6px; color: #34453d; font-size: 13px; font-weight: 750; }
.form-field input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #d9e2dc; border-radius: 12px; background: #fbfcfb; color: #17211d; outline: none; }
.form-field input:focus { border-color: #1d9b45; box-shadow: 0 0 0 3px rgba(29, 155, 69, .12); }
.form-error { margin: 12px 0 0; padding: 9px 11px; border-radius: 10px; background: #fff0f0; color: #b51f2e; font-size: 13px; font-weight: 650; }
.submit-spin { display: flex; width: 100%; min-height: 54px; margin-top: 18px; border: 0; border-radius: 14px; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(135deg, #139b39, #00744a); color: #fff; box-shadow: 0 10px 24px rgba(0, 116, 74, .24); }
.submit-spin span { font-size: 17px; font-weight: 800; }
.submit-spin small { opacity: .85; font-size: 11px; }
.submit-spin[disabled] { cursor: wait; opacity: .72; }
.privacy-note { margin: 10px 0 0; color: #89928e; font-size: 11px; text-align: center; }

.result-card { overflow: hidden; text-align: center; }
.result-card::before { position: absolute; top: -80px; left: 50%; width: 260px; height: 150px; border-radius: 50%; background: rgba(24, 164, 63, .12); content: ''; transform: translateX(-50%); }
.result-heading { position: relative; display: flex; margin: 0 auto 22px; align-items: center; justify-content: center; gap: 9px; }
.result-heading span { font-size: 25px; }
.result-heading h2 { margin: 0; font-size: 20px; }
.result-prize { position: relative; display: flex; min-height: 190px; padding: 24px; border: 2px solid #d9ecd8; border-radius: 18px; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(145deg, #f6fff4, #e5f6e3); }
.result-prize img { width: 110px; height: 110px; margin-bottom: 12px; object-fit: contain; }
.result-prize [data-result-placeholder] { margin-bottom: 12px; font-size: 76px; line-height: 1; }
.result-prize strong { color: #087533; font-size: 25px; line-height: 1.2; }
.result-card [data-result-package] { margin: 16px 0 4px; color: #4d5f56; font-size: 14px; font-weight: 650; }
.remaining-copy { min-height: 20px; margin: 4px 0 18px; color: #7b8580; font-size: 13px; }
.result-close { min-width: 150px; padding: 11px 22px; border: 0; border-radius: 12px; background: #68716d; color: #fff; font-weight: 750; }
.info-card h2 { margin: 0 0 15px; font-size: 24px; }
.info-card ul { margin: 0 0 22px; padding-left: 20px; color: #52625a; line-height: 1.7; }

.toast { position: fixed; z-index: 60; right: 18px; bottom: 84px; max-width: min(360px, calc(100vw - 36px)); padding: 12px 16px; border-radius: 12px; background: #17251f; color: #fff; box-shadow: 0 12px 30px rgba(0,0,0,.25); font-size: 14px; }
.campaign-paused { position: fixed; z-index: 5; top: 50%; left: 50%; width: min(440px, calc(100vw - 36px)); padding: 28px; border-radius: 20px; background: rgba(255,255,255,.95); text-align: center; transform: translate(-50%,-50%); }
.campaign-paused strong { font-size: 23px; }
.campaign-paused p { color: #607068; }
.campaign-paused a { display: inline-block; padding: 10px 16px; border-radius: 10px; background: #087b39; color: #fff; text-decoration: none; }

@media (max-width: 1199px) {
    .lucky-page { min-height: max(100dvh, 980px); }
    .wheel-stage { top: auto; right: auto; bottom: 110px; left: 50%; width: min(620px, 88vw); transform: translateX(-50%); }
    .festive-gifts { left: 50%; width: 70vw; transform: translateX(-50%); animation: festive-mobile-in .7s ease-out both; }
    .festive-gifts { top: calc(70vw * .46154); }
    @keyframes festive-mobile-in { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
}

@media (max-width: 767px) {
    .lucky-page { background-image: url('../images/xmas_mobile.webp'); background-position: top center; }
    .site-logo { top: max(10px, env(safe-area-inset-top)); left: 12px; width: 175px; min-height: 54px; padding: 0; }
    .site-logo img { max-height: 54px; }
    .info-button { top: max(68px, calc(env(safe-area-inset-top) + 58px)); left: 12px; }
    .package-badge { top: 12px; right: 10px; padding: 7px 10px; }
    .package-badge span { display: none; }
    .lucky-page { min-height: max(100dvh, 700px); }
    .wheel-stage { bottom: max(108px, calc(100px + env(safe-area-inset-bottom))); width: min(92vw, 420px); }
    .wheel-controls { gap: 9px; }
    .wheel-package { min-height: 42px; padding: 9px 6px; font-size: 12px; }
    .terms-bar { gap: 8px; min-height: 86px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); flex-direction: column; }
    .terms-bar p { font-size: 12px; line-height: 1.35; }
    .terms-bar button { padding: 6px 14px; font-size: 12px; }
    .modal-layer { padding: 12px; place-items: start center; }
    .modal-card { margin: max(8px, env(safe-area-inset-top)) auto max(8px, env(safe-area-inset-bottom)); padding: 22px 18px; border-radius: 18px; }
    .package-options { gap: 6px; }
    .package-option span { min-height: 60px; padding: 8px 5px; }
    .package-option b { font-size: 12px; }
    .result-prize { min-height: 168px; }
}


/* Uploaded artwork replaces the seasonal composition, not another overlay.
   Cover the entire page without stretching; keep desktop artwork left-aligned. */
@media (min-width: 768px) {
    .lucky-page.custom-desktop-background {
        min-height: max(100dvh, 620px);
        background-color: #eef7ff;
        background-size: cover;
        background-position: left top;
    }
    .custom-desktop-background .festive-gifts { display: none; }
    .custom-desktop-background .wheel-stage {
        top: 50%; right: 24px; bottom: auto; left: auto;
        width: min(680px, 46vw, max(360px, calc(100dvh - 270px)));
        transform: translateY(-50%);
        padding-bottom: 80px;
    }
}
@media (max-width: 767px) {
    .lucky-page.custom-mobile-background {
        min-height: 100dvh;
        background-color: #eef7ff;
        /* Fill both edges on short and tall phones without stretching. */
        background-size: cover;
        background-position: center;
    }
    .custom-mobile-background .festive-gifts { display: none; }
    .custom-mobile-background .wheel-stage {
        position: relative; top: auto; right: auto; bottom: auto; left: auto;
        width: min(92vw, 420px); margin: 0 auto;
        padding-top: 100px; padding-bottom: 150px; transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
