/* ═══════════════════════════════════════════════════════════════════════
   今彩539 號碼預測器 — 完整樣式表
   Design: Taiwan Lottery Branding (Red/Orange/Gold)
   Features: Glassmorphism, micro-animations, responsive
   ═══════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  /* Brand – Taiwan Lottery */
  --brand-red: #D71920;
  --brand-red-dk: #A8141A;
  --brand-red-lt: #FF3B42;
  --brand-orange: #F7931E;
  --brand-orange-dk: #D97B0B;
  --brand-gold: #FFD700;
  --brand-gold-dk: #CC9900;

  /* Functional */
  --hot: #FF6B35;
  --hot-lt: #FF8F5E;
  --cold: #3A7BD5;
  --cold-lt: #5B9BE8;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;

  /* Layout */
  --bg: #F0F2F5;
  --bg-gradient: linear-gradient(160deg, #F7F0E8 0%, #F0F2F5 40%, #EBF0FA 100%);
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-bg-solid: #FFFFFF;
  --card-blur: 16px;
  --border: rgba(215, 25, 32, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.05);

  /* Text */
  --text: #1A1A2E;
  --text-sub: #5A5A6E;
  --text-hint: #9E9EB0;

  /* Typography */
  --ff: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Microsoft JhengHei', sans-serif;
  --ff-mono: 'Roboto Mono', 'Courier New', monospace;

  /* Balls */
  --ball-size: 56px;
  --ball-sm: 36px;

  /* Misc */
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.14);
  --shadow-glow: 0 4px 24px rgba(215, 25, 32, 0.20);
  --trans: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --trans-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Dark Mode ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0B0B14;
  --bg-gradient: linear-gradient(160deg, #0B0B14 0%, #0F0F1E 40%, #121225 100%);
  --card-bg: rgba(26, 26, 40, 0.85);
  --card-bg-solid: #1A1A28;
  --card-blur: 20px;
  --border: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --text: #F0F0F5;
  --text-sub: #A0A0B2;
  --text-hint: #5A5A6E;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 4px 24px rgba(215, 25, 32, 0.35);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
}

body {
  font-family: var(--ff);
  background: var(--bg-gradient);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  transition: background var(--trans), color var(--trans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.main {
  padding: 32px 16px 64px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Glass Card ────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: background var(--trans), border-color var(--trans), box-shadow var(--trans);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: linear-gradient(135deg, var(--brand-red-dk) 0%, var(--brand-red) 50%, #E03030 100%);
  box-shadow: 0 4px 30px rgba(215, 25, 32, 0.40);
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-gold), var(--brand-orange), var(--brand-gold));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo-wrap {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.header-logo {
  font-size: 24px;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: clamp(16px, 3.5vw, 22px);
  font-weight: 900;
  color: #FFF;
  letter-spacing: 0.5px;
  line-height: 1.2;
  white-space: nowrap;
}

.header-subtitle {
  font-weight: 700;
  opacity: 0.92;
}

.header-tagline {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 1px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Update badge */
.update-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
}

.update-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

.update-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  white-space: nowrap;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }

  50% {
    opacity: 0.6;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0);
  }
}

/* Theme toggle */
.btn-theme {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans);
}

.btn-theme:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: rotate(15deg);
}

.theme-icon {
  font-size: 18px;
}

/* Nav pills */
.nav-pills {
  background: rgba(0, 0, 0, 0.22);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nav-pills::-webkit-scrollbar {
  display: none;
}

.nav-list {
  display: flex;
  list-style: none;
  padding: 0 8px;
  gap: 2px;
  max-width: 1100px;
  margin: 0 auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color var(--trans), border-color var(--trans), background var(--trans);
  border-radius: 6px 6px 0 0;
}

.nav-icon {
  font-size: 14px;
}

.nav-link:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #FFF;
  border-bottom-color: var(--brand-gold);
  background: rgba(255, 255, 255, 0.08);
}

/* ── Section ────────────────────────────────────────────────────────────── */
.section {
  margin-bottom: 48px;
  animation: fadeInUp 0.6s ease both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: clamp(18px, 3.5vw, 22px);
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.section-desc {
  font-size: 13px;
  color: var(--text-hint);
  font-weight: 500;
}

/* ── Live Draw ──────────────────────────────────────────────────────────── */
.section-live .glass-card {
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--brand-red), var(--brand-orange), var(--brand-gold)) 1;
}

