/* ============================================
   大樂透號碼預測器 — 台灣彩券風格
   Single-Page Scroll · Red Theme · Glassmorphism
   ============================================ */

/* ─── CSS Variables (Light Theme Default) ──────────────────────── */
:root {
  --primary: #9d161d;
  --primary-light: #e63946;
  --primary-dark: #7a1018;
  --primary-glow: rgba(230, 57, 70, 0.2);
  --gold: #FFD700;
  --gold-soft: #F5A623;
  --bg: #F7F5E6;
  --bg-card: #ffffff;
  --bg-card-hover: #fefcf0;
  --bg-input: #f5f3e8;
  --text: #1a1a2e;
  --text-sub: #555770;
  --text-muted: #8e8e9e;
  --border: #e8e4d4;
  --border-h: #d5d0be;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --trans: 0.25s ease;
  /* Ball — Taiwan Lottery Official Style */
  --ball-regular: radial-gradient(circle at 33% 33%, #FFF5EA 0%, #FFECBB 16%, #FF981E 74%, #EB5E00 100%);
  --ball-special: radial-gradient(circle at 33% 33%, #FFB0B0 0%, #F47A7A 28%, #FF0000 81%, #DD0202 100%);
  --ball-regular-shadow: 0 3px 8px rgba(235, 94, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.15);
  --ball-special-shadow: 0 3px 8px rgba(221, 2, 2, 0.4), 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ─── Dark Theme ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223a;
  --bg-input: #16162b;
  --text: #e8e8f0;
  --text-sub: #a0a0b8;
  --text-muted: #6e6e88;
  --border: #2a2a42;
  --border-h: #3a3a55;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --primary-glow: rgba(230, 57, 70, 0.3);
}

/* ─── Reset & Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
}

body {
  font-family: 'Noto Sans TC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
}

input,
select {
  font: inherit;
  color: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ─── Header ───────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--primary-light) 100%);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}

header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--primary-light), var(--gold));
  opacity: 0.7;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.03em;
}

.brand-sub {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.update-time {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  white-space: nowrap;
}

.theme-toggle {
  font-size: 1.2rem;
  padding: 0.35rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all var(--trans);
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(20deg);
}

/* ─── Navigation ───────────────────────────────────────────────── */
.nav-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 190;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.nav-bar::-webkit-scrollbar {
  display: none;
}

.nav-inner {
  display: flex;
  gap: 0;
  padding: 0;
  min-width: max-content;
}

.nav-link {
  flex-shrink: 0;
  padding: 0.7rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
  border-bottom: 3px solid transparent;
  transition: all var(--trans);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ─── Main Content ─────────────────────────────────────────────── */
.main-content {
  padding-bottom: 3rem;
}

.section {
  padding-top: 1.5rem;
  padding-bottom: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sub-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ─── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: background 0.3s, border 0.3s;
}

.card:hover {
  border-color: var(--border-h);
}

/* ─── Selects & Buttons ────────────────────────────────────────── */
.period-select {
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-h);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
  appearance: auto;
}

.period-select:focus {
  outline: none;
  border-color: var(--primary);
}

.period-select-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-regenerate {
  padding: 0.45rem 1rem;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  border: none;
  transition: all var(--trans);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-regenerate:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-refresh {
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 800;
  transition: all var(--trans);
}

.btn-refresh:hover {
  background: var(--primary);
  color: #fff;
}

/* ─── Disclaimer Bar ───────────────────────────────────────────── */
.disclaimer-bar {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.78rem;
  color: var(--warning);
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

/* ─── Recommend Cards ──────────────────────────────────────────── */
.recommend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.recommend-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: all var(--trans);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recommend-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.recommend-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.recommend-card-title {
  font-size: 0.88rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.recommend-card-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-hot {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.badge-balanced {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.badge-overdue {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

.badge-random {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.recommend-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  padding: 0.5rem 0;
}

.recommend-ball {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 900;
  color: #000;
  background: var(--ball-regular);
  box-shadow: var(--ball-regular-shadow);
  text-shadow: none;
  position: relative;
}

.recommend-ball::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  width: 14px;
  height: 10px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.recommend-ball.special {
  background: var(--ball-special);
  color: #fff;
  box-shadow: var(--ball-special-shadow);
  border: none;
}

.recommend-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.confidence-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
}

.confidence-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

/* ─── Calculator ───────────────────────────────────────────────── */
.calc-card {
  max-width: 560px;
  margin: 0 auto;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.calc-row:last-child {
  border-bottom: none;
}

.calc-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
}

.calc-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.calc-slider {
  width: 180px;
  accent-color: var(--primary);
  cursor: pointer;
}

.calc-value {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  min-width: 45px;
  text-align: right;
}

.calc-price {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

.calc-total-row {
  background: rgba(230, 57, 70, 0.04);
  border-radius: var(--radius-xs);
  padding: 0.85rem 0.5rem;
  margin: 0.25rem -0.5rem;
}

.calc-total {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--primary);
}

.calc-monthly {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-sub);
}

/* ─── Live Results ─────────────────────────────────────────────── */
.live-card {
  border: 2px solid var(--primary);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(230, 57, 70, 0.02) 100%);
  text-align: center;
  padding: 2rem 1.5rem;
}

.live-period {
  margin-bottom: 1.25rem;
}

.live-period-text {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
  display: block;
  letter-spacing: 0.08em;
}

.live-date-text {
  font-size: 0.82rem;
  color: var(--text-sub);
  display: block;
  margin-top: 0.25rem;
}

.live-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.live-ball {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  color: #000;
  background: var(--ball-regular);
  box-shadow: var(--ball-regular-shadow);
  text-shadow: none;
  transition: transform 0.3s;
  position: relative;
}

.live-ball::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 8px;
  width: 18px;
  height: 12px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.live-ball:hover {
  transform: scale(1.1);
}

.live-ball-sep {
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text-muted);
  margin: 0 0.2rem;
}

.live-ball.special-ball {
  background: var(--ball-special);
  color: #fff;
  box-shadow: var(--ball-special-shadow);
  border: none;
}

.live-info-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.live-info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.live-info-icon {
  font-size: 1.3rem;
}

.live-info-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.live-info-value {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--primary);
}

.prize-tiers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.prize-tier {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--trans);
}

.prize-tier:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.prize-tier-icon {
  font-size: 1.2rem;
  display: block;
  margin-bottom: 0.2rem;
}

.prize-tier-name {
  font-size: 0.85rem;
  font-weight: 900;
  display: block;
}

.prize-tier-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin: 0.15rem 0 0.3rem;
}

.prize-tier-amount {
  font-size: 0.78rem;
  font-weight: 800;
  display: block;
}

/* ─── Ball Colors — Taiwan Lottery Official Style ─────────────── */
/* All regular balls: gold-orange 3D radial gradient */
.ball-regular {
  background: var(--ball-regular);
  color: #000 !important;
  text-shadow: none !important;
}

/* Special number ball: red 3D radial gradient */
.ball-special {
  background: var(--ball-special) !important;
  color: #fff !important;
  text-shadow: none !important;
}

/* ─── Analysis Section ─────────────────────────────────────────── */
.analysis-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}

