/* MinhasDezenas — multi-loteria · tema escuro responsivo · por vacp */

:root {
  --bg: #15171f;
  --card: #1e2230;
  --elev: #262b3d;
  --input: #171a23;
  --fg: #e6e8f0;
  --muted: #8a92a6;
  --dim: #5b6175;
  /* accent default = Lotofácil; sobrescrito por JS por jogo */
  --accent: #f5c542;
  --accent-dark: #b8902a;
  --accent-hi: #fff4c8;
  --ball-text: #3d2c00;
  --primary: #7aa2f7;
  --success: #7dd87a;
  --warning: #e0af68;
  --error: #f7768e;
  --divider: #2a2f42;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* Toda área interativa fica sem delay e sem highlight cinza no toque. */
button, .ball, .tab, .game-pill, .heat-cell, .saved-item, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Helper universal: esconde scrollbar em qualquer carrossel/scroll horizontal. */
.hscroll, .tabs, .game-switcher, .chart-wrap, .freq-heat {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hscroll::-webkit-scrollbar,
.tabs::-webkit-scrollbar,
.game-switcher::-webkit-scrollbar,
.chart-wrap::-webkit-scrollbar,
.freq-heat::-webkit-scrollbar { display: none; width: 0; height: 0; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(180deg, #1a1d2a 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--divider);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  padding-top: env(safe-area-inset-top, 0);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, var(--accent-hi) 0%, var(--accent) 45%, var(--accent-dark) 100%);
  color: var(--ball-text);
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.35);
  flex-shrink: 0;
  transition: background 240ms ease;
}
.brand-name { font-size: 18px; font-weight: 700; line-height: 1; }
.brand-tag { font-size: 12px; color: var(--muted); margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.status-dot { font-size: 14px; }
.status-dot.ok { color: var(--success); }
.status-dot.warn { color: var(--warning); }
.status-dot.err { color: var(--error); }
.status-text { font-size: 13px; color: var(--muted); }

/* ---------- icons ---------- */
.ico {
  width: 18px; height: 18px;
  flex-shrink: 0; vertical-align: middle; display: inline-block;
}
.ico-sm { width: 14px; height: 14px; }
button .ico, .tab .ico { margin-right: 6px; }
.tab { display: inline-flex; align-items: center; }
button { display: inline-flex; align-items: center; justify-content: center; }

.bt-hits { display: inline-flex; align-items: center; gap: 6px; }
.bt-hits .ico { width: 16px; height: 16px; }

.status-dot svg { width: 10px; height: 10px; display: block; }
.status-text { display: inline-flex; align-items: center; gap: 6px; }

#winnersLine, #userWinnersLine {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  align-items: center;
}
.winner-bit { display: inline-flex; align-items: center; gap: 6px; }
.winner-ico { display: inline-flex; }
.winner-ico .ico { width: 14px; height: 14px; }
.winner-ico.jackpot { color: var(--accent); }
.winner-ico.near { color: var(--primary); }
.winner-sep { color: var(--dim); }

/* ---------- game switcher ---------- */
.game-switcher-wrap {
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
  border-bottom: 1px solid var(--divider);
  padding: 10px 0;
}
.game-switcher {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.game-pill {
  --pill-accent: #7dd87a;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--divider);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.game-pill:hover { background: var(--elev); }
.game-pill .pill-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--pill-accent);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.game-pill .pill-text {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  line-height: 1.1;
}
.game-pill .pill-name { font-size: 14px; }
.game-pill .pill-tag { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.game-pill.active {
  background: color-mix(in srgb, var(--pill-accent) 14%, var(--card));
  border-color: var(--pill-accent);
  color: var(--fg);
  box-shadow: 0 4px 12px -4px var(--pill-accent);
}
.game-pill.active .pill-tag { color: color-mix(in srgb, var(--pill-accent) 70%, var(--muted)); }
.game-pill:active { transform: translateY(1px); }

/* ---------- buttons ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background 120ms ease, transform 80ms ease, color 120ms ease;
}
button:active { transform: translateY(1px); }
.primary-btn {
  background: var(--accent);
  color: var(--ball-text);
  padding: 12px 18px;
  font-size: 14px;
  min-height: 44px;
}
.primary-btn:hover { filter: brightness(1.08); }
.ghost-btn {
  background: var(--card);
  color: var(--fg);
  padding: 11px 16px;
  font-size: 13px;
  min-height: 44px;
}
.ghost-btn:hover { background: var(--elev); }
.ghost-btn:disabled { opacity: .5; cursor: not-allowed; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--divider);
  padding: 8px 16px 0;
  -webkit-overflow-scrolling: touch;
}
.tab {
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
  min-height: 44px;
}
.tab:hover { color: var(--fg); }
.tab.active {
  color: var(--accent);
  background: var(--card);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- panels & cards ---------- */
main { padding: 20px 0 80px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 200ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--divider);
}
.card h2 { margin: 0 0 4px; font-size: 18px; color: var(--fg); }
.card h3 { font-size: 15px; color: var(--fg); }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.muted.small { font-size: 12px; }

/* ---------- balls ---------- */
.balls-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 14px 0;
}
.ball {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, var(--accent-hi) 0%, var(--accent) 45%, var(--accent-dark) 100%);
  color: var(--ball-text);
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.35);
  user-select: none;
  flex-shrink: 0;
}

