/* === RESET E BASE === */
* {
 margin: 0;
 padding: 0;
 box-sizing: border-box;
}

body {
 font-family: 'Segoe UI', Tahoma, sans-serif;
 background: #f2f2f2;
 color: #333;
 /* CORREÇÃO: Usa DYNAMIC VIEWPORT HEIGHT (dvh) para considerar o teclado mobile */
 height: 100dvh;
 min-height: 100dvh; /* Garante que a altura mínima seja sempre o dvh */
 display: flex;
 flex-direction: column;
 /* Adicionado para garantir que o corpo consiga rolar se o teclado empurrar */
 overflow-y: auto;
}

/* === JOGO === */
.jogo {
 display: flex;
 flex-direction: column;
 /* CORREÇÃO: Usa DYNAMIC VIEWPORT HEIGHT (dvh) */
 height: 100dvh;
 /* Adicionado flex-grow para que o jogo ocupe o espaço restante */
 flex-grow: 1;
 overflow-y: hidden; /* Se o jogo tiver 100dvh, ele não deve rolar */
}

/* === TOPO === */
.topo {
 background: #fff;
 border-bottom: 2px solid #ddd;
 text-align: center;
 padding: 10px 5px;
}

/* CONTAINER PARA O PLACAR E CRONÔMETRO */
.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* NOVO: CRONÔMETRO */
.cronometro-container {
    font-size: 1.1em;
    color: #d9534f; /* Um vermelho/vinho para dar destaque ao tempo */
    font-weight: bold;
    margin-bottom: 5px;
}
#tempoJogo {
    margin-left: 5px;
}

.topo h2 {
 color: #007bff;
 margin-bottom: 5px;
}

.placar {
 font-size: 14px;
 color: #555;
}

/* NOVO: DESTAQUE PARA O PLACAR DE VITÓRIAS */
.placar-vitorias {
    font-weight: bold;
    color: #007bff;
    font-size: 1.1em;
}

.log-status {
 background: #e6f0ff;
 color: #004085;
 padding: 5px;
 font-size: 0.9em;
 border-top: 1px solid #cce5ff;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
}

/* === TABULEIRO E MESA === */
.tabuleiro {
 flex-shrink: 0;
 max-height: 45vh;
 display: flex;
 justify-content: center;
 align-items: center;
}

.mesa {
 width: auto;
 height: auto;
 display: flex;
 flex-wrap: wrap;
 justify-content: center;
 align-items: center;
 gap: 5px;
 padding: 10px;
 overflow: auto;
 margin: 0;
 min-height: 150px;
 background: #f8f8f8;
 border: 0px dashed #aaa;
 border-radius: 10px;
 padding: 15px;
}


/* Peças na Mesa (Horizontal - MANTIDO E CORRIGIDO) */
.mesa .peca {
 /* MANTÉM: Torna a peça nativamente horizontal */
 width: 69px; min-width: 69.px;
 height: 36px; min-height: 36px;
 flex-direction: row;
 cursor: default;
 transform: none !important;
}
.mesa .peca:hover { transform: none; }

/* CORREÇÃO 1: LINHA DIVISÓRIA VERTICAL */
.mesa .peca::after {
 content: ""; 
 position: absolute; 

 /* INVERTE AS DIMENSÕES DO RISCO: Agora ele é alto (vertical) e fino */
 width: 1px;
 height: 24px;

 /* CENTRALIZA: Posiciona no meio e ajusta com transform */
 top: 50%;
 left: 50%;

 background: #999; /* Cor da linha divisória */
 border-radius: 1px;

 /* Move para o centro exato */
 transform: translate(-50%, -50%);
}

/* Os lados da peça */
.mesa .peca .lado {
 width: 50%;
 height: 100%;
}

/* CORREÇÃO 2: REATIVAR O EFEITO LUMINOSO (PONTA JOGÁVEL) NA MESA */
.mesa .peca .lado.ponta-jogavel {
 /* Aplica o estilo de fundo e a sombra do seu código original */
 box-shadow: 0 0 10px 2px rgba(0, 255, 255, 0.9);
 background-color: #20b2aa; /* Fundo esverdeado/azul da ponta */
 border-radius: 4px;
 animation: pulse 1.5s infinite alternate; /* Reativa a animação */
}
/* === CONTROLES === */
.controles {
 background: #fff;
 border-top: 2px solid #ddd;
 display: flex;
 flex-direction: column;
 align-items: center;
 padding: 10px 0;
 gap: 10px;
}

