*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --text-muted: #888;
  --facil: #4ade80;
  --medio: #f59e0b;
  --dificil: #f87171;
  --correct: #4ade80;
  --wrong: #f87171;
  --radius: 14px;
}

html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* TELAS */
.tela { display: none; width: 100%; min-height: 100dvh; }
.tela.ativa { display: flex; flex-direction: column; }

/* INICIO */
#tela-inicio {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  text-align: center;
}

.titulo-principal {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.subtitulo {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 36px;
}

.input-nome-wrap { width: 100%; margin-bottom: 16px; }

.input-nome {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 1rem; /* 16px mínimo — evita zoom no iOS */
  color: var(--text);
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.input-nome::placeholder { color: var(--text-muted); }
.input-nome:focus { border-color: #555; }
.input-nome.invalido { border-color: var(--wrong); }

.erro-nome { margin-top: 8px; font-size: 0.85rem; color: var(--wrong); }
.erro-nome.escondido { display: none; }

/* BOTÃO PRINCIPAL */
.btn-primario {
  width: 100%;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 17px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.1s;
}

.btn-primario:active { opacity: 0.85; }

/* TELA DO JOGO */
#tela-jogo {
  flex-direction: column;
  padding: 0;
}

.jogo-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 16px;
  padding-top: calc(20px + env(safe-area-inset-top));
  -webkit-overflow-scrolling: touch;
}

/* TOPO */
.topo-jogo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.progresso-info { display: flex; align-items: center; gap: 10px; }

#contador-pergunta { font-size: 0.8rem; color: var(--text-muted); }

/* BADGES */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.badge.facil   { background: #4ade8020; color: var(--facil);   border: 1px solid #4ade8040; }
.badge.medio   { background: #f59e0b20; color: var(--medio);   border: 1px solid #f59e0b40; }
.badge.dificil { background: #f8717120; color: var(--dificil); border: 1px solid #f8717140; }

/* CARTA PULAR */
.btn-carta {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
}

.btn-carta:active:not(:disabled) { background: var(--surface2); }
.btn-carta:disabled { opacity: 0.3; }

/* MILESTONES */
.milestones {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.milestone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  transition: border-color 0.3s, background 0.3s;
}

.milestone.atingido {
  border-color: #f59e0b66;
  background: #f59e0b0d;
}

.ms-icone { font-size: 1.1rem; line-height: 1; }

.ms-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.ms-label small { display: block; opacity: 0.75; }

/* BARRA */
.barra-progresso {
  height: 3px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
}

.barra-fill {
  height: 100%;
  background: var(--text);
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0%;
}

/* PERGUNTA */
.pergunta-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  margin-bottom: 14px;
  min-height: 90px;
  display: flex;
  align-items: center;
}

#texto-pergunta {
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 500;
}

/* OPÇÕES — coluna única em mobile */
.opcoes-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.opcao {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s, border-color 0.1s;
  width: 100%;
}

.opcao:active:not(:disabled) { background: var(--surface2); }
.opcao:disabled { cursor: default; }

.opcao .letra {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.opcao.selecionada { background: var(--surface2); border-color: #555; }
.opcao.selecionada .letra { background: #55555540; color: var(--text); }

/* FEEDBACK */
.feedback {
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 14px;
  animation: slideUp 0.2s ease;
}

.feedback.escondido { display: none; }
.feedback.pulado { background: #88888815; border: 1px solid #44444440; color: var(--text-muted); }

/* BOTÃO AVANÇAR */
.btn-avancar {
  width: 100%;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 17px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  margin-bottom: 14px;
  animation: slideUp 0.2s ease;
}

.btn-avancar:active { opacity: 0.85; }
.btn-avancar.escondido { display: none; }
.btn-primario.escondido { display: none; }

/* NAV REVISÃO */
.nav-revisao {
  display: flex;
  gap: 8px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.nav-revisao.escondido { display: none; }

.btn-nav {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn-nav:active:not(:disabled) { background: var(--surface2); color: var(--text); }
.btn-nav:disabled { opacity: 0.2; }

.btn-nav-destaque {
  background: var(--surface2);
  border-color: #444;
  color: var(--text);
  flex: 1.4;
}

/* INSTRUÇÕES */
#tela-instrucoes {
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.instrucoes-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.instrucoes-lista {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0 32px;
  text-align: left;
}

.instrucao-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.instrucao-item.instrucao-destaque {
  border-color: #f59e0b40;
  background: #f59e0b08;
}

.instrucao-icone {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--text-muted);
  width: 22px;
  text-align: center;
}

.instrucao-item strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.instrucao-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* QUALIDADES E DEFEITOS (form embutido no resultado) */
.qualidades-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  width: 100%;
  text-align: left;
}

.campo-secao {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 6px;
}

.campo-grupo { display: flex; flex-direction: column; gap: 4px; }

/* PRESENTE */
#tela-presente {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.presente-emoji { font-size: 5rem; margin-bottom: 20px; animation: bounce 0.6s ease; }

.titulo-resultado { font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.02em; }

.presente-valor {
  font-size: 2.8rem;
  font-weight: 800;
  color: #f59e0b;
  margin: 10px 0 8px;
  letter-spacing: -0.03em;
}

/* RESULTADO */
#tela-resultado {
  flex-direction: column;
  padding: 0;
}

.resultado-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 24px;
  padding-top: calc(40px + env(safe-area-inset-top));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.resultado-conteudo {
  width: 100%;
  transition: filter 0.6s ease;
}

.resultado-conteudo.desfocado {
  filter: blur(30px);
  user-select: none;
  pointer-events: none;
}

.descobrir-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  margin: 24px 0 0;
  text-align: left;
}

.descobrir-box.escondido { display: none; }

.descobrir-titulo {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: center;
}

.descobrir-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  text-align: center;
}

.resultado-emoji { font-size: 4rem; margin-bottom: 14px; }

.placar-box {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 18px;
}

.placar-numero { font-size: 4.5rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.placar-label { color: var(--text-muted); font-size: 1rem; }

.premio-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f59e0b10;
  border: 1px solid #f59e0b40;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
  font-size: 1rem;
  font-weight: 600;
  color: #f59e0b;
  width: 100%;
}

.premio-box.escondido { display: none; }

/* MAIS JOGOS */
.mais-jogos-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.mais-jogos-box.escondido { display: none; }

.mais-jogos-label {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.mais-jogos-btns {
  display: flex;
  gap: 10px;
}

.btn-jogos {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s;
}

.btn-jogos:active { background: #333; }
.btn-jogos.selecionado { border-color: #555; background: #2a2a2a; }
.btn-jogos:disabled { opacity: 0.5; cursor: default; }

.mais-jogos-confirmacao {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.mais-jogos-confirmacao.escondido { display: none; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40%       { transform: translateY(-18px); }
  70%       { transform: translateY(-8px); }
}
