:root {
    --sky-top: #3aa7ee;
    --sky-bottom: #cdeeff;
    --ink: #123a5c;
    --brand: #1677d9;
    --body: #ff6b4a;
    --body-dark: #d6452a;
    --gold: #ffd23f;
    --gold-dark: #e8a800;
    --cream: #fff8e7;
    --card: rgba(255, 255, 255, .82);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--sky-bottom);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Hiragino Sans", "Apple SD Gothic Neo",
        "Microsoft YaHei", "Malgun Gothic", "Noto Sans CJK SC", sans-serif;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
button, select, input { font: inherit; }
:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }
button { touch-action: manipulation; }

/* ---------- Sky ---------- */
.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, var(--sky-top) 0%, #7fcdf7 45%, var(--sky-bottom) 100%);
    overflow: hidden;
}
.cloud {
    position: absolute;
    width: 160px;
    height: 48px;
    border-radius: 48px;
    background: #fff;
    opacity: .85;
    animation: drift 38s linear infinite;
}
.cloud::before, .cloud::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: #fff;
}
.cloud::before { width: 70px; height: 70px; left: 22px; top: -34px; }
.cloud::after { width: 54px; height: 54px; left: 78px; top: -22px; }
.c1 { top: 12%; left: -20%; transform: scale(.8); }
.c2 { top: 38%; left: 60%; transform: scale(.55); animation-duration: 52s; animation-delay: -20s; opacity: .7; }
.c3 { top: 70%; left: 10%; transform: scale(1); animation-duration: 64s; animation-delay: -40s; opacity: .6; }
@keyframes drift { from { translate: -40vw 0; } to { translate: 140vw 0; } }
.plane {
    position: absolute;
    top: 9%;
    left: 0;
    width: 34px;
    height: 34px;
    fill: #fff;
    rotate: 90deg;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .15));
    animation: fly 14s linear infinite;
}
@keyframes fly {
    from { translate: -60px 40px; }
    to { translate: calc(100vw + 60px) -30px; }
}

/* ---------- Layout ---------- */
.game {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: max(12px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
    text-align: center;
}
.toolbar { display: flex; justify-content: flex-end; }
#language {
    min-height: 36px;
    padding: 4px 30px 4px 12px;
    border: 0;
    border-radius: 999px;
    color: var(--ink);
    background: rgba(255, 255, 255, .9) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23123a5c'/%3E%3C/svg%3E") right 12px center / 10px 6px no-repeat;
    -webkit-appearance: none;
    appearance: none;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(18, 58, 92, .15);
}
.hero { margin-top: 6px; }
.badge {
    display: inline-block;
    margin: 0;
    padding: 2px 12px;
    border-radius: 999px;
    color: #fff;
    background: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .18em;
}
h1 {
    margin: 6px 0 0;
    color: #fff;
    font-size: clamp(28px, 8.4vw, 40px);
    line-height: 1.2;
    font-weight: 900;
    text-shadow: 0 3px 0 var(--brand), 0 6px 14px rgba(18, 58, 92, .35);
}
#subtitle { margin: 6px 0 0; color: #fff; font-weight: 700; text-shadow: 0 1px 3px rgba(18, 58, 92, .45); }
#count {
    display: inline-block;
    margin: 12px 0 0;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--card);
    font-weight: 700;
}
#count:empty { display: none; }
#game-status { margin: 10px 0 0; font-weight: 700; }
#game-status:empty { display: none; }
#retry {
    margin-top: 8px;
    padding: 8px 18px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: var(--brand);
    font-weight: 700;
    cursor: pointer;
}
#retry[hidden] { display: none; }

