/* style.css (v9.6 - Audio Visual Feedback) */

/* ... (TODO O CSS ANTERIOR MANTIDO) ... */
body, html { 
    margin: 0; padding: 0; 
    height: 100%; 
    width: 100%;
    overflow: hidden; /* Trava rolagem da página */
    font-family: 'Segoe UI', sans-serif;
    background-color: #2e7d32; 
    background-image: url('img/feltro.jpg'); 
    background-size: cover;
    user-select: none;
    -webkit-user-select: none;
}

#main-container { 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    height: 100dvh; 
    width: 100vw; 
}

/* --- ÁREA SUPERIOR (Mesa + Sidebar) --- */
#area-superior {
    display: flex; 
    flex: 1; 
    height: calc(100% - 160px); 
    width: 100%; 
    overflow: hidden;
}

#mesa-verde { 
    flex: 1; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    overflow-x: hidden;
}

#sidebar-madeira {
    width: 224px; 
    background-image: url('img/table-glass.jpg'); 
    background-size: cover;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 20px;
    z-index: 20; 
    height: 100%; 
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
}

/* --- ÁREA INFERIOR (MÃO) --- */
#minha-mao-area {
    height: 160px; 
    width: 100%; 
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 0 10px; 
    border-top: 2px solid rgba(255,255,255,0.1); 
    transition: border-color 0.3s; 
    z-index: 100; 
}

#minha-mao-container { 
    flex: 1; 
    display: flex; 
    justify-content: center; 
    align-items: center;
}

/* --- ELEMENTOS VISUAIS --- */

.logo-area {
    width: 100%;
    max-width: 180px;
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.morto-area {
    width: 120px; 
    height: 120px; 
    position: relative;
    display: flex; 
    align-items: center; 
    justify-content: center;
    margin-bottom: auto; 
}
.pilha-morto {
    width: 70px; 
    height: 105px; 
    position: absolute;
    background-size: cover; 
    background-position: center;
    border-radius: 6px; 
    box-shadow: 2px 2px 6px rgba(0,0,0,0.5);
    border: 4px solid #fff; 
    transition: opacity 0.5s;
}
.morto-vermelho { background-image: url('img/carta-vermelha.jpg'); z-index: 1; }
.morto-azul { background-image: url('img/carta-azul.jpg'); transform: rotate(90deg); z-index: 2; box-shadow: 4px 4px 8px rgba(0,0,0,0.6); }

/* --- OPONENTES --- */
.player-row { 
    display: flex; 
    align-items: flex-start; 
    padding: 15px; 
    min-height: 140px; 
    border-bottom: 1px dashed rgba(255,255,255,0.1); 
    width: 100%;
}

.player-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 20px;
    flex-shrink: 0;
    width: 120px; 
}

.player-info { 
    width: 100%; 
    background: rgba(0,0,0,0.6); 
    padding: 8px; 
    border-radius: 8px; 
    color: white; 
    text-align: center; 
    border: 2px solid transparent; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.3); 
    position: relative; 
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; /* Adicionado transição */
}

.player-info::before {
    content: '\f007'; 
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    display: block;
    width: 30px; height: 30px;
    line-height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    margin: 0 auto 5px auto;
    font-size: 16px;
    border: 1px solid rgba(255,255,255,0.4);
}
.nome-player { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-cards-row {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    padding-left: 5px;
}

.mini-card {
    width: 14px; height: 20px;
    border-radius: 2px;
    border: 1px solid white;
    background-size: cover;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    margin-left: -8px; 
    margin-top: -14px;  
    position: relative;
}
.mini-card:hover { transform: scale(1.5); z-index: 50; }
.mini-card-red { background-image: url('img/carta-vermelha.jpg'); }
.mini-card-blue { background-image: url('img/carta-azul.jpg'); }

.counter-badge {
    position: absolute; top: -8px; right: -8px;
    background: #12808e; color: white; border-radius: 50%;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: bold; border: 2px solid white; z-index: 10;
}
.player-info .counter-badge { opacity: 0; left: -8px; right: auto; background: #6c757d; }
.player-info:hover .counter-badge { opacity: 1; }

.deck-badge { background: #fff; color: #333; border-color: #333; }
.bateu-badge {
    position: absolute; top: -10px; right: -15px;
    background: #dc3545; color: white; border-radius: 4px;
    padding: 2px 5px; font-size: 9px; font-weight: bold; 
    border: 1px solid white; z-index: 11;
    white-space: nowrap; animation: pulsar 1s infinite;
}

.jogos-baixados-area { 
    flex: 1; 
    display: flex; 
    gap: 15px; 
    overflow-x: auto; 
    align-items: center; 
    padding: 10px 5px;
}
.jogos-baixados-area::-webkit-scrollbar { height: 6px; }
.jogos-baixados-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }

#meus-jogos-row { 
    margin-top: auto; 
    padding: 10px 20px; 
    background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
}
.label-meus-jogos { font-size: 14px; font-weight: bold; color: rgba(255,255,255,0.6); text-transform: uppercase; margin-bottom: 5px; }

.mesa-tools { 
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%); 
    display: flex; flex-direction: column; gap: 15px; z-index: 10; 
}