/* grid de seleção — colunas adaptáveis; JS define grid-template-columns */
.balls-grid {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  /* fallback se JS não rodou */
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
}
.balls-grid .ball {
  width: 100%;
  height: 0; padding-bottom: 100%;
  position: relative;
  cursor: pointer;
  font-size: 0;
  transition: transform 80ms ease, box-shadow 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.balls-grid .ball:hover { transform: scale(1.06); }
.balls-grid .ball::after {
  content: attr(data-num);
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(11px, 3.4vw, 15px);
  font-weight: 800;
}
.balls-grid .ball.deselected {
  background: var(--input);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--dim);
}
.balls-grid .ball.deselected::after { color: var(--muted); }

.counter-row {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0;
}
.counter {
  font-weight: 700; font-size: 16px;
  color: var(--muted);
}
.counter.partial { color: var(--warning); }
.counter.full { color: var(--accent); }

/* ---------- chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}
.chip {
  background: var(--elev);
  padding: 12px 16px;
  border-radius: var(--radius);
  min-width: 96px;
  text-align: center;
  flex: 1 1 96px;
}
.chip-value { font-size: 20px; font-weight: 700; color: var(--accent); }
.chip-label { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: lowercase; }
/* segundo / terceiro chip ganham cor neutra para não competir com o accent do jogo */
.chip:nth-child(2) .chip-value { color: var(--primary); }
.chip:nth-child(3) .chip-value { color: var(--success); }
.chip:nth-child(4) .chip-value { color: var(--muted); font-size: 14px; }

/* ---------- backtest table ---------- */
.bt-table { display: grid; gap: 4px; margin-top: 12px; }
.bt-row {
  display: grid;
  grid-template-columns: 56px 80px 60px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--input);
  border-radius: 8px;
  font-size: 13px;
}
.bt-row .bt-hits { font-weight: 700; }
.bt-row.jackpot { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--input)); }
.bt-row.near { color: var(--primary); background: rgba(122,162,247,0.06); }
.bt-bar { height: 8px; background: var(--elev); border-radius: 4px; overflow: hidden; }
.bt-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bt-row.jackpot .bt-bar > span { background: var(--accent); }
.bt-row.near .bt-bar > span { background: var(--primary); }
.bt-row:not(.jackpot):not(.near) .bt-bar > span { background: var(--dim); }

/* ---------- weight table ---------- */
.weight-table { display: grid; gap: 4px; margin-top: 8px; }
.w-row {
  display: grid;
  grid-template-columns: 56px 40px 90px 90px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--input);
  border-radius: 8px;
  font-size: 13px;
}
.w-row .rank { color: var(--muted); }
.w-row .num { font-weight: 700; }
.w-row.hot .num, .w-row.hot .lift { color: var(--accent); }
.w-row.cold .num, .w-row.cold .lift { color: var(--primary); }
.w-bar { height: 6px; background: var(--elev); border-radius: 3px; overflow: hidden; }
.w-bar > span { display: block; height: 100%; }
.w-row.hot .w-bar > span { background: var(--accent); }
.w-row.cold .w-bar > span { background: var(--primary); }

