/**
 * NEXUS AI Core — Design System v5
 * Cyberpunk Dark OLED — Telegram Mini App optimized
 * Single CSS file, no conflicts, scroll guaranteed.
 */

/* ═══════ VARIABLES ═══════ */
:root {
  --bg: #0F0F23;
  --bg-card: rgba(15, 15, 40, 0.85);
  --bg-surface: rgba(255, 255, 255, 0.03);
  --border: rgba(124, 58, 237, 0.12);
  --border-hover: rgba(124, 58, 237, 0.3);

  --primary: #7C3AED;
  --primary-dim: rgba(124, 58, 237, 0.12);
  --accent: #00E5FF;
  --accent-dim: rgba(0, 229, 255, 0.08);
  --success: #00DC82;
  --success-dim: rgba(0, 220, 130, 0.1);
  --danger: #F43F5E;
  --danger-dim: rgba(244, 63, 94, 0.1);
  --gold: #FFD700;
  --gold-dim: rgba(255, 215, 0, 0.1);

  /* istaff game compatibility variables */
  --panel-bg: rgba(15, 10, 40, 0.65);
  --panel-border: rgba(139, 92, 246, 0.2);
  --muted: #8b8ba7;
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.4);
  --pink: #ec4899;
  --primary-glow: rgba(124, 58, 237, 0.4);
  --success-glow: rgba(0, 220, 130, 0.4);
  --gold-glow: rgba(255, 215, 0, 0.4);
  --page-pad: 16px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-xl: 24px;

  --text: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: rgba(255, 255, 255, 0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --space: 16px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max-width: 480px;
}

/* ═══════ RESET ═══════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; border: none; outline: none; background: none; }
img { max-width: 100%; display: block; }

/* ═══════ BODY — SCROLL WORKS ═══════ */
html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* NO overflow-y:hidden, NO height:100vh, NO display:flex on body */
}

/* Background gradient (no pointer blocking) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(124, 58, 237, 0.12), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(0, 229, 255, 0.04), transparent 40%);
  pointer-events: none;
  z-index: -1;
}

/* ═══════ LAYOUT ═══════ */
.main-content {
  padding: var(--space);
  padding-top: 70px;
  padding-bottom: calc(var(--nav-height) + 24px + var(--safe-bottom));
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

/* ═══════ HEADER ═══════ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 15, 35, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px var(--space);
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* ═══════ BOTTOM NAV ═══════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 15, 35, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 0;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.2s;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 20px; height: 20px; }

/* ═══════ PANELS / CARDS ═══════ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: 12px;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.panel-sm { padding: 12px; }

/* ═══════ BUTTONS ═══════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { box-shadow: 0 0 16px rgba(124, 58, 237, 0.4); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-gold { background: var(--gold-dim); color: var(--gold); border-color: rgba(255, 215, 0, 0.25); }
.btn-ghost { background: var(--bg-surface); color: var(--text-secondary); border-color: var(--border); }
.btn-ghost.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* ═══════ SECTION LABELS ═══════ */
.section-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 10px;
}

/* ═══════ GAME CARDS ═══════ */
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.game-card:active { transform: scale(0.95); border-color: var(--border-hover); }
.game-card-icon { font-size: 28px; margin-bottom: 2px; }
.game-card-name { font-size: 11px; font-weight: 800; color: var(--text); }
.game-card-desc { font-size: 9px; color: var(--text-muted); display: none; }
.game-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 7px;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.game-badge.hot { background: var(--danger-dim); color: var(--danger); }
.game-badge.new { background: var(--accent-dim); color: var(--accent); }

/* ═══════ ANIMATIONS ═══════ */
.animate-in {
  opacity: 0;
  transform: translateY(10px);
  animation: slideIn 0.4s ease forwards;
}
.animate-in:nth-child(2) { animation-delay: 0.05s; }
.animate-in:nth-child(3) { animation-delay: 0.1s; }
.animate-in:nth-child(4) { animation-delay: 0.15s; }
.animate-in:nth-child(5) { animation-delay: 0.2s; }
@keyframes slideIn { to { opacity: 1; transform: translateY(0); } }

/* ═══════ UTILITY ═══════ */
.glass { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.skeleton { background: linear-gradient(90deg, var(--bg-surface) 25%, rgba(124,58,237,0.05) 50%, var(--bg-surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-xs); }
.skeleton-card { height: 60px; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Toast */
.error-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  display: none;
  background: rgba(244, 63, 94, 0.95);
  color: #fff;
}

/* Loading */
.loading-state { text-align: center; padding: 60px 20px; }
.loading-dots { display: flex; justify-content: center; gap: 6px; }
.loading-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: dotPulse 1.2s infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
.loading-text { font-size: 12px; color: var(--text-muted); margin-top: 12px; }

/* Wins feed */
.wins-feed { display: flex; flex-direction: column; gap: 8px; }

/* Scanlines (hidden — causes touch issues) */
.scanlines { display: none; }

/* Live ticker */
.marquee-container { overflow: hidden; }
.marquee-content { white-space: nowrap; animation: marquee 20s linear infinite; }
@keyframes marquee { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* Glow pulse for promo panels */
@keyframes glow-pulse { 0%, 100% { box-shadow: 0 0 8px rgba(0, 229, 255, 0.1); } 50% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.2); } }
@keyframes float-slow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes navDotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Quick bets / selectors */
.quick-bets { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-bet-btn { padding: 8px 12px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); font-size: 12px; font-weight: 700; cursor: pointer; }
.quick-bet-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.2); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Form inputs */
.input, .bet-input, .game-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
.input:focus, .bet-input:focus { border-color: var(--primary); outline: none; }