.pilha-mesa {
    width: 75px; height: 105px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.2s;
    position: relative;
}
.pilha-mesa:hover { transform: scale(1.05); }

#lixo { 
    border: 2px dashed rgba(255,255,255,0.6); 
    background: rgba(0,0,0,0.3); color: white; backdrop-filter: blur(2px);
}
#deck { 
    border: 4px solid white;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.5);
    background-color: #1b5e20; 
    background-size: cover;
}
.deck-vermelho { background-image: url('img/carta-vermelha.jpg'); }
.deck-azul { background-image: url('img/carta-azul.jpg'); }

/* --- CARTAS E EFEITOS (ATUALIZADO) --- */
.card-game {
    width: 70px; height: 100px; background-color: white; border-radius: 5px;
    display: inline-block; position: relative; box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
    cursor: pointer; color: black; font-family: 'Arial', sans-serif;
}
.hand-card { margin-left: -35px; transition: transform 0.2s; }
.hand-card:first-child { margin-left: 0; }

/* HOVER DESKTOP: Apenas sobe, SEM empurrar horizontalmente */
.hand-card:hover { 
    transform: translateY(-30px); 
    z-index: 100; 
    /* margin-right: 20px; -> REMOVIDO PARA EVITAR MOVIMENTO LATERAL */
}

.hand-card.selected {
    background-color: #97ce65d4;
    border: 2px solid #8bc34a;
    transform: translateY(-40px);
    z-index: 101;
    box-shadow: 0 0 15px #8bc34a;
    backdrop-filter: blur(2px);
}

.table-card { margin-right: -35px; width: 60px; height: 90px; cursor: default; }
.table-card:first-child { margin-left: 0; }

