/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f2a;
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-glass-hover: rgba(255, 255, 255, 0.2);

  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --indigo-400: #818cf8;
  --indigo-500: #6366f1;
  --pink-400: #f472b6;
  --pink-500: #ec4899;
  --gold-400: #fbbf24;
  --gold-500: #f59e0b;
  --teal-400: #2dd4bf;
  --cyan-400: #22d3ee;
  --red-400: #f87171;
  --red-500: #ef4444;
  --blue-400: #60a5fa;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --gradient-hero: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a1a2e 100%);
  --gradient-card: linear-gradient(135deg, rgba(139,92,246,0.1) 0%, rgba(59,130,246,0.05) 100%);
  --gradient-btn: linear-gradient(135deg, #7c3aed 0%, #4f46e5 50%, #0891b2 100%);
  --gradient-hot: linear-gradient(135deg, #ef4444, #f97316);
  --gradient-cold: linear-gradient(135deg, #0891b2, #3b82f6);
  --gradient-overdue: linear-gradient(135deg, #7c3aed, #ec4899);

  --shadow-card: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-card-hover: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(139,92,246,0.3);
  --shadow-ball: 0 8px 24px rgba(139,92,246,0.4);
  --shadow-btn: 0 4px 24px rgba(79,70,229,0.5);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  --blur: blur(20px);
  --font: 'Outfit', system-ui, sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gradient-hero);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Background Particles ───────────────────────────────────────────────── */
.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-particles::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(139,92,246,0.15) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: floatBlob1 12s ease-in-out infinite;
}
.bg-particles::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  animation: floatBlob2 15s ease-in-out infinite;
}
@keyframes floatBlob1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.1); }
}
@keyframes floatBlob2 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-60px, -40px) scale(1.05); }
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 10;
  background: rgba(10,10,26,0.8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border-glass);
  padding: 16px 24px;
  position: sticky;
  top: 0;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 2.2rem; filter: drop-shadow(0 0 12px rgba(139,92,246,0.6)); }
