/* ======================================================
   STYLE-TORNEIO.CSS - Versão Final Consolidada
   ====================================================== */

/* --- 1. LOBBY DE SERVIDORES (Tela Inicial) --- */
#screen-server-lobby {
    width: 100%;
    height: 100vh;
    background: var(--dark-bg);
    overflow: hidden; /* A página inteira não rola */
    display: flex;
    align-items: center;
    justify-content: center;
}

.lobby-content-wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
}

/* CAIXA PRINCIPAL (Esquerda) */
.server-lobby-box {
    background: white; 
    padding: 15px; 
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2); 
    
    flex: 1;
    min-width: 320px; /* Largura mínima para não quebrar */
    max-width: 500px;
    
    /* CORREÇÃO DE ROLAGEM: */
    max-height: 95vh; /* Nunca ultrapassa a altura da tela */
    overflow-y: auto; /* Cria barra de rolagem se necessário */
    
    display: flex;    
    flex-direction: column; 
    text-align: center; 
    position: relative; 
}

/* Estilo da barra de rolagem da caixa */
.server-lobby-box::-webkit-scrollbar { width: 6px; }
.server-lobby-box::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.server-lobby-box::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.server-lobby-box::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--gold));
}

.server-lobby-box h2 { 
    margin-top: 10px; margin-bottom: 5px;
    color: var(--primary); font-size: 1.6rem; 
}

.server-lobby-box h3 { 
    color: #7f8c8d; font-size: 0.9rem; margin: 15px 0 5px 0; text-transform: uppercase;
}

/* Lista de Salas */
.lista-salas {
    /* Altura controlada para deixar espaço para os inputs */
    max-height: 180px; 
    min-height: 80px;
    overflow-y: auto; 
    margin-bottom: 10px; padding: 5px;
    display: flex; flex-direction: column; gap: 5px;
    border: 1px solid #eee; border-radius: 8px;
}
.lista-salas::-webkit-scrollbar { width: 4px; }
.lista-salas::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.sala-item {
    background: #f8f9fa; border: 1px solid #e1e8ed; padding: 10px;
    border-radius: 8px; display: flex; justify-content: space-between; align-items: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.badge-livre { background: var(--success); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight:bold; }
.badge-ocupado { background: var(--accent); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight:bold; }

/* Inputs e Formulários Compactos */
#input-nova-sala, #input-senha-sala, #input-modo-vitoria {
    width: 100%; padding: 10px; margin-bottom: 8px;
    border-radius: 5px; border: 1px solid #ddd; font-size: 0.9rem;
}

/* Grid de Prêmios */
#container-premios-letras {
    display: grid; grid-template-columns: 1fr 1fr; gap: 5px; text-align: left;
}
#container-premios-letras input {
    padding: 8px; font-size: 0.85rem; border: 1px solid #ddd; border-radius: 4px; width: 100%;
}
#container-premio-cheia input {
    padding: 10px; font-weight: bold; font-size: 0.9rem; border-radius: 4px; width: 100%;
}

