/* Estilos Gerais */
*,
*::before,
*::after {
    box-sizing: border-box; /* Garante consistência no modelo de caixa */
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #333;
    color: #fff;
    display: flex; /* Usa Flexbox para o layout principal */
    flex-direction: column; /* Empilha header, main, footer verticalmente */
    min-height: 100vh; /* Permite que o conteúdo cresça */
    margin: 0;
    user-select: none; /* Impede a seleção de texto */
}

/* Variáveis de Cores */
:root {
    --team-a-color: #BDB76B; /* Dark Khaki / Sand */
    --team-b-color: #556B2F; /* Dark Olive Green */
    --neutral-color: #4A4A4A; /* Darker Gray */
}

/* Ecrã de Configuração */
.setup-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-grow: 1; /* Faz a tela de setup ocupar o espaço disponível */
    padding: 20px;
    background-image: url('SetupBG.png');
    background-size: cover;
    background-position: center;
}

.setup-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 30px;
    background-color: rgba(68, 68, 68, 0.9);
    border-radius: 10px;
}
.setup-form input {
    margin: 8px 0; /* Reduz o espaçamento vertical para tornar o formulário mais compacto */
    padding: 8px;
    border-radius: 5px;
    border: none;
}

.setup-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    width: 100%;
    justify-content: center;
}
.setup-form button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: var(--team-b-color); /* Themed green */
    color: white;
}

/* Container Principal do Jogo */
.game-container {
    display: flex;
    justify-content: space-evenly; /* Garante espaçamento proporcional entre os elementos */
    align-items: center;
    width: 100%;
    flex-grow: 1; /* Faz a tela de jogo ocupar o espaço disponível */
    padding: 20px;
    background-image: url('GameBG.png');
    background-size: cover;
    background-position: center;
}

/* Área das Equipas */
.team-area {
    width: 30%; /* Reduz a largura para criar mais espaço */
    height: 75%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 15px;
    position: relative; /* Necessário para o posicionamento da barra e do h2 */
    overflow: hidden; /* Garante que a barra não ultrapasse as bordas arredondadas */
    touch-action: manipulation; /* Impede ações de toque padrão como o menu de contexto */
}
.team-area h2 {
    position: relative; /* ou z-index: 1; para garantir que fique sobre a barra */
    z-index: 1;    
    font-size: clamp(2em, 5vw, 3.5em); /* Fonte fluida */
}

.team-a {
    background-color: rgba(189, 183, 107, 0.5); /* Fundo semi-transparente Sand */
    border: 3px solid var(--team-a-color);
}
.team-b {
    background-color: rgba(85, 107, 47, 0.5); /* Fundo semi-transparente Olive */
    border: 3px solid var(--team-b-color);
}
.timer {
    font-size: clamp(1.8em, 4vw, 2.5em); /* Fonte fluida */
    font-weight: bold;
    position: relative; /* Garante que o timer fique sobre a barra de progresso */
    z-index: 1; /* Garante que o timer fique sobre a barra de progresso */
}

/* Painel Central */
.central-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6); /* Fundo para legibilidade */
    padding: 20px;
    min-width: 250px; /* Garante que o painel não encolha */
    min-height: 350px; /* Garante que o painel não encolha */
    border-radius: 15px;
}
.main-timer {
    font-size: clamp(3em, 8vw, 4.5em); /* Fonte fluida */
    font-weight: bold;
    margin-bottom: 20px;
}

#logo {
    max-width: 150px; /* Define a largura máxima da logo */
    max-height: 150px; /* Define a altura máxima da logo */
    margin-bottom: 10px; /* Adiciona um pequeno espaçamento abaixo da logo */
}
#hotspot {
    width: 200px;
    height: 200px;
    border: 5px solid;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background-color 0.5s, border-color 0.5s;
}
#hotspot span {
    z-index: 2;
    font-weight: bold;
}

/* MUDANÇA: Estilo movido de um ID para uma classe genérica */
.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0;
    transition: height 0.1s linear; /* Transição suave da altura */
}

/* Estados do Hotspot */
.hotspot.neutral {
    background-color: #495057;
    border-color: var(--neutral-color);
}
.hotspot.owned-a {
    background-color: var(--team-a-color);
    border-color: #fff;
}
.hotspot.owned-b {
    background-color: var(--team-b-color);
    border-color: #fff;
}

#status-message {
    margin-top: 15px;
    font-size: 1.2em;
    font-weight: bold;
}

