@font-face {
    font-family: 'PressStart2P';
    src: url('PressStart2P-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PressStart2P', Arial, sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh; 
    margin: 0;
    padding: 0;
    overflow: hidden; 
    background-color: #000; 
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none; 
    font-family: Arial, sans-serif;
}

#game-container {
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    margin: 0;
    background-color: #000;
}

#ui-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 6px 10px;
    background-color: #000;
    flex-shrink: 0;
}

.team-char {
    height: 60px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.active-turn {
    border: 3px solid #F44336;
    box-shadow: 0 0 15px #F44336;
    transform: scale(1.1);
}

#scoreboard {
    position: relative;
    width: 150px;
    text-align: center;
}

.placar-bg {
    width: 100%;
    display: block;
}

#scoreboard span {
    position: absolute;
    top: 65%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: bold;
    color: white;
}

#score-team1 { left: 16px; }
#score-team2 { right: 16px; }

#canvas-wrapper {
    position: relative;
    width: 100%;
    flex: 1; 
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #000;
}

canvas {
    background-color: #000;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100dvh;
    object-fit: contain; 
}

/* --- Menu Unificado --- */
#setup-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10; 
}

/* Modos de Jogo (Botões Grandes) */
.btn-main-mode {
    width: 100%;
    padding: 25px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 5px rgba(0,0,0,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-main-mode:active {
    box-shadow: 0 0 rgba(0,0,0,0.5);
    transform: translateY(5px);
}

/* Cores de Status */
.status-red { color: #F44336; transition: color 0.3s; }
.status-green { color: #4CAF50; transition: color 0.3s; }
.status-gray { color: #777; transition: color 0.3s; }

.disabled-section {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.3s;
}

#setup-screen h2, #setup-screen h3 {
    margin: 5px 0;
    text-shadow: 2px 2px #000;
    text-align: center;
}

/* Grid de Times (3x2) */
.team-page {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 95%;
    max-width: 380px;
    margin: 0 auto;
    background-color: #222;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #555;
}

.char-select, .btn-plus, .slot-empty {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}
.char-select:hover { transform: scale(1.08); }
.char-select.disabled { pointer-events: none; opacity: 0.8; filter: grayscale(100%); }

.btn-plus {
    background-color: #333;
    color: #ffd700;
    font-size: 36px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ffd700;
}
.slot-empty { background-color: transparent; border: none; cursor: default; }

/* Botões Esticados */
.btn-group {
    display: flex;
    gap: 10px;
    width: 95%;
    max-width: 380px;
    margin: 0 auto;
}
.btn-group .btn {
    flex: 1;
    padding: 15px 0;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background-color: #444;
    border: 2px solid #777;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}
.btn-group .btn:active { background-color: #555; transform: scale(0.95); }

/* Gols Visor */
.goals-counter { align-items: center; }
.goal-number {
    flex: 1;
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    color: white;
}

/* Input da Sala */
.input-room {
    width: 95%;
    max-width: 380px;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #555;
    background-color: #222;
    color: white;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    outline: none;
}
.input-room:focus { border-color: #FF9800; }

/* Resumo da Partida */
.summary-box {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px dashed #ffd700;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    width: 95%;
    max-width: 380px;
    text-align: center;
}
.summary-box p { color: white; margin: 10px 0 0 0; font-size: 14px; font-weight: bold; }
#summary-teams { font-size: 20px; color: #ffd700; }

.summary-empty { background-color: transparent !important; border: 2px dashed #444 !important; }
.summary-empty p, .summary-empty h3 { color: #666 !important; }
.summary-empty #summary-teams { color: #666 !important; }

/* Botões Finais de Ação */
.btn-start {
    font-size: 18px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px rgba(0,0,0,0.4);
    transition: 0.2s;
    padding: 15px;
}
.btn-start:disabled {
    background-color: #444 !important;
    color: #777 !important;
    cursor: not-allowed;
    box-shadow: none;
}
.btn-start:not(:disabled):active {
    box-shadow: 0 0 #000;
    transform: translateY(4px);
}

/* Modais Base (Join/Waiting) */
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal-box {
    background-color: #222;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #555;
    text-align: center;
    width: 85%;
    max-width: 350px;
    position: relative;
}
.btn-close-modal {
    position: absolute;
    top: 10px; right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}
.modal-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid #777;
    background-color: #333;
    color: white;
    font-size: 16px;
    text-align: center;
}
.btn-auth {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.btn-auth:disabled { background-color: #555 !important; color: #888; }
@keyframes piscar { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* --- TELA INICIAL (SPLASH) --- */
#splash-screen {
    position: absolute;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    background: #000 url('images/INICIAL.png') center/contain no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    z-index: 25;
    padding-bottom: 10vh; /* Afasta o texto do fundo da tela */
    cursor: pointer;
}

#btn-iniciar {
    background-color: transparent;
    color: white;
    font-size: 14px;
    font-weight: bold;
    border: none;
    animation: piscar 1s infinite; /* Usa a animação de piscar que já criamos */
    cursor: pointer;
    text-shadow: 2px 2px 4px #000; /* Garante que dê pra ler independente do fundo */
}

/* Trava a largura das telas de menu no computador para simular o tamanho de um celular */
#section-mode, #section-setup {
    max-width: 380px !important;
    margin: 0 auto !important;
}

@media (max-width: 600px), (max-height: 850px) {
    
    #setup-screen {
        justify-content: flex-start !important; 
        padding-top: max(15px, env(safe-area-inset-top)) !important;
        padding-bottom: max(15px, env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important; 
        gap: 1.5vh !important; 
    }

    #setup-screen > * {
        max-width: 350px !important; 
        margin-top: 0 !important;    
        margin-bottom: 0 !important;
    }

    /* --- COLOQUE AS REGRAS NOVAS AQUI --- */
    #section-setup {
        justify-content: flex-start !important; 
        min-height: 100% !important;
        gap: 15px !important; 
        padding-bottom: 20px !important;
    }

    #section-setup > div:last-child {
        margin-top: auto !important; 
    }

    .btn-start {
        min-height: 55px !important;
    }
    /* ------------------------------------ */

    .btn-group .btn {
        padding: 10px 0 !important; 
    }
    .btn-arrow {
        padding: 8px !important; 
    }
    .summary-box {
        padding: 10px !important; 
    }
    .summary-box p {
        margin: 5px 0 0 0 !important; 
    }
}

/* --- TELA DE SELEÇÃO DE IDIOMA --- */
#lang-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#lang-screen h2 {
    text-align: center;
    line-height: 1.5;
    color: white;
    margin-bottom: 40px;
    font-size: 14px;
}

/* O Botão agora é a própria bandeira */
.lang-btn {
    width: 90%;
    max-width: 350px; /* Impede a bandeira de ficar gigante no PC */
    height: 20vh; /* Exatamente 20% da altura da tela */
    margin-bottom: 25px; /* Margem entre elas */
    border: 3px solid #555;
    border-radius: 12px;
    cursor: pointer;
    padding: 0;
    position: relative;
    overflow: hidden; /* Corta as quinas da bandeira para respeitar o arredondamento */
    transition: transform 0.2s, border-color 0.2s;
}

/* ==========================================================================
   BANDEIRAS DESENHADAS EM CSS PURO
========================================================================== */

/* Tela de pintura e limites da bandeira */
.flag-icon { width: 22px; height: 14px; position: relative; overflow: hidden; display: inline-block; border-radius: 2px; vertical-align: middle; opacity: 0.95; }

/* 🇧🇷 BANDEIRA DO BRASIL */
.flag-br { background: #009c3b; }
.flag-br::before { content: ''; position: absolute; top: 10%; left: 10%; right: 10%; bottom: 10%; background: #ffdf00; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.flag-br::after { content: ''; position: absolute; top: 28%; left: 35%; width: 30%; height: 44%; background: #002776; border-radius: 50%; }

/* 🇬🇧 BANDEIRA DO REINO UNIDO (Matemática de Gradientes) */
.flag-en { background: linear-gradient(0deg, transparent 40%, #c8102e 40%, #c8102e 60%, transparent 60%), linear-gradient(90deg, transparent 43%, #c8102e 43%, #c8102e 57%, transparent 57%), linear-gradient(0deg, transparent 33%, #fff 33%, #fff 67%, transparent 67%), linear-gradient(90deg, transparent 35%, #fff 35%, #fff 65%, transparent 65%), linear-gradient(33deg, transparent 46%, #c8102e 46%, #c8102e 54%, transparent 54%), linear-gradient(-33deg, transparent 46%, #c8102e 46%, #c8102e 54%, transparent 54%), linear-gradient(33deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%), linear-gradient(-33deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%), #012169; }

/* 🇪🇸 BANDEIRA DA ESPANHA */
.flag-es { background: linear-gradient(180deg, #c60d1f 25%, #ffc400 25%, #ffc400 75%, #c60d1f 75%); }
.flag-es::before { content: ''; position: absolute; top: 35%; left: 20%; width: 15%; height: 30%; background: #c60d1f; border-radius: 1px; }

/* ========================================= */
/* --- BANNERS DE CRÉDITOS (PARTIDA) --- */
/* ========================================= */
.credit-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px; 
    flex: 1; /* Faz os dois banners dividirem a tela em exatos 50/50 */
    background-color: transparent; 
    border: 1px dashed #444; 
    border-radius: 6px;
    padding: 4px; 
    text-decoration: none;
    transition: transform 0.2s, border-color 0.2s;
    text-align: center;
}

/* O efeito de clique e borda amarela funciona apenas no banner que é Link (<a>) */
a.credit-banner {
    cursor: pointer;
}

a.credit-banner:active {
    transform: scale(0.97);
    border-color: #ffd700;
}

.banner-text-small {
    color: #888; 
    font-size: 6px; 
    line-height: 1; 
}

.banner-text-highlight {
    color: #ffd700;
    font-size: 8px; 
    font-weight: bold;
    line-height: 1;
    text-shadow: 1px 1px 0px #000;
}

/* --- BOTÃO CRIADO POR (RODAPÉ DO MENU) --- */
.btn-credits-menu {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    width: 100%;
    height: 5em;
    border: none;
    color: #888;
    font-size: 10px;
    cursor: pointer;
    text-decoration: underline;
    text-align: center;
    font-family: 'PressStart2P', Arial, sans-serif;
    transition: color 0.2s, transform 0.2s;
}

.btn-credits-menu:active {
    color: #ffd700;
    transform: translateX(-50%) scale(0.95);
}