:root {
    --bg-color: #1A1F2B;
    --key-bg: #2B3445;
    --key-text: #FFFFFF;
    --border-color: #3A475C;
    --correct: #00D2BE;
    --present: #DCA54C;
    --absent: #12151C; 
}

* { box-sizing: border-box; }

/* 1. CONFIGURAÇÃO BASE (Permite rolagem se necessário) */
html, body {
    width: 100%;
    min-height: 100vh; /* Garante que cubra a tela toda */
    margin: 0;
    padding: 0;
    
    /* AQUI: Permite rolar a tela se o conteúdo for grande */
    overflow-y: auto; 
    overflow-x: hidden;
    
    background-color: var(--bg-color);
    color: white;
    font-family: 'Nunito', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* 2. LAYOUT GLOBAL */
.main-layout {
    display: flex;
    justify-content: center;
    width: 100%;
    min-height: 100vh; /* Acompanha o crescimento da página */
}

/* Laterais (Desktop) */
.ad-side {
    width: 160px;
    display: none; /* Escondido no mobile */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    /* Sticky: Acompanha a rolagem no PC */
    position: sticky;
    top: 0;
    height: 100vh; 
}
.ad-skyscraper { 
    width: 160px; height: 600px; 
    background: rgba(255,255,255,0.05); 
    display: flex; justify-content: center; align-items: center; 
}
@media (min-width: 1024px) { .ad-side { display: flex; } }


/* 3. COLUNA CENTRAL (FLUXO NATURAL) */
.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    
    width: 100%;
    max-width: 600px; /* Limite no PC */
    
    /* Importante: permite crescer o quanto precisar */
    height: auto; 
    min-height: 100vh;
    
    padding: 0 10px 40px 10px; /* Padding no fundo pro teclado não colar na borda */
}

/* --- CABEÇALHO --- */
header {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}
h1 { margin: 0; font-size: 1.8rem; font-weight: 800; text-transform: uppercase; text-shadow: 0 0 10px rgba(0,210,190,0.3); }
.icon-btn { background: none; border: none; color: white; width: 40px; height: 40px; cursor: pointer; }

/* --- ABAS --- */
.mode-tabs {
    display: flex; justify-content: center; gap: 15px;
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px; /* Espaço antes do tabuleiro */
    flex-wrap: wrap;
}
.mode-tab { background: none; border: none; color: #888; font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; padding-bottom: 5px; position: relative; text-decoration: none; }
.mode-tab.active { color: white; }
.mode-tab.active::after { content: ''; position: absolute; bottom: -6px; left: 0; right: 0; height: 3px; background: var(--correct); box-shadow: 0 -2px 10px rgba(0,210,190,0.5); }
.expo { font-size: 0.7em; margin-left: 2px; transform: translateY(-3px); display: inline-block; color:#00D2BE; }


/* --- TABULEIRO (FLUXO NATURAL) --- */
#board-container {
    width: 100%;
    display: flex;
    justify-content: center;
    
    /* Não tem altura fixa. A altura será definida pelo conteúdo (#board) */
    margin-bottom: 20px; /* Empurra o teclado para baixo */
}

#board {
    display: grid;
    gap: 5px;
    
    /* LARGURA: Ocupa 100% da tela (ou até 500px no PC) */
    width: 100%;
    max-width: 500px; 
    
    /* ALTURA: Automática! */
    /* Como os tiles têm aspect-ratio 1/1, a altura vai crescer conforme a largura */
    height: auto;
}

.board-row {
    display: grid;
    gap: 5px;
    width: 100%;
    justify-content: center;
}

.tile {
    width: 100%;
    aspect-ratio: 1 / 1; 
    border-radius: 5px;
    border: 4px solid var(--border-color);
    background: transparent;
    display: flex; justify-content: center; align-items: center;
    font-size: 2rem; font-weight: 800; color: white;
    user-select: none;
}

/* Ajuste de fonte para telas pequenas ou muitas letras */
@media (max-width: 400px) {
    .tile { font-size: 1.5rem; }
}


/* --- TECLADO (Vem DEPOIS do tabuleiro) --- */
#keyboard-container {
    width: 100%;
    display: flex;
    justify-content: center;
    
    /* Se sobrar espaço na tela (PC), empurra o teclado pro fundo.
       Se faltar espaço (Celular), ele fica logo após o tabuleiro e rola. */
    margin-top: auto; 
}

#keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    
    width: 100%;
    max-width: 650px; /* Limite do teclado no PC */
}

.keyboard-row {
    display: flex;
    width: 100%;
    gap: 6px;
    justify-content: center;
}