/* Mensagem extra abaixo do status */
#extra-message {
    margin-top: 5px;
}

/* Botões de Controle */
.controls {
    display: flex;
    margin-top: 20px;
}
.controls button {
    padding: 10px 15px;
    margin: 0 10px;
    cursor: pointer;
    border-radius: 5px;
    border: 2px solid #fff;
    background-color: transparent;
    color: #fff;
    font-weight: bold;
    position: relative; /* Necessário para a barra de progresso */
    overflow: hidden; /* Esconde a barra que excede o botão */
}

.hold-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0; /* Começa com largura 0 */
    background-color: #dc3545; /* Vermelho para cancelamento */
    opacity: 0.8;
    transition: width 5s linear; /* Animação de 5 segundos */
    z-index: 0; /* Fica atrás do texto do botão */
}

#cancel-btn span { position: relative; z-index: 1; }

/* Cabeçalho e Rodapé */
header {
    width: 100%;
    text-align: center;
    padding: clamp(5px, 1vh, 10px) 0; /* Padding vertical dinâmico (Reduzido) */
    background-color: rgba(0, 0, 0, 0.6);
}

header h1 {
    font-size: clamp(1.1em, 3vw, 1.8em); /* Fonte fluida para o título principal (Reduzida) */
    margin: 0;
}

footer {
    width: 100%;
    padding: clamp(5px, 1vh, 10px) 25px; /* Padding dinâmico (Reduzido) */
    background-color: rgba(0, 0, 0, 0.6);
    font-size: clamp(0.6em, 1.8vw, 0.8em); /* Fonte fluida (Reduzida) */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Permite que o conteúdo quebre a linha em telas pequenas */
    gap: 10px;
}
footer a {
    color: var(--team-a-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Overlay de Contagem Regressiva */
#countdown-overlay {
    position: fixed; /* Fixo para cobrir a tela inteira, independente da rolagem */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

#countdown-number {
    font-size: clamp(8em, 25vw, 15em); /* Fonte fluida */
    font-weight: bold;
    color: #fff;
}

/* Ecrã de Fim de Jogo */
.end-screen {
    position: fixed; /* Fixo para cobrir a tela inteira */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.end-screen-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    background-color: rgba(68, 68, 68, 0.9);
    border-radius: 10px;
    text-align: center;
}

.end-screen h1 {
    margin-bottom: 30px;
}

#end-stats {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
    font-size: 1.5em;
}

#end-stats div {
    padding: 20px;
    border: 2px solid #888;
    border-radius: 10px;
    min-width: 180px; /* Garante que os quadrados tenham a mesma largura */
}

#end-stats .winner-highlight {
    border-color: #ffd700; /* Dourado para destacar o vencedor */
    box-shadow: 0 0 15px #ffd700;
}

#end-summary {
    margin-top: 20px;
    margin-bottom: 30px;
    padding: 15px;
    border-top: 1px solid #888;
    border-bottom: 1px solid #888;
    width: 100%;
    font-size: 1.1em;
}

#play-again-btn {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: var(--team-b-color); /* Themed green */
    color: white;
}

.end-screen.victory-bg {
    background-image: url('VictoryBG.png');
}

.end-screen.drawn-bg {
    background-image: url('DrawnBG.png');
}

/* Painel de Debug */
#debug-panel {
    position: absolute;
    top: 80px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #fff;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
    color: #0f0;
    z-index: 1000;
    white-space: pre; /* Mantém a formatação do texto */
}

/* --- Media Queries para Responsividade --- */
@media (max-width: 800px) {
    /* Ajusta o layout principal para empilhar verticalmente */
    .game-container {
        flex-direction: column;
        justify-content: center;
        gap: 15px;
        padding: 15px;
    }

    /* Ajusta as áreas das equipas */
    .team-area {
        width: 100%;
        min-height: 180px; /* Altura mínima para acomodar o conteúdo */
        padding: 10px;
    }

    /* Ajusta o painel central */
    .central-panel {
        width: 100%;
        min-height: auto; /* Remove a altura mínima fixa */
        padding: 15px;
        order: -1; /* Move o painel central para o topo no layout de coluna */
    }

    #logo {
        max-width: 80px;
        max-height: 80px;
    }

    /* Ajusta o formulário de setup */
    .setup-form {
        width: 90%;
        padding: 20px;
    }

    /* Ajusta o rodapé */
    footer {
        justify-content: center; /* Centraliza o conteúdo no rodapé */
        font-size: 0.8em;
    }
}