@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&display=swap');

:root {
    --azul-ceu: #87CEEB;
    --laranja: #ff9800;
    --btn-vermelho: #ff7675;
    --btn-verde: #2ecc71;
    --btn-roxo: #a29bfe;
    --azul-tile: #3498db;
}

body {
    font-family: 'Fredoka', sans-serif;
    margin: 0; 
    overflow-x: hidden; 
    overflow-y: auto;
    min-height: 100vh;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.8s ease;
}

body.bg-vitoria {
    background: linear-gradient(180deg, #ffeaa7 0%, #fab1a0 100%) !important;
}


.cabecalho-jogo { 
    background: rgba(255, 255, 255, 0.95); 
    width: 100%; 
    padding: 10px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    z-index: 50; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
    box-sizing: border-box;
}

.header-esquerda {
    flex: 1 1 0; 
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
}

.header-centro {
    flex: 1 1 0; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-direita {
    flex: 1 1 0; 
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.recorde-simples-topo {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.label-recorde {
    font-size: 1.1rem;
    color: #636e72;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.valor-recorde {
    font-size: 1.8rem;
    color: var(--laranja);
    font-weight: 900;
}

.btn-sair, .btn-topo, .btn-repetir, .btn-conferir, .btn-grande, .letra-tile, .btn-circular {
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    touch-action: manipulation;
}

.btn-sair:active, .btn-topo:active, .btn-repetir:active, .btn-conferir:active:not(:disabled), .btn-grande:active, .letra-tile:active:not(.correta-fixa), .btn-circular:active {
    transform: translateY(4px);
}

.btn-sair {
    background: var(--btn-vermelho); color: white; text-decoration: none;
    padding: 10px 22px; border-radius: 50px; font-weight: bold;
    box-shadow: 0 5px 0 #d63031; white-space: nowrap; border: none; font-family: 'Fredoka';
}
.btn-sair:active { box-shadow: 0 1px 0 #d63031; }

.btn-topo {
    padding: 10px 15px; border-radius: 50px; font-weight: bold; border: none;
    cursor: pointer; font-family: 'Fredoka'; color: white; white-space: nowrap;
}

.btn-modos-cor { background: var(--azul-tile); box-shadow: 0 5px 0 #2980b9; }
.btn-modos-cor:active { box-shadow: 0 1px 0 #2980b9; }

.progresso-container {
    display: flex; align-items: center; gap: 10px;
    color: var(--btn-roxo); font-weight: bold; font-size: 1.2rem;
    background: rgba(162, 155, 254, 0.15); padding: 5px 15px;
    border-radius: 20px; border: 2px solid var(--btn-roxo);
    width: 100%; max-width: 300px; 
}

.tempo-regressivo {
    font-size: 1.2rem; background: #ff7675; color: white;
    padding: 2px 10px; border-radius: 10px; font-weight: bold;
}

.progresso-barra-bg {
    flex-grow: 1; height: 10px; background: #dfe6e9;
    border-radius: 5px; overflow: hidden; position: relative;
}
.progresso-barra-fill {
    height: 100%; background: var(--btn-roxo); width: 0%;
    transition: width 0.3s ease; border-radius: 5px;
}
.modo-infinito-ui .progresso-barra-fill {
    background: linear-gradient(90deg, var(--btn-roxo), #00cec9, var(--btn-roxo));
    background-size: 200% 100%;
    animation: moveGradient 2s linear infinite;
}
@keyframes moveGradient { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }

.container {
    background: white; margin-top: clamp(10px, 3vh, 20px); padding: clamp(15px, 3vh, 25px);
    border-radius: 30px; width: 90%; max-width: 600px;
    text-align: center; color: #333; box-shadow: 0 10px 0 rgba(0,0,0,0.1);
    z-index: 10; transition: filter 0.3s ease; flex-shrink: 0;
}

body.inicio-aberto .container { filter: blur(8px); }

.legenda-instrucao { font-size: 1.15rem; font-weight: bold; color: #555; margin-bottom: 5px; line-height: 1.3; }
#emoji-display { font-size: 70px; margin: 5px; cursor: default; user-select: none; }
.palavra-topo { display: flex; align-items: center; justify-content: center; gap: 12px; }

.btn-repetir {
    width: 48px; height: 48px; border-radius: 50%; border: 3px solid white;
    background: var(--btn-roxo); color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    box-shadow: 0 5px 0 #6c5ce7;
}
.btn-repetir:active { box-shadow: 0 1px 0 #6c5ce7; }

.zona-alvo { display: flex; justify-content: center; gap: 8px; margin: 15px 0; min-height: 70px; flex-wrap: wrap; }

.box-alvo {
    width: 55px; height: 55px; background: #f1f2f6; border: 3px dashed #bdc3c7;
    border-radius: 12px; display: flex; justify-content: center; align-items: center;
    box-shadow: inset 0 3px 0 rgba(0,0,0,0.05);
}

.letras-disponiveis {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
    padding: 15px; background: #dfe6e9; border-radius: 20px; min-height: 80px;
}

.letra-tile {
    width: 55px; height: 55px; background: var(--azul-tile); border-radius: 15px; color: white; 
    font-size: 1.8rem; font-weight: bold; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 6px 0 #2980b9; cursor: grab;
}
.letra-tile:active:not(.correta-fixa) { box-shadow: 0 2px 0 #2980b9; }

.letra-tile.correta-fixa {
    background: #f1c40f !important; box-shadow: 0 6px 0 #d4ac0d !important;
    cursor: default; transform: none !important;
}

/* ======================================================== */
/* 💡 AJUSTE INTELIGENTE PARA PALAVRAS DE 8 OU MAIS LETRAS */
/* ======================================================== */
.palavra-longa .box-alvo, 
.palavra-longa .letra-tile {
    width: 42px !important;
    height: 42px !important;
    font-size: 1.4rem !important;
    border-radius: 10px !important;
}

.zona-alvo.palavra-longa { gap: 6px; }
.letras-disponiveis.palavra-longa { gap: 8px; }

@media (max-width: 480px) {
    .palavra-longa .box-alvo, 
    .palavra-longa .letra-tile {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.1rem !important;
        border-radius: 8px !important;
    }
    .zona-alvo.palavra-longa { gap: 4px; }
}
/* ======================================================== */

.dica-pulinho { animation: animDica 1s ease infinite; border: 3px solid #f1c40f; }
@keyframes animDica {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px) scale(1.05); }
}

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100;
}

.menu-caixa {
    background: white; padding: 30px; border-radius: 25px; text-align: center;
    max-width: 420px; width: 90%; box-shadow: 0 10px 0 rgba(0,0,0,0.1);
    max-height: 90vh; overflow-y: auto;
}

.titulo-menu { color: var(--laranja); margin: 0 0 5px 0; font-size: 2.2rem;}
.subtitulo-menu { color: #555; font-weight: bold; margin-bottom: 20px; font-size: 1.1rem;}

.dificuldade-botoes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px;}

.btn-grande {
    color: white; border: none; padding: 15px 20px; border-radius: 15px; 
    font-size: 1.2rem; font-weight: bold; cursor: pointer; font-family: 'Fredoka';
    width: 100%; 
}
.btn-facil { background: #55efc4; box-shadow: 0 5px 0 #00b894; color: #1e371e;}
.btn-facil:active { box-shadow: 0 2px 0 #00b894; }
.btn-medio { background: #fab1a0; box-shadow: 0 5px 0 #e17055; color: #371e1e;}
.btn-medio:active { box-shadow: 0 2px 0 #e17055; }
.btn-dificil { background: #ff7675; box-shadow: 0 5px 0 #d63031; }
.btn-dificil:active { box-shadow: 0 2px 0 #d63031; }
.btn-infinito { background: #a29bfe; box-shadow: 0 5px 0 #6c5ce7; }
.btn-infinito:active { box-shadow: 0 2px 0 #6c5ce7; }
.btn-tempo { background: #fdcb6e; box-shadow: 0 5px 0 #e1b12c; color: #2d3436; }
.btn-tempo:active { box-shadow: 0 2px 0 #e1b12c; }
.btn-sair-menu { background: #b2bec3; box-shadow: 0 5px 0 #636e72; color: #2d3436;}
.btn-sair-menu:active { box-shadow: 0 2px 0 #636e72; }

.separador-menu { border-top: 2px dashed #eee; margin: 20px 0; }

.como-jogar-menu { text-align: left; line-height: 1.5; font-size: 1.05rem; color: #222; }
.como-jogar-titulo { color: var(--laranja); font-weight: bold; font-size: 1.2rem; margin-bottom: 10px;}
.como-jogar-item { margin-bottom: 8px;}


.palavra-vitoria .letra-tile {
    animation: dancaLetras 0.6s ease infinite alternate;
    background: #f1c40f !important; box-shadow: 0 4px 0 #d4ac0d !important; border: 2px solid white;
}
@keyframes dancaLetras {
    0% { transform: translateY(0) rotate(0deg) scale(1); }
    50% { transform: translateY(-12px) rotate(8deg) scale(1.05); }
    100% { transform: translateY(0) rotate(-8deg) scale(1); }
}

.btn-conferir {
    background: var(--btn-verde); color: white; border: none; padding: 15px; font-size: 1.2rem; 
    border-radius: 20px; font-weight: bold; cursor: pointer; box-shadow: 0 6px 0 #27ae60; width: 100%; 
    font-family: 'Fredoka'; margin-top: 5px;
}
.btn-conferir:active:not(:disabled) { box-shadow: 0 2px 0 #27ae60; }
.btn-conferir:disabled { opacity: 0.7; cursor: default; box-shadow: 0 2px 0 #27ae60; transform: translateY(4px); }

.controles-fixos { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 110; }
.btn-circular { 
    width: 55px; height: 55px; border-radius: 50%; border: 3px solid white; 
    background: #e0e0e0; color: #555; cursor: pointer; display: flex; align-items: center; 
    justify-content: center; font-size: 1.4rem; box-shadow: 0 5px 0 rgba(0,0,0,0.15); 
}
.btn-circular:active { box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.btn-circular.ativo { background: var(--btn-verde) !important; color: white !important; }
.btn-circular.roxo { background: var(--btn-roxo) !important; color: white !important; }

#mensagem { font-size: 1.1rem; font-weight: bold; margin-top: 10px; height: 1.5em; }

.placar-rodape { display: flex; justify-content: center; flex-wrap: wrap; gap: clamp(10px, 2vw, 15px); margin-top: clamp(10px, 2vh, 15px); margin-bottom: clamp(30px, 6vh, 80px); z-index: 10; flex-shrink: 0; }
.caixa-placar {
    background: white; padding: 12px 20px; border-radius: 20px; font-size: 1.2rem; font-weight: bold; 
    color: #2d3436; box-shadow: 0 6px 0 rgba(0,0,0,0.08); display: flex; align-items: center; gap: 8px;
}

.confetti-layer{ position:fixed; top:0; left:0; width:100%; height:100%; pointer-events:none; z-index:120; overflow:hidden;}
.confetti{
    position:absolute; width:12px; height:12px; opacity:1; border-radius:3px;
    animation: confettiExplosion var(--dur) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes confettiExplosion{
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(720deg) scale(0.5); opacity: 0; }
}

.letra-tile.pop { animation: popIn 0.18s ease; }
@keyframes popIn { from { transform: scale(0.85); } to { transform: scale(1); } }

.container.shake { animation: shake 0.35s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.container.glow{ box-shadow: 0 10px 0 rgba(0,0,0,0.1), 0 0 0 7px rgba(241,196,15,0.25), 0 18px 35px rgba(0,0,0,0.18); }

@media (max-width: 768px) {
    .cabecalho-jogo { flex-direction: column; gap: 10px; padding: 10px; }
    .header-esquerda, .header-centro, .header-direita { flex: none; width: 100%; justify-content: center; }
    .header-direita { order: -1; justify-content: flex-end; position: absolute; top: 10px; right: 15px; width: auto;}
    .progresso-container { max-width: 90%; margin: 0; }
    .sol-pulsante { width: 80px; height: 80px; top: 140px; left: 10px; }
    .menu-caixa { padding: 20px; }
}

@media (max-width: 480px) {
    .titulo-menu { font-size: 1.8rem; }
    .btn-sair, .btn-topo { padding: 8px 10px; font-size: 0.85rem; }
    .progresso-container { font-size: 1rem; padding: 4px 10px;}
    .container { margin-top: 12px; padding: 16px; border-radius: 24px; }
    .legenda-instrucao { font-size: 0.95rem; }
    .letra-tile, .box-alvo { width: 48px; height: 48px; font-size: 1.5rem; }
    #emoji-display { font-size: 60px; }
    .caixa-placar { font-size: 1rem; padding: 10px 15px; }
}

@media (max-height: 700px) {
    .container { margin-top: 10px; padding: 12px 15px; }
    #emoji-display { font-size: 45px; margin: 2px; }
    .btn-repetir { width: 35px; height: 35px; font-size: 0.9rem; }
    .legenda-instrucao { font-size: 0.95rem; margin-bottom: 2px; }
    .zona-alvo { margin: 8px 0; min-height: 45px; gap: 5px; }
    .letras-disponiveis { padding: 10px; min-height: 55px; gap: 6px; }
    .letra-tile, .box-alvo { width: 42px; height: 42px; font-size: 1.3rem; border-radius: 10px; }
    .btn-conferir { padding: 10px; font-size: 1.1rem; margin-top: 2px; }
    #mensagem { margin-top: 5px; font-size: 1rem; }
    .placar-rodape { margin-top: 10px; gap: 10px; }
    .caixa-placar { padding: 8px 15px; font-size: 1.1rem; }
    .cabecalho-jogo { padding: 8px 15px; }
    
    .palavra-longa .box-alvo, 
    .palavra-longa .letra-tile {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.1rem !important;
    }
}