body {
    font-family: 'Fredoka One', cursive;
    margin: 0;
    padding: 0;
    background: linear-gradient(160deg, #a0eaff, #ffe0f0);
    overflow-x: hidden;
    position: relative;
}

/* Clouds */
.cloud {
    position: absolute;
    top: 50px;
    width: 120px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.8;
    animation: floatClouds 60s linear infinite;
    z-index: -1;
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: #fff;
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.cloud::before {
    top: -20px;
    left: 10px;
}

.cloud::after {
    top: -10px;
    left: 40px;
}

@keyframes floatClouds {
    0% {
        transform: translateX(-150px);
    }

    100% {
        transform: translateX(120vw);
    }
}

h1 {
    text-align: center;
    color: #ff6f91;
    font-size: 2.2rem;
    margin-top: 20px;
    text-shadow: 2px 2px #fff;
}

#levelScreen {
    text-align: center;
    margin-top: 10px;
}

#levelScreen button {
    padding: 7px 12px;
    font-size: 0.95rem;
    margin: 4px;
    border-radius: 10px;
}

button {
    background: #ffcb05;
    color: #fff;
    border: none;
    border-radius: 15px;
    padding: 12px 20px;
    margin: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

button:hover {
    background: #ffb500;
    transform: scale(1.05);
}

#gameBoard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 22px;
    max-width: 820px;
    margin: 10px auto;
    padding: 28px;
    background: url('../images/board_bg.png') repeat;
    border: 8px solid #baea0d;
    border-radius: 32px;
    box-shadow: 0 12px 32px rgba(255, 111, 145, 0.18), 0 2px 24px rgba(0, 0, 0, 0.12);
    animation: moveBoardBg 120s linear infinite;
}

@keyframes moveBoardBg {
    0% {
        background-position-x: 0;
    }

    100% {
        background-position-x: 600px;
    }
}



.card {
    perspective: 1200px;
    /* Stronger 3D perspective */
    position: relative;
}

.card-inner {
    position: relative;
    width: 100%;
    padding-top: 65%;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(.4, 2, .3, .9);
    /* Smoother, springy effect */
    cursor: pointer;
}

.card.flip .card-inner {
    transform: rotateY(180deg) scale(1.05);
    /* Slight scale for pop effect */
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 15px;
    display: flex;
    flex-direction: row;
    font-size: 1rem;
    padding: 8px;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.13);
}

.card-front {
    background: linear-gradient(120deg, #fffbe8 80%, #f8e495 100%), url('images/card_bg.png') center/cover no-repeat;
    border: 4px solid #0aa10f;
    transform: rotateY(180deg);
    padding: 10px;
    font-size: 0.9rem;
}

.card-front img {
    width: 55px;
    height: 72px;
    margin-right: 2px;
}

.card-front span {
    color: #c92323;
    margin-top: 0;
    margin-left: 8px;
}

.card-back {
    --card-back-overlay: 0.2;
    background:
        linear-gradient(rgba(0,0,0,var(--card-back-overlay)), rgba(0,0,0,var(--card-back-overlay))),
        url('../images/card_bg_2.png') center/cover no-repeat;
    color: white;
    font-size: 2.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

.matched .card-inner {
    opacity: 1;
}

/* Sparkles */
.sparkle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: url('../images/spark.png') no-repeat center/contain;
    pointer-events: none;
    animation: sparkleAnim 0.8s forwards;
}

@keyframes sparkleAnim {
    0% {
        opacity: 1;
        transform: scale(0);
    }

    50% {
        transform: scale(1.2) rotate(45deg);
    }

    100% {
        opacity: 0;
        transform: scale(0.5) rotate(90deg);
    }
}

#scoreDisplay {
    text-align: center;
    font-weight: bold;
    color: #ff6f91;
    margin-top: 10px;
    font-size: 1.2rem;
}

#popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: #fff;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    animation: popupAnim 0.5s ease;
}

.popup-content img {
    width: 90px;
    height: 90px;
    margin: 5px;
}

.popup-content h3 {
    color: #ff6f91;
    margin: 8px 0;
}

@keyframes popupAnim {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#mascot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 240px;
    height: 240px;
    background: url('../images/PandaMascot.png') no-repeat center/contain;
    z-index: 100;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

#musicBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff6f91;
}

/* Confetti styles */
#confetti {
    pointer-events: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    opacity: 0.85;
    will-change: transform;
    animation: confetti-fall 1.2s linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(80vh) rotate(360deg) scale(0.7);
        opacity: 0;
    }
}

.butterfly {
    position: absolute;
    width: 48px;
    height: 48px;
    background: url('../images/butterfly.png') no-repeat center/contain;
    animation: flyButterfly 12s linear infinite;
    z-index: 10;
}

@keyframes flyButterfly {
    0% {
        transform: translateY(0) scaleX(1);
    }

    20% {
        transform: translateY(-30px) scaleX(-1);
    }

    40% {
        transform: translateY(10px) scaleX(1);
    }

    60% {
        transform: translateY(-20px) scaleX(-1);
    }

    80% {
        transform: translateY(0) scaleX(1);
    }

    100% {
        transform: translateY(0) scaleX(1);
    }
}

/* Add to your <style> section */
#extractedCards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 12px auto 0 auto;
    max-width: 780px;
    min-height: 48px;
}

.extracted-pair {
    display: flex;
    align-items: center;
    background: #fffbe8;
    border: 2px solid #ffcb05;
    border-radius: 12px;
    padding: 6px 12px;
    box-shadow: 0 2px 8px rgba(255, 203, 5, 0.15);
    gap: 8px;
}

.extracted-pair img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.extracted-pair span {
    font-weight: bold;
    color: #ff6f91;
    font-size: 1rem;
}

#timerDisplay {
    text-align: center;
    font-weight: bold;
    color: #ff6f91;
    margin-top: 10px;
    font-size: 1.2rem;
}

/* Mobile Responsive Styles */
@media (max-width: 600px) {
    h1 {
        font-size: 1.3rem;
        margin-top: 10px;
    }

    #levelScreen {
        margin-top: 4px;
        font-size: 0.95rem;
    }

    #levelScreen button {
        padding: 7px 10px;
        font-size: 0.9rem;
        margin: 3px;
        border-radius: 8px;
    }

    #gameBoard {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-width: 98vw;
        padding: 8px;
        border-width: 4px;
        border-radius: 18px;
    }

    .card-front,
    .card-back {
        border-radius: 10px;
        font-size: 0.8rem;
        padding: 5px;
    }

    .card-front img,
    .extracted-pair img {
        width: 32px;
        height: 32px;
    }

    .extracted-pair {
        padding: 4px 6px;
        border-radius: 8px;
        gap: 4px;
        font-size: 0.9rem;
    }

    #scoreDisplay,
    #timerDisplay {
        font-size: 1rem;
        margin-top: 6px;
    }

    #mascot {
        width: 70px;
        height: 70px;
        bottom: 8px;
        right: 8px;
    }

    #musicBtn {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 1rem;
    }

    .popup-content img {
        width: 60px;
        height: 60px;
    }

    .cloud {
        width: 60px;
        height: 30px;
    }

    .butterfly {
        width: 28px;
        height: 28px;
    }
}