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;
}

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

.fafa {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 45%;
    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: 57%;
    left: 52%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 10px;
    justify-items: center;
    align-items: center;
    z-index: 2;
}

.chest-grid img {
    width: 170px;
    height: auto;
    cursor: pointer;
    transition: transform 0.8s ease-in-out;
    animation: chestFloat 6s ease-in-out infinite, glow 5s ease-in-out infinite alternate;
    transition: transform 0.8s ease-in-out
}

.chest-grid img:hover {
    animation-play-state: paused;
    transform: scale(1.05);
}


/* Glowing shadow color animation (slower and smoother) */
@keyframes glow {
    0% {
        filter: drop-shadow(0 0 5px hsl(150, 81%, 79%)) drop-shadow(0 0 15px #c4f1db);
    }

    50% {
        filter: drop-shadow(0 0 5px #eef082) drop-shadow(0 0 5px #00ffcc);
    }

    100% {
        filter: drop-shadow(0 0 5px #00ff80) drop-shadow(0 0 5px #00ff80);
    }
}

.footer-img {
    position: absolute;
    bottom: 10%;
    left: 50%;
    width: 40%;
    transform: translateX(-50%);
    color: white;
    font-size: 20px;
    text-align: center;
    z-index: 3;
}

/* Popup overlay */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

/* Popup content container */
.popup-content {
    position: relative;
    background: transparent;
    border: none;
    text-align: center;

}

/* Zoom animation */
@keyframes popupZoom {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Popup image style */
.popup-content img {
    max-width: 200px;
    margin: 10px auto;
    display: block;
    animation: zoomInOut 3s ease-in-out infinite;
}

#you-lose {
    position: absolute;
    max-width: 200px;
    top: -5%;
    left: 24%;
    z-index: 100;
}

#sorry {
    position: absolute;
    max-width: 200px;
    top: 15%;
    left: 26%;
    z-index: 100;
}

#happy {
    position: absolute;
    max-width: 200px;
    top: 20%;
    left: 26%;
    z-index: 100;
}

#emoji {
    position: absolute;
    max-width: 110px;
    top: 22%;
    left: 35%;
    z-index: 100;
}

#dullar {
    position: absolute;
    max-width: 110px;
    top: 30%;
    left: 35%;
    z-index: 100;
}


#the-prize {
    position: absolute;
    max-width: 110px;
    top: 90%;
    left: 35%;
    z-index: 100;
}

.popup-btn-link {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    max-width: 400px;
}

#open-chest {
    top: 30%;
    max-width: 400px;
}
/* Auto Zoom In/Out Animation */
@keyframes zoomInOut {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

/* Close button */
.popup button {
    margin-top: 15px;
    padding: 10px 25px;
    border: none;
    background: gold;
    color: #000;
    font-weight: bold;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.3s;
}

.popup button:hover {
    background: #ffea80;
}


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

/* iPhone 14 Pro Max / 430px wide */
@media (max-width: 430px) {
    .fafa {
        width: 55%;
        top: 10%;
    }

    .box {
        top: 15%;
        width: 70%;
    }

    .reward {
        top: 25%;
        width: 90%;
    }

    .chest-grid {
        top: 58%;
        max-width: 350px;
        gap: 8px;
    }

    .chest-grid img {
        width: 150px;
    }

    .footer-img {
        width: 50%;
        bottom: 10%;
    }

    #you-lose {
        position: absolute;
        max-width: 180px;
        bottom: 30%;
        left: 20%;
        z-index: 100;
    }

    #sorry {
        position: absolute;
        max-width: 150px;
        top: 15%;
        left: 26%;
        z-index: 100;
    }

    #happy {
        position: absolute;
        max-width: 150px;
        top: 20%;
        left: 26%;
        z-index: 100;
    }

    #emoji {
        position: absolute;
        max-width: 90px;
        top: 22%;
        left: 35%;
        z-index: 100;
    }

    #dullar {
        position: absolute;
        max-width: 110px;
        top: 30%;
        left: 35%;
        z-index: 100;
    }


    #the-prize {
        position: absolute;
        max-width: 110px;
        top: 93%;
        left: 35%;
        z-index: 100;
    }

    .popup-btn-link {
        position: absolute;
        top: 105%;
        left: 50%;
        transform: translateX(-50%);
        max-width: 400px;
    }

    #open-chest {
        max-width: 320px;
    }
}

/* iPhone 14 Pro / 428px */
@media (max-width: 428px) {
    .fafa {
        width: 50%;
        top: 9%;
    }
    .box{
        width: 55%;
        top: 15%;
    }
    .reward {
        width: 85%;
        top: 24%;
    }
    .chest-grid {
        top: 57%;
        max-width: 340px;
        gap: 8px;
    }

    .chest-grid img {
        width: 145px;
    }

    .footer-img {
        width: 50%;
        bottom: 7%;
    }
}