.live-card {
  padding: 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.live-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(215, 25, 32, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* Dot live */
.dot-live {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }

  60% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
}

.badge-live {
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.08);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
  letter-spacing: 0.5px;
}

.live-meta {
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.live-period {
  font-family: var(--ff-mono);
  font-size: clamp(17px, 3.5vw, 22px);
  font-weight: 700;
  color: var(--brand-red);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.live-date {
  font-size: 14px;
  color: var(--text-sub);
  font-weight: 500;
}

/* ── Number Balls ───────────────────────────────────────────────────────── */
.balls-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2.5vw, 16px);
  flex-wrap: wrap;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: clamp(17px, 2.8vw, 22px);
  font-weight: 700;
  color: #FFF;
  letter-spacing: -0.5px;
  background: radial-gradient(circle at 35% 30%, var(--brand-red-lt), var(--brand-red) 50%, var(--brand-red-dk));
  box-shadow:
    inset -2px -4px 8px rgba(0, 0, 0, 0.25),
    inset 2px 2px 6px rgba(255, 255, 255, 0.20),
    0 6px 20px rgba(215, 25, 32, 0.35);
  animation: ball-pop var(--trans-bounce) both;
  user-select: none;
  flex-shrink: 0;
  cursor: default;
  transition: transform 0.2s ease;
  position: relative;
}

.ball::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  width: 14px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.45), transparent);
  border-radius: 50%;
  pointer-events: none;
}

.ball:hover {
  transform: scale(1.12) translateY(-2px);
}

/* Staggered ball entry */
.balls-container .ball:nth-child(1) {
  animation-delay: 0.05s;
}

.balls-container .ball:nth-child(2) {
  animation-delay: 0.12s;
}

.balls-container .ball:nth-child(3) {
  animation-delay: 0.19s;
}

.balls-container .ball:nth-child(4) {
  animation-delay: 0.26s;
}

.balls-container .ball:nth-child(5) {
  animation-delay: 0.33s;
}

/* Hot ball */
.ball.hot {
  background: radial-gradient(circle at 35% 30%, #FF8A50, #E64A19 50%, #BF360C);
  box-shadow:
    inset -2px -4px 8px rgba(0, 0, 0, 0.25),
    inset 2px 2px 6px rgba(255, 255, 255, 0.20),
    0 0 16px rgba(255, 107, 53, 0.50),
    0 6px 20px rgba(230, 74, 25, 0.35);
  animation: ball-pop var(--trans-bounce) both, glow-hot 2.5s ease-in-out infinite;
}

/* Cold ball */
.ball.cold {
  background: radial-gradient(circle at 35% 30%, #5B9BE8, #1565C0 50%, #0D47A1);
  box-shadow:
    inset -2px -4px 8px rgba(0, 0, 0, 0.25),
    inset 2px 2px 6px rgba(255, 255, 255, 0.20),
    0 0 16px rgba(100, 181, 246, 0.50),
    0 6px 20px rgba(21, 101, 192, 0.35);
  animation: ball-pop var(--trans-bounce) both, glow-cold 2.5s ease-in-out infinite;
}

/* Small ball */
.ball-sm {
  width: var(--ball-sm) !important;
  height: var(--ball-sm) !important;
  font-size: 13px !important;
  letter-spacing: -0.3px;
}

.ball-sm::after {
  display: none;
}

/* Table balls no animation */
.history-table .ball {
  animation: none;
}

/* Ball placeholder skeleton */
.ball-placeholder {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--border-subtle), rgba(215, 25, 32, 0.06));
  animation: skeleton-pulse 1.8s ease-in-out infinite;
}

@keyframes ball-pop {
  0% {
    transform: scale(0) rotate(-120deg);
    opacity: 0;
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes glow-hot {

  0%,
  100% {
    box-shadow: inset -2px -4px 8px rgba(0, 0, 0, .25), inset 2px 2px 6px rgba(255, 255, 255, .2), 0 0 8px rgba(255, 107, 53, .3), 0 6px 20px rgba(230, 74, 25, .35);
  }

  50% {
    box-shadow: inset -2px -4px 8px rgba(0, 0, 0, .25), inset 2px 2px 6px rgba(255, 255, 255, .2), 0 0 24px rgba(255, 107, 53, .65), 0 6px 24px rgba(230, 74, 25, .5);
  }
}

@keyframes glow-cold {

  0%,
  100% {
    box-shadow: inset -2px -4px 8px rgba(0, 0, 0, .25), inset 2px 2px 6px rgba(255, 255, 255, .2), 0 0 8px rgba(100, 181, 246, .3), 0 6px 20px rgba(21, 101, 192, .35);
  }

  50% {
    box-shadow: inset -2px -4px 8px rgba(0, 0, 0, .25), inset 2px 2px 6px rgba(255, 255, 255, .2), 0 0 24px rgba(100, 181, 246, .65), 0 6px 24px rgba(21, 101, 192, .5);
  }
}

@keyframes skeleton-pulse {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.7;
  }
}

/* ── Live Stats ────────────────────────────────────────────────────────── */
.live-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  position: relative;
  z-index: 1;
}