.logo-text h1 {
  font-size: 1.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--purple-400), var(--indigo-400), var(--cyan-400));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  line-height: 1.1;
}
.logo-text span { font-size: 0.75rem; color: var(--text-secondary); letter-spacing: 0.05em; }
.header-meta { display: flex; gap: 24px; flex-wrap: wrap; }
.meta-item { display: flex; flex-direction: column; align-items: center; }
.meta-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.meta-value { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ─── Glass Card ──────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.glass-card:hover {
  border-color: var(--border-glass-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

/* ─── Section Header ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.section-title {
  font-size: 1.25rem; font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--purple-400));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.section-subtitle {
  font-size: 0.8rem; color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Prediction Section ──────────────────────────────────────────────────── */
.prediction-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.12) 0%, rgba(79,70,229,0.08) 50%, rgba(8,145,178,0.08) 100%);
  border-color: rgba(139,92,246,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px 28px;
}

/* Lottery Balls */
.balls-container {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.ball-placeholder, .ball {
  width: 72px; height: 72px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800;
}
.ball-placeholder {
  background: rgba(255,255,255,0.04);
  border: 2px dashed rgba(255,255,255,0.15);
  color: transparent;
}
.ball {
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.35), transparent 60%), var(--gradient-btn);
  color: white;
  box-shadow: var(--shadow-ball), inset 0 1px 1px rgba(255,255,255,0.2);
  animation: ballDrop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.ball::before {
  content: '';
  position: absolute;
  top: 10px; left: 15px;
  width: 20px; height: 12px;
  background: rgba(255,255,255,0.35);
  border-radius: var(--radius-full);
  filter: blur(3px);
}
@keyframes ballDrop {
  from {
    opacity: 0;
    transform: translateY(-60px) scale(0.5) rotate(-20deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

/* Predict Button */
.predict-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 36px;
  background: var(--gradient-btn);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.predict-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.predict-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(79,70,229,0.6); }
.predict-btn:hover::before { opacity: 1; }
.predict-btn:active { transform: translateY(0); }
.predict-btn.loading { opacity: 0.7; pointer-events: none; }
.btn-icon { font-size: 1.2rem; }

.prediction-note {
  font-size: 0.75rem; color: var(--text-muted);
  text-align: center; max-width: 500px;
}

/* ─── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.stat-card-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.stat-card-header h3 { font-size: 1rem; font-weight: 600; flex: 1; }
.stat-icon { font-size: 1.3rem; }
.stat-badge {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 10px; border-radius: var(--radius-full);
  background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3);
}
.stat-badge.cold { background: rgba(8,145,178,0.2); color: #67e8f9; border-color: rgba(8,145,178,0.3); }
.stat-badge.overdue { background: rgba(124,58,237,0.2); color: #c4b5fd; border-color: rgba(124,58,237,0.3); }

/* Number Badges */
.number-badges {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.num-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 700;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.num-badge:hover { transform: scale(1.1); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.num-badge.hot {
  background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(249,115,22,0.2));
  border: 1px solid rgba(239,68,68,0.3); color: #fca5a5;
}
.num-badge.cold {
  background: linear-gradient(135deg, rgba(8,145,178,0.2), rgba(59,130,246,0.2));
  border: 1px solid rgba(59,130,246,0.3); color: #93c5fd;
}
.num-badge.overdue {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(236,72,153,0.2));
  border: 1px solid rgba(139,92,246,0.3); color: #c4b5fd;
}
.num-badge .count { font-size: 0.7rem; opacity: 0.7; font-weight: 400; }

/* ─── Chart ───────────────────────────────────────────────────────────────── */
.chart-card { }
.chart-wrapper {
  width: 100%; height: 320px;
  position: relative;
}
#freqChart { width: 100% !important; height: 100% !important; }
.chart-controls { display: flex; gap: 8px; }
.chip {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.chip:hover { border-color: var(--border-glass-hover); color: var(--text-primary); }
.chip.active {
  background: rgba(124,58,237,0.25);
  border-color: rgba(124,58,237,0.5);
  color: var(--purple-400);
}

/* ─── History Table ───────────────────────────────────────────────────────── */
.history-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.search-input {
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  min-width: 200px;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: rgba(124,58,237,0.5); }

.result-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.table-wrapper { overflow-x: auto; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.history-table th {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
  position: sticky; top: 0;
  background: rgba(10,10,26,0.9);
  backdrop-filter: blur(8px);
}
.history-table td {
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.1s;
}
.history-table tr:hover td { background: rgba(255,255,255,0.04); }
.history-table .loading-row { color: var(--text-muted); padding: 40px; }

.draw-idx { color: var(--text-muted); font-size: 0.75rem; }
.draw-date { color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; }
.draw-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  font-weight: 700;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.2), transparent 60%), rgba(124,58,237,0.25);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--purple-400);
  font-size: 0.85rem;
  transition: transform 0.15s;
}
.draw-num:hover { transform: scale(1.15); }
.draw-num.highlight {
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.3), transparent 60%), var(--gradient-hot);
  border-color: rgba(239,68,68,0.6);
  color: white;
  box-shadow: 0 0 12px rgba(239,68,68,0.4);
}

/* Pagination */
.pagination {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  margin-top: 20px;
}
.page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: rgba(124,58,237,0.5); color: var(--text-primary); }
.page-btn.active {
  background: rgba(124,58,237,0.3);
  border-color: rgba(124,58,237,0.6);
  color: var(--purple-400);
}
.page-btn:disabled { opacity: 0.3; pointer-events: none; }

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-glass);
  position: relative; z-index: 1;
}
.site-footer a { color: var(--purple-400); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px 40px; gap: 20px; }
  .glass-card { padding: 20px; }
  .ball { width: 60px; height: 60px; font-size: 1.25rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .header-meta { display: none; }
  .section-header { flex-direction: column; align-items: flex-start; }
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.5s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
