:root {
    --primary: #3498db;
    --secondary: #2c3e50;
    --accent: #f1c40f;
    --bg: #ecf0f1;
    --card-bg: #fff;
    --card-back: #34495e;
    --text: #2c3e50;
    --font: 'Rubik', 'Assistant', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    position: relative;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 10px;
}

.stat-box {
    background: white;
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: bold;
    min-width: 80px;
}

.stat-box .label {
    font-size: 0.8rem;
    color: #7f8c8d;
    text-transform: uppercase;
}

/* Grid */
.grid-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    /* 4x4 Grid = 8 pairs */
    gap: 8px;
    padding-bottom: 10px;
    perspective: 1000px;
    /* Enable 3D space */
}

/* Card Styles */
.card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

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

.card.matched .card-back {
    background: var(--success-color, #2ecc71);
    color: white;
    border-color: var(--success-color, #2ecc71);
    cursor: default;
    transform: rotateY(180deg);
}

.card.matched .card-front {
    display: none;
    /* Hide the back of the card (question mark) effectively */
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    /* Hide back when rotated */
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1rem;
    /* Base, will scale */
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.card-front {
    background: var(--card-back);
    color: white;
    font-size: 2rem;
}

.card-front::after {
    content: '?';
    /* Or Logo */
}

.card-back {
    background: var(--card-bg);
    color: var(--secondary);
    transform: rotateY(180deg);
    padding: 5px;
    border: 2px solid var(--primary);
    display: flex;
    flex-direction: column;
    word-break: break-word;
}

.card-back img {
    max-width: 80%;
    max-height: 80%;
}

/* Overlay & Modal */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 85%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal h1 {
    color: var(--primary);
    margin-bottom: 10px;
}

.modal p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes matchPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive Font Scaling */
@media (max-width: 350px) {
    .card-face {
        font-size: 0.8rem;
    }
}