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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    max-width: 95vw;
    overflow-x: auto;
}

h1 {
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #e0e0e0;
}

.difficulty {
    display: flex;
    gap: 10px;
}

.difficulty-btn, .action-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.difficulty-btn {
    background: #e0e0e0;
    color: #333;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
}

.difficulty-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
}

.action-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.stats span {
    background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%);
    padding: 8px 16px;
    border-radius: 25px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.board {
    display: grid;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.card {
    width: 70px;
    height: 90px;
    cursor: pointer;
    position: relative;
    border-radius: 12px;
    font-size: 36px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card:not(.flipped) {
    background: linear-gradient(145deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card.flipped {
    background: linear-gradient(145deg, #f093fb 0%, #f5576c 100%);
}

.card.matched {
    animation: matchedPulse 0.5s ease forwards;
    opacity: 0.6;
    cursor: default;
}

.card:hover:not(.matched) {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.card.hint {
    animation: hintGlow 0.5s ease infinite alternate;
}

@keyframes matchedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes hintGlow {
    0% { box-shadow: 0 0 10px #f5576c, 0 0 20px #f5576c; }
    100% { box-shadow: 0 0 20px #f5576c, 0 0 40px #f5576c; }
}

@keyframes cardAppear {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1); }
}

.card {
    animation: cardAppear 0.4s ease forwards;
}

.message {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-top: 15px;
    padding: 12px;
    border-radius: 10px;
    min-height: 50px;
    transition: all 0.3s ease;
}

.message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    animation: messagePop 0.4s ease;
}

.message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.message.info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

@keyframes messagePop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

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

.message.win {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #8b6914;
    animation: winCelebration 0.6s ease infinite;
}

@media (max-width: 768px) {
    .card {
        width: 55px;
        height: 70px;
        font-size: 28px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .difficulty, .actions {
        justify-content: center;
    }

    .stats {
        justify-content: center;
        flex-wrap: wrap;
    }

    h1 {
        font-size: 1.5rem;
    }
}
