/* =========================================
   1. FONTES E VARIÁVEIS GERAIS
   ========================================= */

@font-face {
    font-family: 'Alata';
    src: url('fonts/Alata-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

:root {
    --bg-color: #02021c;
    --tile-default: #352b50;
    --tile-border: #655991;
    --tile-text: #FFFFFF;
    
    /* Cores de Feedback (Ajustadas para melhor contraste) */
    --color-correct: #355e37; /* Verde */
    --color-present: #b59f3b; /* Amarelo/Ouro */
    --color-absent: #15101e;  /* Mais escuro que o fundo */
    
    --key-bg: #211433;
    --key-hover: #4e4167;
}

/* =========================================
   2. ESTRUTURA BASE (BODY E LAYOUT)
   ========================================= */

html, body {
    touch-action: manipulation; /* Melhora a resposta ao toque em mobile */
    height: 100%;
}

body {
    /* Mantendo a imagem original e o posicionamento da logo */
    background-image: url("../imagens/app/logo-bg.jpg");
    background-position: center top;
    background-size: 1500px;
    background-repeat: no-repeat;
    background-color: var(--bg-color);

    font-family: "Alata", sans-serif !important;
    font-weight: 400 !important;
    color: var(--tile-text);
    overflow-x: hidden; /* Evita rolagem lateral */
}

/*
@media (display-mode: standalone) {
    .h100 {
        
        height: 100vh !important;
        height: calc(100vh - 60px) !important;

        height: calc(100vh - env(safe-area-inset-bottom)); 
    }
}
*/

.h100 {
    /* Fallback para navegadores antigos */
    height: 100vh;
    /* Solução moderna para mobile */
    height: 100dvh; 
    
    display: flex;
    flex-direction: column;
}


/* Espaço reservado para a logo que está na imagem de fundo */
.header {
    height: 145px;
    width: 100%;
    padding: 0;
}

/* Ícones e Botões do Header */
#open-ranking, #manual, #login-google, .user-info {
    cursor: pointer;
    transition: transform 0.2s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#open-ranking:hover, #manual:hover {
    transform: scale(1.05);
    color: #d8b4fe;
}

#login-google img {
    width: 24px;
}

.btn.btn-light {
    border-radius: 20px;
    padding: 4px 10px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

#user-photo {
    box-shadow: 0px 0px 9px 2px rgba(255,255,255,0.4);
    transition: border 0.2s;
}

/* =========================================
   3. TABULEIRO (GAME BOARD)
   ========================================= */

.game-board {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: start;
}

.letter-box {
    width: 55px;
    height: 55px;
    text-align: center;
    font-size: 28px; /* Aumentei levemente */
    font-weight: bold;
    text-transform: uppercase;
    margin: 3px;
    
    background-color: var(--tile-default);
    border: 2px solid var(--tile-border); /* Borda mais definida */
    color: var(--tile-text);
    border-radius: 5px; /* Leve arredondamento moderno */
    
    box-shadow: inset 0px 0px 13px 2px rgba(255, 255, 255, 0.1);
    user-select: none;
    outline: none;
    cursor: default; /* Mudado para default pois o input é automático */
    transition: border-color 0.1s, transform 0.1s;
}

