body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background: #000;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background {
    position: relative;
    width: 100%;
    max-width: 550px;
    height: 100%;
    overflow: hidden;
}

.video-background {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* Countdown overlay */
.countdown-overlay {
    position: fixed;
    top: -50px;
    left: 0;
    width: 100%;
    height: 100%;

    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.countdown-overlay.show {
    visibility: visible;
    opacity: 1;
}

.countdown-image {
    width: 80px;
    height: auto;
    animation: countdownPop 0.5s ease-out;
}

@keyframes countdownPop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.fafa {
    position: absolute;
    top: 3%;
    left: 50%;
    transform: translateX(-50%);
    width: 30%;
    z-index: 1;
    animation: fafaGlow 4s ease-in-out infinite alternate;
}

/* Glowing shadow animation */
@keyframes fafaGlow {
    0% {
        filter: drop-shadow(0 0 5px #a0f3e241) drop-shadow(0 0 10px #00ff9963) drop-shadow(0 0 20px #00ffcc65);
        transform: translateX(-50%) scale(1);
    }

    50% {
        filter: drop-shadow(0 0 10px #f08fe838) drop-shadow(0 0 20px #f385e148) drop-shadow(0 0 30px #f484f848);
        transform: translateX(-50%) scale(1.03);
    }

    70% {
        filter: drop-shadow(0 0 5px #7c96ec52) drop-shadow(0 0 10px #9f7dfc44) drop-shadow(0 0 20px #8c97fd50);
        transform: translateX(-50%) scale(1);
    }
}

.box {
    position: absolute;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    z-index: 1;
}

.reward {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    z-index: 1;
}

.chest-grid {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 300px;
    gap: 10px;
    justify-items: center;
    align-items: center;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chest-grid img {
    width: 80%;
    height: 70%;
    object-fit: cover;
}
.chest-grid .vs{
    width: 40%;
    height: 40%;
    object-fit: cover;
}

/* Wind-blown flag animation for dragon and tiger */
@keyframes windWave {
    0% {
        transform: skewY(0deg) rotateZ(0deg) translateX(0);
    }
    20% {
        transform: skewY(3deg) rotateZ(2deg) translateX(2px);
    }
    40% {
        transform: skewY(-1deg) rotateZ(-1deg) translateX(-1px);
    }
    60% {
        transform: skewY(2deg) rotateZ(1.5deg) translateX(1px);
    }
    80% {
        transform: skewY(-2deg) rotateZ(-1.5deg) translateX(-2px);
    }
    100% {
        transform: skewY(0deg) rotateZ(0deg) translateX(0);
    }
}

@keyframes windWaveReverse {
    0% {
        transform: skewY(0deg) rotateZ(0deg) translateX(0);
    }
    20% {
        transform: skewY(-3deg) rotateZ(-2deg) translateX(-2px);
    }
    40% {
        transform: skewY(1deg) rotateZ(1deg) translateX(1px);
    }
    60% {
        transform: skewY(-2deg) rotateZ(-1.5deg) translateX(-1px);
    }
    80% {
        transform: skewY(2deg) rotateZ(1.5deg) translateX(2px);
    }
    100% {
        transform: skewY(0deg) rotateZ(0deg) translateX(0);
    }
}

.chest-grid .dragon {
    animation: windWave 4s ease-in-out infinite;
    transform-origin: left center;
    transition: transform 0.1s ease-out;
}

.chest-grid .tiger {
    animation: windWaveReverse 4s ease-in-out infinite;
    transform-origin: right center;
    transition: transform 0.1s ease-out;
}

.box-grid{
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 450px;
    gap: 20px;
    justify-items: center;
    align-items: center;
    z-index: 1; /* sits behind cards */
    display: flex;
    justify-content: center;
    align-items: center;
}
.box-grid img {
    width: 45%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    flex: 0 0 auto;
}
.box-grid .boxdragon{
    width: 45%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    transition: filter 0.3s ease-in-out, opacity 0.3s ease-in-out;
}
.box-grid .boxtiger{
    width: 45%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    transition: filter 0.3s ease-in-out, opacity 0.3s ease-in-out;
}


/* Border glow effect for tiger box */
@keyframes boxBorderGlow {
    0% {
        filter: drop-shadow(0 0 8px rgba(255, 200, 0, 0.6)) 
                drop-shadow(0 0 15px rgba(255, 165, 0, 0.7))
                drop-shadow(0 0 25px rgba(255, 140, 0, 0.5));
        box-shadow: 0 0 5px rgba(255, 200, 0, 0.5),
                    inset 0 0 10px rgba(255, 200, 0, 0.3);
    }
    50% {
        filter: drop-shadow(0 0 5px rgba(255, 200, 0, 0.9)) 
                drop-shadow(0 0 25px rgba(255, 140, 0, 0.8));
        box-shadow: 0 0 5px rgba(255, 200, 0, 0.7),
                    inset 0 0 15px rgba(255, 200, 0, 0.5);
    }
   
}

/* Cards overlay the boxes and stay centered on each box */
.cards-grid{
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 45%;
    z-index: 3; /* above boxes */
    pointer-events: none; /* clicks pass through to boxes if needed */
}
.cards-grid img{
    width: 12%;
    max-width: 55px;
    height: auto;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
    position: relative;
    pointer-events: auto; /* Enable clicks on card images */
    cursor: pointer; /* Show pointer cursor on hover */
}
.cards-grid .cards1{
    width: 12%;
    max-width: 55px;
    height: auto;
    object-fit: contain;
    /* Center the card on the dragon box */
    transform: translateX(0);
    pointer-events: auto; /* Enable clicks */
    cursor: pointer;
    transition: transform 0.6s ease-in-out, filter 0.3s ease-in-out;
    transform-style: preserve-3d;
    position: relative;
}
.cards-grid .cards2{
    width: 12%;
    max-width: 55px;
    height: auto;
    object-fit: contain;
    /* Center the card on the tiger box */
    transform: translateX(0);
    pointer-events: auto; /* Enable clicks */
    cursor: pointer;
    transition: transform 0.6s ease-in-out, filter 0.3s ease-in-out;
    transform-style: preserve-3d;
    position: relative;
}

/* Card flip animation */
@keyframes cardFlip {
    0% {
        transform: rotateY(0deg) scale(1);
    }
    50% {
        transform: rotateY(90deg) scale(0.9);
    }
    100% {
        transform: rotateY(0deg) scale(1);
    }
}

.cards-grid .cards1.flipping,
.cards-grid .cards2.flipping {
    animation: cardFlip 0.6s ease-in-out;
    transform-style: preserve-3d;
}


/* Popup overlay - centered */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s ease, visibility 0.4s ease, background 0.4s ease;
    backdrop-filter: blur(0px);
}

.popup.show {
    visibility: visible;
    opacity: 1;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0.2px);
}

/* Popup content container - centered */
.popup-content {
    position: relative;
    background: transparent;
    border: none;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 350px;
    max-height: 90%;
    transform: scale(0) rotate(-10deg);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.popup.show .popup-content {
    animation: popupEntrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Popup image style */
.popup-content .popup-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 0 20px rgba(255, 200, 0, 0.5))
            drop-shadow(0 0 40px rgba(255, 165, 0, 0.4));
    animation: popupPulse 2s ease-in-out infinite;
    animation-delay: 0.8s;
}

/* Enhanced popup entrance animation */
@keyframes popupEntrance {
    0% {
        transform: scale(0) rotate(-15deg) translateY(-50px);
        opacity: 0;
        filter: blur(10px);
    }
    50% {
        transform: scale(1.15) rotate(5deg) translateY(0);
        opacity: 0.9;
        filter: blur(2px);
    }
    70% {
        transform: scale(0.95) rotate(-2deg) translateY(0);
        opacity: 1;
        filter: blur(0px);
    }
    85% {
        transform: scale(1.05) rotate(1deg) translateY(0);
        opacity: 1;
        filter: blur(0px);
    }
    100% {
        transform: scale(1) rotate(0deg) translateY(0);
        opacity: 1;
        filter: blur(0px);
    }
}

/* Continuous pulse animation for popup image */
@keyframes popupPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px rgba(255, 200, 0, 0.5))
                drop-shadow(0 0 40px rgba(255, 165, 0, 0.4));
    }
    50% {
        transform: scale(1.02);
        filter: drop-shadow(0 0 25px rgba(255, 200, 0, 0.7))
                drop-shadow(0 0 50px rgba(255, 165, 0, 0.6));
    }
}

/* Coin rain container - centered */
.coin-rain {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 550px;
    height: 100vh;
    pointer-events: none;
    z-index: 1001;
    overflow: hidden;
}

/* Individual coin styles */
.coin {
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url('./images/coin.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    animation: coinFall linear forwards;
}

/* Coin rain animation */
@keyframes coinFall {
    0% {
        transform: translateY(-100px) translateX(0) rotate(0deg) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    50% {
        transform: translateY(calc(50vh)) translateX(var(--drift, 0px)) rotate(360deg) scale(1);
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 100px)) translateX(calc(var(--drift, 0px) * 2)) rotate(720deg) scale(1);
        opacity: 0;
    }
}

/* Varied coin sizes and speeds */
.coin.small {
    width: 30px;
    height: 30px;
    animation: coinFall 3s linear forwards;
}

.coin.medium {
    width: 40px;
    height: 40px;
    animation: coinFall 4s linear forwards;
}

.coin.large {
    width: 50px;
    height: 50px;
    animation: coinFall 5s linear forwards;
}

/* ---------- Responsive for Mobile Devices ---------- */

/* Max width 550px */
@media (max-width: 550px) {
    .background {
        height: 100vh;
        min-height: 100%;
        max-width: 550px;
    }

    .video-background {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Fire circles - positioned at bottom */
    .box-grid {
        bottom: 3%;
        max-width: 550px;
        width: 100%;
        gap: 20px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 42%;
        max-width: 200px;
        height: auto;
        object-fit: contain;
    }

    /* Cards - centered on fire circles */
    .cards-grid {
        bottom: 12%;
        max-width: 400px;
        width: 100%;
        gap: 48%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 10%;
        max-width: 55px;
        height: auto;
        object-fit: contain;
    }

    /* Popup adjustments */
    .popup-content {
        max-width: 90%;
        padding: 10px;
    }

    .popup-content .popup-image {
        max-width: 100%;
        max-height: 50vh;
    }
}

/* iPhone 14 Pro Max / 430px wide */
@media (max-width: 440px) {
    .box-grid {
        bottom: 4%;
        gap: 12px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 45%;
        max-width: 200px;
    }

    .cards-grid {
        bottom: 12%;
        gap: 40%;
        max-width: 500px;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 11%;
        max-width: 45px;
    }

    .popup-content .popup-image {
        max-height: 45vh;
    }
}

/* iPhone 14 Pro / 428px */
@media (max-width: 428px) {
    .box-grid {
        bottom: 4%;
        gap: 10px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 40%;
        max-width: 200px;
    }

    .cards-grid {
        bottom: 12%;
        gap: 32%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 10%;
        max-width: 42px;
    }
}

/* iPhone 13 / 414px */
@media (max-width: 414px) {
    .box-grid {
        bottom: 3%;
        gap: 8px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 40%;
        max-width:205px;
    }

    .cards-grid {
        bottom: 10%;
        gap: 30%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 10%;
        max-width: 40px;
    }

    .popup-content .popup-image {
        max-height: 40vh;
    }
}

/* iPhone 12 Mini / 390px */
@media (max-width: 390px) {
    .box-grid {
        bottom: 3%;
        gap: 6px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 38%;
        max-width: 190px;
    }

    .cards-grid {
        bottom: 10%;
        gap: 28%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 9%;
        max-width: 38px;
    }
}

/* Galaxy S21 / 360px */
@media (max-width: 360px) {
    .box-grid {
        bottom: 2%;
        gap: 5px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 36%;
        max-width: 180px;
    }

    .cards-grid {
        bottom: 9%;
        gap: 28%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 9%;
        max-width: 35px;
    }

    .popup-content .popup-image {
        max-height: 38vh;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .box-grid {
        bottom: 2%;
        gap: 4px;
    }

    .box-grid img,
    .box-grid .boxdragon,
    .box-grid .boxtiger {
        width: 35%;
        max-width: 100px;
    }

    .cards-grid {
        bottom: 4%;
        gap: 22%;
    }

    .cards-grid img,
    .cards-grid .cards1,
    .cards-grid .cards2 {
        width: 8%;
        max-width: 32px;
    }

    .popup-content .popup-image {
        max-height: 35vh;
    }
}