/* Memory Match - Beautiful Card Game Styles */

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #ffffff;
    --card-back: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text);
    padding: 20px;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.title {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

/* Controls */
.controls {
    background: white;
    border-radius: 16px;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-muted);
}

.control-group select {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.control-group select:hover {
    border-color: var(--primary);
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

/* Stats Bar */
.stats-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 30px;
    display: flex;
    justify-content: center;
    gap: 40px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

/* Game Container */
.game-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.game-board {
    display: grid;
    gap: 10px;
    padding: 20px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

/* Grid sizes */
.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

.grid-8 {
    grid-template-columns: repeat(8, 1fr);
}

/* Card Styles */
.card {
    width: 70px;
    height: 70px;
    perspective: 1000px;
    cursor: pointer;
}

.grid-6 .card {
    width: 60px;
    height: 60px;
}

.grid-8 .card {
    width: 50px;
    height: 50px;
}

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

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

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

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

.card-front {
    background: var(--card-back);
    box-shadow: var(--shadow-sm);
}

.card-front::after {
    content: '?';
    font-size: 1.8rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.8);
}

.card-back {
    background: var(--card-bg);
    transform: rotateY(180deg);
    font-size: 2rem;
    box-shadow: var(--shadow-sm);
    border: 3px solid var(--border);
}

.grid-6 .card-back {
    font-size: 1.6rem;
}

.grid-8 .card-back {
    font-size: 1.3rem;
}

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

.card.matched .card-back {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: var(--success);
    animation: pulse 0.5s ease;
}

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

/* Win Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    animation: modalPop 0.3s ease;
}

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

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--success);
}

.win-message {
    color: var(--text-muted);
    margin-bottom: 24px;
}

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

.win-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.win-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.win-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.win-record {
    padding: 12px 20px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 10px;
    margin-bottom: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.win-record:empty {
    display: none;
}

/* Statistics Panel */
.stats-panel {
    background: white;
    border-radius: 16px;
    padding: 24px 30px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.stats-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-card h4 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
}

.stat-card .stat-row span:first-child {
    color: var(--text-muted);
}

.stat-card .stat-row span:last-child {
    font-weight: 700;
    color: var(--text);
}

.no-stats {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* Recent Games */
.recent-games {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.recent-games h4 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 0.9rem;
}

.recent-item .difficulty {
    font-weight: 600;
    color: var(--primary);
    text-transform: capitalize;
}

.recent-item .stats {
    color: var(--text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }
    
    .title {
        font-size: 1.8rem;
    }
    
    .controls {
        padding: 16px 20px;
        gap: 12px;
    }
    
    .control-group {
        flex-direction: column;
        gap: 4px;
    }
    
    .stats-bar {
        padding: 12px 16px;
        gap: 20px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .card {
        width: 55px;
        height: 55px;
    }
    
    .grid-6 .card {
        width: 48px;
        height: 48px;
    }
    
    .grid-8 .card {
        width: 42px;
        height: 42px;
    }
    
    .card-back {
        font-size: 1.5rem;
    }
    
    .grid-8 .card-back {
        font-size: 1.1rem;
    }
    
    .modal-content {
        padding: 24px;
        margin: 16px;
    }
    
    .win-stats {
        gap: 24px;
    }
}