/* Estado Ativo (Onde o usuário vai digitar) */
.letter-box.active {
    border-color: #ffffff;
    border-bottom-width: 4px;
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

.letter-box.disabled {
    opacity: 1; /* Mantém visibilidade total para leitura */
    pointer-events: none;
}

/* ANIMAÇÃO DE FLIP (O Efeito Wordle) */
.flip-in {
    animation: flip 0.6s ease forwards;
    backface-visibility: hidden;
}

@keyframes flip {
    0% { transform: rotateX(0); border-color: var(--tile-border); }
    45% { transform: rotateX(90deg); border-color: var(--tile-border); }
    55% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

/* Cores aplicadas após a lógica JS */
.letter-box.correct {
    background-color: var(--color-correct) !important;
    border-color: var(--color-correct) !important;
    box-shadow: none;
}

.letter-box.present {
    background-color: var(--color-present) !important;
    border-color: var(--color-present) !important;
    box-shadow: none;
}

.letter-box.absent {
    background-color: var(--color-absent) !important;
    border-color: var(--color-absent) !important;
    box-shadow: none;
    opacity: 0.8;
}

/* =========================================
   4. TECLADO VIRTUAL
   ========================================= */

.keyboard {
    width: 100%;
    max-width: 500px;
    margin: auto auto 35px auto;
    padding: 0 5px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 4px; /* Espaçamento uniforme */
    margin-bottom: 5px;
}

.key-button {
    flex: 1;
    height: 52px; /* Altura fixa para consistência */
    min-width: 28px;
    max-width: 45px;
    
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 6px;
    
    background-color: var(--key-bg);
    color: white;
    border: none;
    
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
}

.key-button:active {
    transform: scale(0.95);
}

/* Teclas Especiais */
.key-enter {
    max-width: 109px;
    min-width: 109px;
    font-size: 20px;
    background-color: #3e3252; /* Um pouco mais claro para destaque */
}

.ru-enter{
    max-width: 92px !important;
    min-width: 92px !important;
}

.key-backspace {
    max-width: 75px;
    font-size: 15px;
    background-color: #3e3252; /* Um pouco mais claro para destaque */
}


.key-button:hover {
    background-color: var(--key-hover);
}

/* Feedback no teclado */
.key-button.correct { background-color: var(--color-correct) !important; }
.key-button.present { background-color: var(--color-present) !important; }
.key-button.absent { background-color: var(--color-absent) !important; opacity: 0.5; }

/* =========================================
   5. MODAIS E OVERLAYS (Glassmorphism)
   ========================================= */

/* Classe base para todos os overlays (Regras, Ranking, Mensagens) */
.modal-overlay, .rules-overlay, .ranking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 2, 28, 0.85); /* Fundo escuro semi-transparente */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px); /* Efeito de vidro fosco */
}

.show {
    opacity: 1;
    visibility: visible;
}

/* Conteúdo Comum dos Modais */
.modal-content, .rules-content, .ranking-content {
    background: #281c37;
    color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    position: relative;
}

/* ABAS DO RANKING (NOVO) */
.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
}

.ranking-tabs img{
    width: 35px;

}

.tab-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    border-radius: 35px;
    padding: 8px;

}

.tab-btn:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}

.tab-btn.active {
    background-color: #655991;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Ajustes específicos de conteúdo */
.rules-content, .ranking-content {
    text-align: left;
}

.ranking-list ol {
    padding-left: 0;
    list-style: none;
}

#ranking-players li:hover img{
    transform: scale(2);
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid rgba(78, 65, 103, 0.5);
}

.player-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid white;
    transition: transform 0.2s ease;
}

.player-name {
    flex-grow: 1;
    font-weight: 500;
}

.player-points {
    color: #4CAF50; /* Verde neon para pontos */
    font-weight: bold;
}

/* Botões de Fechar */
.close-modal, #close-rules-btn, #close-ranking-btn {
    background: var(--key-hover);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 15px;
    width: 100%;
    transition: background 0.3s;
}

.close-modal:hover, #close-rules-btn:hover, #close-ranking-btn:hover {
    background: #5e517a;
}

/* =========================================
   6. INSTALADOR (PWA Banner)
   ========================================= */

.instalador {
    position: fixed; /* Alterado de absolute para fixed para garantir visibilidade */
    top: -190px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 360px;
    background-color: #FFF;
    color: #333;
    padding: 15px;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    text-align: center;
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.3);
    transition: top 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Efeito elástico */
    z-index: 10000;
    padding-top: 50px;
}

.instalador.show {
    top: -35px;
}

.instalador .titulo {
    color: #411381;
    font-size: 17px;
}

/* =========================================
   7. RODAPÉ E EXTRAS
   ========================================= */

.footer {
    color: #8979a9;
    font-size: 12px;
    text-align: center;
    padding-bottom: 10px;
}

.footer a {
    color: #a395c4;
    text-decoration: none;
}

/* Scrollbar personalizada para Webkit */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
    background: #4e4167;
    border-radius: 3px;
}

/* Estilos específicos das bandeiras e menu */
.lang-flag { 
    width: 22px; 
    height: auto; 
    margin-right: 10px; 
    border-radius: 2px;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.dropdown-menu-dark { 
    background-color: #281c37; 
    border: 1px solid #4e4167; 
    min-width: 150px;
}
.dropdown-item { 
    display: flex; 
    align-items: center; 
    padding: 8px 15px;
}
.dropdown-item:hover { background-color: #4e4167; }

.btn-lang-toggle {
    background-color: var(--key-bg) !important;
    border: none;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-lang-toggle:hover { background-color: rgba(0,0,0,0.5) !important; }

.pix-container {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px dashed #655991;
}
.pix-key {
    font-family: monospace;
    color: #d8b4fe;
    font-size: 14px;
}