:root {
    --bg-dark: #0a0a1a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent-1: #ff007f;
    --accent-2: #00f0ff;
    --accent-3: #7b2cbf;
    --text-main: #f8f9fa;
    --text-dim: #a0a0b5;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background animated blobs for wow factor */
.background-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.stars-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(1.5px 1.5px at 10vw 10vh, rgba(255,255,255,0.8) 100%, transparent),
        radial-gradient(2px 2px at 25vw 35vh, rgba(255,255,255,0.9) 100%, transparent),
        radial-gradient(1px 1px at 40vw 70vh, rgba(255,255,255,0.6) 100%, transparent),
        radial-gradient(2.5px 2.5px at 60vw 20vh, #fff 100%, transparent),
        radial-gradient(1.5px 1.5px at 75vw 80vh, rgba(255,255,255,0.8) 100%, transparent),
        radial-gradient(2px 2px at 90vw 40vh, rgba(255,255,255,0.9) 100%, transparent),
        radial-gradient(1px 1px at 30vw 90vh, #fff 100%, transparent),
        radial-gradient(2.5px 2.5px at 80vw 10vh, rgba(0, 240, 255, 0.8) 100%, transparent),
        radial-gradient(1.5px 1.5px at 15vw 60vh, rgba(255, 0, 127, 0.8) 100%, transparent);
    background-size: 100vw 100vh;
    animation: starTwinkle 5s infinite alternate;
}

@keyframes starTwinkle {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.floating-emojis-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.floating-emoji {
    position: absolute;
    opacity: 0;
    animation: floatUp 15s linear infinite;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

@keyframes floatUp {
    0% {
        transform: translateY(110vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-20vh) rotate(360deg);
        opacity: 0;
    }
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--accent-1) 0%, transparent 70%);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
    animation-delay: -5s;
}

.blob-3 {
    top: 30%;
    left: 30%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 15%) scale(1.1); }
}

.game-container {
    background: rgba(20, 20, 40, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 650px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.game-container.hidden {
    display: none;
}

header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-2), var(--accent-1));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(255, 0, 127, 0.3);
}

.stats {
    display: flex;
    gap: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid var(--card-border);
}

.stats div {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stats span:first-child {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats span:last-child {
    font-size: 1.5rem;
    font-weight: 700;
}

.glow-btn {
    background: linear-gradient(45deg, var(--accent-1), var(--accent-3));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
}

.glow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.7);
}

.glow-btn:active {
    transform: translateY(1px);
}

.btn-easy {
    background: linear-gradient(45deg, #00f0ff, #0077ff);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}
.btn-easy:hover {
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.7);
}

.btn-medium {
    background: linear-gradient(45deg, #7b2cbf, #ff007f);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.4);
}
.btn-medium:hover {
    box-shadow: 0 0 25px rgba(123, 44, 191, 0.7);
}

.btn-hard {
    background: linear-gradient(45deg, #ff007f, #ff4c00);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
}
.btn-hard:hover {
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.7);
}

/* Grid layout */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px;
    perspective: 1000px;
}

/* Card Styling */
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border-radius: 16px;
}

.card:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    transform: rotateY(180deg) scale(0.95);
    box-shadow: 0 0 20px var(--accent-2);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
}

.card-front {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    transform: rotateY(180deg);
}

.card-back {
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border: 1px solid var(--card-border);
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 0h2v2H2V0zm4 0h2v2H6V0zm4 0h2v2h-2V0zm4 0h2v2h-2V0zm4 0h2v2h-2V0zM0 4h2v2H0V4zm4 4h2v2H4V8zm8 0h2v2h-2V8zm4 0h2v2h-2V8zM2 12h2v2H2v-2zm4 0h2v2H6v-2zm12 0h2v2h-2v-2zm-4 4h2v2h-2v-2zm-8 0h2v2H6v-2zm4 0h2v2h-2v-2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    transition: background-color 0.3s ease;
}

.card:hover .card-back {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 15, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(15, 15, 25, 0.65);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 240, 255, 0.15);
    padding: 60px 50px;
    border-radius: 30px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
    width: 450px;
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

.modal h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(to right, var(--accent-2), #ffffff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Unique Landing Modal Styling */
#landing-modal .modal-content {
    background: rgba(20, 20, 30, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    padding: 70px 50px;
    border-radius: 24px;
}

#landing-modal h2 {
    font-size: 4rem !important;
    background: linear-gradient(135deg, #ffffff, #dcdcf2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    margin-bottom: 20px !important;
    font-weight: 700;
}

#landing-modal p {
    font-size: 1.2rem;
    color: #a0a0b5;
    letter-spacing: 0.5px;
    margin-bottom: 40px;
    font-weight: 300;
}

#main-play-btn {
    font-size: 1.3rem !important;
    padding: 15px 40px !important;
    border-radius: 50px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: none;
    color: #ffffff;
    transition: all 0.3s ease;
}

#main-play-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4), inset 0 0 10px rgba(0, 240, 255, 0.2);
    border-color: rgba(0, 240, 255, 0.5);
}

.stars-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    height: 60px;
}

.star {
    font-size: 4rem;
    color: rgba(255, 255, 255, 0.1);
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star.earned {
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.4);
}

.star.show {
    transform: scale(1);
    opacity: 1;
}

.modal p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: var(--text-dim);
}

.difficulty-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .game-container {
        padding: 20px;
    }
    header {
        flex-direction: column;
    }
    h1 {
        font-size: 2rem;
    }
    .card-face {
        font-size: 2rem;
    }
    #landing-modal h2 {
        font-size: 3.5rem !important;
    }
    #landing-modal .modal-content {
        padding: 50px 30px;
    }
}
