:root {
    --dark-bg: #1A1B41;
    --medium-bg: #2E294E;
    --light-accent: #4B3F72;
    --highlight: #6247AA;
    --electric-orange: #FF7F11;
    --card-back: #1D3461;
    --card-front: #292D3E;
    --text-color: #F1F1F1;
    --accent-text: #BDD5EA;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--dark-bg);
    color: var(--text-color);
    padding: 20px;
}

h1 {
    margin-bottom: 20px;
    color: var(--text-color);
    font-size: 2.5rem;
}

.container {
    width: 90%;
    max-width: 800px;
    text-align: center;
    margin: 2rem auto;
}

/* Language Selection Screen */
#languageScreen {
    background: var(--medium-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    max-width: 600px;
    margin: 0 auto;
}

.selection-title {
    margin-bottom: 2rem;
    color: var(--text-color);
    font-size: 2.2rem;
}

.language-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.language-btn {
    padding: 1.5rem 3rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--highlight);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    font-weight: 700;
}

.language-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(98, 71, 170, 0.3);
    background: var(--electric-orange);
}

/* Game Screen */
#gameScreen {
    width: 100%;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--medium-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.timer, .misses {
    font-size: 1.2rem;
    color: var(--accent-text);
    font-weight: 600;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    perspective: 1000px;
    margin: 0 auto;
    max-width: 700px;
}

.memory-card {
    width: 100%;
    aspect-ratio: 3/4;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
    margin-bottom: 0;
}

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

.memory-card.matched {
    transform: rotateY(180deg);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s 0.5s;
    pointer-events: none;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
}

.card-front {
    background: var(--card-front);
    transform: rotateY(180deg);
}

.card-back {
    background: var(--card-back);
    background-image: linear-gradient(135deg, var(--card-back) 0%, var(--highlight) 100%);
    color: var(--text-color);
}

.card-emoji {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.card-word {
    font-size: 1.2rem;
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 600;
}

/* Results Screen */
#resultsScreen {
    background: var(--medium-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    margin: 0 auto;
}

.results-title {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-size: 2rem;
}

.results-stats {
    margin-bottom: 2rem;
    font-size: 1.2rem;
    color: var(--accent-text);
}

.results-stats p {
    margin: 0.5rem 0;
}

.restart-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--electric-orange);
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-size: 1.2rem;
    font-weight: 700;
}

.restart-btn:hover {
    transform: translateY(-2px);
    background: #FF9A3F;
    box-shadow: 0 4px 12px rgba(255, 127, 17, 0.3);
}

/* Firework effects */
.fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Animation for fireworks */
@keyframes explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

@keyframes particle {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y)) scale(0);
        opacity: 0;
    }
}

.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FFD6E8;
    animation: explode 0.5s ease-out forwards;
}

.particle {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #FFD6E8;
    animation: particle 0.5s ease-out forwards;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 100%;
        gap: 8px;
    }
    
    .language-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .card-emoji {
        font-size: 2.5rem;
    }
    
    .card-word {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
    }
    
    .card-emoji {
        font-size: 1.8rem;
    }
    
    .card-word {
        font-size: 0.7rem;
    }
    
    .memory-card {
        aspect-ratio: 2/3;
        margin-bottom: 5px;
    }
}