/* Botões */
.btn-confirm {
    margin-top: 15px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    background: var(--success);
    color: white;
    transition: transform 0.1s;
}
.btn-confirm:active { transform: scale(0.98); }
.btn-confirm:disabled { background: #ccc; cursor: not-allowed; }

.btn-cancel {
    margin-top: 10px;
    font-size: 0.9rem;
    padding: 8px;
    color: #7f8c8d;
    cursor: pointer;
    background: none; border: none;
}
.btn-cancel:hover { text-decoration: underline; color: var(--accent); }

/* --- PUBLICIDADE (Direita) --- */
.ad-container {
    width: 300px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    height: 450px; 
    flex-shrink: 0;
}

.ad-header {
    background: var(--primary); color: white; padding: 10px;
    text-align: center; font-weight: bold; font-size: 0.9rem; letter-spacing: 1px;
}

/* Estilos do Carrossel */
.ad-content {
    flex: 1; 
    background: #eee;
    display: flex; justify-content: center; align-items: center;
    color: #999; text-align: center;
    position: relative;
    padding: 0 !important;
    overflow: hidden;
}

.carousel-slide {
    display: none; width: 100%; height: 100%;
    flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 15px; box-sizing: border-box;
    animation: fadeEffect 1s;
}
.carousel-slide.ativa { display: flex; }

.carousel-slide img, .carousel-slide video {
    max-width: 100%; max-height: 250px; object-fit: contain;
    border-radius: 8px; margin-bottom: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.carousel-slide div {
    font-size: 1.1rem; font-weight: bold; color: #555; word-break: break-word;
}
@keyframes fadeEffect { from {opacity: 0.4;} to {opacity: 1;} }


/* ======================================================
   --- 2. LAYOUT DO JOGO (3 COLUNAS) ---
   ====================================================== */
.main-layout-torneio {
    display: flex;
    width: 100%; height: 100vh;
    overflow: hidden;
    background: var(--dark-bg);
}

/* Coluna 1: Sidebar Esquerda (Sorteio) */
.sidebar {
    background: #2c3e50; color: white;
    width: 220px; padding: 15px;
    display: flex; flex-direction: column; align-items: center;
    box-shadow: 4px 0 15px rgba(0,0,0,0.3); z-index: 10;
    flex-shrink: 0; overflow-y: auto;
}

/* Coluna 2: Container Central (Cartela) */
.container-jogo {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: 10px; overflow-y: auto;
    background: var(--dark-bg);
    scrollbar-width: none;
}
.container-jogo::-webkit-scrollbar { display: none; }

/* Coluna 3: Sidebar Direita (Jogadores/Chat) */
.sidebar-right {
    width: 280px;
    background: #2c3e50;
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column;
    padding: 15px;
    box-shadow: -4px 0 15px rgba(0,0,0,0.3); z-index: 10;
    flex-shrink: 0;
}

/* Elementos do Jogo */
#status-sorteio { font-size: 1.5rem; color: var(--gold); margin-bottom: 15px; text-align: center; }
#bola-atual {
    width: 110px; height: 110px; background: #fff; border: 5px solid #f1c40f;
    border-radius: 50%; display: flex; flex-direction: column;
    justify-content: center; align-items: center; margin-bottom: 15px;
}
#bola-atual > div:first-child { font-size: 1.5rem; color: #333; font-weight: bold; margin-bottom: -5px; }
#bola-atual > div:last-child { font-size: 3.5rem; color: #333; font-weight: 900; }

#ultimas-bolas {
    display: flex; justify-content: center; gap: 5px; margin-bottom: 20px;
    flex-wrap: wrap; background: rgba(0,0,0,0.2); padding: 5px; border-radius: 20px;
}

.mapa-sorteio {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; width: 100%; margin-bottom: auto;
}
.mapa-item {
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.5);
    font-size: 0.7rem; text-align: center; padding: 2px 0; border-radius: 2px;
}
.mapa-item.sorteado { background: var(--gold); color: #2c3e50; font-weight: bold; }

.btn-sair-jogo {
    background: #c0392b; color: white; padding: 10px; width: 100%; text-align: center;
    border-radius: 8px; font-weight: bold; text-decoration: none; cursor: pointer; 
    margin-top: 20px; display: block; border: none;
}

/* Prêmios e Cartela */
.painel-premios-top {
    background: white; padding: 10px; border-radius: 8px; margin-bottom: 10px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); width: 100%; max-width: 500px;
}
#lista-premios-game { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; font-size: 0.9rem; }

