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

:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    min-height: 100vh;
    padding: 1rem;
}

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

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

.back-btn {
    position: absolute;
    left: 0;
    top: 0;
    background: white;
    color: var(--primary);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn:hover {
    transform: translateX(-5px);
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.back-btn:active {
    transform: translateX(-3px) scale(0.98);
}

.brand h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.brand-text {
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.game-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 1rem;
    gap: 1rem;
}

.high-score-display {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: 10px;
}

.action-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.action-btn:hover::before {
    left: 100%;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

.action-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.info-box {
    flex: 1;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    color: white;
}

.label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.new-game-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    position: relative;
    overflow: hidden;
}

.new-game-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.new-game-btn:hover::before {
    left: 100%;
}

.new-game-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.new-game-btn:active {
    transform: scale(0.98);
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
}

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

.card.matched {
    animation: matchAnimation 0.6s;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 3rem;
}

.card-front {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    animation: scaleIn 0.3s;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.stats {
    font-size: 1.2rem;
    margin: 0.5rem 0;
    font-weight: 600;
}

.modal-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

@keyframes matchAnimation {
    0%, 100% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
    .header {
        margin-bottom: 1.5rem;
    }
    
    .back-btn {
        position: relative;
        left: auto;
        top: auto;
        margin-bottom: 1rem;
        width: 100%;
        justify-content: center;
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .brand {
        text-align: center;
    }
    
    .brand h1 {
        font-size: 2rem;
    }
    
    .game-info {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .action-btn, .new-game-btn {
        padding: 1.2rem;
        font-size: 1.2rem;
    }
    
    .cards-grid {
        gap: 0.75rem;
    }
    
    .card-front, .card-back {
        font-size: 2rem;
    }
    
    .game-container {
        padding: 1rem;
    }
}
