/* Site para gerar background gradient: https://cssgradient.io/ */

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #fc1e8a;
    user-select: none;
}

.container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    background: linear-gradient(325deg, #03001e 0%, #7303c0 30%, #ec38bc 70%, #fdeff9 100%);
    padding: 40px 60px;
}

h2 {
    font-size: 3em;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.reset {
    padding: 15px 20px;
    width: 100%;
    color: #000;
    background-color: #fff;
    border: none;
    font-size: 1.5em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    font-weight: 600;
}

.reset:focus {
    color: #ec38bc;
    background-color: #262809;
}

.game {
    width: 430px;
    height: 430px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    transform-style: preserve-3d;
    perspective: 500px;
}

.item {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;

    font-size: 3em;
    transform: rotateY(180deg);
    transition: 0.25s;
}

.item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #404040;
    transition: .25s;
    transform: rotateY(0deg);
    backface-visibility: hidden;
}

.item.boxOpen {
    transform: rotateY(0deg);
}

.boxOpen::after,
.boxMatch::after {
    transform: rotateY(180deg);
}

/* Responsividade */
@media (max-width: 768px) {
    html, body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .container {
        padding: 10px;
        gap: 20px;
        width: 100%;
        max-width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 15px 0 15px;
    }

    h2 {
        font-size: 2em;
        text-align: center;
        word-wrap: break-word;
    }

    .reset {
        font-size: 1.2em;
        padding: 10px;
        width: auto;
    }

    .game {
        display: grid;
        width: 75vw; /* Reduzido para dar margem lateral */
        height: auto;
        grid-template-columns: repeat(4, 1fr); /* 4 colunas */
        gap: 10px; /* Espaço maior entre itens */
    }

    .item {
        aspect-ratio: 1; /* Garante itens quadrados */
        width: 80%; /* Ajusta ao grid */
        font-size: 1.8em; /* Reduz o tamanho da fonte */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
        gap: 15px;
    }

    h2 {
        font-size: 1.5em;
    }

    .reset {
        font-size: 1em;
        padding: 8px;
    }

    .game {
        width: 90vw; /* Reduzido para margem adicional */
        gap: 8px; /* Espaçamento menor para itens em telas menores */
        grid-template-columns: repeat(4, 1fr); /* 4 colunas */
    }

    .item {
        aspect-ratio: 1; /* Mantém itens quadrados */
        font-size: 1.5em; /* Reduz tamanho da fonte */
    }
}