.key {
    flex: 1; /* Estica para ocupar a largura */
    height: 58px;
    border-radius: 8px;
    background: var(--key-bg);
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    border: none;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    text-transform: uppercase;
    touch-action: manipulation;
}

.key.big { flex: 1.5; font-size: 0.85rem; font-weight: 800; }
.key:active { transform: scale(0.95); opacity: 0.8; }

/* Cores */
.key.correct { background: var(--correct); color: #0A2A25; }
.key.present { background: var(--present); }
.key.absent  { background: var(--absent); opacity: 0.5; }
.tile.filled { border-color: #565758; animation: pop 0.1s; }
.tile.active { border-color: #4b5563; }
.board-row.active-row .tile.active { border-color: var(--correct); box-shadow: inset 0 0 15px rgba(0, 210, 190, 0.4);}
.tile.correct { background: var(--correct) !important; border-color: var(--correct) !important; color: #0A2A25; }
.tile.present { background: var(--present) !important; border-color: var(--present) !important; }
.tile.absent  { background: var(--absent) !important;  border-color: var(--absent) !important; }
.tile.flip { animation: flip-reveal 0.6s forwards; }

.shake {
            animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
        }

        @keyframes shake {
            10%, 90% { transform: translateX(-2px); }
            20%, 80% { transform: translateX(4px); }
            30%, 50%, 70% { transform: translateX(-6px); }
            40%, 60% { transform: translateX(6px); }
        }


/* --- CORREÇÃO DO MODAL DE AJUDA --- */

.help-container {
    text-align: left; /* Alinha os textos explicativos à esquerda */
    padding: 20px 25px;
}

.help-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
    /* Removemos a lógica de grid aqui para usar tamanho fixo */
}

/* Forçamos o tile de ajuda a ter tamanho fixo, ignorando o 100% do jogo principal */
.help-tile {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.5rem !important;
    border: 2px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border-radius: 4px; /* Mantém o visual arredondado */
}

.help-example {
    margin-top: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.help-example:last-child {
    border-bottom: none;
}

.help-example p {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    color: #ccc;
}
/* --- RESPONSIVIDADE (Ajuste Fino) --- */

/* Celulares pequenos: Reduz um pouco o teclado para caber mais coisa */
@media (max-width: 400px) {
    .key { height: 50px; font-size: 1rem; }
    #keyboard { gap: 6px; }
    .keyboard-row { gap: 4px; }
    h1 { font-size: 1.5rem; }
}

/* Anúncios Mobile */
.ad-slot { display: flex; justify-content: center; background: rgba(255,255,255,0.05); width: 100%; height: 50px; margin: 10px 0; }
.mobile-only { display: flex; }
@media (min-width: 1024px) { .mobile-only { display: none; } }

/* Outros */
#toast { position: fixed; top: 12%; left: 50%; transform: translateX(-50%); background: white; color: black; padding: 10px 20px; border-radius: 4px; font-weight: bold; z-index: 3000; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
#toast.show { opacity: 1; visibility: visible; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; backdrop-filter: blur(2px); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-container { background: #242933; padding: 20px; border-radius: 8px; width: 90%; max-width: 400px; max-height: 90vh; overflow-y: auto; position: relative; text-align: center; color: white; }
.close-modal { position: absolute; top: 10px; right: 10px; background: none; border: none; color: white; cursor: pointer; }
.stats-grid { display: flex; justify-content: space-between; margin: 15px 0; } .stat-box { display: flex; flex-direction: column; } .stat-value { font-size: 1.5rem; font-weight: bold; } .stat-label { font-size: 0.7rem; }
.chart-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; } .chart-bar-container { flex: 1; background: #2B3445; height: 18px; } .chart-bar { background: #565758; height: 100%; text-align: right; padding-right: 5px; font-size: 0.75rem; } .chart-bar.highlight { background: var(--correct); color: black; }
.share-btn { width: 100%; background: var(--correct); padding: 12px; border: 0; border-radius: 20px; font-weight: bold; margin-top: 15px; cursor: pointer; }
@keyframes pop { 50% { transform: scale(1.1); } } @keyframes flip-reveal { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }

/* Container abaixo do teclado */
.footer-actions {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 20px;
    width: 100%;
}

/* O botão em si */
.share-text-btn {
    background-color: var(--correct); /* Verde do tema */
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s, background-color 0.2s;
}

.share-text-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.share-text-btn:active {
    transform: scale(0.95);
}

/*ADS*/
.ad-slot, .ad-side, .ad-skyscraper,.ad-rectangle {
    display: none !important;
}
