* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a1a;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e0e0f0;
  --text-dim: rgba(255, 255, 255, 0.5);
  --primary: #667eea;
  --primary-end: #764ba2;
  --accent: #ffd700;
  --red: #ff4757;
  --blue: #3498db;
  --hot: #ff6b6b;
  --cold: #74b9ff;
  --radius: 16px;
  --blur: 20px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background ambient */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(118, 75, 162, 0.06) 0%, transparent 50%);
  z-index: -1;
  animation: ambientDrift 30s ease-in-out infinite;
}

@keyframes ambientDrift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, 1%); }
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 30px 0 10px;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.header .subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* Navigation */
.nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 10px 24px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
  backdrop-filter: blur(10px);
}

.nav-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.15);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* Lottery panel */
.lottery-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 32px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.panel-countdown {
  display: flex;
  align-items: center;
  gap: 12px;
}

.countdown-mini {
  display: flex;
  align-items: center;
  gap: 4px;
}

.countdown-num-sm {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.countdown-label-sm {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-right: 4px;
}

.draw-info-mini {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Section tabs */
.section-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.tab-btn:hover, .tab-btn.active {
  color: var(--text);
  background: var(--card-bg);
}

/* Glass card */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur));
  padding: 24px;
  margin-bottom: 16px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Countdown */
.countdown-section {
  text-align: center;
  padding: 30px 0;
}

.countdown {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.countdown-num {
  font-size: 3rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  min-width: 70px;
}

.countdown-sep {
  font-size: 2rem;
  color: var(--text-dim);
  margin-top: -12px;
}

.countdown-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

#drawInfo {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* Balls */
.ball-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ball-red {
  background: radial-gradient(circle at 35% 35%, #ff6b6b, var(--red));
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
}

.ball-blue {
  background: radial-gradient(circle at 35% 35%, #5dade2, var(--blue));
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.ball-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

/* Prediction cards */
.prediction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.prediction-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.prediction-card h3 {
  font-size: 1rem;
  color: var(--text);
}

.confidence {
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  font-size: 0.75rem;
  color: #fff;
  font-weight: 600;
}

/* Recent draws */
.draw-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.draw-row:last-child {
  border-bottom: none;
}

.draw-issue {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 80px;
}

.draw-date {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 90px;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.85rem;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
}

.data-table td .ball-row {
  display: inline-flex;
}

/* Charts */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 10px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 20px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
}

.bar-red {
  background: linear-gradient(to top, var(--red), #ff6b6b);
}

.bar-blue {
  background: linear-gradient(to top, var(--blue), #5dade2);
}

.bar-warn {
  background: linear-gradient(to top, var(--accent), #ffe066);
}

.bar-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.trend-svg {
  width: 100%;
  height: 200px;
}

.trend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

/* Loader */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Section visibility */
.section {
  display: none;
}

.section.active {
  display: block;
}

/* Hot/Cold badges */
.heat-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 4px;
}

.heat-hot { background: var(--hot); box-shadow: 0 0 6px var(--hot); }
.heat-cold { background: var(--cold); box-shadow: 0 0 6px var(--cold); }
.heat-normal { background: rgba(255,255,255,0.2); }

/* Refresh button */
.refresh-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(var(--blur));
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: 100;
}

.refresh-btn:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  border-color: transparent;
  transform: rotate(180deg);
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .header h1 { font-size: 1.4rem; }
  .lottery-panel { padding: 16px; }
  .panel-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .panel-title { font-size: 1.2rem; }
  .countdown-num-sm { font-size: 1rem; }
  .prediction-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .draw-row { flex-wrap: wrap; gap: 8px; }
  .ball { width: 36px; height: 36px; font-size: 0.8rem; }
  .ball-sm { width: 28px; height: 28px; font-size: 0.7rem; }
  .section-tabs { flex-wrap: wrap; }
}

/* Data source info */
.data-source {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

/* Status bar */
.data-source-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

/* Quick pick */
.quick-pick-section {
  margin-bottom: 20px;
}

.quick-pick-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quick-pick-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.btn-primary {
  padding: 8px 24px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.quick-pick-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.pick-rank {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 30px;
}

.pick-score {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

/* Winnings */
.winnings-summary .winnings-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.winnings-record {
  margin-bottom: 12px;
}

.record-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.record-issue {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
}

.record-date {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.record-actual {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.result-row.prize-won {
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.result-row.prize-none {
  background: rgba(255, 255, 255, 0.01);
}

.result-algo {
  min-width: 60px;
  color: var(--text-dim);
}

.result-match {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-dim);
  min-width: 30px;
}

.result-prize {
  margin-left: auto;
  font-weight: 600;
}

.result-prize {
  color: var(--text-dim);
}

.prize-won .result-prize {
  color: var(--accent);
}

.ball-xs {
  width: 24px;
  height: 24px;
  font-size: 0.65rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-live {
  background: #2ecc71;
  box-shadow: 0 0 8px #2ecc71;
  animation: pulse 2s ease-in-out infinite;
}

.status-offline {
  background: #e67e22;
  box-shadow: 0 0 8px #e67e22;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-sep {
  opacity: 0.3;
}

/* Spinning refresh */
.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