/* ---------- history table ---------- */
.hist-table { display: grid; gap: 2px; }
.h-row {
  display: grid;
  grid-template-columns: 70px 90px 1fr;
  gap: 12px;
  padding: 10px;
  background: var(--input);
  border-radius: 8px;
  font-size: 13px;
  align-items: center;
}
.h-row.alt { background: var(--elev); }
.h-row .nums { display: flex; flex-wrap: wrap; gap: 4px; }
.h-row .nums span {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 28px; height: 24px; padding: 0 6px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- chart ---------- */
.chart-wrap {
  margin-top: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
canvas#freqChart {
  height: 320px;
  display: block;
}

/* ---------- 2-column check grid ---------- */
.check-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 1fr);
  gap: 32px;
}
@media (max-width: 820px) {
  .check-grid { grid-template-columns: 1fr; gap: 20px; }
}

/* ---------- ads ---------- */
/* Não reserva espaço enquanto não houver ad preenchido (conta em análise/sem fill) */
.ad-slot { margin: 0; text-align: center; }
.ad-slot ins { width: 100%; }

.ad-slot:has(ins[data-ad-status="filled"]) {
  margin: 16px 0;
  min-height: 90px;
  background: rgba(255,255,255,0.015);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.ad-rectangle:has(ins[data-ad-status="filled"]) { min-height: 250px; }

.ad-slot ins:not([data-ad-status]),
.ad-slot ins[data-ad-status="unfilled"] {
  display: none !important;
}

.ad-sticky-mobile {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--divider);
  z-index: 40;
  padding: 0;
  display: none;
}
.ad-sticky-mobile:has(ins[data-ad-status="filled"]) {
  display: block;
  padding: 4px 8px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 760px) {
  main { padding-bottom: env(safe-area-inset-bottom, 0px); }
  body:has(.ad-sticky-mobile ins[data-ad-status="filled"]) main {
    padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--divider);
  padding: 24px 0;
  margin-top: 40px;
}
.footer-row { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .header-actions .status-text { display: none; }
  .icon-only-mobile .btn-label { display: none; }
  .icon-only-mobile .ico { margin-right: 0; }
  .ghost-btn.icon-only-mobile { padding: 11px; min-width: 44px; }
}

@media (max-width: 600px) {
  .container { padding: 0 12px; }
  .brand-tag { font-size: 11px; }
  .ball { width: 40px; height: 40px; font-size: 13px; }
  .actions { gap: 6px; }
  .actions .primary-btn,
  .actions .ghost-btn { flex: 1 1 calc(50% - 3px); }
  .card { padding: 16px; }
  .bt-row { grid-template-columns: 42px 50px 50px 1fr; gap: 8px; font-size: 12px; padding: 8px; }
  .w-row { grid-template-columns: 38px 32px 64px 64px 1fr; gap: 6px; font-size: 12px; padding: 8px; }
  .h-row { grid-template-columns: 56px 76px 1fr; gap: 8px; font-size: 12px; padding: 8px; }
  .h-row .nums span { min-width: 24px; height: 22px; font-size: 11px; padding: 0 4px; }
  .chip { padding: 10px 12px; min-width: 80px; flex-basis: calc(50% - 5px); }
  .chip-value { font-size: 18px; }
  .game-pill { padding: 8px 12px; font-size: 13px; }
  .game-pill .pill-name { font-size: 13px; }
  .game-pill .pill-tag { font-size: 10px; }
  .balls-grid { gap: 6px; }
  .header-row { padding: 10px 12px; }
  .logo-mark { width: 36px; height: 36px; font-size: 14px; }
  .brand-name { font-size: 16px; }
}

@media (max-width: 380px) {
  .ball { width: 36px; height: 36px; font-size: 12px; }
  .chip-value { font-size: 16px; }
  .tab { padding: 10px 10px; font-size: 13px; }
  .tab .ico { width: 16px; height: 16px; }
}

/* Lotomania tem 100 dezenas — grid mais denso por padrão */
body[data-game="lotomania"] .balls-grid { gap: 6px; }
body[data-game="quina"] .balls-grid { gap: 6px; }

/* ---------- próximo concurso ---------- */
.next-contest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 0;
  align-items: center;
}
.next-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--input);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--divider);
}
.next-pill strong { color: var(--accent); font-weight: 700; }
.next-pill .next-label { color: var(--dim); }
.next-pill .ico { color: var(--muted); }