.grupo-jogo {
    position: relative;
    margin-right: 20px;
    display: flex; background: rgba(0,0,0,0.15); padding: 4px 10px 4px 4px;
    border-radius: 6px; transition: transform 0.2s; border: 2px solid transparent;
}
.grupo-jogo.meu-jogo:hover { background: rgba(255,255,255,0.2); border-color: #ffeb3b; }

.canastra-limpa { background: rgba(76, 175, 80, 0.3) !important; border-color: #4caf50 !important; }
.canastra-suja { background: rgba(255, 193, 7, 0.3) !important; border-color: #ffc107 !important; }
.canastra-real { background: rgba(33, 150, 243, 0.3) !important; border-color: #2196f3 !important; }
.canastra-royal { background: rgba(156, 39, 176, 0.3) !important; border-color: #9c27b0 !important; }

.naipe-vermelho { color: #d32f2f; } .naipe-preto { color: #212121; }
.card-top { position: absolute; top: 4px; left: 5px; font-size: 16px; font-weight: bold; line-height: 1; text-align: center; }
.card-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 36px; }

@keyframes highlight-pulse { 0% { box-shadow: 0 0 5px #ffeb3b; transform: translateY(-5px); } 50% { box-shadow: 0 0 15px #ffeb3b; transform: translateY(-10px); } 100% { box-shadow: 0 0 5px #ffeb3b; transform: translateY(-5px); } }
.card-new { animation: highlight-pulse 2s infinite; border: 2px solid #ffeb3b !important; z-index: 50;     margin-bottom: -75px;}

.pegou-morto-bg { background-color: rgba(255, 235, 59, 0.1) !important; border-top: 2px solid #ffeb3b !important; }
.pegou-morto-border { border: 2px solid #ffeb3b !important; box-shadow: 0 0 10px rgba(255, 235, 59, 0.4); position: relative; }
.pegou-morto-border::after { content: '💀'; position: absolute; top: -8px; right: 5px; background: #ffeb3b; color: #333; font-size: 10px; font-weight: bold; padding: 1px 4px; border-radius: 4px; }

@keyframes piscar-borda { 0% { border-color: #00e676; } 50% { border-color: #69f0ae; box-shadow: 0 0 10px #69f0ae; } 100% { border-color: #00e676; } }
@keyframes piscar-fundo-mao { 0% { border-color: #00e676; background-color: rgba(238, 190, 58, 0.307); } 50% { border-color: #69f0ae; background-color: rgba(230, 161, 0, 0.459); } 100% { border-color: #00e676; background-color: rgba(0, 230, 118, 0.1); } }
.vez-ativa { animation: piscar-borda 1.5s infinite; }
#minha-mao-area.vez-ativa { animation: piscar-fundo-mao 1.5s infinite; }

#toast-container { position: absolute; top: 20px; right: 20px; width: 300px; z-index: 2000; pointer-events: none; }
.toast { pointer-events: auto; }

/* ====================================
   GAME OVER - GLASSMORPHISM
   ==================================== */
#game-over-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 9999; display: none; flex-direction: column; align-items: center; justify-content: center; color: white; }

.game-over-card {
    background: #1e1e245c;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    text-align: center;
    max-width: 90%;
    width: 600px;
    border: 1px solid #2f2f2f;
    backdrop-filter: blur(13px);
    box-shadow: inset 0px 0px 70px 1px rgba(255, 255, 255, 0.12);
    position: relative; /* Para posicionar o botão X */
}

/* BOTÃO FECHAR (X) */
.btn-close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}
.btn-close-modal:hover { color: white; }

/* BOTÃO ABRIR PLACAR (Flutuante) */
#btn-open-score {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1000;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #ffc107;
    color: #333;
    border: 2px solid #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}
#btn-open-score:hover { transform: scale(1.1); }

.scoreboard-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    margin-top: 10px;
    color: #eee;
}

.scoreboard-table th {
    text-transform: uppercase;
    font-size: 0.8rem;
    color: #888;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

.scoreboard-table td {
    padding: 15px 10px;
    background: #5f5f5f4d;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}

.scoreboard-table tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-left: 1px solid #333;
}

.scoreboard-table tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-right: 1px solid #333;
}

.vencedor-row td {
    background: linear-gradient(90deg, #2e7d3233, #1b5e2066);
    border-color: #4caf50;
    color: #fff;
}

.meu-score td { border-color: #2196f3; }
.score-total { font-size: 1.2rem; font-weight: bold; color: #ffd700; }

.game-badge-score {
    position: absolute; top: -10px; right: -10px;
    background: #333; color: white; border-radius: 50%; width: 30px; height: 30px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 9px; font-weight: bold; border: 1px solid white; z-index: 10; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.grupo-jogo:hover .game-badge-score { opacity: 1; }
.score-num { font-size: 11px; line-height: 1; }
.score-label { font-size: 7px; text-transform: uppercase; color: #aaa; }

#btn-mic-toggle { transition: transform 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.3); z-index: 1000; }
#btn-mic-toggle:active { transform: scale(0.95); }
#btn-mic-toggle.btn-success { animation: pulseMic 2s infinite; box-shadow: 0 0 10px #00e676; }
@keyframes pulseMic { 0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(0, 230, 118, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); } }

.badge-topo{
    position:absolute;
    top:10px; 
    left:50%;
    transform:translateX(-50%);
    z-index:50; 
    color:white; 
    background:rgba(0,0,0,0.3); 
    padding:5px 15px;
    border-radius:15px; 
    font-size:12px;
}

/* NOVO: Feedback Visual de Voz (FALANDO) */
.speaking {
    border-color: #0d6efd !important;
    box-shadow: 0 0 15px #0d6efd !important;
    transition: all 0.1s;
}

/* =========================================================
   MOBILE (Refeito para layout vertical limpo)
   ========================================================= */
@media (max-width: 768px) {
    
    #main-container { height: 100dvh; }
    #area-superior { flex-direction: column; height: calc(100% - 140px); }

    #sidebar-madeira {
        width: 100%; height: 60px; 
        min-height: auto;
        flex-direction: row;
        padding: 0 15px;
        justify-content: space-between;
        position: relative;
    }

    .logo-area { display: none; }
    .morto-area { width: auto; height: 100%; margin: 0; transform: scale(0.6); transform-origin: left center; }
    #toast-container {
        top: 7px;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        align-items: center; 
    }

    #mesa-verde { padding: 10px 0; }

    .player-row {
        height: auto; min-height: auto; padding: 5px 10px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        flex-direction: column; align-items: flex-start;
    }
    
    .player-wrapper { width: 100%; flex-direction: row; justify-content: flex-start; margin-right: 0; margin-bottom: 5px; }
    .player-info {
        width: auto;
        background: rgb(0 0 0 / 14%);
        box-shadow: none;
        padding: 0;
        display: flex;
        align-items: center;
        border: none;
        padding-right: 10px;
        border-radius: 14px;
    } 
    .player-info::before { width: 24px; height: 24px; line-height: 24px; font-size: 12px; margin: 0 8px 0 0; }
    .nome-player { font-size: 0.9rem; font-weight: bold; margin-left: 5px;}
    
    .mini-cards-row { display: none; }
    .player-info .counter-badge { position: static; opacity: 1; margin-left: 10px; background: #444; border: 1px solid #aaa; }

    .jogos-baixados-area { width: 100%; padding: 5px 0; min-height: 80px; }

    .mesa-tools {
        position: static; transform: none; flex-direction: row; justify-content: center;
        width: 100%; margin: 10px 0; gap: 20px; order: 2;
    }

    #area-op1 { order: 1; } #area-op2 { order: 1; }
    #meus-jogos-row { order: 3; margin-top: 10px; background: none; padding: 5px 10px; }

    /* CARTAS MOBILE AJUSTADAS */
    .card-game {
        width: 55px; height: 80px; /* Aumentei um pouco para facilitar visão */
        font-size: 12px;
        border-radius: 4px;
        box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    }
    .card-top { left: 2px; top: 1px; font-size: 12px; }
    .card-center { font-size: 24px; }
    
    .grupo-jogo .card-game { margin-right: -35px; }
    .grupo-jogo { margin-right: 10px; padding: 2px; }
    
    .table-card { width: 55px; height: 80px; margin-right: -35px; }
    .pilha-mesa { width: 65px; height: 90px; }
    #lixo, #deck { width: 65px; height: 90px; }

    /* MÃO DO JOGADOR */
    #minha-mao-area {
        height: 140px;
        padding: 5px 0;
        flex-direction: column;
        justify-content: flex-end;
        background: #00000054;
        backdrop-filter: blur(1px);
    }
    
    #minha-mao-container {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start; 
        padding: 0 15px;
        width: 100%;
        align-items: center;
    }

    #minha-mao-container .hand-card { margin-left: -35px; transition: transform 0.2s; }

    .hand-card:hover { 
        transform: translateY(-20px); 
        z-index: 100; 
        /* margin-right: 20px; -> REMOVIDO PARA EVITAR MOVIMENTO LATERAL */
    }

    .hand-card.selected {
        transform: translateY(-25px); z-index: 999; box-shadow: 0 0 15px #8bc34a;
    }
    
    /* Centraliza o grupo de cartas se não preencherem a tela */
    #minha-mao-container .card-game:first-child { margin-left: auto; }
    #minha-mao-container .card-game:last-child { margin-right: auto; }
    
    #minha-mao-container::after { content: ""; flex: 0 0 30px; height: 1px; }

    #btn-mic-toggle { bottom: 150px; right: 10px; width: 45px; height: 45px; font-size: 1.2rem; }

    .badge-topo {
        top: 13px;
        right: 8px;
        left: initial;
        padding: 5px 15px;
        border-radius: 15px;
        font-size: 12px;
        transform: translateX(0);
    }

    /* POSICIONAMENTO BOTÃO PLACAR MOBILE */
    #btn-open-score {
        top: 13px;
        left: 8px; /* Lado oposto do badge/sidebar */
        width: 35px; height: 35px;
        font-size: 1rem;
    }

    /* GAME OVER RESPONSIVO MOBILE */
    .game-over-card {
        width: 95%;
        padding: 15px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .game-over-card h1 {
        font-size: 1.5rem;
        margin-bottom: 15px !important;
    }

    .scoreboard-table {
        font-size: 0.75rem; 
        display: block; 
        overflow-x: auto;
        white-space: nowrap;
    }

    .scoreboard-table th, .scoreboard-table td {
        padding: 8px 5px; 
    }
    
    /* Limita nome do jogador */
    .scoreboard-table td:nth-child(2) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}