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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    min-height: 100vh;
    color: white;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 255, 255, 0.3); }
    to { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 255, 255, 0.5); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.game-setup {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.setup-controls {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-weight: bold;
    font-size: 1.1rem;
    color: #ffd700;
}

select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    min-width: 150px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.start-button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 25px;
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Setup Stats Section */
.setup-stats {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.setup-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.setup-stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.setup-stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.setup-stat-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.3rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.game-setup::before,
.game-info::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
    pointer-events: none;
}

.game-info {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.game-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.navigation {
    margin-bottom: 1rem;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-button {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
    font-weight: 500;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: white;
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

.stat-label {
    font-size: 0.8rem;
    color: #e0e0e0;
    margin-top: 0.25rem;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.timer.warning {
    color: #ff3333;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.memorization-phase {
    display: none;
    text-align: center;
    margin-bottom: 2rem;
}

.memorization-text {
    font-size: 1.3rem;
    color: #ffd700;
    margin-bottom: 1rem;
    font-weight: bold;
}

.memorization-timer {
    font-size: 3rem;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.8);
    animation: countdown 1s ease-in-out infinite;
}

@keyframes countdown {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.game-board {
    display: none;
    grid-gap: 15px;
    justify-content: center;
    margin-bottom: 2rem;
    perspective: 1000px;
}

.game-board.grid-8 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
    margin: 0 auto;
}

.game-board.grid-10 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    max-width: 700px;
    margin: 0 auto;
}

.game-board.grid-12 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    max-width: 800px;
    margin: 0 auto;
}

.card {
    width: 120px;
    height: 120px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.card-back {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.card-front {
    background: rgba(255, 255, 255, 0.95);
    transform: rotateY(180deg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}


.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 13px;
    display: block;
    margin: 0;
    padding: 0;
}

.game-over {
    display: none;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-over.success {
    border-color: rgba(76, 175, 80, 0.5);
    background: rgba(76, 175, 80, 0.2);
}

.game-over.failure {
    border-color: rgba(244, 67, 54, 0.5);
    background: rgba(244, 67, 54, 0.2);
}

.game-over h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* Final Stats in Game Over Screen */
.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.final-stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.final-stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.final-stat-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.3rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.play-again-button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 25px;
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1rem;
}

.play-again-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    .title {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }

    .game-setup {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card {
        width: 80px;
        height: 80px;
    }
    
    .setup-controls {
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .control-group label {
        font-size: 1rem;
    }

    select {
        min-width: 120px;
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .start-button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }

    .setup-stats {
        padding: 1rem;
    }

    .setup-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.8rem;
    }

    .setup-stat-value {
        font-size: 1.2rem;
    }

    .setup-stat-label {
        font-size: 0.75rem;
    }
    
    .game-info {
        padding: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .game-stats {
        gap: 0.5rem;
        justify-content: space-around;
    }
    
    .stat-item {
        padding: 0.4rem 0.6rem;
        min-width: 70px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .timer {
        font-size: 1.5rem;
    }
    
    .memorization-text {
        font-size: 1.1rem;
    }
    
    .memorization-timer {
        font-size: 2rem;
    }
    
    .card {
        width: 60px;
        height: 60px;
    }
    
    .card-face {
        font-size: 1.2rem;
    }
    
    .game-board.grid-8 {
        max-width: 280px;
        grid-gap: 8px;
    }
    
    .game-board.grid-10 {
        max-width: 320px;
        grid-gap: 6px;
    }
    
    .game-board.grid-12 {
        max-width: 360px;
        grid-gap: 5px;
    }
    
    .game-over {
        padding: 1rem;
    }
    
    .game-over h2 {
        font-size: 1.5rem;
    }

    .final-stats {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 0.8rem;
        margin: 1rem 0;
        padding: 0.8rem;
    }

    .final-stat-value {
        font-size: 1.2rem;
    }

    .final-stat-label {
        font-size: 0.75rem;
    }

    
    .play-again-button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .nav-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}