/* =============================
   Memory Game - Matching Pairs
   Modern, Responsive CSS Design
   ============================= */

/* Root variables for easy theming */
:root {
    --primary-bg: #f6f8fc;
    --card-bg: #fff;
    --card-front: #e0e7ef;
    --card-back: #b3c2e7;
    --accent: #6c63ff;
    --success: #4caf50;
    --text: #222;
    --shadow: 0 4px 24px rgba(44, 62, 80, 0.08);
    --border-radius: 16px;
    --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background: var(--primary-bg);
    color: var(--text);
    font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header styling */
.game-header {
    width: 100%;
    max-width: 480px;
    margin: 2rem auto 1rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.game-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 1px;
}
.game-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 1.1rem;
}
#restart-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.5rem 1.2rem;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}
#restart-btn:hover {
    background: #5548c8;
}

/* Difficulty selector */
.difficulty-selector {
    margin-bottom: 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#difficulty {
    border-radius: var(--border-radius);
    border: 1px solid #d1d5db;
    padding: 0.3rem 0.7rem;
    font-size: 1rem;
}

/* Game board grid */
.game-board {
    display: grid;
    gap: 1rem;
    justify-content: center;
    margin: 0 auto;
    max-width: 480px;
    min-height: 320px;
}

/* Card styles */
.card {
    width: 80px;
    height: 100px;
    perspective: 800px;
    cursor: pointer;
    position: relative;
}
.card-inner {
    width: 100%;
    height: 100%;
    position: absolute;
    transition: transform var(--transition);
    transform-style: preserve-3d;
}
.card.flipped .card-inner,
.card.matched .card-inner {
    transform: rotateY(180deg);
}
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    user-select: none;
    backface-visibility: hidden;
}
.card-front {
    background: var(--card-front);
    color: var(--accent);
    transform: rotateY(180deg);
}
.card-back {
    background: var(--card-back);
    color: #fff;
}
.card.matched .card-front {
    background: var(--success);
    color: #fff;
    transition: background 0.6s;
}

/* Win message styling */
.win-message {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(246, 248, 252, 0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.4s;
}
.win-message.hidden {
    opacity: 0;
    pointer-events: none;
}
.win-message h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
#final-stats {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}
#play-again-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.7rem 1.5rem;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background var(--transition);
}
#play-again-btn:hover {
    background: #5548c8;
}

/* Responsive design for mobile */
@media (max-width: 600px) {
    .game-header, .game-board {
        max-width: 98vw;
    }
    .card {
        width: 20vw;
        height: 24vw;
        min-width: 56px;
        min-height: 68px;
        max-width: 90px;
        max-height: 110px;
    }
    .game-board {
        gap: 0.6rem;
    }
}