.stat-item {
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--trans);
}

.stat-item:hover {
  background: rgba(215, 25, 32, 0.03);
}

.stat-icon {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-family: var(--ff-mono);
  font-size: clamp(14px, 2.8vw, 18px);
  font-weight: 700;
  color: var(--brand-red);
}

.stat-value.gold {
  color: var(--brand-orange-dk);
}

/* ── Prizes Grid ───────────────────────────────────────────────────────── */
.prizes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}

@media (min-width: 600px) {
  .prizes-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.prize-card {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  transition: all var(--trans);
  position: relative;
  overflow: hidden;
}

.prize-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.prize-1st::before {
  background: linear-gradient(90deg, var(--brand-gold), var(--brand-orange));
}

.prize-2nd::before {
  background: linear-gradient(90deg, #C0C0C0, #E0E0E0);
}

.prize-3rd::before {
  background: linear-gradient(90deg, #CD7F32, #DDA15E);
}

.prize-4th::before {
  background: linear-gradient(90deg, var(--brand-red), var(--brand-red-lt));
}

.prize-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.prize-medal {
  display: block;
  font-size: 28px;
  margin-bottom: 6px;
}

.prize-level {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}

.prize-desc {
  display: block;
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.prize-amt {
  display: block;
  font-family: var(--ff-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-orange);
}

/* ── Analysis / Tab ─────────────────────────────────────────────────────── */
.tab-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
}

.tab-btn:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dk));
  border-color: var(--brand-red);
  color: #FFF;
  box-shadow: 0 4px 16px rgba(215, 25, 32, 0.25);
}

.chart-container {
  padding: 24px 18px 18px;
  margin-bottom: 16px;
}

.chart-container canvas {
  max-height: 300px;
}

/* Stats list */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--trans);
}

.stats-row:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.stats-rank {
  font-family: var(--ff-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hint);
  width: 22px;
  text-align: right;
}

.stats-ball {
  flex-shrink: 0;
}

.stats-bar-wrap {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.stats-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stats-bar.hot {
  background: linear-gradient(90deg, var(--hot), var(--brand-orange));
}

.stats-bar.cold {
  background: linear-gradient(90deg, var(--cold), var(--cold-lt));
}

.stats-bar.all {
  background: linear-gradient(90deg, var(--brand-red), var(--brand-red-lt));
}

.stats-count {
  font-family: var(--ff-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 50px;
  text-align: right;
}

/* ── Gap Analysis ──────────────────────────────────────────────────────── */
.gap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.gap-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--border);
  cursor: default;
  transition: all var(--trans);
  gap: 2px;
}

.gap-cell:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow);
}

.gap-cell.gap-hot {
  border-color: rgba(255, 107, 53, 0.3);
  background: rgba(255, 107, 53, 0.06);
}

.gap-cell.gap-warm {
  border-color: rgba(247, 147, 30, 0.3);
  background: rgba(247, 147, 30, 0.06);
}

.gap-cell.gap-cool {
  border-color: rgba(58, 123, 213, 0.2);
  background: rgba(58, 123, 213, 0.04);
}

.gap-cell.gap-cold {
  border-color: rgba(58, 123, 213, 0.4);
  background: rgba(58, 123, 213, 0.08);
}

.gap-num {
  font-family: var(--ff-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.gap-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
}

/* Overdue list */
.overdue-list {
  padding: 20px;
}

.overdue-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--text);
}

.overdue-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.overdue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(215, 25, 32, 0.04);
  border: 1px solid rgba(215, 25, 32, 0.08);
  transition: all var(--trans);
}

.overdue-item:hover {
  background: rgba(215, 25, 32, 0.08);
  transform: translateY(-2px);
}

.overdue-rank {
  font-family: var(--ff-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-hint);
  width: 18px;
}