.botoes-acao {
 display: flex;
 gap: 10px;
}

.controles button {
 background: #007bff;
 color: #fff;
 border: none;
 padding: 8px 16px;
 border-radius: 6px;
 cursor: pointer;
}

.controles button:hover {
 background: #0056b3;
}

/* === CARROSSEL DAS PEÇAS === */
.carrossel {
 display: flex;
 align-items: center;
 justify-content: center;
 gap: 8px;
 width: 100%;
 overflow: hidden;
}

.carrossel-seta {
 background: #007bff;
 border: none;
 color: white;
 font-size: 18px;
 padding: 6px 10px;
 border-radius: 4px;
 flex-shrink: 0;
}

.mao {
 display: flex;
 flex-wrap: nowrap;
 overflow-x: auto;
 overflow-y: hidden;
 gap: 6px;
 padding: 6px;
 flex-grow: 1;
 scroll-snap-type: x mandatory;
}

.mao::-webkit-scrollbar { height: 8px; }
.mao::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }

.peca {
 flex-shrink: 0; /* Impede de se espremer */
}


.mao::-webkit-scrollbar { height: 6px; }
.mao::-webkit-scrollbar-thumb { background: #aaa; border-radius: 3px; }

/* === PEÇAS === */
.peca {
 width: 48px;
 height: 96px;
 background: linear-gradient(180deg, #222 0%, #000 100%);
 border-radius: 6px;
 border: 2px solid #555;
 display: flex;
 flex-direction: column;
 justify-content: space-between;
 position: relative;
 cursor: pointer;
 box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
 transition: transform 0.2s;
}

.peca::after {
 content: "";
 position: absolute;
 top: 50%;
 left: 6%;
 width: 88%;
 height: 2px;
 background: #999;
 transform: translateY(-50%);
 border-radius: 1px;
}

/* Lados das peças */
.lado {
 height: 50%;
 display: grid;
 grid-template-columns: repeat(3, 1fr);
 grid-template-rows: repeat(3, 1fr);
 place-items: center;
}

/* === LOGIN === */
.telaLogin {
 position: fixed; /* Manter fixed para cobrir toda a tela do jogo */
 top: 0;
 left: 0;
 width: 100%;
 /* CORREÇÃO: Usa DYNAMIC VIEWPORT HEIGHT (dvh) */
 height: 100dvh;
 /* Permite que o conteúdo da tela de login (a caixa) role internamente
se o teclado reduzir a área visível demais. */
 overflow-y: auto;
 background: linear-gradient(180deg, #fff 0%, #ddd 100%);
 display: flex;
 /* Ajusta o alinhamento para o início quando a tela é muito pequena */
 align-items: flex-start;
 justify-content: center;
 z-index: 10;
 padding-top: 5vh; /* Adiciona um padding para a caixa não colar no topo */
 padding-bottom: 5vh;
}

.login-caixa {
 background: #fff;
 border: 2px solid #ccc;
 border-radius: 12px;
 padding: 20px;
 width: 80%;
 max-width: 350px;
 text-align: center;
 box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
 /* Garantia: A caixa de login não terá altura fixa para evitar recortes */
 max-height: 90%;
 flex-shrink: 0; /* Impede que a caixa seja espremida */
}


.login-caixa h1 {
 margin-bottom: 20px;
 color: #007bff;
}

.login-caixa label {
 display: block;
 text-align: left;
 margin-top: 10px;
}

.login-caixa input,
.login-caixa select {
 width: 100%;
 margin: 8px 0;
 padding: 8px;
 border-radius: 6px;
 border: 1px solid #ddd;
 background-color: #f9f9f9;
}

.login-caixa button {
 width: 100%;
 margin-top: 12px;
 padding: 10px;
 background-color: #28a745;
 color: white;
 border: none;
 border-radius: 6px;
 cursor: pointer;
}

.login-caixa button:hover {
 background-color: #218838;
}
/* === PONTOS DAS PEÇAS === */
.lado {
 height: 50%;
 display: grid;
 grid-template-columns: repeat(3, 1fr);
 grid-template-rows: repeat(3, 1fr);
 gap: 2px;
 place-items: center;
}

.ponto {
 width: 5px;
 height: 5px;
 background-color: #fff;
 border-radius: 50%;
 opacity: 0;
}

/* === DESTAQUE DAS JOGÁVEIS === */
.peca .lado.ponta-jogavel {
 box-shadow: 0 0 10px 2px rgba(0, 255, 255, 0.9);
 background-color: #20b2aa;
 border-radius: 4px;
 animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
 from { box-shadow: 0 0 5px rgba(0, 255, 255, 0.5); }
 to { box-shadow: 0 0 12px rgba(0, 255, 255, 1); }
}

.mao .peca.jogavel {
 border: 3px solid #20b2aa !important;
 transform: scale(1.05);
 transition: transform 0.2s, border 0.2s;
}

.mao .peca.jogavel:hover {
 box-shadow: 0 0 15px rgba(32, 178, 170, 0.7);
}


/* Padrões dos números */
.peca .lado[data-value="1"] .ponto:nth-child(5) { opacity: 1; }
.peca .lado[data-value="2"] .ponto:nth-child(1), .peca .lado[data-value="2"] .ponto:nth-child(9) { opacity: 1; }
.peca .lado[data-value="3"] .ponto:nth-child(1), .peca .lado[data-value="3"] .ponto:nth-child(5), .peca .lado[data-value="3"] .ponto:nth-child(9) { opacity: 1; }
.peca .lado[data-value="4"] .ponto:nth-child(1), .peca .lado[data-value="4"] .ponto:nth-child(3), .peca .lado[data-value="4"] .ponto:nth-child(7), .peca .lado[data-value="4"] .ponto:nth-child(9) { opacity: 1; }
.peca .lado[data-value="5"] .ponto:nth-child(1), .peca .lado[data-value="5"] .ponto:nth-child(3), .peca .lado[data-value="5"] .ponto:nth-child(5), .peca .lado[data-value="5"] .ponto:nth-child(7), .peca .lado[data-value="5"] .ponto:nth-child(9) { opacity: 1; }
.peca .lado[data-value="6"] .ponto:nth-child(1), .peca .lado[data-value="6"] .ponto:nth-child(3), .peca .lado[data-value="6"] .ponto:nth-child(4), .peca .lado[data-value="6"] .ponto:nth-child(6), .peca .lado[data-value="6"] .ponto:nth-child(7), .peca .lado[data-value="6"] .ponto:nth-child(9) { opacity: 1; }

/* --- ESTILOS DO MODAL (MANTIDOS E MELHORADOS) --- */
.fimModal {
 display: none; 
 position: fixed;
 z-index: 1000;
 left: 0;
 top: 0;
 width: 100%;
 height: 100%;
 /* O "fundo embaçado" */
 background-color: rgba(0, 0, 0, 0.7);

 /* Centralização perfeita quando o JS usa display: flex */
 justify-content: center;
 align-items: center;
}

/* --- ESTILO DA CAIXA BRANCA DE CONTEÚDO (modal-conteudo) --- */
.modal-conteudo {
 /* Fundo branco */
 background-color: #fff;
 padding: 30px;
 border-radius: 10px;
 text-align: center;
 box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
 max-width: 400px;
 width: 90%;
}

/* --- ESTILO DA MENSAGEM FINAL (O Título Azul) --- */
#mensagemFinal {
 font-size: 1.5em;
 color: #007bff; 
 margin-bottom: 20px;
 padding-bottom: 10px;
 border-bottom: 1px solid #ddd;
}

/* --- NOVO: ESTILOS DO LAUDO DETALHADO --- */
.laudo-detalhado {
    text-align: left;
    margin-top: 15px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #fafafa;
}

.laudo-detalhado h3 {
    font-size: 1.2em;
    color: #555;
    margin-top: 10px;
    margin-bottom: 5px;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 3px;
}

.laudo-detalhado p {
    font-size: 0.95em;
    margin: 4px 0;
    color: #333;
}

/* --- ESTILO DOS BOTÕES FINAIS --- */
.modal-conteudo button {
    display: block;
    width: 100%;
    margin-top: 10px; /* Adicionado para separar os botões no final */
}

#btnReiniciar {
 background-color: #28a745;
 color: white;
 padding: 10px 20px;
 border: none;
 border-radius: 5px;
 cursor: pointer;
 margin-top: 20px;
 font-size: 1.1em;
 transition: background-color 0.3s;
}

#btnReiniciar:hover {
 background-color: #218838;
}

#btnFinalizarJogo { /* Novo botão para o FIM DE JOGO (Melhor de N) */
    background-color: #d9534f;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s;
    margin-top: 10px;
}

#btnFinalizarJogo:hover {
    background-color: #c9302c;
}