:root{
    --bg: hsl(0, 0%, 10%);
    --cell-bg: #ffffff;
    --cell-hover: #e6e6e6;
    --cell-border: #000000;
    --win: #4caf50;
    --gap: 0.5rem;
}

/* Reset básico e tipografia */
body{
    background-color: var(--bg);
    color: #fff;
    font-family: 'Century Gothic', 'Trebuchet MS', Arial, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

main{
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 1rem;
    min-height: 100vh;
}

.jogo-da-velha{
    margin: 1rem auto;
    width: min(90vmin, 500px);
    height: min(90vmin, 500px); /* mantém quadrado em telas pequenas */
    border-radius: 20px;
    background-color: var(--bg);
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 0.25rem;
}

.jogo-da-velha .celula{
    display: flex;
    background-color: var(--cell-bg);
    border: 1px solid var(--cell-border);
    justify-content: center;
    align-items: center;
    font-size: clamp(1.6rem, 6vw, 3rem);
    font-weight: bold;
    color: #000;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    aspect-ratio: 1 / 1;
    padding: 0.25rem;
}

.jogo-da-velha .celula:hover{
    background-color: var(--cell-hover);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.jogo-da-velha .celula:active{
    transform: scale(0.995);
}

.jogo-da-velha .celula:nth-child(1){
    border-radius: 18px 0 0 18px;
}

.jogo-da-velha .celula:nth-child(3){
    border-radius: 0 18px 18px 0;
}

.jogo-da-velha .celula:nth-child(7){
    border-radius: 0 0 0 18px;
}

.jogo-da-velha .celula:nth-child(9){
    border-radius: 0 0 18px 0;
}

.jogo-da-velha .celula.vencedor{
    background-color: var(--win) !important;
    color: #fff;
}

#reiniciar{
    margin: 1rem auto;
    padding: clamp(0.4rem, 1.5vw, 0.7rem) clamp(0.8rem, 3vw, 1rem);
    border: none;
    border-radius: 6px;
    background-color: var(--cell-bg);
    color: #000;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: bold;
    cursor: pointer;
}

#reiniciar:hover{
    background-color: #f0f0f0;
    transition: background-color 0.25s ease;
}

#currentPlayer{
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: bold;
    margin: 1rem auto;
    text-align: center;
}

@media screen and (max-width: 360px){
    .jogo-da-velha{
        gap: 0.35rem;
        padding: 0.2rem;
        border-radius: 14px;
    }
    .jogo-da-velha .celula{
        padding: 0.15rem;
        font-size: clamp(1.4rem, 7vw, 2.2rem);
    }
    #reiniciar{ padding: 0.35rem 0.6rem }
}

@supports not (aspect-ratio: 1 / 1){
    .jogo-da-velha{
        height: auto;
    }
    .jogo-da-velha .celula{
        min-height: calc((min(90vmin, 500px) - 2 * var(--gap)) / 3);
    }
}