.overdue-gap {
  font-family: var(--ff-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-red);
  margin-left: auto;
}

/* ── History Table ──────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 400px;
}

.history-table th {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-red-dk), var(--brand-red));
  color: #FFF;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.history-table th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.history-table th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.history-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
}

.history-table tbody tr {
  transition: background var(--trans);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:hover td {
  background: rgba(215, 25, 32, 0.03);
}

.numbers-col {
  min-width: 220px;
}

.history-balls {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.loading-row td {
  text-align: center;
  padding: 48px;
  color: var(--text-hint);
  font-weight: 500;
}

/* ── Recommend ──────────────────────────────────────────────────────────── */
.disclaimer-box {
  background: rgba(247, 147, 30, 0.06);
  border: 1px solid rgba(247, 147, 30, 0.18);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  color: #c47209;
  margin-bottom: 18px;
  line-height: 1.6;
}

[data-theme="dark"] .disclaimer-box {
  color: var(--brand-orange);
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  border: none;
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dk));
  color: #FFF;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
  box-shadow: 0 4px 16px rgba(215, 25, 32, 0.25);
}

.btn-refresh:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 24px rgba(215, 25, 32, 0.35);
}

.btn-refresh:active {
  transform: scale(0.96);
}

.refresh-icon {
  display: inline-block;
  transition: transform 0.5s ease;
}

.btn-refresh:hover .refresh-icon {
  transform: rotate(360deg);
}

.recommend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 700px) {
  .recommend-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .recommend-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Period Selector Controls ───────────────────────────────────────── */
.recommend-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.period-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  white-space: nowrap;
}

.period-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 32px 8px 14px;
  border: 2px solid var(--brand-red-lt);
  border-radius: var(--radius-pill);
  background: var(--card-bg-solid);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23D71920' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.period-select:hover {
  border-color: var(--brand-red);
  box-shadow: 0 2px 12px rgba(215, 25, 32, 0.15);
}

.period-select:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.2);
}

.recommend-card {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all var(--trans);
}

.recommend-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.recommend-header {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recommend-header.hot_weighted {
  background: linear-gradient(135deg, #FF6B35, #E64A19);
}

.recommend-header.balanced {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dk));
}

.recommend-header.overdue {
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
}

.recommend-header.random {
  background: linear-gradient(135deg, var(--cold), #0D47A1);
}

/* Legacy support */
.recommend-header.hot {
  background: linear-gradient(135deg, #FF6B35, #E64A19);
}

.recommend-header.bal {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dk));
}

.recommend-header.rnd {
  background: linear-gradient(135deg, var(--cold), #0D47A1);
}

.recommend-strategy {
  font-size: 14px;
  font-weight: 800;
  color: #FFF;
}

.recommend-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.20);
  color: #FFF;
  letter-spacing: 0.5px;
}

.recommend-body {
  padding: 20px 16px;
  text-align: center;
}

.recommend-body .balls-container {
  margin-bottom: 16px;
  justify-content: center;
}

.recommend-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 12px;
  line-height: 1.5;
}

.confidence-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-label {
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
  font-weight: 500;
}

.confidence-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.confidence-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confidence-bar.hot_weighted,
.confidence-bar.hot {
  background: linear-gradient(90deg, var(--hot), var(--brand-orange));
}

.confidence-bar.balanced,
.confidence-bar.bal {
  background: linear-gradient(90deg, var(--brand-red), var(--brand-red-lt));
}

.confidence-bar.overdue {
  background: linear-gradient(90deg, #7C3AED, #A78BFA);
}

.confidence-bar.random,
.confidence-bar.rnd {
  background: linear-gradient(90deg, var(--cold), var(--cold-lt));
}

.confidence-pct {
  font-family: var(--ff-mono);
  font-size: 13px;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

/* ── Calculator ─────────────────────────────────────────────────────────── */
.calc-card {
  padding: 28px;
  max-width: 580px;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
  flex-wrap: wrap;
}

.calc-label {
  font-size: 15px;
  font-weight: 600;
}

.calc-fixed {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-sub);
}

.calc-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.calc-total .calc-amount {
  font-family: var(--ff-mono);
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 700;
  color: var(--brand-red);
}

.calc-monthly .calc-amount {
  font-family: var(--ff-mono);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  color: var(--brand-orange);
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border), var(--brand-red-lt));
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-red-lt), var(--brand-red));
  box-shadow: 0 2px 8px rgba(215, 25, 32, 0.40);
  transition: transform var(--trans), box-shadow var(--trans);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 4px 12px rgba(215, 25, 32, 0.50);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--brand-red-lt), var(--brand-red));
  box-shadow: 0 2px 8px rgba(215, 25, 32, 0.40);
}

