/* CSS ATUALIZADO */
:root {
    --cell-size: 100px;
    --mark-size: calc(var(--cell-size) * .9);
    --cor-x: #e74c3c;
    /* Vermelho */
    --cor-o: #3498db;
    /* Azul */
    --cor-empate: #555;
    /* Cinza Escuro */
}

body {
    margin: 0;
    padding: 20px;
    background-color: #f7f7f7;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
    transition: all 0.3s ease;
}

h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 3.5rem;
    margin-bottom: 20px;
    background: linear-gradient(45deg, var(--cor-x), var(--cor-o));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

/* Layout Padrão (Mobile First): Empilhado */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

#scoreboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.score-card {
    background-color: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.score-card span:first-child {
    font-size: 0.9rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 5px;
}

.score-card span:last-child {
    font-size: 2.5rem;
    font-weight: bold;
}

#player-x .score-value {
    color: var(--cor-x);
}

#player-o .score-value {
    color: var(--cor-o);
}

#draws .score-value {
    color: var(--cor-empate);
}

.score-card.active-turn {
    transform: translateY(-5px);
}

#player-x.active-turn {
    box-shadow: 0 0 20px var(--cor-x);
}

#player-o.active-turn {
    box-shadow: 0 0 20px var(--cor-o);
}

.board {
    display: grid;
    grid-template-columns: repeat(3, var(--cell-size));
    grid-template-rows: repeat(3, var(--cell-size));
    gap: 10px;
    background-color: #333;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: white;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.cell:not(.x):not(.circle):hover {
    background-color: #f0f0f0;
}

.cell.x,
.cell.circle {
    cursor: not-allowed;
}

.cell.x::before,
.cell.x::after {
    content: '';
    position: absolute;
    width: calc(var(--mark-size) * .15);
    height: var(--mark-size);
    background-color: var(--cor-x);
    border-radius: 5px;
}

.cell.x::before {
    transform: rotate(45deg);
}

.cell.x::after {
    transform: rotate(-45deg);
}

.cell.circle::before {
    content: '';
    position: absolute;
    width: calc(var(--mark-size) * .8);
    height: calc(var(--mark-size) * .8);
    background-color: transparent;
    border: calc(var(--mark-size) * .15) solid var(--cor-o);
    border-radius: 50%;
}

.winning-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, .9);
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 5rem;
    flex-direction: column;
    gap: 20px;
}

.winning-message button {
    font-size: 3rem;
    background-color: white;
    border: 1px solid black;
    padding: .25em .5em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s, color 0.2s;
}

.winning-message button:hover {
    background-color: #333;
    color: white;
}

.winning-message.show {
    display: flex;
}

/* --- CSS RESPONSIVO CORRIGIDO --- */

/* 1. Layout para Telas Grandes (Desktops e Tablets deitados) */
/* Ativado quando a largura for 800px ou mais */
@media (min-width: 800px) {
    .game-container {
        flex-direction: row;
        /* Alinha placar e tabuleiro lado a lado */
        align-items: flex-start;
        /* Alinha no topo */
        gap: 50px;
    }

    #scoreboard {
        flex-direction: column;
        /* Empilha os cartões de pontuação verticalmente */
        gap: 25px;
        margin-top: 15px;
        /* Alinha melhor com o tabuleiro */
    }
}

/* 2. Layout para Telas Pequenas (Celulares em pé) */
@media (max-width: 799px) {
    :root {
        --cell-size: 24vw;
        /* Usa a largura da tela como base */
    }

    h1 {
        font-size: 2.8rem;
    }

    .score-card {
        width: 100px;
        padding: 10px 15px;
    }

    .score-card span:last-child {
        font-size: 2rem;
    }

    .winning-message {
        font-size: 3rem;
    }

    .winning-message button {
        font-size: 2rem;
    }
}

/* 3. Caso especial: Celulares deitados (largos e baixos) */
@media (max-height: 450px) and (min-width: 500px) {
    :root {
        --cell-size: 18vh;
        /* Usa a altura da tela como base */
    }

    .game-container {
        flex-direction: row;
        gap: 25px;
    }

    #scoreboard {
        flex-direction: column;
        gap: 15px;
    }

    .score-card {
        width: 120px;
        padding: 5px 10px;
    }

    .score-card span:first-child {
        font-size: 0.8rem;
    }

    .score-card span:last-child {
        font-size: 1.8rem;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }
}