:root {
    --bg-color: #0d1117;
    --bg-panel: #161b22;
    --primary: #00ff66;
    --primary-hover: #00cc55;
    --secondary: #30363d;
    --text-main: #c9d1d9;
    --text-dark: #000000;
    --danger: #ff4444;
    --danger-hover: #cc0000;
    --cell-bg: #ffffff;
    --cell-border: #30363d;
    --cell-active: #b3ffcc;
    --cell-correct: #99ff99;
    --cell-wrong: #ff9999;
    --cell-black: #000000;
    --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;
}

#app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.tela {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
}

.tela.ativa {
    display: flex;
}

/* TELA INICIAL */
.logo-container { text-align: center; margin-bottom: 30px; }
.titulo-animado {
    color: var(--primary);
    font-size: 2.5rem;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
    animation: pulse 2s infinite alternate;
}
.subtitulo { font-size: 1.5rem; letter-spacing: 2px; margin-bottom: 10px; }
.slogan { font-size: 0.9rem; color: #8b949e; }

@keyframes pulse {
    0% { text-shadow: 0 0 5px rgba(0, 255, 102, 0.2); }
    100% { text-shadow: 0 0 20px rgba(0, 255, 102, 0.8); }
}

.form-inicio {
    background: var(--bg-panel);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--secondary);
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
}

.input-group { margin-bottom: 15px; display: flex; flex-direction: column; }
.input-group label { margin-bottom: 5px; font-weight: bold; }
.input-group input, .input-group select {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--secondary);
    background: var(--bg-color);
    color: var(--text-main);
    font-size: 1rem;
}
.erro-msg { color: var(--danger); font-size: 0.8rem; display: none; margin-top: 5px; }

button {
    cursor: pointer; font-weight: bold; border: none; border-radius: 5px;
    padding: 12px 20px; transition: all 0.3s ease; font-size: 1rem;
}
.btn-primario { background: var(--primary); color: var(--text-dark); width: 100%; margin-top: 10px; }
.btn-primario:hover { background: var(--primary-hover); transform: translateY(-2px); }
.btn-secundario { background: var(--secondary); color: var(--text-main); margin: 5px; }
.btn-secundario:hover { filter: brightness(1.2); }
.btn-perigo { background: var(--danger); color: white; }
.btn-perigo:hover { background: var(--danger-hover); }
.menu-botoes { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* HUD DO JOGO */
.header-jogo {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
    background: var(--bg-panel); padding: 15px; border-radius: 8px; width: 100%;
    border-bottom: 2px solid var(--primary); margin-bottom: 15px;
}
.hud-status { display: flex; gap: 15px; font-size: 1.2rem; font-weight: bold; }
.cronometro-box { color: var(--primary); }
.hud-stats { display: flex; gap: 10px; font-size: 0.9rem; color: #8b949e; }
.acertos { color: var(--primary); }
.erros { color: var(--danger); }

/* ÁREA PRINCIPAL DO JOGO */
.area-principal {
    display: flex; flex-direction: column; width: 100%; gap: 20px; flex: 1;
}

@media (min-width: 1024px) {
    .area-principal { flex-direction: row; align-items: flex-start; }
    .area-grade-container { flex: 2; }
    .area-interacao { flex: 1; position: sticky; top: 20px; }
}

.area-grade-container {
    overflow: auto; background: var(--bg-panel); padding: 10px;
    border-radius: 8px; border: 1px solid var(--secondary);
    display: flex; justify-content: center; align-items: center;
}

#area-grade {
    display: grid;
    gap: 0;
    background-color: var(--cell-border);
    border: 2px solid var(--cell-border);
}

.celula {
    width: 35px; height: 35px; background: var(--cell-bg);
    border: 1px solid var(--cell-border); position: relative;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.2rem; font-weight: bold; color: var(--text-dark);
    text-transform: uppercase; cursor: pointer; user-select: none;
}
.celula.preta { background: var(--cell-black); border-color: var(--cell-black); cursor: default; }
.celula.ativa { background: var(--cell-active); }
.celula.foco { border: 2px solid var(--primary); outline: none; background: #ffffcc; }
.celula.correta { background: var(--cell-correct); pointer-events: none; }
.celula.errada { background: var(--cell-wrong); animation: shake 0.3s; }
.celula-numero {
    position: absolute; top: 1px; left: 2px; font-size: 0.6rem;
    color: #333; line-height: 1; font-weight: normal;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* INTERAÇÃO E PISTAS */
.painel-pista {
    background: var(--bg-panel); padding: 15px; border-radius: 8px;
    border: 1px solid var(--primary); margin-bottom: 15px; text-align: center;
}
.pista-header { font-weight: bold; color: var(--primary); margin-bottom: 10px; font-size: 1.1rem; }
#pista-texto { font-size: 1.1rem; }

.controles-jogo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.btn-acao { background: var(--secondary); color: var(--text-main); font-size: 0.9rem; padding: 10px; }
.btn-acao.destaque { background: var(--primary); color: var(--text-dark); grid-column: span 2; }

.teclado-virtual { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.tecla {
    background: var(--secondary); color: var(--text-main); border: none; border-radius: 5px;
    width: calc(10% - 5px); padding: 10px 0; font-size: 1rem; cursor: pointer;
    text-align: center; font-weight: bold;
}
.tecla:active { background: var(--primary); color: var(--text-dark); }
.tecla.tecla-larga { width: calc(20% - 5px); font-size: 0.9rem; }

/* RODAPÉ E OVERLAYS */
.footer-controles { display: flex; justify-content: space-between; width: 100%; margin-top: 20px; }
.btn-rodape { flex: 1; margin: 0 5px; }

.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.overlay.oculto { display: none; }
.modal { background: var(--bg-panel); padding: 30px; border-radius: 10px; text-align: center; border: 1px solid var(--primary); }

.modal-fim { background: var(--bg-panel); padding: 30px; border-radius: 10px; text-align: center; width: 100%; max-width: 500px; }
.resumo-fim { margin: 20px 0; text-align: left; background: var(--bg-color); padding: 15px; border-radius: 5px; }
.resumo-fim p { margin: 5px 0; font-size: 1.1rem; }
.destaque-pontos { color: var(--primary); font-size: 1.5rem; font-weight: bold; }

/* TOAST E OUTROS */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--primary); color: var(--text-dark); padding: 10px 20px;
    border-radius: 5px; font-weight: bold; opacity: 0; transition: opacity 0.3s;
    pointer-events: none; z-index: 2000;
}
.toast.mostrar { opacity: 1; }

.table-container { width: 100%; max-width: 800px; overflow-x: auto; margin: 20px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid var(--secondary); padding: 10px; text-align: center; }
th { background: var(--secondary); color: var(--primary); }

footer { margin-top: 30px; padding: 20px; text-align: center; font-size: 0.8rem; color: #8b949e; width: 100%; }

@media (max-width: 768px) {
    .celula { width: 30px; height: 30px; font-size: 1rem; }
    .titulo-animado { font-size: 1.8rem; }
    .tecla { width: calc(14% - 5px); padding: 12px 0; }
    .tecla.tecla-larga { width: calc(28% - 5px); }
    .hud-status { font-size: 1rem; }
}
@media (max-width: 400px) {
    .celula { width: 25px; height: 25px; font-size: 0.9rem; }
    .controles-jogo { grid-template-columns: 1fr; }
    .btn-acao.destaque { grid-column: span 1; }
}