/* ---------- Machine ---------- */
.machine {
    position: relative;
    width: min(82vw, 330px);
    margin: 18px auto 0;
    container-type: inline-size;
}
.dome {
    position: relative;
    z-index: 1;
    width: 92cqw;
    aspect-ratio: 1;
    margin: 0 auto;
}
.dome-glass {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, .55), rgba(190, 230, 255, .4) 70%, rgba(120, 190, 240, .55));
    border: 1.6cqw solid rgba(255, 255, 255, .95);
    box-shadow: inset 0 -4cqw 8cqw rgba(22, 119, 217, .25), 0 3cqw 6cqw rgba(18, 58, 92, .2);
}
.capsules {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
}
.dome-shine {
    position: absolute;
    left: 16%;
    top: 12%;
    width: 24%;
    height: 34%;
    border-radius: 50%;
    background: linear-gradient(160deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 70%);
    rotate: 28deg;
    pointer-events: none;
}
.capsule, .out-capsule, .big-capsule {
    border-radius: 50%;
    overflow: hidden;
}
.capsule {
    position: absolute;
    width: 22%;
    aspect-ratio: 1;
    background: linear-gradient(var(--c) 50%, #fff 50%);
    border: .5cqw solid rgba(0, 0, 0, .12);
    box-shadow: inset -1.2cqw -1.2cqw 2.4cqw rgba(0, 0, 0, .14), inset 1cqw 1cqw 2cqw rgba(255, 255, 255, .6);
    transform: translate(-50%, -50%) rotate(var(--r));
}
.mixing .capsule { animation: mix .32s ease-in-out infinite alternate; }
@keyframes mix {
    to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(calc(var(--r) + 50deg)); }
}
.neck {
    position: relative;
    z-index: 2;
    width: 58cqw;
    height: 7cqw;
    margin: -5cqw auto 0;
    border-radius: 3cqw 3cqw 0 0;
    background: linear-gradient(var(--body-dark), #bd3a22);
}
.body {
    position: relative;
    height: 64cqw;
    border-radius: 7cqw 7cqw 5cqw 5cqw;
    background: linear-gradient(180deg, #ff8566 0%, var(--body) 40%, var(--body-dark) 100%);
    box-shadow: inset 0 1.2cqw 0 rgba(255, 255, 255, .35), 0 3cqw 6cqw rgba(18, 58, 92, .25);
}
.mixing .body { animation: shake .16s linear infinite; }
@keyframes shake {
    0%, 100% { translate: 0 0; }
    25% { translate: -.6cqw .3cqw; }
    75% { translate: .6cqw -.3cqw; }
}
.plate {
    position: absolute;
    top: 5cqw;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2cqw;
    width: 70cqw;
    height: 11cqw;
    translate: -50% 0;
    border-radius: 6cqw;
    color: var(--brand);
    background: var(--cream);
    font-size: 5.6cqw;
    font-weight: 900;
    letter-spacing: .08em;
    box-shadow: inset 0 -.8cqw 0 rgba(0, 0, 0, .08);
}
.plate svg { width: 6.5cqw; height: 6.5cqw; fill: currentColor; rotate: 90deg; }
.knob {
    position: absolute;
    left: 9cqw;
    top: 22cqw;
    width: 32cqw;
    height: 32cqw;
    padding: 0;
    border: 1.6cqw solid #fff;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff3b0, var(--gold) 55%, var(--gold-dark));
    box-shadow: 0 1.4cqw 0 rgba(0, 0, 0, .18), inset 0 -1cqw 2cqw rgba(0, 0, 0, .15);
    cursor: pointer;
    transition: transform 1.3s cubic-bezier(.45, .05, .25, 1);
}
.knob:disabled { cursor: default; }
.knob-bar {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72%;
    height: 22%;
    translate: -50% -50%;
    border-radius: 4cqw;
    background: linear-gradient(#fff, #f1f1f1);
    box-shadow: 0 .8cqw 0 rgba(0, 0, 0, .18);
}
.chute {
    position: absolute;
    right: 9cqw;
    top: 24cqw;
    width: 34cqw;
    height: 30cqw;
    border-radius: 5cqw;
    background: radial-gradient(ellipse at 50% 0%, #3b1a12, #1d0c08 70%);
    box-shadow: inset 0 2cqw 3cqw rgba(0, 0, 0, .6), 0 .8cqw 0 rgba(255, 255, 255, .25);
    overflow: hidden;
}
.out-capsule {
    position: absolute;
    left: 50%;
    bottom: 2cqw;
    width: 21cqw;
    height: 21cqw;
    margin-left: -10.5cqw;
    padding: 0;
    border: .6cqw solid rgba(0, 0, 0, .12);
    background: none;
    cursor: pointer;
}
.out-capsule[hidden] { display: none; }
.out-capsule.drop { animation: drop .9s cubic-bezier(.3, 1.35, .5, 1) both; }
.out-capsule.ready { animation: wobble 1.2s ease-in-out infinite; box-shadow: 0 0 0 1.2cqw rgba(255, 210, 63, .55); }
@keyframes drop {
    from { transform: translateY(-140%) rotate(-120deg); }
    to { transform: translateY(0) rotate(0); }
}
@keyframes wobble {
    0%, 100% { transform: rotate(0) scale(1); }
    25% { transform: rotate(-10deg) scale(1.06); }
    75% { transform: rotate(10deg) scale(1.06); }
}
.cap-top, .cap-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
}
.cap-top { top: 0; background: var(--c, #ff5a5f); }
.cap-bottom { bottom: 0; background: #fff; }
.out-capsule .cap-top::after, .big-capsule .cap-top::after {
    content: "";
    position: absolute;
    left: 18%;
    top: 22%;
    width: 26%;
    height: 30%;
    border-radius: 50%;
    background: rgba(255, 255, 255, .55);
}
.feet {
    width: 84cqw;
    height: 5cqw;
    margin: 0 auto;
    border-radius: 0 0 3cqw 3cqw;
    background: #9e3018;
}

/* ---------- Main button ---------- */
#spin {
    display: block;
    width: min(100%, 320px);
    min-height: 58px;
    margin: 22px auto 0;
    padding: 10px 20px;
    border: 0;
    border-radius: 999px;
    color: #5a2a00;
    background: linear-gradient(180deg, #ffe57a, var(--gold) 55%, #ffb800);
    box-shadow: 0 5px 0 var(--gold-dark), 0 10px 18px rgba(18, 58, 92, .25);
    font-size: 21px;
    font-weight: 900;
    letter-spacing: .04em;
    cursor: pointer;
    transition: transform .1s, box-shadow .1s;
}
#spin:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-dark), 0 4px 10px rgba(18, 58, 92, .25); }
#spin:disabled { cursor: default; filter: saturate(.35); opacity: .75; }
#spin.pulse:not(:disabled) { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }

/* ---------- Info cards ---------- */
.steps, .prizes {
    margin-top: 24px;
    padding: 16px;
    border-radius: 18px;
    background: var(--card);
    box-shadow: 0 6px 18px rgba(18, 58, 92, .12);
    text-align: left;
}
.steps h2, .prizes h2 { margin: 0 0 10px; font-size: 18px; color: var(--brand); }
.steps ol { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.step-no {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    background: var(--body);
    font-size: 14px;
    font-weight: 800;
}
#prize-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#prize-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #fff;
    font-weight: 700;
    overflow-wrap: anywhere;
}
#prize-list .dot {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, .1);
    background: linear-gradient(var(--c) 50%, #fff 50%);
}
.prizes:has(#prize-list:empty) { display: none; }

/* ---------- Footer ---------- */
.site-footer {
    margin-top: 28px;
    padding: 18px 16px 4px;
    border-top: 1px solid rgba(18, 58, 92, .15);
    color: #3d5d7a;
    font-size: 13px;
    line-height: 1.6;
    text-align: left;
}
.site-footer[hidden] { display: none; }
.site-footer p { margin: 0 0 10px; }
.site-footer p:empty { display: none; }
.footer-notice { white-space: pre-line; }
.footer-info { display: grid; gap: 4px; margin: 0 0 10px; }
.footer-info:empty { display: none; }
.footer-info div { display: flex; gap: 8px; }
.footer-info dt { flex: none; min-width: 5.5em; color: #6c8aa5; font-weight: 700; }
.footer-info dd { margin: 0; overflow-wrap: anywhere; }
.site-footer a { color: var(--brand); text-decoration: none; }
.footer-copyright, .footer-license { text-align: center; color: #6c8aa5; }

/* ---------- Result dialog ---------- */
dialog {
    width: min(400px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    padding: 18px;
    border: 0;
    border-radius: 22px;
    color: var(--ink);
    background: #f2f9ff;
    text-align: center;
    box-shadow: 0 18px 60px rgba(10, 40, 70, .45);
    overflow: auto;
    overscroll-behavior: contain;
}
dialog:not([open]) { display: none; }
dialog.fallback-open { position: fixed; inset: 0; margin: auto; z-index: 10; height: fit-content; }
dialog::backdrop { background: rgba(10, 40, 70, .7); }
.reveal {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    background: #f2f9ff;
    pointer-events: none;
    overflow: hidden;
}
dialog:not(.opening) .reveal { display: none; }
.opening .reveal { animation: fade-out .35s ease 1.25s forwards; }
.burst {
    position: absolute;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: repeating-conic-gradient(rgba(255, 210, 63, .7) 0 10deg, transparent 10deg 22deg);
    -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
    mask: radial-gradient(circle, #000 30%, transparent 70%);
    opacity: 0;
    scale: .3;
}
.opening .burst { animation: burst 1.2s ease-out .45s forwards; }
@keyframes burst { 40% { opacity: 1; } to { opacity: 0; scale: 1.4; rotate: 40deg; } }
.big-capsule {
    position: relative;
    width: 120px;
    height: 120px;
    overflow: visible;
}
.big-capsule .cap-top, .big-capsule .cap-bottom { border: 3px solid rgba(0, 0, 0, .12); }
.big-capsule .cap-top { border-radius: 60px 60px 0 0; border-bottom: 0; overflow: hidden; }
.big-capsule .cap-bottom { border-radius: 0 0 60px 60px; border-top: 2px solid rgba(0, 0, 0, .15); }
.opening .big-capsule { animation: pop-in .45s cubic-bezier(.3, 1.5, .5, 1) both; }
.opening .big-capsule .cap-top { animation: lid-off .6s ease-in .55s forwards; }
.opening .big-capsule .cap-bottom { animation: base-off .6s ease-in .55s forwards; }
@keyframes pop-in { from { scale: .2; rotate: -90deg; } }
@keyframes lid-off { to { translate: -30px -110px; rotate: -40deg; opacity: 0; } }
@keyframes base-off { to { translate: 20px 90px; rotate: 25deg; opacity: 0; } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }
.opening .ticket { animation: ticket-in .55s cubic-bezier(.2, 1.2, .4, 1) 1.15s both; }
@keyframes ticket-in { from { translate: 0 40px; scale: .9; opacity: 0; } }

.ticket {
    position: relative;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(18, 58, 92, .15);
    text-align: left;
}
.ticket:focus { outline: none; }
.ticket-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 16px 16px 0 0;
    color: #fff;
    background: linear-gradient(90deg, var(--brand), #3aa7ee);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .12em;
}
.ticket-head svg { width: 20px; height: 20px; fill: currentColor; rotate: 90deg; }
.ticket-main { padding: 14px 16px 16px; }
.ticket h2 { margin: 0; color: var(--body-dark); font-size: 15px; }
#prize { margin: 4px 0 0; font-size: 24px; line-height: 1.25; font-weight: 900; overflow-wrap: anywhere; }
.itinerary { display: grid; gap: 10px; margin: 14px 0 0; }
.itinerary[hidden] { display: none; }
.leg { padding: 10px 12px; border-radius: 12px; background: #f2f8fe; }
.leg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; }
.leg-tag { padding: 0 8px; border-radius: 999px; color: #fff; background: var(--brand); font-size: 12px; font-weight: 800; }
.leg + .leg .leg-tag { background: var(--body-dark); }
.leg-date { font-weight: 800; }
.leg-flight { margin-left: auto; color: #6c8aa5; font-weight: 700; }
.leg-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.leg-point { display: grid; min-width: 0; }
.leg-point:last-child { text-align: right; }
.leg-point strong { font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.leg-code { font-size: 13px; font-weight: 800; letter-spacing: .06em; }
.leg-name { color: #6c8aa5; font-size: 12px; overflow-wrap: anywhere; }
.leg-line {
    position: relative;
    width: 56px;
    height: 2px;
    background: repeating-linear-gradient(90deg, #9cc3e6 0 4px, transparent 4px 8px);
}
.leg-line::after {
    content: "";
    position: absolute;
    right: -4px;
    top: -5px;
    border: 6px solid transparent;
    border-left-color: var(--brand);
    border-right: 0;
}
#proof-note { white-space: pre-line; }
#prize-list li.group-head { padding: 6px 2px 0; background: none; color: #6c8aa5; font-size: 13px; font-weight: 800; }
.ticket-stub {
    position: relative;
    padding: 12px 16px 14px;
    border-top: 2px dashed #c9dbea;
}
.ticket-stub::before, .ticket-stub::after {
    content: "";
    position: absolute;
    top: -11px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f2f9ff;
}
.ticket-stub::before { left: -10px; }
.ticket-stub::after { right: -10px; }
.barcode {
    display: block;
    height: 34px;
    background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 7px, transparent 7px 9px, var(--ink) 9px 10px, transparent 10px 13px);
    opacity: .85;
}
.ticket.miss .ticket-head { background: linear-gradient(90deg, #8a9bab, #b5c3cf); }
.ticket.miss h2 { color: #6c8aa5; }
.ticket.miss #prize { font-size: 19px; color: var(--ink); }
.ticket.miss .barcode { opacity: .25; }
#proof-note { margin: 8px 0 0; color: #6c8aa5; font-size: 12px; }
#proof-note:empty { display: none; }
#prize-image { display: block; width: 100%; max-height: 160px; object-fit: contain; margin: 12px 0 0; }
#prize-image[hidden] { display: none; }
#claim-form { margin-top: 14px; text-align: left; }
#claim-form[hidden] { display: none; }
#claim-form label { display: block; font-weight: 800; }
#claim-phone {
    width: 100%;
    min-height: 48px;
    margin: 6px 0 0;
    padding: 10px 12px;
    border: 2px solid #b9d3e8;
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
    font-size: 17px;
}
#claim-phone:focus { outline: none; border-color: var(--brand); }
#claim-phone[aria-invalid="true"] { border-color: #d6452a; }
#phone-error { margin: 6px 0 0; color: #d6452a; font-size: 14px; font-weight: 700; }
#phone-error:empty { display: none; }
#phone-note { margin: 6px 0 0; color: #6c8aa5; font-size: 13px; }
#claim {
    width: 100%;
    min-height: 52px;
    margin-top: 12px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(180deg, #ff8566, var(--body-dark));
    box-shadow: 0 4px 0 #a83620;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
}
#claim:disabled { opacity: .7; cursor: wait; }
#claim-link { display: block; margin-top: 12px; color: var(--brand); font-weight: 700; }
#claim-link[hidden] { display: none; }
#claim-status { margin: 12px 0 0; font-weight: 700; }
#claim-status:empty { display: none; }
#close {
    min-height: 44px;
    margin-top: 12px;
    padding: 8px 28px;
    border: 2px solid #b9d3e8;
    border-radius: 999px;
    color: var(--ink);
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}

@media (min-width: 600px) {
    .machine { width: 340px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .plane, .cloud { display: none; }
}
