:root {
  --bg: #070b14;
  --surface: #111827;
  --surface-2: #1a2438;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #94a3b8;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --cyan: #06b6d4;
  --gold: #f59e0b;
  --purple: #8b5cf6;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: radial-gradient(circle at top, #131f3b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 14px 96px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 10px; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--emerald), var(--cyan));
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}
.brand-title { font-weight: 900; font-size: 1.08rem; display: flex; align-items: center; gap: 5px; }
.pro-tag {
  font-size: 0.6rem; font-weight: 800; padding: 2px 6px; border-radius: 999px;
  background: rgba(6, 182, 212, 0.2); color: #67e8f9;
}
.brand-sub { font-size: 0.72rem; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 8px; }

.wallet-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid rgba(16, 185, 129, 0.5);
  color: var(--text); padding: 6px 10px; border-radius: 999px; cursor: pointer;
}
.pill-plus {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--emerald); color: #052e16;
  display: grid; place-items: center; font-weight: 800; font-size: 0.9rem;
}

.ticker-wrap {
  width: 100%; overflow: hidden; white-space: nowrap;
  background: rgba(17, 24, 39, 0.85); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 0; margin-bottom: 12px;
}
.ticker-track {
  display: inline-flex; white-space: nowrap; gap: 22px;
  font-size: 0.76rem; color: #cbd5e1; padding-left: 14px;
  animation: tickerRun 24s linear infinite;
}
@keyframes tickerRun {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.toast {
  position: fixed; top: 14px; right: 14px; z-index: 250;
  background: #1e293b; border: 1px solid var(--emerald); color: #fff;
  padding: 11px 15px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  max-width: 330px; font-size: 0.88rem;
}
.toast.error { border-color: var(--danger); }

.promo-banner {
  background: linear-gradient(125deg, #064e3b, #0f172a 55%, #4c1d95);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px; padding: 14px 16px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.promo-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 800; color: #fde68a;
  background: rgba(245, 158, 11, 0.2); padding: 3px 8px; border-radius: 999px; margin-bottom: 4px;
}
.promo-content h1 { margin: 2px 0; font-size: 1.25rem; font-weight: 800; line-height: 1.15; }
.promo-content p { margin: 0; font-size: 0.78rem; color: #cbd5e1; }
.promo-cta { flex-shrink: 0; }

.lobby-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cat-tabs { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  white-space: nowrap; background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-family: inherit; font-weight: 700; font-size: 0.8rem; cursor: pointer;
}
.cat-tab.active { background: var(--emerald); color: #042f1a; border-color: var(--emerald); }

.search-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 9px 13px; border-radius: 12px; font-family: inherit; font-size: 0.88rem;
}

.section-mini-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.section-mini-head h2 { margin: 0; font-size: 1.08rem; font-weight: 800; }

.poster-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.poster-tile {
  position: relative; border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12); background: var(--surface);
  cursor: pointer; aspect-ratio: 4 / 3.4;
  transition: transform 0.16s ease, border-color 0.16s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.poster-tile:hover { transform: translateY(-3px); border-color: var(--emerald); }
.poster-tile svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.poster-top {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; justify-content: space-between; align-items: center; pointer-events: none;
}
.poster-badge {
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.03em;
  background: rgba(5, 8, 17, 0.78); color: #fff; border: 1px solid rgba(255,255,255,0.18);
  padding: 3px 7px; border-radius: 999px;
}
.poster-live {
  font-size: 0.64rem; font-weight: 800; color: #fde047;
  background: rgba(234, 179, 8, 0.25); border: 1px solid rgba(250, 204, 21, 0.5);
  padding: 3px 7px; border-radius: 999px;
}
.poster-overlay {
  position: absolute; inset: auto 0 0 0; padding: 28px 10px 10px;
  background: linear-gradient(to top, rgba(5, 8, 17, 0.96) 35%, rgba(5, 8, 17, 0.55) 75%, transparent);
  display: flex; justify-content: space-between; align-items: flex-end; gap: 6px;
}
.poster-title { font-weight: 800; font-size: 0.94rem; line-height: 1.15; }
.poster-sub { font-size: 0.7rem; color: #6ee7b7; font-weight: 600; margin-top: 2px; }
.play-pill {
  flex-shrink: 0; background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
  color: #042f1a; font-weight: 900; font-size: 0.72rem; padding: 5px 10px; border-radius: 999px;
}

.badge-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: rgba(16,185,129,0.18); color: #6ee7b7; font-size: 0.7rem; font-weight: 700;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px; margin-bottom: 14px;
}
.card h3 { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { margin: 0; }

.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: #cbd5e1; }
input, select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-family: inherit; font-size: 0.92rem;
}
input:focus, select:focus { outline: 2px solid var(--emerald); border-color: transparent; }

.checkbox-row { flex-direction: row; align-items: flex-start; gap: 9px; font-size: 0.8rem; }
.checkbox-row input { width: 17px; height: 17px; margin-top: 2px; }

.btn {
  border: none; border-radius: 11px; padding: 10px 14px;
  font-family: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer;
}
.btn-lg { padding: 12px 16px; font-size: 0.95rem; }
.btn-sm { padding: 7px 11px; font-size: 0.78rem; }
.btn-primary { background: linear-gradient(135deg, var(--emerald), var(--emerald-dark)); color: #042f1a; }
.btn-gold { background: linear-gradient(135deg, #fbbf24, #d97706); color: #271502; }
.btn-glass { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid rgba(255,255,255,0.14); }
.btn-danger { background: rgba(239,68,68,0.18); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }

/* Redesigned Wallet Hero */
.wallet-hero {
  background: linear-gradient(135deg, #064e3b 0%, #0f172a 55%, #1e1b4b 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.wallet-hero-total span {
  display: block; font-size: 0.78rem; color: #cbd5e1;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.wallet-hero-total strong {
  display: block; font-size: 2rem; font-weight: 900; color: #34d399; line-height: 1.15; margin-top: 4px;
}
.wallet-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wallet-hero-actions a { text-decoration: none; min-width: 128px; text-align: center; }

.wallet-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.bucket-card { border-radius: 14px; padding: 13px; border: 1px solid var(--border); background: var(--surface); }
.bucket-card span { display: block; font-size: 0.76rem; color: var(--muted); }
.bucket-card strong { display: block; font-size: 1.25rem; margin: 4px 0; }
.bucket-card small { font-size: 0.7rem; color: var(--muted); }
.bucket-card.emerald strong { color: var(--emerald); }
.bucket-card.gold strong { color: var(--gold); }
.bucket-card.purple strong { color: #a78bfa; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.quick-amounts { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-family: inherit;
}

.list-stack { display: flex; flex-direction: column; gap: 8px; }
.list-stack.compact { margin-top: 10px; }
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 9px 12px; border-radius: 12px; font-size: 0.85rem;
}
.list-row .amt-pos { color: var(--emerald); font-weight: 700; }
.list-row .amt-neg { color: #f87171; font-weight: 700; }

.referral-box {
  background: var(--surface-2); border: 1px dashed rgba(139,92,246,0.5);
  padding: 12px; border-radius: 12px; margin: 12px 0;
}
.referral-box span { display: block; font-size: 0.76rem; color: var(--muted); margin-bottom: 6px; }
.ref-row { display: flex; justify-content: space-between; align-items: center; }
.ref-row strong { font-size: 1.1rem; color: #c4b5fd; letter-spacing: 0.08em; }
.ref-link-row { display: flex; gap: 8px; align-items: center; }
.ref-link-row input { flex: 1; font-size: 0.78rem; padding: 8px 10px; }

.google-auth-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 10px 0; }
.google-btn {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: #ffffff; color: #111827; border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px; padding: 11px 16px; font-family: inherit; font-weight: 700; font-size: 0.94rem;
  cursor: pointer; transition: transform 0.12s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.google-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,0.38); }
.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 12px 0;
  color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.detect-hint {
  font-size: 0.78rem; padding: 7px 10px; border-radius: 9px;
  background: rgba(6, 182, 212, 0.14); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.3);
}
.detect-hint.existing {
  background: rgba(16, 185, 129, 0.14); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35);
}

/* 0-9 Spin Wheel Modal */
.wheel-stage {
  width: 100%; max-width: 500px; max-height: 94vh; overflow-y: auto;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.14); border-radius: 22px;
}
.wheel-body { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.wheel-status-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 13px; border-radius: 12px;
  background: rgba(16, 185, 129, 0.16); border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 0.88rem; font-weight: 700;
}
.wheel-status-bar.locked { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.5); color: #fde68a; }
.wheel-status-bar.spinning { background: rgba(139, 92, 246, 0.22); border-color: rgba(139, 92, 246, 0.55); color: #ddd6fe; }
.wheel-status-bar.settled { background: rgba(6, 182, 212, 0.2); border-color: rgba(6, 182, 212, 0.5); color: #bae6fd; }
.wheel-recent { display: flex; align-items: center; gap: 6px; overflow-x: auto; font-size: 0.75rem; }
.recent-ball {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800;
  background: var(--surface-2); border: 1px solid var(--border);
}
.wheel-canvas-wrap { position: relative; display: grid; place-items: center; padding-top: 8px; }
#wheel-canvas { max-width: 270px; width: 100%; height: auto; }
.wheel-stake-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.wheel-stake-row .chip.active { background: var(--gold); color: #271502; border-color: var(--gold); }
.wheel-boxes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.wheel-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 13px; padding: 8px 4px; text-align: center; color: var(--text); cursor: pointer; font-family: inherit;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.wheel-box:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--emerald); }
.wheel-box:disabled { opacity: 0.6; cursor: not-allowed; }
.wheel-box .wb-num { display: block; font-size: 1.25rem; font-weight: 900; line-height: 1.1; }
.wheel-box .wb-mult { display: block; font-size: 0.72rem; color: #fbbf24; font-weight: 700; }
.wheel-box .wb-bet { display: block; font-size: 0.66rem; color: #6ee7b7; font-weight: 700; margin-top: 2px; min-height: 14px; }
.wheel-box.has-bet { border-color: var(--emerald); background: rgba(16, 185, 129, 0.15); }
.wheel-box.winner { border-color: #fbbf24; background: rgba(245, 158, 11, 0.28); box-shadow: 0 0 16px rgba(251, 191, 36, 0.45); }

.site-footer { text-align: center; padding: 12px 8px; font-size: 0.75rem; color: var(--muted); }
.footer-links {
  display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 6px;
}
.footer-links a { color: #cbd5e1; text-decoration: none; font-weight: 600; }
.footer-links a:hover { color: var(--emerald); text-decoration: underline; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: rgba(10, 15, 28, 0.97); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
}
.bottom-nav-inner {
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 680px; margin: 0 auto; gap: 4px;
}
.nav-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 7px 4px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit; cursor: pointer; text-decoration: none;
}
.nav-btn span { font-size: 0.72rem; font-weight: 700; }
.nav-btn.active { color: #34d399; background: rgba(16, 185, 129, 0.15); }

.modal {
  position: fixed; inset: 0; z-index: 160;
  background: rgba(5, 8, 15, 0.9);
  display: grid; place-items: center; padding: 12px;
}
.launch-sheet, .game-stage {
  width: 100%; max-width: 480px;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px; overflow: hidden;
}
.launch-art { height: 140px; }
.launch-art svg { width: 100%; height: 100%; display: block; }
.launch-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.launch-body h3 { margin: 0; font-size: 1.25rem; }
.launch-body p { margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.tier-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tier-btn {
  background: var(--surface-2); border: 1px solid rgba(16,185,129,0.4);
  color: var(--text); border-radius: 12px; padding: 10px 6px;
  cursor: pointer; text-align: center; font-family: inherit;
}
.tier-btn strong { display: block; font-size: 1rem; color: var(--emerald); }
.tier-btn span { display: block; font-size: 0.72rem; color: var(--muted); }
.tier-btn .live-tag { color: #fde047; font-weight: 700; margin-top: 2px; }

.stage-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.stage-hud { display: flex; align-items: center; gap: 8px; }
.hud-chip { background: #0b1220; padding: 5px 10px; border-radius: 999px; font-size: 0.84rem; }
.hud-chip.timer strong { color: var(--gold); }
.stage-body { padding: 14px; }
.stage-hint { text-align: center; font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

#game-canvas {
  width: 100%; height: auto; display: block; border-radius: 14px;
  background: radial-gradient(circle at center, #1e293b, #090d16);
  touch-action: none; cursor: crosshair;
}
.quiz-progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
#quiz-bar { height: 100%; width: 100%; background: var(--emerald); transition: width 0.1s linear; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.quiz-opt {
  text-align: left; padding: 13px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}

.result-box { text-align: center; padding: 24px 18px; }
.result-icon { font-size: 3rem; margin-bottom: 8px; }
.result-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.result-scores div { background: var(--surface-2); padding: 12px; border-radius: 12px; }
.result-scores span { display: block; font-size: 0.78rem; color: var(--muted); }
.result-scores strong { font-size: 1.4rem; color: var(--emerald); }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 720px) {
  .poster-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .wallet-cards { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
  .poster-title { font-size: 0.85rem; }
  .play-pill { padding: 4px 8px; font-size: 0.68rem; }
}