.analysis-tab {
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-sub);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--trans);
  cursor: pointer;
}

.analysis-tab:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.analysis-tab:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.analysis-tab:not(:first-child) {
  margin-left: -1px;
}

.analysis-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  z-index: 1;
}

.analysis-tab:hover:not(.active) {
  color: var(--primary);
  border-color: var(--primary-light);
}

.freq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 1rem;
}

.freq-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
}

.freq-rank {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 20px;
  text-align: right;
}

.freq-ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 900;
  color: #000;
  background: var(--ball-regular);
  box-shadow: var(--ball-regular-shadow);
  flex-shrink: 0;
  position: relative;
}

.freq-ball::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 5px;
  width: 11px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.55) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.freq-bar-wrap {
  flex: 1;
  height: 24px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.freq-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
  min-width: 3px;
}

.freq-bar-hot {
  background: linear-gradient(90deg, #FF981E, #EB5E00);
}

.freq-bar-warm {
  background: linear-gradient(90deg, #FFECBB, #FF981E);
}

.freq-bar-cold {
  background: linear-gradient(90deg, #648CB4, #90afd0);
}

.freq-bar-all {
  background: linear-gradient(90deg, #EB5E00, #FF981E);
}

.freq-count {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-sub);
  min-width: 40px;
  text-align: right;
}

/* ─── Gap Analysis ─────────────────────────────────────────────── */
.gap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.gap-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--trans);
  cursor: default;
  gap: 0;
  position: relative;
}

.gap-cell:hover {
  transform: scale(1.06);
  z-index: 1;
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.gap-cell-num {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
}

.gap-cell-val {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.gap-cell.hot {
  background: rgba(230, 57, 70, 0.1);
  border-color: var(--primary-light);
}

.gap-cell.hot .gap-cell-num {
  color: var(--primary);
}

.gap-cell.hot .gap-cell-val {
  color: var(--primary-light);
}

.gap-cell.cold {
  background: rgba(59, 130, 246, 0.08);
  border-color: #93c5fd;
}

.gap-cell.cold .gap-cell-num {
  color: #3b82f6;
}

.gap-cell.cold .gap-cell-val {
  color: #60a5fa;
}

.gap-top10 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.gap-top10-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--trans);
}

.gap-top10-item:hover {
  border-color: var(--primary-light);
}

.gap-top10-rank {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
}

.gap-top10-ball {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 900;
  color: #000;
  background: var(--ball-regular);
  box-shadow: var(--ball-regular-shadow);
  position: relative;
}

.gap-top10-ball::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  width: 13px;
  height: 9px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.55) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.gap-top10-periods {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary);
}