/* iPhone 13 / 414px */
@media (max-width: 414px) {
    .fafa {
        width: 50%;
        top: 7%;
    }

    .box {
        width: 65%;
        top: 13%;
    }

    .reward {
        width: 90%;
        top: 23%;
    }

    .chest-grid {
        top: 56%;
        max-width: 330px;
        gap: 8px;
    }

    .chest-grid img {
        width: 140px;
    }

    .footer-img {
        width: 55%;
        bottom: 8%;
    }

    #you-lose {
        position: absolute;
        max-width: 170px;
        top: -5%;
        left: 24%;
        z-index: 100;
    }

    #sorry {
        position: absolute;
        max-width: 150px;
        top: 15%;
        left: 26%;
        z-index: 100;
    }

    #happy {
        position: absolute;
        max-width: 150px;
        top: 20%;
        left: 26%;
        z-index: 100;
    }

    #emoji {
        position: absolute;
        max-width: 90px;
        top: 22%;
        left: 35%;
        z-index: 100;
    }

    #dullar {
        position: absolute;
        max-width: 110px;
        top: 30%;
        left: 35%;
        z-index: 100;
    }


    #the-prize {
        position: absolute;
        max-width: 110px;
        top: 93%;
        left: 35%;
        z-index: 100;
    }

    .popup-btn-link {
        position: absolute;
        top: 105%;
        left: 50%;
        transform: translateX(-50%);
        max-width: 400px;
    }
}

/* iPhone 12 Mini / 390px */
@media (max-width: 390px) {
    .fafa {
        width: 50%;
        top: 7%;
    }

    .box {
        width: 60%;
        top: 14%;
    }

    .reward {
        width: 80%;
        top: 23%;
    }

    .chest-grid {
        top: 56%;
        max-width: 300px;
        gap: 8px;
    }

    .chest-grid img {
        width: 130px;
    }

    .footer-img {
        width: 55%;
        bottom: 8%;
    }

    #you-lose {
        position: absolute;
        max-width: 170px;
        top: -5%;
        left: 20%;
        z-index: 100;
    }

    #sorry {
        position: absolute;
        max-width: 140px;
        top: 15%;
        left: 26%;
        z-index: 100;
    }

    #happy {
        position: absolute;
        max-width: 150px;
        top: 20%;
        left: 26%;
        z-index: 100;
    }

    #emoji {
        position: absolute;
        max-width: 80px;
        top: 22%;
        left: 35%;
        z-index: 100;
    }

    #dullar {
        position: absolute;
        max-width: 110px;
        top: 30%;
        left: 35%;
        z-index: 100;
    }


    #the-prize {
        position: absolute;
        max-width: 110px;
        top: 90%;
        left: 34%;
        z-index: 100;
    }

    .popup-btn-link {
        position: absolute;
        top: 105%;
        left: 53%;
        transform: translateX(-50%);
        max-width: 400px;
    }
    #open-chest {
        max-width: 300px;
    }
}

/* Galaxy S21 / 360px */
@media (max-width: 360px) {
    .fafa {
        width: 55%;
        top: 5%;
    }

    .box {
        width: 75%;
        top: 12%;
    }

    .reward {
        width: 80%;
        top: 24%;
    }

    .chest-grid {
        top: 56%;
        max-width: 270px;
        gap: 6px;
    }

    .chest-grid img {
        width: 120px;
    }

    .footer-img {
        width: 60%;
        bottom: 7%;
    }
    #you-lose {
        position: absolute;
        max-width: 150px;
        top: -5%;
        left: 25%;
        z-index: 100;
    }

    #sorry {
        position: absolute;
        max-width: 150px;
        top: 15%;
        left: 26%;
        z-index: 100;
    }

    #happy {
        position: absolute;
        max-width: 140px;
        top: 20%;
        left: 26%;
        z-index: 100;
    }

    #emoji {
        position: absolute;
        max-width: 90px;
        top: 22%;
        left: 35%;
        z-index: 100;
    }

    #dullar {
        position: absolute;
        max-width: 100px;
        top: 30%;
        left: 35%;
        z-index: 100;
    }


    #the-prize {
        position: absolute;
        max-width: 110px;
        top: 93%;
        left: 30%;
        z-index: 100;
    }

    .popup-btn-link {
        position: absolute;
        top: 105%;
        left: 50%;
        transform: translateX(-50%);
        max-width: 300px;
    }
    #open-chest {
        max-width: 300px;
    }
}