:root {
    --navy: #26216d;
    --red: #ff372f;
    --red-dark: #dd1919;
    --orange: #ff8a00;
    --yellow: #ffd423;
    --cream: #fff3bf;
    --paper: #fff8dc;
    --ink: #461b16;
    --shadow: 0 18px 42px rgba(183, 23, 12, .24);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    background: #17144e;
}

body {
    width: min(500px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #252071 0, #252071 126px, #ffc91d 126px, #ffd633 255px, #ff3b30 255px, #ff3b30 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

.lottery-page {
    min-height: 100vh;
    position: relative;
    padding: 0 18px 30px;
    overflow: hidden;
}

.hero {
    min-height: 282px;
    position: relative;
    margin: 0 -18px;
    padding: 22px 18px 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 13% 12%, rgba(255, 255, 255, .95) 0 4px, transparent 5px),
        radial-gradient(circle at 82% 9%, rgba(255, 255, 255, .95) 0 3px, transparent 4px),
        radial-gradient(circle at 56% 30%, rgba(255, 238, 118, .95) 0 5px, transparent 6px),
        linear-gradient(180deg, #27236f 0%, #231a65 58%, #ffd323 58%, #ffc414 100%);
}

.hero::after {
    content: "";
    position: absolute;
    right: -45px;
    bottom: -22px;
    width: 210px;
    height: 88px;
    border-radius: 999px 0 0 0;
    background: #ffd323;
}

.back-home,
.sound-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    position: absolute;
    top: 18px;
    z-index: 3;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .32);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}

.back-home {
    left: 18px;
}

.sound-btn {
    right: 18px;
    cursor: pointer;
}

.sound-btn.is-playing {
    background: #ffe261;
    color: #2a1a6e;
}

.hero-sign {
    width: min(430px, calc(100% - 24px));
    min-height: 96px;
    margin: 26px auto 0;
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
}

.hero-sign h1 {
    position: relative;
    z-index: 1;
    color: #ffe14d;
    font-size: 42px;
    font-weight: 1000;
    letter-spacing: 0;
    line-height: 1.08;
    text-align: center;
    text-shadow: 0 4px 0 #8f1b14, 0 8px 16px rgba(0, 0, 0, .28);
}

.hero-actions {
    width: min(360px, 100%);
    display: flex;
    justify-content: space-between;
    gap: 42px;
    position: relative;
    z-index: 3;
    margin: 18px auto 0;
}

