/* ============================================================
 * Analisador de Loterias — folha de estilo
 * Design moderno (tarjetas com cantos suaves, gradientes sutis,
 * malha de calor do volante), 100% responsivo e acessível:
 * contraste WCAG AA, foco visível, área de toque confortável,
 * movimento reduzido (prefers-reduced-motion) e tema claro/escuro.
 * ============================================================ */

:root {
  --raio: 16px;
  --raio-mini: 10px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --largura-max: 74rem;
  --sombra: 0 10px 30px -18px rgb(2 6 23 / 0.55);
}

/* ---------- Tema escuro (padrão) ---------- */
[data-theme="escuro"] {
  color-scheme: dark;
  --bg: #0b1220;
  --painel: #121d31;
  --campo: #0e1727;
  --trilha: #22314d;
  --borda: #2a3b5c;
  --texto: #e8eef7;
  --texto-2: #a8b6ca;
  --acento: #2dd4bf;
  --acento-2: #818cf8;
  --btn-texto: #062224;
  --ok: #4ade80;
  --erro: #fb7185;
  --foco: #93c5fd;
  --h0: #152238;   --h0-t: #c3cede;
  --h1: #1d4666;   --h1-t: #dcebf9;
  --h2: #1c6f63;   --h2-t: #e7fffb;
  --h3: #2b9d87;   --h3-t: #062224;
  --h4: #eab308;   --h4-t: #573b00;
  --sombra: 0 12px 34px -18px rgb(0 0 0 / 0.7);
}

/* ---------- Tema claro ---------- */
[data-theme="claro"] {
  color-scheme: light;
  --bg: #eef3fa;
  --painel: #ffffff;
  --campo: #f2f6fb;
  --trilha: #dbe4f0;
  --borda: #ccd8e6;
  --texto: #12233d;
  --texto-2: #51637c;
  --acento: #0f766e;
  --acento-2: #4338ca;
  --btn-texto: #ffffff;
  --ok: #067647;
  --erro: #b42345;
  --foco: #1d4ed8;
  --h0: #e2e8f0;   --h0-t: #24324a;
  --h1: #bfdbfe;   --h1-t: #172a4d;
  --h2: #99f6e4;   --h2-t: #0b3d38;
  --h3: #7dd3fc;   --h3-t: #0c3b55;
  --h4: #fbbf24;   --h4-t: #573b00;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--fonte);
  background: var(--bg);
  color: var(--texto);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid var(--foco);
  outline-offset: 2px;
  border-radius: 6px;
}

.pular-para-conteudo {
  position: absolute;
  left: -9999px;
  top: .6rem;
  left: .6rem;
  z-index: 99;
  background: var(--acento);
  color: var(--btn-texto);
  padding: .7rem 1rem;
  border-radius: var(--raio-mini);
  font-weight: 700;
  text-decoration: none;
}
.pular-para-conteudo:focus { left: .6rem; }

/* ---------- cabeçalho ---------- */
.topo {
  background: linear-gradient(135deg, #134e4a, #312e81 55%, #4c1d95);
  color: #f8fafc;
}
.topo-interno {
  max-width: var(--largura-max);
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}
.topo h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -0.02em; }
.topo p { margin: .35rem 0 0; color: #c7d2fe; max-width: 46rem; font-size: .95rem; }
.topo button {
  background: rgb(255 255 255 / 0.14);
  border: 1px solid rgb(255 255 255 / 0.35);
  color: #f8fafc;
  padding: .55rem .95rem;
  border-radius: 999px;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}
.topo button:hover { background: rgb(255 255 255 / 0.24); }

/* ---------- estrutura ---------- */
main {
  max-width: var(--largura-max);
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

.painel {
  background: var(--painel);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: var(--sombra);
}

h2 {
  margin: 0 0 .9rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
h2::before {
  content: "";
  display: inline-block;
  width: .55rem; height: .55rem;
  margin-right: .5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--acento-2), var(--acento));
  vertical-align: middle;
}

h3 { margin: .2rem 0 .6rem; font-size: .98rem; }

/* ---------- tarjetas de resumo ---------- */
.resumo-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .7rem;
}
.res-card {
  background: var(--campo);
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: .7rem .9rem;
}
.res-card dt {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--texto-2);
  margin-bottom: .15rem;
}
.res-card dd { margin: 0; font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.res-origem { font-size: .78rem !important; font-weight: 500 !important; }

/* ---------- formulário ---------- */
.controles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: .8rem 1rem;
  margin-bottom: .8rem;
}
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
select, input[type="text"] {
  width: 100%;
  padding: .6rem .7rem;
  border-radius: var(--raio-mini);
  border: 1px solid var(--borda);
  background: var(--campo);
  color: var(--texto);
  font: inherit;
  min-height: 2.75rem; /* alvo de toque confortável */
}
select:hover, input[type="text"]:hover { border-color: var(--acento); }

details.filtros { margin: .2rem 0 .4rem; }
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--texto);
  padding: .45rem .2rem;
  border-radius: 8px;
}
summary:hover { color: var(--acento); }
.filtros-interno { margin-top: .4rem; }
.dica { color: var(--texto-2); font-size: .8rem; margin: .3rem 0 0; }

.acoes { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }

.btn {
  appearance: none;
  font: inherit;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .68rem 1.15rem;
  cursor: pointer;
  min-height: 2.75rem;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario {
  background: linear-gradient(120deg, var(--acento-2), var(--acento));
  color: var(--btn-texto);
  box-shadow: var(--sombra);
}
[data-theme="escuro"] .btn-primario { color: #04262b; }
.btn-secundario { background: transparent; border-color: var(--borda); color: var(--texto); }
.btn-secundario:hover { border-color: var(--acento); color: var(--acento); }
.btn-mini { padding: .32rem .7rem; font-size: .8rem; min-height: 2rem; border-radius: 9px; }

.status { min-height: 1.5em; margin: .6rem 0 0; color: var(--texto-2); font-size: .92rem; }
.status-ok { color: var(--ok); }
.status-erro { color: var(--erro); }

/* ---------- resultados ---------- */
.info-vazia { color: var(--texto-2); margin: .2rem 0 .8rem; }

#jogos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  gap: .9rem;
  margin-top: .4rem;
}
.jogo {
  background: var(--campo);
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.jogo-topo { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.jogo-topo h3 { margin: 0; }

.dezenas {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 0;
  padding: 0;
}
.dezena {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(circle at 30% 28%, rgb(255 255 255 / 0.35), transparent 46%),
    linear-gradient(150deg, var(--acento-2), var(--acento));
  color: #04262b;
  box-shadow: inset 0 -2px 6px rgb(0 0 0 / 0.18);
}

.metricas { display: flex; flex-wrap: wrap; gap: .4rem 1.3rem; margin: 0; }
.metricas div { min-width: 4.5rem; }
.metricas dt {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texto-2);
}
.metricas dd { margin: 0; font-weight: 650; font-size: .95rem; font-variant-numeric: tabular-nums; }

/* ---------- volante (malha de calor) ---------- */
.modo-clique {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.2rem;
  align-items: center;
  border: 1px dashed var(--borda);
  border-radius: 12px;
  padding: .55rem .8rem .7rem;
  margin: 0 0 .4rem;
}
.modo-clique legend { font-size: .8rem; color: var(--texto-2); padding: 0 .35rem; }
.modo-clique label {
  display: inline-flex;
  gap: .35rem;
  align-items: center;
  font-weight: 500;
  margin: 0;
}
.modo-clique input[type="radio"] { width: 1.1rem; height: 1.1rem; accent-color: var(--acento); }

.info-marcas { color: var(--texto-2); font-size: .88rem; margin: .1rem 0 .6rem; }

.letra-mais { font-size: .85rem; color: var(--texto-2); margin: .3rem 0 .35rem; }
.legenda { display: flex; align-items: center; gap: .55rem; font-size: .78rem; color: var(--texto-2); margin-bottom: .7rem; }
.legenda-escala {
  flex: 1;
  max-width: 22rem;
  height: .6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--h0), var(--h1), var(--h2), var(--h3), var(--h4));
  border: 1px solid var(--borda);
}

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.9rem, 1fr));
  gap: .45rem;
}
button.dez {
  aspect-ratio: 1;
  min-height: 2.75rem;
  border: none;
  border-radius: .85rem;
  font: inherit;
  font-weight: 650;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
button.dez:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -6px rgb(0 0 0 / 0.45); }
button.dez[data-heat="0"] { background: var(--h0); color: var(--h0-t); }
button.dez[data-heat="1"] { background: var(--h1); color: var(--h1-t); }
button.dez[data-heat="2"] { background: var(--h2); color: var(--h2-t); }
button.dez[data-heat="3"] { background: var(--h3); color: var(--h3-t); }
button.dez[data-heat="4"] { background: var(--h4); color: var(--h4-t); }
button.dez.fixado  { outline: 3px solid var(--acento); outline-offset: 2px; }
button.dez.excluido { outline: 3px solid var(--erro); outline-offset: 2px; text-decoration: line-through 2px; }

/* ---------- rankings ---------- */
.ranking-duplo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr));
  gap: 1rem;
  margin-top: 1.1rem;
}
.ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.ranking li {
  display: grid;
  grid-template-columns: 2.3rem 1fr auto;
  gap: .6rem;
  align-items: center;
  font-size: .88rem;
}
.rank-dez {
  display: grid;
  place-items: center;
  background: var(--campo);
  border: 1px solid var(--borda);
  border-radius: .6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  height: 1.9rem;
}
.rank-barra { height: .5rem; border-radius: 999px; background: var(--trilha); overflow: hidden; display: block; }
.rank-barra span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--acento-2), var(--acento)); }
.rank-info { color: var(--texto-2); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ---------- testes / histórico / metodologia ---------- */
.lista-testes { list-style: none; margin: .4rem 0; padding: 0; }
.teste { padding: .38rem .1rem; border-bottom: 1px dashed var(--borda); }
.teste-ok { color: var(--ok); }
.teste-falha { color: var(--erro); font-weight: 600; }
.teste-detalhe { color: var(--texto-2); font-size: .82rem; font-weight: 400; }

.lista-hist { padding-left: 1.3rem; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.lista-hist li { color: var(--texto-2); }

.metodologia { color: var(--texto-2); font-size: .92rem; display: flex; flex-direction: column; gap: .6rem; }
.metodologia strong { color: var(--texto); }
.metodologia code {
  background: var(--campo);
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: .05rem .3rem;
  font-size: .85em;
}

/* ---------- rodapé ---------- */
.rodape {
  max-width: var(--largura-max);
  margin: .4rem auto 2rem;
  padding: 0 1.25rem;
  color: var(--texto-2);
  font-size: .82rem;
}
.rodape a { color: var(--acento); }

.aviso-js {
  margin: 1rem;
  padding: 1rem;
  border: 2px solid var(--erro);
  border-radius: var(--raio);
  color: var(--texto);
}

/* ---------- responsividade ---------- */
@media (max-width: 560px) {
  .topo-interno { padding: 1.1rem .9rem 1.2rem; }
  main { padding: .9rem; gap: .8rem; }
  .painel { padding: .95rem .85rem 1.05rem; }
  .dezena { width: 2.4rem; height: 2.4rem; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); }
}

/* ---------- acessibilidade: movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
