:root {
  --bg: #0b0e16;
  --surface: #131826;
  --surface-2: #1b2238;
  --border: #2a3149;
  --primary: #f0b030;
  --primary-fg: #1a1206;
  --text: #e9edf6;
  --muted: #8590ad;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }

#app { min-height: 100vh; padding-bottom: 72px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 14, 22, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--primary); font-weight: 700; font-size: 18px; text-decoration: none; }
.phase-pill {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
}
.phase-pill.selling { color: var(--success); border-color: var(--success); }
.phase-pill.drawing { color: var(--primary); border-color: var(--primary); }
.phase-pill.result { color: var(--warning); border-color: var(--warning); }
.phase-pill.ad { color: var(--muted); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }

.view { padding: 16px; max-width: 720px; margin: 0 auto; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(11, 14, 22, 0.94);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 10;
}
.navlink { color: var(--muted); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; }
.navlink .ico { font-size: 20px; }
.navlink.active { color: var(--primary); }

/* Botões */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.block { width: 100%; justify-content: center; }
.btn.large { font-size: 16px; padding: 14px 20px; }

/* Cards / surfaces */
.surface { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.surface + .surface { margin-top: 12px; }

/* Phase indicator centrão */
.hero { text-align: center; padding: 24px 16px; }
.hero h2 { margin: 0 0 8px; font-size: 24px; }
.hero p { color: var(--muted); margin: 0; }

/* Cartela */
.cartela { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: var(--surface-2);
  padding: 6px; border-radius: 12px; user-select: none; max-width: 360px; margin: 0 auto; }
.cartela-header {
  font-weight: 800; text-align: center; color: var(--primary); padding: 8px 0;
  background: var(--bg); border-radius: 6px;
}
.cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; background: var(--bg); border-radius: 6px;
  position: relative;
}
.cell.free { background: var(--primary); color: var(--primary-fg); }
.cell.marked { background: var(--success); color: white; }
.cell.last-drawn { animation: pop 0.5s ease-out; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); background: var(--warning); }
  100% { transform: scale(1); }
}

/* Sorteio: lista de bolas */
.bolas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; justify-content: center; }
.bola {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  border: 1px solid var(--border);
}
.bola.last { background: var(--primary); color: var(--primary-fg); border-color: var(--primary);
  transform: scale(1.15); box-shadow: 0 0 12px rgba(240, 176, 48, 0.5); }

.big-ball {
  width: 120px; height: 120px; border-radius: 50%; margin: 12px auto;
  background: radial-gradient(circle at 35% 35%, #ffd76e, var(--primary));
  color: var(--primary-fg); display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 800; box-shadow: 0 8px 24px rgba(240, 176, 48, 0.4);
}

/* QR */
.qr-display { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
.qr-display img { width: 280px; height: 280px; background: white; padding: 12px; border-radius: 12px; }
.qr-display code { background: var(--surface-2); padding: 4px 10px; border-radius: 6px; font-size: 13px; }

/* Scanner */
#scanner-video { width: 100%; max-width: 480px; border-radius: 12px; background: black; aspect-ratio: 4/3; object-fit: cover; }

/* Lista de cartelas */
.cards-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 600px) {
  .cards-grid { grid-template-columns: 1fr 1fr; }
}

.winner-list { list-style: none; padding: 0; margin: 8px 0 0; }
.winner-list li {
  background: var(--surface-2); border-left: 4px solid var(--primary);
  padding: 8px 12px; margin-bottom: 6px; border-radius: 6px;
  font-family: monospace;
}

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.tag.win-quadra { background: rgba(74, 222, 128, 0.15); color: var(--success); border: 1px solid var(--success); }
.tag.win-linha { background: rgba(251, 191, 36, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.tag.win-cheia { background: rgba(240, 176, 48, 0.15); color: var(--primary); border: 1px solid var(--primary); }

.ad-screen { text-align: center; padding: 40px 16px; }
.ad-screen .placeholder { font-size: 96px; opacity: 0.3; }
.ad-screen h2 { font-size: 32px; margin: 16px 0 8px; }
.ad-screen p { color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.center { text-align: center; }
