:root {
    --bg-color: #0d1117;
    --bg-panel: #161b22;
    --primary: #00ff66;
    --primary-hover: #00cc55;
    --secondary: #30363d;
    --text-main: #f0f6fc;
    --text-muted: #9ba3ae;
    --text-dark: #050505;
    --danger: #ff4444;
    --danger-hover: #cc0000;
    --cell-bg: #ffffff;
    --cell-outline: #11161d;
    --cell-active: #c8ffde;
    --cell-focus: #fff066;
    --cell-correct: #9ef5bc;
    --cell-wrong: #ffb3b3;
    --cell-black: #121720;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hidden { display: none !important; }

.tela {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
}

.tela.ativa { display: flex; }

.titulo-secao {
    font-size: 1.7rem;
    color: #ffffff;
    margin-bottom: 18px;
    text-align: center;
    letter-spacing: 0.5px;
}

/* LOGO & INÍCIO */
.logo-container { text-align: center; margin-bottom: 22px; }
.titulo-animado {
    color: var(--primary);
    font-size: 2.3rem;
    font-weight: 900;
    text-shadow: 0 0 12px rgba(0, 255, 102, 0.4);
    animation: pulse 2s infinite alternate;
}
.subtitulo { font-size: 1.25rem; letter-spacing: 3px; color: #ffffff; margin-top: 2px; }
.slogan { font-size: 0.92rem; color: var(--text-muted); margin-top: 6px; }

@keyframes pulse {
    0% { text-shadow: 0 0 6px rgba(0, 255, 102, 0.25); }
    100% { text-shadow: 0 0 22px rgba(0, 255, 102, 0.85); }
}

.form-inicio {
    background: var(--bg-panel);
    padding: 22px;
    border-radius: 12px;
    border: 1px solid var(--secondary);
    width: 100%;
    max-width: 450px;
    margin-bottom: 18px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.55);
}

.input-group { margin-bottom: 14px; display: flex; flex-direction: column; }
.input-group label { margin-bottom: 6px; font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.input-group input, .input-group select {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--secondary);
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus, .input-group select:focus {
    border-color: var(--primary);
}

button {
    cursor: pointer; font-weight: 700; border: none; border-radius: 8px;
    padding: 12px 20px; transition: all 0.2s ease; font-size: 1rem;
    touch-action: manipulation;
}
.btn-primario { background: var(--primary); color: var(--text-dark); width: 100%; margin-top: 8px; font-size: 1.08rem; }
.btn-primario:hover { background: var(--primary-hover); transform: translateY(-2px); }
.btn-secundario { background: var(--secondary); color: var(--text-main); margin: 4px; border: 1px solid #444c56; }
.btn-secundario:hover { filter: brightness(1.2); border-color: var(--primary); }
.btn-perigo { background: var(--danger); color: white; margin: 4px; }
.btn-perigo:hover { background: var(--danger-hover); }
.menu-botoes, .botoes-rodape { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }

/* HUD DO JOGO */
.header-jogo {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    background: var(--bg-panel); padding: 12px 18px; border-radius: 10px; width: 100%;
    border: 1px solid var(--secondary); border-bottom: 3px solid var(--primary); margin-bottom: 14px; gap: 10px;
}
.info-jogador { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.hud-status { display: flex; gap: 18px; font-size: 1.2rem; font-weight: 800; }
.cronometro-box { color: var(--primary); }
.cronometro-box.alerta { color: var(--danger); animation: pulse 0.6s infinite alternate; }
.pontos-box { color: #ffd700; }
.hud-stats { display: flex; gap: 14px; font-size: 0.98rem; color: var(--text-muted); align-items: center; }
.acertos { color: var(--primary); font-weight: 800; }
.erros { color: var(--danger); font-weight: 800; }
.badge-turno {
    background: var(--primary); color: var(--text-dark); padding: 3px 9px;
    border-radius: 5px; font-size: 0.85rem; font-weight: 800;
}

/* ÁREA DA GRADE & ARRASTE */
.area-principal { display: flex; flex-direction: column; width: 100%; gap: 16px; flex: 1; }

@media (min-width: 1024px) {
    .area-principal { flex-direction: row; align-items: flex-start; }
    .area-grade-wrapper { flex: 1.7; }
    .area-interacao { flex: 1; position: sticky; top: 12px; }
}

.area-grade-wrapper { width: 100%; display: flex; flex-direction: column; align-items: center; }
.dica-arraste { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px; text-align: center; }

.area-grade-container {
    width: 100%;
    max-height: 66vh;
    overflow: auto;
    background: #080b10;
    padding: 18px;
    border-radius: 10px;
    border: 1px solid var(--secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    touch-action: pan-x pan-y;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.7);
}
.area-grade-container:active { cursor: grabbing; }

#area-grade {
    display: grid;
    gap: 0;
    background-color: var(--cell-black);
    border: 2px solid #30363d;
    border-radius: 4px;
    margin: auto;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.8);
}

/* NITIDEZ EXTREMA E CONTORNO DEFINIDO EM TODOS OS QUADRANTES */
.celula {
    width: 40px;
    height: 40px;
    background: var(--cell-bg);
    border: 2px solid var(--cell-outline);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 900;
    color: #050505;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-main);
    transition: background-color 0.12s ease, transform 0.08s ease;
}

.celula.preta {
    background: var(--cell-black);
    border: 1px solid #1b222d;
    box-shadow: none;
    cursor: default;
}

.celula:not(.preta):hover {
    filter: brightness(0.96);
}

.celula.ativa {
    background: var(--cell-active);
    border-color: #00993d;
}

.celula.foco {
    background: var(--cell-focus);
    border: 2.5px solid #00ff66;
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.85), inset 0 0 0 1px #000000;
    z-index: 5;
}

.celula.correta {
    background: var(--cell-correct);
    border-color: #007a30;
    color: #003814;
    font-weight: 900;
}

.celula.errada {
    background: var(--cell-wrong);
    border-color: #cc0000;
    color: #7a0000;
    animation: shake 0.3s;
}

.celula-numero {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.68rem;
    color: #111111;
    line-height: 1;
    font-weight: 800;
    pointer-events: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* PAINEL DE DICAS E CONTROLES */
.painel-pista {
    background: var(--bg-panel); padding: 15px; border-radius: 10px;
    border: 1.5px solid var(--primary); margin-bottom: 12px; text-align: center;
    box-shadow: 0 0 14px rgba(0, 255, 102, 0.12);
}
.pista-header { font-weight: 800; color: var(--primary); margin-bottom: 8px; font-size: 0.98rem; letter-spacing: 1px; text-transform: uppercase; }
#pista-texto { font-size: 1.12rem; font-weight: 600; color: #ffffff; line-height: 1.45; }

.controles-jogo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.btn-acao { background: var(--secondary); color: var(--text-main); font-size: 0.92rem; padding: 10px 8px; border: 1px solid #444c56; }
.btn-acao:hover { border-color: var(--primary); }
.btn-acao.destaque { background: var(--primary); color: var(--text-dark); grid-column: span 3; font-size: 1.08rem; border: none; }
.btn-acao.destaque:hover { background: var(--primary-hover); }

/* TECLADO VIRTUAL */
.teclado-virtual { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-bottom: 12px; }
.tecla {
    background: var(--secondary); color: #ffffff; border: 1px solid #444c56; border-radius: 6px;
    width: calc(10% - 4px); padding: 11px 0; font-size: 1.05rem; font-weight: 800;
    cursor: pointer; text-align: center; touch-action: manipulation;
}
.tecla:hover { border-color: var(--primary); }
.tecla:active { background: var(--primary); color: var(--text-dark); }
.tecla.tecla-larga { width: calc(20% - 4px); font-size: 0.95rem; background: #3b2326; border-color: #6e363c; }

/* LISTA RÁPIDA DE PALAVRAS */
.lista-pistas-box {
    background: var(--bg-panel);
    border: 1px solid var(--secondary);
    border-radius: 8px;
    padding: 10px 12px;
}
.lista-pistas-titulo {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.8px;
}
.lista-pistas-rapida {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip-palavra {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--secondary);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}
.chip-palavra:hover { border-color: var(--primary); }
.chip-palavra.selecionada { background: var(--primary); color: var(--text-dark); border-color: var(--primary); }
.chip-palavra.resolvida { background: #143d24; color: #7ef5a8; border-color: #00cc55; text-decoration: line-through; }

/* PAINÉIS E MODAIS */
.footer-controles { display: flex; justify-content: space-between; width: 100%; margin-top: 15px; gap: 10px; }
.btn-rodape { flex: 1; margin: 0; }

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.88); display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.overlay.oculto { display: none; }
.modal { background: var(--bg-panel); padding: 30px; border-radius: 12px; text-align: center; border: 1.5px solid var(--primary); min-width: 280px; }
.modal-sub { color: var(--text-muted); margin: 10px 0 18px; font-size: 0.95rem; }

.modal-fim { background: var(--bg-panel); padding: 26px; border-radius: 12px; text-align: center; width: 92%; max-width: 500px; border: 1.5px solid var(--primary); box-shadow: 0 10px 30px rgba(0,0,0,0.7); }
.resumo-fim { margin: 16px 0; text-align: left; background: var(--bg-color); padding: 16px; border-radius: 8px; border: 1px solid var(--secondary); }
.resumo-fim p { margin: 7px 0; font-size: 1.02rem; }
.divisor { border: none; border-top: 1px solid var(--secondary); margin: 10px 0; }
.destaque-pontos { color: var(--primary); font-size: 1.3rem; font-weight: 800; }

/* CARDS DE PROGRESSO, CONFIG E INSTRUÇÕES */
.grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 520px; margin: 10px 0 20px; }
.card-stat { background: var(--bg-panel); border: 1px solid var(--secondary); border-radius: 10px; padding: 18px 14px; text-align: center; }
.card-stat-full { grid-column: span 2; }
.stat-num { display: block; font-size: 2rem; font-weight: 900; color: var(--primary); margin-bottom: 4px; }
.stat-rotulo { font-size: 0.88rem; color: var(--text-muted); font-weight: 600; }

.painel-card {
    background: var(--bg-panel);
    border: 1px solid var(--secondary);
    border-radius: 10px;
    padding: 20px;
    width: 100%;
    max-width: 540px;
    margin-bottom: 18px;
}

.config-opcoes { display: flex; flex-direction: column; gap: 14px; }
.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--secondary);
    font-weight: 600;
    cursor: pointer;
}
.config-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.lista-instrucoes { list-style: none; display: flex; flex-direction: column; gap: 12px; line-height: 1.5; font-size: 0.98rem; }
.lista-instrucoes li { background: var(--bg-color); padding: 12px 14px; border-radius: 8px; border-left: 3px solid var(--primary); }

.table-container { width: 100%; max-width: 820px; overflow-x: auto; margin: 10px 0 18px; background: var(--bg-panel); border-radius: 10px; border: 1px solid var(--secondary); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--secondary); padding: 12px 10px; text-align: center; font-size: 0.95rem; }
th { background: #1f2630; color: var(--primary); font-weight: 800; }
tr:last-child td { border-bottom: none; }

.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--primary); color: var(--text-dark); padding: 11px 22px;
    border-radius: 8px; font-weight: 800; opacity: 0; transition: opacity 0.25s;
    pointer-events: none; z-index: 2000; box-shadow: 0 4px 18px rgba(0,0,0,0.65);
}
.toast.mostrar { opacity: 1; }

footer { margin-top: 24px; padding: 14px; text-align: center; font-size: 0.82rem; color: var(--text-muted); width: 100%; }

@media (max-width: 768px) {
    .celula { width: 33px; height: 33px; font-size: 1.15rem; border-width: 1.5px; }
    .tecla { width: calc(14.28% - 4px); padding: 10px 0; font-size: 1rem; }
    .tecla.tecla-larga { width: calc(28.5% - 4px); }
    .hud-status { font-size: 1.02rem; }
}