#area-player-cartela { width: 100%; display: flex; flex-direction: column; align-items: center; }
.titulo-jogador {
    color: var(--primary); margin-bottom: 10px; font-size: 1.3rem; text-transform: uppercase;
    display: flex; align-items: center; gap: 10px; background: white; padding: 8px 20px; border-radius: 10px;
}
.badge-trofeu-online {
    background: linear-gradient(135deg, #f1c40f, #f39c12); color: #fff;
    padding: 2px 8px; border-radius: 50px; font-size: 0.8rem; font-weight: bold;
}

.bingo-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px;
    background: #34495e; padding: 8px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); width: 95%; max-width: 450px;
}
.grid-cell { 
    background: white; aspect-ratio: 1/1; 
    display: flex; align-items: center; justify-content: center;
    font-family: 'Arial', sans-serif; font-size: clamp(1.2rem, 2.5vw, 2rem);
    font-weight: bold; color: #333; border-radius: 5px; cursor: default;
}
.header-cell { background: var(--accent); color: white; font-weight: bold; text-align: center; padding: 4px 0; font-size: 1rem; }
.grid-cell.marked { background: #ecf0f1; color: #bdc3c7; position: relative; }
.grid-cell.marked::after { content: 'X'; position: absolute; color: var(--accent); font-size: 2rem; opacity: 0.6; }
.grid-cell.sorteado-na-cartela { background: #fff9c4; border: 2px solid var(--gold); }
.grid-cell.free { background: var(--gold); color: white; font-size: 1.5rem; }
.por-uma-anim { animation: shake-card 0.5s infinite; box-shadow: inset 0 0 0 4px #e74c3c !important; }

/* Jogadores Live e Chat */
.lista-live {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
    min-height: 100px;
}
.player-live-item {
    background: rgba(255,255,255,0.05); padding: 8px; border-radius: 8px;
    font-size: 0.85rem; color: white; border: 1px solid rgba(255,255,255,0.05);
}
.live-badge.ganho { background: var(--gold); color: #333; padding: 2px 5px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; }

/* CHAT + EMOJI */
#chat-container {
    margin-top: 10px; display: flex; flex-direction: column; 
    height: 220px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px;
    position: relative; flex-shrink: 0;
}
#chat-mensagens {
    flex: 1; overflow-y: auto; background: rgba(0,0,0,0.3); 
    font-size: 0.8rem; padding: 8px; border-radius: 5px; margin-bottom: 5px; color: #eee;
}
#chat-input {
    flex: 1; background: rgba(255,255,255,0.1); border: none; padding: 8px;
    color: white; border-radius: 4px; outline: none;
}
#chat-container button[type="submit"] {
    background: var(--gold); border: none; width: 35px; margin-left: 5px;
    border-radius: 4px; cursor: pointer; color: #333;
}
.emoji-popup {
    position: absolute; bottom: 45px; left: 0; width: 100%;
    background: #2c3e50; border: 1px solid var(--gold); border-radius: 8px;
    padding: 10px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5); z-index: 100;
}
.emoji-popup span { font-size: 1.2rem; cursor: pointer; text-align: center; }
.emoji-popup span:hover { transform: scale(1.4); }

/* --- LOBBY DE ESPERA (Dentro da Sala) --- */
.lobby-container {
    background: var(--primary);
    padding: 30px; border-radius: 20px; width: 700px; max-width: 95%;
    color: white; display: flex; flex-direction: column; align-items: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1);
    max-height: 90vh; overflow-y: auto;
}
.lobby-player-item {
    background: rgba(255,255,255,0.05); padding: 10px 20px; border-radius: 50px;
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid rgba(255,255,255,0.1); margin-bottom: 8px;
}
.status-border-ready .lobby-player-status { color: #2ecc71; border: 1px solid #2ecc71; }

/* MODAIS */
.overlay-selecao {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: flex; justify-content: center; align-items: center; z-index: 5000;
}
.modal-selecao {
    background: #fff; width: 350px; max-width: 95%; border-radius: 20px; padding: 25px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5); text-align: center; border: 4px solid var(--gold);
}
.overlay-vitoria {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); display: flex; justify-content: center; align-items: center; z-index: 6000;
}
.conteudo-vitoria { text-align: center; animation: popIn 0.5s; }
.banner-vitoria { font-size: 4rem; color: gold; font-weight: 900; text-shadow: 0 0 20px orange; margin-bottom: 20px; }

/* ANIMAÇÕES */
@keyframes shake-card { 0% { transform: rotate(0deg); } 25% { transform: rotate(1deg); } 75% { transform: rotate(-1deg); } }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* RESPONSIVIDADE */
@media (max-width: 900px) {
    .lobby-content-wrapper { flex-direction: column; }
    .server-lobby-box, .ad-container { width: 100%; max-width: 450px; }
    .ad-container { height: 200px; margin-top: 20px; } /* Ad menor no mobile */
    .ad-content { display: none; } /* Opcional: esconder conteúdo se quiser */
    
    .main-layout-torneio { flex-direction: column; overflow-y: auto; height: auto; }
    .sidebar, .sidebar-right { width: 100%; height: auto; flex-shrink: 0; border: none; }
    .sidebar-right { order: 3; } .container-jogo { order: 2; } .sidebar { order: 1; }
    .mapa-sorteio { display: none; }
}