/* ---------- bilhetes salvos ---------- */
.saved-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.saved-item {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--input);
  border-radius: 8px;
}
.saved-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.saved-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mini-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 13px;
  background: radial-gradient(circle at 30% 25%, var(--accent-hi) 0%, var(--accent) 60%, var(--accent-dark) 100%);
  color: var(--ball-text);
  font-weight: 800;
  font-size: 11px;
}
.saved-actions {
  display: inline-flex;
  gap: 4px;
}
.saved-actions .ghost-btn {
  padding: 8px 10px;
  min-height: 36px;
  font-size: 0;
}
.saved-actions .ghost-btn .ico { margin: 0; }
@media (max-width: 600px) {
  .saved-item { grid-template-columns: 1fr; gap: 8px; padding: 10px; }
  .saved-meta { font-size: 11px; }
  .saved-actions { justify-content: flex-end; }
}

/* ---------- heatmap (Quina/Lotomania) ---------- */
.freq-heat {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), 1fr);
  gap: 4px;
  margin-top: 12px;
}
.heat-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background-color: color-mix(in srgb, var(--cell-color, var(--dim)) calc(var(--intensity, 0.5) * 100%), var(--input));
  border: 1px solid rgba(255,255,255,0.04);
  font-size: clamp(9px, 1.6vw, 12px);
  line-height: 1;
}
.heat-cell.hot { --cell-color: var(--accent); }
.heat-cell.cold { --cell-color: #7aa2f7; }
.heat-num { color: var(--fg); font-weight: 700; }
.heat-val { color: var(--muted); font-size: 0.85em; margin-top: 1px; }
.heat-cell.hot .heat-num { color: var(--ball-text); }
.heat-cell.hot .heat-val { color: color-mix(in srgb, var(--ball-text) 70%, transparent); }
@media (max-width: 600px) {
  .freq-heat { gap: 3px; }
  .heat-val { display: none; }
}

/* ---------- responsividade extra ---------- */

/* Mobile pequeno: tabs viram só ícone, header bem compacto */
@media (max-width: 420px) {
  .tab .tab-label { display: none; }
  .tab { padding: 12px 14px; min-width: 44px; }
  .tab .ico { margin-right: 0; width: 20px; height: 20px; }
  .brand-tag { display: none; }
  .brand-name { font-size: 15px; }
  .header-row { padding: 10px 12px; gap: 8px; }
}

/* Tela extra estreita (iPhone SE etc.) */
@media (max-width: 340px) {
  .container { padding: 0 10px; }
  .game-pill { padding: 7px 10px; }
  .game-pill .pill-tag { display: none; }
  .ball { width: 34px; height: 34px; font-size: 11px; }
  .chip { padding: 8px 10px; min-width: 70px; }
  .chip-value { font-size: 16px; }
}

/* Cards encostam menos na borda no mobile, mais respiro lateral */
@media (max-width: 600px) {
  .card { margin-bottom: 14px; border-radius: 12px; }
  .game-switcher-wrap { padding: 8px 0; }
  .game-switcher { padding: 0 12px; gap: 6px; }
  .next-contest { padding: 8px 12px 0; gap: 6px; }
  .next-pill { padding: 5px 10px; font-size: 11px; }
}

/* Garantia anti-zoom no iOS: qualquer input/select/textarea ≥ 16px */
input, select, textarea {
  font-size: 16px;
}

/* Botões mantêm alvo de toque mínimo 44×44 mesmo quando "icon-only" */
.ghost-btn.icon-only-mobile { min-width: 44px; min-height: 44px; }
.saved-actions .ghost-btn { min-width: 40px; min-height: 40px; }

/* Evita "zoom de duplo toque" mantendo scroll suave em qualquer dispositivo */
main, .tab-panel { -webkit-overflow-scrolling: touch; }

/* Heatmap respira melhor no mobile */
@media (max-width: 600px) {
  .heat-cell { border-radius: 4px; padding: 1px; }
  .heat-num { font-size: clamp(9px, 2.6vw, 12px); }
}

/* Cross-link para o projeto irmão (MinhasOrações) */
.cross-link {
  margin: 24px 0 8px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(240,198,116,0.08), rgba(91,95,199,0.08));
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  text-align: center;
}
.cross-link .cl-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.cross-link a {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

/* Quando o app está rodando como PWA standalone, esconde o sticky-ad pra ganhar tela */
@media (display-mode: standalone) {
  .ad-sticky-mobile { display: none !important; }
  main { padding-bottom: env(safe-area-inset-bottom, 0px) !important; }
}