.pill-btn {
    min-width: 96px;
    height: 36px;
    border: 0;
    border-radius: 7px;
    background: linear-gradient(180deg, #ff7747, #ff452f);
    color: #fff9dc;
    font-size: 15px;
    font-weight: 900;
    box-shadow: 0 5px 0 #d22017, 0 10px 18px rgba(174, 37, 18, .2);
    cursor: pointer;
}

.draw-panel {
    margin-top: -34px;
    position: relative;
    z-index: 4;
    padding: 16px 12px 15px;
    border-radius: 28px 28px 18px 18px;
    background: linear-gradient(180deg, #ff4438, #ff2f2a);
    box-shadow: var(--shadow);
}

.draw-panel::before {
    content: "";
    position: absolute;
    inset: 12px;
    border: 2px solid rgba(255, 207, 67, .42);
    border-radius: 22px 22px 12px 12px;
    pointer-events: none;
}

.panel-head {
    margin: 0 auto 13px;
    color: #fff;
    text-align: center;
    font-size: 22px;
    font-weight: 1000;
    text-shadow: 0 2px 0 rgba(135, 24, 14, .3);
}

.code-entry {
    position: relative;
    z-index: 1;
    margin: 0 8px 10px;
}

.code-entry input {
    width: 100%;
    height: 44px;
    border: 3px solid #ffc437;
    border-radius: 999px;
    outline: none;
    background: #fff9df;
    color: #6b231b;
    font-size: 16px;
    font-weight: 1000;
    letter-spacing: 2px;
    text-align: center;
    box-shadow: inset 0 -4px 0 rgba(255, 199, 54, .18);
}

.code-entry input::placeholder {
    color: #c38376;
    font-size: 14px;
    letter-spacing: 0;
}

.code-entry p {
    min-height: 18px;
    margin-top: 5px;
    color: #fff6ca;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}

.code-entry p.is-error {
    color: #fff;
    text-shadow: 0 2px 0 rgba(145, 19, 12, .35);
}

.grid-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    position: relative;
    z-index: 1;
    padding: 8px;
    border-radius: 12px;
    background: #9b1910;
    box-shadow: inset 0 0 0 2px rgba(80, 12, 7, .24);
}

.prize-cell,
.draw-start {
    aspect-ratio: 1 / .78;
    min-height: 82px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 3px solid #ffc437;
    border-radius: 12px;
}

.prize-cell {
    background: #fff2c6;
    color: #662117;
    box-shadow: inset 0 -7px 0 rgba(255, 199, 54, .18);
    transition: transform .08s ease, background .08s ease, box-shadow .08s ease;
}

.prize-cell.active {
    background: #fff100;
    box-shadow: 0 0 0 4px rgba(255, 246, 88, .38), 0 0 20px rgba(255, 244, 52, .85);
    transform: scale(.96);
}

.prize-cell i {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #fff;
    font-size: 22px;
    box-shadow: 0 5px 12px rgba(112, 25, 10, .14);
}

.prize-cell img {
    width: 48px;
    height: 48px;
    display: block;
    border-radius: 13px;
    object-fit: cover;
    box-shadow: 0 5px 12px rgba(112, 25, 10, .16);
}

.prize-cell.has-image {
    gap: 6px;
}

.prize-cell span {
    max-width: 90%;
    overflow: hidden;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tone-gold i { color: #f5a400; }
.tone-pink i { color: #ff3869; }
.tone-green i { color: #0bbd62; }
.tone-blue i { color: #1687f5; }
.tone-purple i { color: #8d4df5; }
.tone-cyan i { color: #11a9ca; }
.tone-orange i { color: #ff7b00; }
.tone-red i { color: #e8332a; }

.draw-start {
    border: 0;
    background: radial-gradient(circle at 45% 30%, #ff6b5c, #f52c28 70%);
    color: #fff;
    cursor: pointer;
    font-weight: 1000;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .20), 0 5px 0 #c51b16;
}

.draw-start span,
.draw-start strong {
    display: block;
    font-size: 27px;
    line-height: .95;
    text-shadow: 0 3px 0 rgba(123, 22, 12, .28);
}

.draw-start.is-running {
    filter: brightness(1.08);
    transform: scale(.98);
}

.draw-meta {
    margin-top: 13px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 236, 151, .22);
    color: #fff8d7;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
}

.winner-strip {
    margin: 16px 0 0;
    padding: 13px 14px;
    border-radius: 16px;
    background: rgba(255, 248, 220, .96);
    box-shadow: 0 10px 24px rgba(122, 22, 12, .16);
}

.strip-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    color: #d31e17;
    font-size: 14px;
    font-weight: 1000;
}

.winner-list {
    height: 56px;
    overflow: hidden;
    color: #6c3028;
    font-size: 12px;
    font-weight: 700;
    line-height: 28px;
}

.lottery-modal,
.result-pop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(26, 13, 28, .62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lottery-modal.visible,
.result-pop.visible {
    display: flex;
}

.modal-card,
.result-card {
    width: min(360px, 100%);
    position: relative;
    border: 4px solid #ffe15f;
    border-radius: 20px;
    background: #fff9df;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
    color: #5a241e;
    text-align: center;
}

.modal-card {
    padding: 28px 22px 24px;
}

.modal-card h2,
.result-card h2 {
    color: #e82b24;
    font-size: 24px;
    font-weight: 1000;
}

.modal-card p {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.65;
    text-align: left;
}

.modal-close,
.result-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    position: absolute;
    top: 10px;
    right: 10px;
    border: 0;
    border-radius: 50%;
    background: #f13a2d;
    color: #fff;
    cursor: pointer;
}

.result-card {
    padding: 30px 22px 24px;
}

.result-icon {
    width: 78px;
    height: 78px;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd830, #ff8f00);
    color: #c11b13;
    font-size: 34px;
    box-shadow: 0 10px 24px rgba(255, 133, 0, .3);
}

.result-card p {
    color: #8a3328;
    font-size: 14px;
    font-weight: 900;
}

.claim-btn {
    width: 100%;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff4637, #ff8b1a);
    color: #fff;
    font-size: 15px;
    font-weight: 1000;
    box-shadow: 0 9px 18px rgba(226, 42, 22, .24);
}

@media (max-width: 390px) {
    .lottery-page {
        padding-right: 12px;
        padding-left: 12px;
    }

    .hero {
        margin-right: -12px;
        margin-left: -12px;
    }

    .hero-sign h1 {
        font-size: 38px;
    }

    .hero-actions {
        gap: 24px;
    }

    .prize-cell,
    .draw-start {
        min-height: 75px;
    }

    .draw-start span,
    .draw-start strong {
        font-size: 23px;
    }

    .prize-cell span {
        font-size: 11px;
    }
}

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