* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fafafa;
    height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100vw;
}

.header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.controls select,
.controls button {
    padding: 8px 16px;
    font-size: 13px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    background: white;
    color: #1a1a1a;
    transition: all 0.2s;
    font-weight: 500;
}

.controls button {
    background: #1a1a1a;
    color: white;
    border: none;
}

.controls button:hover {
    background: #333;
    transform: translateY(-1px);
}

.controls select:hover {
    border-color: #999;
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: #666;
    margin-left: auto;
    font-weight: 500;
}

.game-area {
    flex: 1;
    overflow: hidden;
    padding: 16px;
    background: #fafafa;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-board-container {
    background: white;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    max-width: 100%;
    max-height: 100%;
}

.game-board {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.game-board.easy {
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(3, 80px);
}

.game-board.medium {
    grid-template-columns: repeat(4, 75px);
    grid-template-rows: repeat(4, 75px);
}

.game-board.hard {
    grid-template-columns: repeat(6, 65px);
    grid-template-rows: repeat(4, 65px);
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    color: white;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    transform: scale(0.95);
    opacity: 0.8;
    pointer-events: none;
}

.card.wrong {
    animation: shake 0.5s ease-in-out;
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.card .front, .card .back {
    position: absolute;
    backface-visibility: hidden;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    font-weight: 600;
}

.card .front {
    background: white;
    color: #1a1a1a;
    transform: rotateY(180deg);
    border: 2px solid #e8e8e8;
}

.card .back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5em;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #1a1a1a;
    margin-bottom: 16px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.modal-content p {
    font-size: 16px;
    margin-bottom: 24px;
    color: #666;
}

.modal-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 24px;
}

.stat {
    text-align: center;
}

.stat .stat-label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons button {
    padding: 12px 24px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

#playAgain {
    background: #1a1a1a;
    color: white;
}

#playAgain:hover {
    background: #333;
    transform: translateY(-1px);
}

#changeDifficulty {
    background: #f8f9fa;
    color: #1a1a1a;
    border: 1px solid #e8e8e8;
}

#changeDifficulty:hover {
    background: #e9ecef;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
}

@keyframes matchSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(0.95); }
}

.card.match-success {
    animation: matchSuccess 0.6s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.card.hint {
    animation: pulse 1s ease-in-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-board.easy {
        grid-template-columns: repeat(4, 70px);
        grid-template-rows: repeat(3, 70px);
    }
    
    .game-board.medium {
        grid-template-columns: repeat(4, 65px);
        grid-template-rows: repeat(4, 65px);
    }
    
    .game-board.hard {
        grid-template-columns: repeat(6, 55px);
        grid-template-rows: repeat(4, 55px);
    }
    
    .card {
        font-size: 1.5em;
    }
    
    .game-stats {
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .game-area {
        padding: 12px;
    }
    
    .game-board-container {
        padding: 16px;
    }
    
    .game-board.easy {
        grid-template-columns: repeat(4, 60px);
        grid-template-rows: repeat(3, 60px);
        gap: 8px;
    }
    
    .game-board.medium {
        grid-template-columns: repeat(4, 55px);
        grid-template-rows: repeat(4, 55px);
        gap: 8px;
    }
    
    .game-board.hard {
        grid-template-columns: repeat(6, 45px);
        grid-template-rows: repeat(4, 45px);
        gap: 6px;
    }
    
    .card {
        font-size: 1.2em;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .stats {
        margin-left: 0;
        justify-content: center;
    }
}
/* Footer styles */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
}

footer a {
    color: #666;
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.2s ease;
}

footer a:hover,
footer a:focus {
    color: #4CAF50;
    text-decoration: underline;
}