/* ─── History Table ────────────────────────────────────────────── */
.history-card {
  padding: 0;
  overflow: hidden;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.history-table thead {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
}

.history-table th {
  padding: 0.75rem 0.85rem;
  font-weight: 800;
  text-align: left;
  font-size: 0.82rem;
  white-space: nowrap;
}

.history-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table tbody tr {
  transition: background 0.2s;
}

.history-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.history-table tbody tr:nth-child(even) {
  background: var(--bg-input);
}

.history-table tbody tr:nth-child(even):hover {
  background: var(--bg-card-hover);
}

.history-balls {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.history-ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  color: #000;
  background: var(--ball-regular);
  box-shadow: var(--ball-regular-shadow);
  position: relative;
}

.history-ball::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 5px;
  width: 10px;
  height: 7px;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.55) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.history-special {
  background: var(--ball-special) !important;
  color: #fff !important;
  box-shadow: var(--ball-special-shadow);
  border: none;
}

/* ─── Footer ───────────────────────────────────────────────────── */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 1rem;
}

.footer-affiliate {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.affiliate-iframe {
  width: calc(50% - 0.5rem);
  max-width: 420px;
  height: 620px;
  border-radius: 12px;
  overflow: hidden;
}

@media (max-width: 860px) {
  .affiliate-iframe {
    width: 100%;
    max-width: 100%;
    height: 580px;
  }
}

.footer-disclaimer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  max-width: 680px;
  margin: 0 auto 0.5rem;
}

.footer-info {
  font-size: 0.72rem;
  color: var(--text-sub);
  text-align: center;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.footer-copy {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Ad Modal ─────────────────────────────────────────────────── */
.ad-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: adFadeIn 0.3s ease;
}

@keyframes adFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.ad-modal-box {
  background: linear-gradient(135deg, #fff8f0, #ffffff);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: adSlideUp 0.35s ease;
}

@keyframes adSlideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.ad-modal-tag {
  display: inline-block;
  background: linear-gradient(135deg, #FF981E, #EB5E00);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  margin-bottom: 1rem;
}

.ad-modal-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: #1a1a2e;
  margin: 0 0 0.5rem;
}

.ad-modal-desc {
  font-size: 0.9rem;
  color: #555;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.ad-modal-btn {
  display: inline-block;
  background: linear-gradient(135deg, #ee4d2d, #ff6633);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.85rem 2.2rem;
  border-radius: 12px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(238, 77, 45, 0.35);
}

.ad-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(238, 77, 45, 0.45);
}

.ad-modal-hint {
  font-size: 0.72rem;
  color: #aaa;
  margin: 1rem 0 0;
}

/* ─── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-h);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .recommend-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .prize-tiers {
    grid-template-columns: repeat(2, 1fr);
  }

  .live-ball {
    width: 48px;
    height: 48px;
    font-size: 0.95rem;
  }

  .calc-slider {
    width: 140px;
  }
}

@media (max-width: 520px) {
  .recommend-grid {
    grid-template-columns: 1fr;
  }

  .prize-tiers {
    grid-template-columns: repeat(2, 1fr);
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-sub {
    font-size: 0.6rem;
  }

  .gap-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }

  .gap-cell-num {
    font-size: 0.75rem;
  }

  .gap-cell-val {
    font-size: 0.55rem;
  }

  .live-info-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .live-info-item {
    flex-direction: row;
    gap: 0.5rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-table {
    font-size: 0.75rem;
  }

  .history-ball {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }
}

/* ─── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}