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

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

.game-container {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 25px;
}

.title-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    border: 3px solid #e94560;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(233, 69, 96, 0.1);
}

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

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

.stat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.stat-label {
    margin-right: 8px;
}

#restart-btn, #play-again-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

#restart-btn:hover, #play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

#restart-btn:active, #play-again-btn:active {
    transform: translateY(0);
}

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

.difficulty-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
    opacity: 0.7;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.5);
    opacity: 0.9;
}

.difficulty-btn.active {
    opacity: 1;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.5);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    perspective: 1000px;
}

.card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

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

.card.matched {
    cursor: default;
}

.card.matched .card-front {
    box-shadow: 0 0 20px 5px rgba(76, 175, 80, 0.6);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border: 3px solid #e94560;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(233, 69, 96, 0.1);
}

.card-back::before {
    content: "?";
    font-size: 3rem;
    font-weight: bold;
    color: #e94560;
    text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.card-front {
    background: white;
    border: 3px solid #667eea;
    transform: rotateY(180deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Win Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.4s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #333;
    font-size: 2rem;
    margin-bottom: 15px;
}

.modal-content p {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.final-stats {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
}

.final-stats p {
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    margin: 8px 0;
}

/* Responsive Design */
@media (max-width: 700px) {
    .game-container {
        padding: 15px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .stats {
        gap: 15px;
    }

    .stat {
        padding: 8px 15px;
        font-size: 0.95rem;
    }

    .game-board {
        gap: 8px;
    }

    .card-back::before {
        font-size: 2rem;
    }
}

@media (max-width: 500px) {
    .game-board {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
    
    .card-back::before {
        font-size: 1.5rem;
    }
}

/* Loading state */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    font-size: 1.5rem;
    color: #667eea;
    font-weight: bold;
}

/* Leaderboard Button */
#leaderboard-btn {
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(241, 39, 17, 0.4);
    margin-left: 10px;
}

#leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(241, 39, 17, 0.5);
}

/* Leaderboard Status in Win Modal */
#leaderboard-status {
    margin: 15px 0;
    font-size: 1.1rem;
    color: #f5af19;
    font-weight: bold;
}

#view-leaderboard-btn {
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(241, 39, 17, 0.4);
    margin-left: 10px;
}

#view-leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(241, 39, 17, 0.5);
}

/* Name Entry Modal */
.name-input-container {
    margin: 20px 0;
}

.name-input-container label {
    display: block;
    margin-bottom: 10px;
    color: #666;
    font-size: 1rem;
}

.name-input-container input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 2px solid #667eea;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input-container input:focus {
    border-color: #f5576c;
    box-shadow: 0 0 10px rgba(245, 87, 108, 0.3);
}

#submit-score-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
    margin-right: 10px;
}

#submit-score-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

#skip-submit-btn {
    background: linear-gradient(135deg, #8e8e8e 0%, #5c5c5c 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(92, 92, 92, 0.4);
}

#skip-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(92, 92, 92, 0.5);
}

/* Leaderboard Modal */
.leaderboard-content {
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.leaderboard-tab {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    opacity: 0.6;
}

.leaderboard-tab:hover {
    opacity: 0.8;
}

.leaderboard-tab.active {
    opacity: 1;
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    box-shadow: 0 4px 15px rgba(241, 39, 17, 0.4);
}

.leaderboard-difficulty-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.difficulty-tab {
    background: #e0e0e0;
    color: #333;
    border: none;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-tab:hover {
    background: #d0d0d0;
}

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

.leaderboard-table-container {
    margin: 20px 0;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.leaderboard-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
}

.leaderboard-table tbody tr:nth-child(odd) {
    background: #f9f9f9;
}

.leaderboard-table tbody tr:nth-child(1) td:first-child::before {
    content: "🥇 ";
}

.leaderboard-table tbody tr:nth-child(2) td:first-child::before {
    content: "🥈 ";
}

.leaderboard-table tbody tr:nth-child(3) td:first-child::before {
    content: "🥉 ";
}

.leaderboard-table tbody tr.highlight {
    background: linear-gradient(135deg, rgba(245, 175, 25, 0.2) 0%, rgba(241, 39, 17, 0.2) 100%);
    font-weight: bold;
}

#leaderboard-empty {
    color: #888;
    font-style: italic;
    padding: 30px;
}

#close-leaderboard-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    margin-top: 10px;
}

#close-leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.hidden {
    display: none !important;
}
