:root {
    --green-deep: #64ab1b;
    --green: #00a651;
    --green-light: #2bbd6b;
    --yellow: #f5e500;
    --tile-bg: #ffffff;
    --tile-text: #000;
    --reel-h: 76px;
    --tile-w: 54px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-sans);
    color: #fff;
    background: var(--green);
}

/* --- Dropdown hadiah --- */
.prize-picker {
    gap: 10px;
    font-size: 14px;
}

.prize-picker label {
    opacity: 0.9;
}

#prize-select {
    appearance: none;
    padding: 8px 34px 8px 14px;
    border-radius: 999px;
    border: 2px solid var(--yellow);
    background: rgba(0, 0, 0, 0.18)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='%23f5e500'%3E%3Cpath d='M0 0h12L6 8z'/%3E%3C/svg%3E")
        no-repeat right 14px center / 11px;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

#prize-select option {
    color: #123f1f;
    background: #fff;
}
#prize-select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.quota {
    font-size: 12px;
}

.quota.empty {
    background: #b3261e;
}

/* --- Hadiah --- */
.prize-image {
    display: block;
    margin: 0 auto;
    height: 150px;
    max-width: 90%;
    object-fit: contain;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.28));
}

.prize-label {
    text-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}

/* --- Reel --- */
.reel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tiles {
    display: flex;
    gap: 8px;
}

.tile {
    position: relative;
    width: var(--tile-w);
    height: var(--reel-h);
    overflow: hidden;
    /* Jendela tile sudah memotong isinya; ini mengunci area repaint per tile. */
    contain: paint;
    background: var(--tile-bg);
    border-radius: 8px;
    border: 2px solid #64ab1b;
    box-sizing: border-box;
    box-shadow: 0px 4px 0 rgba(1, 121, 57, 1);
}

/* Drum digit yang bergulir vertikal di balik jendela tile.
   filter diisi inline oleh app.js hanya saat nilainya berubah — kalau ditaruh
   di sini lewat custom property, tiap frame memicu raster ulang seluruh strip. */
.strip {
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* Bayangan tepi jendela, bukan tepi strip: overlay tetap diam saat drum bergulir. */
.tile::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(
        to bottom,
        var(--tile-bg) 0%,
        rgba(255, 255, 255, 0) 34%,
        rgba(255, 255, 255, 0) 66%,
        var(--tile-bg) 100%
    );
    opacity: 0.9;
}

.cell {
    height: var(--reel-h);
    line-height: var(--reel-h);
    font-size: 42px;
    font-weight: 800;
    color: var(--tile-text);
    text-align: center;
}

.tile.pop {
    animation: pop 0.28s ease;
}

@keyframes pop {
    0% {
        transform: translateY(0) scale(1);
    }
    45% {
        transform: translateY(-5px) scale(1.09);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

/* --- Tombol --- */
.controls {
    display: flex;
    justify-content: center;
    gap: 14px;
}

.btn {
    min-width: 116px;
    padding: 11px 22px;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #fff;
    background: var(--green-deep);
    border: 3px solid var(--yellow);
    border-radius: 10px;
    cursor: pointer;
    transition:
        transform 0.12s ease,
        background 0.12s ease,
        opacity 0.12s ease;
    box-shadow: 0px 4px 0 rgba(1, 121, 57, 1);
}

/* Cukup lebar untuk label "MENGHENTIKAN..." supaya tombol tidak melompat. */
#btn-stop {
    min-width: 186px;
}

.btn:hover:not(:disabled) {
    background: #0a7c3c;
    transform: translateY(-1px);
}
.btn:active:not(:disabled) {
    transform: translateY(1px);
}
.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.btn-ghost {
    min-width: 0;
    padding: 9px 18px;
    border-color: rgba(255, 255, 255, 0.6);
    background: transparent;
}

.tagline {
    display: inline-block;
    margin: 0;
    padding: 8px 16px;
    border-radius: 999px;
}

.tagline.error {
    border-color: #ffd0cc;
    background: #b3261e;
}

/* Nama pemenang tampil di tagline, bukan lagi di kartu terpisah. */
.tagline.winner {
    color: #fff100;
}

/* --- Kartu pemenang --- */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.winner-eyebrow {
    font-size: 12px;
    color: var(--green-deep);
    opacity: 0.75;
}

.winner-card h2 {
    font-size: 32px;
    line-height: 1.5;
}

.winner-card .btn-ghost {
    color: #123f1f;
    border-color: rgba(0, 0, 0, 0.28);
}

.pool-info {
    margin-top: 22px;
    font-size: 13px;
    opacity: 0.82;
}

/* --- Confetti pemenang ---
   Lapisan PNG utuh yang diubin lalu diturunkan berulang. Semuanya transform,
   jadi jalannya di compositor dan tidak mengganggu loop rAF reel. */
.confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 600ms ease;
}

.confetti.show {
    opacity: 1;
}

.confetti-layer {
    position: absolute;
    /* Tinggi dua kali layar: satu layar menunggu di atas viewport. */
    inset: -100% 0 0 0;
    background: url("assets/images/pngwing.com-1.png") repeat top center;
    animation: confetti-fall linear infinite;
    will-change: transform;
}

/* Geser 50% dari tinggi ganda = tepat satu layar, jadi ulangannya menyambung. */
@keyframes confetti-fall {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(0, 50%, 0);
    }
}

.confetti-layer:nth-child(1) {
    background-size: 780px auto;
    animation-duration: 9s;
    opacity: 1;
}

.confetti-layer:nth-child(2) {
    background-size: 546px auto;
    animation-duration: 14s;
    opacity: 0.8;
}

.confetti-layer:nth-child(3) {
    background-size: 1014px auto;
    animation-duration: 20s;
    opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
    .strip {
        filter: none;
    }
    .tile.pop {
        animation: none;
    }
    /* Confetti tetap tampil, tapi diam. */
    .confetti-layer {
        animation: none;
    }
}

@media (max-width: 700px) {
    :root {
        --tile-w: 34px;
        --reel-h: 54px;
    }
    .cell {
        font-size: 28px;
    }
    .prize-image {
        height: 110px;
    }
    .winner-card h2 {
        font-size: 28px;
    }
}
