body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    background: linear-gradient(135deg, #e0e7ff, #ffffff);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(8, 85px);
    grid-template-rows: repeat(6, 85px);
    gap: 12px;
    justify-content: center;
    margin: 30px auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-width: 800px;
}

.card {
    width: 85px;
    height: 85px;
    background: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    perspective: 1000px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card-front {
    background: linear-gradient(45deg, #bdc3c7, #ecf0f1);
    font-size: 1.5rem; /* Adjusted font size for numbers */
    color: #34495e; /* Darker color for better contrast */
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.card-back {
    transform: rotateY(180deg);
    background: #ffffff;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid #3498db;
}

.card.matched {
    animation: matchAnimation 0.5s ease forwards;
}

@keyframes matchAnimation {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 10px 20px rgba(46, 204, 113, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
    }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: #ffffff;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transform: translateY(-20px);
    animation: slideIn 0.3s ease forwards;
}

.modal-content p {
    font-size: 1.2rem;
    color: #2c3e50;
    line-height: 1.6;
    margin: 15px 0;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #7f8c8d;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #e74c3c;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}