/* memory.css */

/* Memory Game Container */
#memory-container {
    width: 100%;
    max-width: 800px; /* Limits size on ultra-wide monitors */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Memory Game Grid Layout */
#memory-grid {
    display: grid; 
    /* Responsive columns: 4 across, sized relative to the viewport width */
    grid-template-columns: repeat(4, 1fr); 
    gap: 1vmin; /* Gap scales with screen size */
    width: 90vw; /* Takes up most of the screen width on mobile */
    max-width: 1000px; /* But stays reasonable on desktop */
}

/* Memory Card Container */
.memory-card {
    aspect-ratio: 1 / 1; /* Keeps cards perfectly square */
    perspective: 1000px;
    cursor: pointer;
    width: 100%; /* Fill the grid cell */
}

/* Flip Animation Logic */
.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

/* Card Faces */
.memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12%; /* Relative rounding */
    border: 2px solid #555;
    box-sizing: border-box;
}

.memory-card-front {
    background-color: #333;
}

.memory-card-front img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.memory-card-back {
    background-color: #007bff;
    color: white;
    /* Font size scales based on the card size */
    font-size: 16vmin; 
    transform: rotateY(180deg);
}

/* Cap the font size for very large screens */
@media (min-width: 800px) {
    .memory-card-back {
        font-size: 7.5rem;
    }
}

/* Success State */
.memory-card.matched .memory-card-inner {
    border: 3px solid #28a745;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}