* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Comic Sans MS', 'Bubblegum Sans', 'Arial', sans-serif;
}

body {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 900px;
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 8px solid #FFD700;
}

h1 {
    color: #FF6B6B;
    margin-bottom: 20px;
    font-size: 2.8rem;
    text-shadow: 2px 2px 0 #FFD700;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

h2 {
    color: #FF6B6B;
    margin-bottom: 15px;
    font-size: 2.2rem;
    text-shadow: 1px 1px 0 #FFD700;
}

p {
    margin-bottom: 20px;
    font-size: 1.2rem;
    line-height: 1.5;
}

button {
    background: linear-gradient(to right, #FF6B6B, #FF8E53);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 25px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform-origin: center;
}

button:hover {
    background: linear-gradient(to right, #FF8E53, #FF6B6B);
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    background: linear-gradient(to right, #95a5a6, #bdc3c7);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#score-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 1.1rem;
    background-color: #4ECDC4;
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: white;
    font-weight: bold;
    animation: slide-in 0.5s ease;
}

@keyframes slide-in {
    0% { transform: translateX(-100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

.score-item {
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9rem;
}

.score-item span {
    font-size: 1.2rem;
    color: #FFED00;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
}

#start-screen, #game-over, #level-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

#start-screen {
    animation: fade-in 1s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.emoji-showcase {
    font-size: 3rem;
    margin: 20px 0;
    animation: emoji-dance 2s infinite;
}

@keyframes emoji-dance {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(5deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
}

.emoji-celebration {
    font-size: 2.5rem;
    margin: 20px 0;
    animation: celebration-bounce 1s infinite;
}

@keyframes celebration-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-15px) scale(1.1); }
}

#game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#instruction-text {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #2c3e50;
    font-weight: bold;
    padding: 10px 15px;
    background-color: #F7FFF7;
    border-radius: 10px;
    border-left: 5px solid #4ECDC4;
}

#game-board {
    display: grid;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
    perspective: 1000px;
}

/* Grid layouts for different levels */
.grid-3x4 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    max-width: 400px;
}

.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    max-width: 500px;
}

.grid-4x5 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
    max-width: 500px;
}

.grid-5x4 {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    max-width: 600px;
}

.memory-card {
    width: 80px;
    height: 80px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.memory-card.matched {
    animation: match-celebration 0.8s ease;
    pointer-events: none;
}

@keyframes match-celebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.2) rotateY(180deg); }
    100% { transform: scale(1) rotateY(180deg); }
}

.memory-card.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    border: 3px solid #4ECDC4;
    transition: all 0.3s ease;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

.card-front::before {
    content: '🎮';
    font-size: 2rem;
}

.card-back {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    transform: rotateY(180deg);
    border-color: #FF8E53;
}

.memory-card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

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

#level-info {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #4ECDC4;
}

.level-stats {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
}

.level-stats-summary {
    background-color: #e8f5e8;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border-left: 4px solid #2ecc71;
}

.level-stats-summary p {
    margin: 5px 0;
    font-size: 1.1rem;
}

.final-stats {
    background-color: #fff3cd;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    border: 2px solid #ffc107;
}

.final-stats p {
    margin: 8px 0;
    font-size: 1.2rem;
    font-weight: bold;
}

.achievement {
    margin: 20px 0;
}

.badge {
    display: inline-block;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #333;
    padding: 15px 25px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    animation: badge-glow 2s infinite;
}

@keyframes badge-glow {
    0%, 100% { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.5); }
}

.progress-container {
    margin-top: 20px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress {
    height: 100%;
    background: linear-gradient(to right, #4ECDC4, #44A08D);
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-weight: bold;
    color: #2c3e50;
}

.hidden {
    display: none !important;
}

.how-to-play {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: left;
    border: 2px dashed #4ECDC4;
    position: relative;
}

.how-to-play h3 {
    color: #FF6B6B;
    margin-bottom: 15px;
    text-align: center;
}

.how-to-play ul {
    list-style: none;
    padding: 0;
}

.how-to-play li {
    margin: 10px 0;
    padding: 8px 0;
    font-size: 1.1rem;
    border-bottom: 1px solid #e0e0e0;
}

.how-to-play li:last-child {
    border-bottom: none;
}

/* Confetti animation (matching helper-match style) */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f00;
    top: -10px;
    animation: confetti-fall 5s linear forwards;
}

@keyframes confetti-fall {
    0% { 
        transform: translateY(0) rotate(0deg); 
        opacity: 1;
    }
    100% { 
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    #score-container {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    .score-item {
        font-size: 0.8rem;
    }
    
    .memory-card {
        width: 60px;
        height: 60px;
    }
    
    .card-face {
        font-size: 2rem;
    }
    
    .grid-3x4, .grid-4x4, .grid-4x5, .grid-5x4 {
        max-width: 300px;
        gap: 10px;
    }
    
    .emoji-showcase {
        font-size: 2rem;
    }
    
    .emoji-celebration {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .memory-card {
        width: 50px;
        height: 50px;
    }
    
    .card-face {
        font-size: 1.5rem;
    }
    
    .grid-3x4, .grid-4x4, .grid-4x5, .grid-5x4 {
        max-width: 250px;
        gap: 8px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .how-to-play {
        padding: 15px;
    }
}