/* Basic styling */
body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f8f9fa;
    font-family: 'Poppins', sans-serif;
    padding: 10px;
}

header {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    width: 100%;
    padding: 10px 0;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 5px solid #2980b9;
}

header h1 {
    margin: 0;
    color: white;
    font-size: 2.5em;
    font-weight: 600;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-gap: 10px;
    width: 100%;
    max-width: 600px;
}

.square {
    width: 100%;
    padding-bottom: 100%; /* This creates a square aspect ratio */
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.square .front,
.square .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1em;
    color: white;
    border-radius: 10px;
}

.square .front {
    background-color: #3498db;
}

.square .back {
    background-color: #2ecc71; /* Default back color */
    transform: rotateY(180deg);
}

/* Additional colors for the back of the square */
.square.color1 .back { background-color: #e74c3c; }
.square.color2 .back { background-color: #9b59b6; }
.square.color3 .back { background-color: #f1c40f; }
.square.color4 .back { background-color: #1abc9c; }
.square.color5 .back { background-color: #e67e22; }

button {
    width: 80%;
    max-width: 300px;
    margin: 20px auto;
    display: block;
    font-size: 1em;
    padding: 10px;
}

/* Media queries for smaller screens */
@media (max-width: 600px) {
    header h1 {
        font-size: 2em;
    }

    .square {
        padding-bottom: 100%; /* Maintain square aspect ratio */
    }

    button {
        font-size: 0.9em;
    }
}