/* Luxury Black & Gold Theme with Animations */
:root {
    --black: #0a0a0a;
    --dark: #1a1a1a;
    --gold-light: #FFD700;
    --gold-dark: #D4AF37;
    --gold-accent: #f5d042;
    --text-light: #f5f5f5;
    --text-dark: #222;
    --success: #00b894;
    --error: #d63031;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--black);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.game-container {
    width: 100%;
    max-width: 800px;
    background: var(--dark);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
    padding: 30px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.background-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.03) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(255, 215, 0, 0.03) 0%, transparent 20%);
    z-index: -1;
}

.game-header {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
}

.game-header h1 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(to right, var(--gold-light), var(--gold-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-btn {
    background: rgba(255, 215, 0, 0.1);
    color: var(--gold-light);
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn.active {
    background: linear-gradient(to right, var(--gold-dark), var(--gold-light));
    color: var(--text-dark);
    font-weight: 500;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.difficulty-btn:hover {
    transform: translateY(-2px);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px 0;
}

.stat {
    background: rgba(255, 215, 0, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 90px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    backdrop-filter: blur(5px);
}

.label {
    font-size: 0.8rem;
    color: var(--gold-light);
    display: block;
    margin-bottom: 5px;
}

.value {
    font-size: 1.3rem;
    font-weight: 500;
    background: linear-gradient(to right, var(--gold-light), var(--gold-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Game Board - Fixed Version */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    perspective: 1000px;
    width: 100%;
    padding: 10px;
    margin: 0 auto;
    min-height: 400px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Scrollbar styling */
.game-board::-webkit-scrollbar {
    width: 6px;
}

.game-board::-webkit-scrollbar-track {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 3px;
}

.game-board::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--gold-dark), var(--gold-light));
    border-radius: 3px;
}

.card {
    aspect-ratio: 3/4;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    border-radius: 10px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

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

.card.matched {
    transform: scale(0.95);
    animation: goldPulse 1.5s ease-in-out infinite;
    cursor: default;
}

.card.mismatch {
    animation: shake 0.5s ease-in-out;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    user-select: none;
}

.card-back {
    background: linear-gradient(135deg, var(--dark), #252525);
    border: 2px solid rgba(255, 215, 0, 0.4);
    transform: rotateY(0deg);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.card-front {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    border: 2px solid var(--gold-accent);
    transform: rotateY(180deg);
    font-size: 2rem;
    color: var(--gold-light);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Buttons */
.btn {
    background: linear-gradient(to right, var(--gold-dark), var(--gold-light));
    color: var(--text-dark);
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0.3),
        rgba(255, 255, 255, 0)
    );
    transform: rotate(30deg);
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn:hover::after {
    left: 100%;
}

.btn:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    color: var(--gold-light);
    border: 2px solid var(--gold-light);
    box-shadow: none;
}

.btn-outline:hover {
    background: rgba(255, 215, 0, 0.1);
}

.btn-icon {
    margin-right: 8px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(to bottom right, #1e1e1e, #2a2a2a);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        transparent,
        transparent,
        transparent,
        rgba(255, 215, 0, 0.1)
    );
    transform: rotate(30deg);
    animation: shine 3s infinite;
    z-index: -1;
}

.modal-content h2 {
    font-family: 'Cinzel', serif;
    color: var(--gold-light);
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 0 2px 5px rgba(255, 215, 0, 0.3);
}

.trophy-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.modal-content .stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 25px 0;
}

.modal-content .stat {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    padding: 15px;
}

.modal-content .label {
    font-size: 0.9rem;
}

.modal-content .value {
    font-size: 1.5rem;
}

#best-message {
    color: var(--gold-light);
    font-weight: 500;
    margin: 15px 0;
    display: none;
    font-size: 1.2rem;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

/* Sound Control */
.sound-control {
    position: absolute;
    top: 20px;
    right: 20px;
}

.sound-btn {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--gold-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.sound-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.1);
}

/* Animations */
@keyframes goldPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 20px 5px rgba(255, 215, 0, 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.3); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

@keyframes shine {
    0% { left: -50%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .card {
        height: 100px;
    }
    
    .card-front {
        font-size: 1.8rem;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .modal-content .stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .card {
        height: 80px;
    }
    
    .card-front {
        font-size: 1.5rem;
    }
    
    .game-header h1 {
        font-size: 1.8rem;
    }
    
    .stats {
        flex-wrap: wrap;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Moves left indicator */
#moves-left {
    transition: color 0.3s ease;
}

/* Efficiency grades */
#efficiency {
    font-weight: bold;
}
#efficiency[data-grade="A+"] { color: #4CAF50; }
#efficiency[data-grade="A"] { color: #4CAF50; }
#efficiency[data-grade="B"] { color: #8BC34A; }
#efficiency[data-grade="C"] { color: #FFC107; }
#efficiency[data-grade="D"] { color: #FF9800; }
#efficiency[data-grade="F"] { color: #F44336; }