@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

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

:root {
    --primary-gradient: linear-gradient(135deg, #ffd6e8 0%, #c9a0dc 100%);
    --secondary-gradient: linear-gradient(135deg, #ffc4d6 0%, #ffb5c5 100%);
    --success-gradient: linear-gradient(135deg, #a8e6cf 0%, #88d8b0 100%);
    --light-bg: #fff5f8;
    --card-bg: #ffffff;
    --text-dark: #5a5a5a;
    --text-muted: #9a9a9a;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 20px rgba(255, 182, 193, 0.3);
    --pastel-purple: #e8d5f2;
    --pastel-pink: #ffd6e8;
    --pastel-blue: #d5e8f7;
    --pastel-green: #d5f2e3;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--dark-bg);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
}

.container {
    max-width: 900px;
    width: 100%;
}

/* Header Styles */
.game-header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.6s ease-out;
}

.game-header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.3);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--card-bg);
    padding: 15px 30px;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 120px;
    transition: all 0.3s ease;
    border: 2px solid var(--pastel-purple);
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

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

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.btn-reset, .btn-print {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-print {
    background: var(--secondary-gradient);
}

.btn-reset:hover, .btn-print:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-reset:active, .btn-print:active {
    transform: translateY(0);
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    perspective: 1000px;
    animation: fadeIn 0.8s ease-out;
}

/* Card Styles */
.card {
    aspect-ratio: 3/4;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

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

.card.matched {
    animation: matchPulse 0.6s ease-out;
    pointer-events: none;
}

.card.disabled {
    pointer-events: none;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-back {
    background: var(--card-bg);
    background-image: var(--primary-gradient);
    border: 3px solid var(--pastel-purple);
}

.card-back img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.card-front {
    background: var(--card-bg);
    transform: rotateY(180deg);
    padding: 15px;
    border: 3px solid var(--pastel-pink);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.card:hover:not(.flipped):not(.matched) {
    transform: translateY(-5px) scale(1.02);
}

/* Victory Modal */
.victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.victory-modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 50px 60px;
    border-radius: 30px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 3px solid var(--pastel-pink);
    max-width: 500px;
    width: 90%;
}

.trophy-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}

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

.final-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.final-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-play-again {
    background: var(--secondary-gradient);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-play-again:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 25px rgba(255, 182, 193, 0.5);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes matchPulse {

    0%,
    100% {
        transform: scale(1) rotateY(180deg);
    }

    50% {
        transform: scale(1.1) rotateY(180deg);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-header h1 {
        font-size: 2.2rem;
    }

    .game-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .stats {
        gap: 15px;
    }

    .stat-item {
        padding: 12px 20px;
        min-width: 100px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .modal-content {
        padding: 40px 30px;
    }

    .modal-content h2 {
        font-size: 2rem;
    }

    .trophy-icon {
        font-size: 4rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .game-header h1 {
        font-size: 1.8rem;
    }

    .stats {
        gap: 10px;
    }

    .stat-item {
        padding: 10px 15px;
        min-width: 90px;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }
}