.slider-value {
  font-family: var(--ff-mono);
  font-size: 15px;
  font-weight: 700;
  min-width: 48px;
  text-align: right;
}

.counter-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-counter {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 2px solid var(--brand-red);
  background: transparent;
  color: var(--brand-red);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--trans);
}

.btn-counter:hover {
  background: var(--brand-red);
  color: #FFF;
  transform: scale(1.08);
}

.btn-counter:active {
  transform: scale(0.92);
}

.counter-value {
  font-family: var(--ff-mono);
  font-size: 16px;
  font-weight: 700;
  min-width: 42px;
  text-align: center;
}

.budget-warning {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.20);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #DC2626;
  margin-top: 14px;
  animation: shake 0.4s ease;
}

[data-theme="dark"] .budget-warning {
  color: #F87171;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

/* ── Select ─────────────────────────────────────────────────────────────── */
.select-control {
  padding: 8px 32px 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  color: var(--text);
  font-family: var(--ff);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C6C70' fill='none' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--trans);
}

.select-control:hover {
  border-color: var(--brand-red);
}

.select-control:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.10);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  background: var(--card-bg-solid);
  border-top: 1px solid var(--border);
  padding: 32px 16px 40px;
  text-align: center;
  transition: background var(--trans);
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.footer-logo {
  font-size: 24px;
}

.footer-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-red);
}

.footer-disclaimer {
  font-size: 12px;
  color: var(--text-sub);
  max-width: 720px;
  margin: 0 auto 10px;
  line-height: 1.8;
}

.footer-info {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 6px;
}

.footer-copy {
  font-size: 11px;
  color: var(--text-hint);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --ball-size: 46px;
    --ball-sm: 30px;
  }

  .ball {
    font-size: 17px !important;
  }

  .ball-sm {
    font-size: 12px !important;
  }

  .stat-value {
    font-size: 13px;
  }

  .calc-card {
    padding: 20px 16px;
  }

  .slider {
    width: 100px;
  }

  .live-card {
    padding: 20px 16px;
  }

  .header-tagline {
    display: none;
  }

  .gap-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;
  }

  .gap-num {
    font-size: 14px;
  }

  .gap-val {
    font-size: 10px;
  }
}

@media (min-width: 768px) {
  :root {
    --ball-size: 62px;
  }

  .ball {
    font-size: 24px !important;
  }
}

@media (min-width: 1024px) {
  .main {
    padding-top: 40px;
  }
}

/* ── Ad Interstitial Modal ──────────────────────────────────────────── */
.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: adFadeIn 0.3s ease;
  padding: 16px;
}

.ad-overlay[hidden] {
  display: none;
}

@keyframes adFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.ad-modal {
  background: var(--card-bg-solid);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  animation: adSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes adSlideUp {
  from {
    transform: translateY(40px) scale(0.95);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.ad-header {
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-red));
  padding: 14px 20px;
  text-align: center;
}

.ad-badge {
  font-size: 14px;
  font-weight: 800;
  color: #FFF;
  letter-spacing: 1px;
}

.ad-body {
  padding: 32px 28px 28px;
  text-align: center;
}

.ad-icon {
  font-size: 56px;
  margin-bottom: 16px;
  animation: adBounce 1.5s ease-in-out infinite;
}

@keyframes adBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.ad-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 10px;
}

.ad-desc {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.7;
  margin-bottom: 24px;
}

.ad-link {
  display: inline-block;
  padding: 14px 40px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #EE4D2D, #FF6633);
  color: #FFF;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  transition: all var(--trans);
  box-shadow: 0 6px 24px rgba(238, 77, 45, 0.35);
  animation: adPulse 2s ease-in-out infinite;
}

.ad-link:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 36px rgba(238, 77, 45, 0.50);
}

.ad-link:active {
  transform: scale(0.97);
}

@keyframes adPulse {

  0%,
  100% {
    box-shadow: 0 6px 24px rgba(238, 77, 45, 0.35);
  }

  50% {
    box-shadow: 0 6px 32px rgba(238, 77, 45, 0.55);
  }
}

.ad-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-hint);
  font-weight: 500;
  animation: adBlink 2s ease-in-out infinite;
}

@keyframes adBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}