/* =============================================
   Analyzer Screen（大樂透 & 威力彩共用）
   ============================================= */

/* ── Chart Containers ────────────────────── */

.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap canvas {
  max-width: 100%;
}
.chart-wrap.tall { height: 300px; }
.chart-wrap.short { height: 200px; }

/* ── Frequency Bar Tab ───────────────────── */

.freq-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.freq-toggle {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-raised);
  border-radius: var(--r-full);
  padding: 3px;
}
.freq-toggle-btn {
  padding: 4px var(--sp-3);
  border: none;
  border-radius: var(--r-full);
  background: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-family: var(--font-base);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.freq-toggle-btn.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

/* ── Trend Tab ───────────────────────────── */

.trend-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 640px) {
  .trend-charts-grid { grid-template-columns: 1fr; }
}

/* ── Pairs Tab ───────────────────────────── */

.pair-top {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.pair-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-raised);
  border-radius: var(--r-sm);
}
.pair-nums {
  display: flex;
  gap: var(--sp-2);
  min-width: 90px;
}
.pair-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-overlay);
  border-radius: var(--r-full);
}
.pair-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(to right, var(--lotto-gold), var(--heat-4));
}
.pair-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-num);
  min-width: 28px;
  text-align: right;
}

/* 威力彩配對用紅色 */
.power-mode .pair-bar {
  background: linear-gradient(to right, var(--power-red), #FF8070);
}

/* ── Recent Tab ──────────────────────────── */

.recent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.recent-table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.recent-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.recent-table tr:last-child td { border-bottom: none; }
.recent-table .period-cell {
  font-family: var(--font-num);
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.recent-table .nums-cell {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

/* ── Gap (Overdue) Visualization ─────────── */

.gap-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.gap-item {
  background: var(--bg-raised);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.gap-item.is-overdue {
  border-left: 3px solid var(--color-warning);
}
.gap-item .gap-num { flex-shrink: 0; }
.gap-item .gap-body { flex: 1; min-width: 0; }
.gap-item .gap-top-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}
.gap-item .gap-current {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-warning);
  font-family: var(--font-num);
}
.gap-item .gap-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-num);
  margin-left: auto;
}
.gap-overdue-badge {
  font-size: 13px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: rgba(243,156,18,0.2);
  color: var(--color-warning);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.gap-percentile-wrap {
  height: 4px;
  background: var(--bg-overlay);
  border-radius: var(--r-full);
  overflow: hidden;
}
.gap-percentile-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(to right, var(--heat-2), var(--heat-4));
  transition: width 0.4s var(--ease-out);
}

/* ── Decay Heat Toggle ───────────────────── */

.heat-mode-toggle {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-raised);
  border-radius: var(--r-full);
  padding: 3px;
  margin-bottom: var(--sp-4);
  align-self: flex-start;
}
.heat-mode-btn {
  padding: 4px var(--sp-3);
  border: none;
  border-radius: var(--r-full);
  background: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-family: var(--font-base);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.heat-mode-btn.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

/* ── Companion (Transition Probs) UI ────── */

.companion-section {
  margin-top: var(--sp-5);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: var(--sp-4);
}
.companion-section h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  margin-bottom: var(--sp-3);
}
.companion-grid {
  display: grid;
  gap: 4px;
  margin-bottom: var(--sp-4);
}
.companion-grid.grid-49 { grid-template-columns: repeat(7, 1fr); }
.companion-grid.grid-38 { grid-template-columns: repeat(8, 1fr); }
.companion-tile {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  background: var(--bg-raised);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: clamp(14px, 1.8vw, 20px);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--dur-fast), border-color var(--dur-fast);
  user-select: none;
}
.companion-tile:hover:not(.active) { transform: scale(1.1); }
.companion-tile.active {
  border-color: var(--lotto-gold);
  background: var(--lotto-gold-dim);
  color: var(--lotto-gold);
}
.power-mode .companion-tile.active {
  border-color: var(--power-red);
  background: var(--power-red-dim);
  color: var(--power-red);
}
.companion-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.companion-empty {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--sp-4) 0;
}
.companion-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-raised);
  border-radius: var(--r-sm);
}
.companion-row .c-rank {
  font-size: var(--text-xs);
  color: var(--text-muted);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}
.companion-row .c-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-overlay);
  border-radius: var(--r-full);
}
.companion-row .c-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(to right, var(--lotto-gold), var(--heat-4));
  transition: width 0.4s var(--ease-out);
}
.power-mode .companion-row .c-bar {
  background: linear-gradient(to right, var(--power-red), #FF8070);
}
.companion-row .c-pct {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-num);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Jackpot Analysis ─────────────────────── */

.jackpot-analysis { margin-top: var(--sp-6); }
.jackpot-section-title {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.jp-day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.jp-day-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
}
.jp-day-card.active        { border-color: var(--lotto-gold-border); }
.jp-day-card.active.red    { border-color: var(--power-red-border); }
.jp-day-label { font-size: var(--text-xs); color: var(--text-muted); }
.jp-day-count {
  font-size: var(--text-xl);
  font-weight: var(--weight-black);
  font-family: var(--font-num);
  line-height: 1.2;
  margin: var(--sp-1) 0;
}
.jp-day-count.gold  { color: var(--lotto-gold); }
.jp-day-count.red   { color: var(--power-red); }
.jp-day-count.muted { color: var(--text-muted); font-size: var(--text-base); }
.jp-day-bar {
  height: 3px;
  background: var(--bg-raised);
  border-radius: var(--r-full);
  overflow: hidden;
}
.jp-day-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.6s var(--ease-out);
}

.jp-city-rows { display: flex; flex-direction: column; gap: var(--sp-2); }
.jp-city-row  { display: flex; align-items: center; gap: var(--sp-3); }
.jp-city-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  width: 72px;
  flex-shrink: 0;
}
.jp-city-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-raised);
  border-radius: var(--r-full);
  overflow: hidden;
}
.jp-city-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--lotto-gold);
  transition: width 0.6s var(--ease-out);
}
.jp-city-bar.red { background: var(--power-red); }
.jp-city-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.jp-recent-table { display: flex; flex-direction: column; margin-top: var(--sp-2); }
.jp-recent-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--text-xs);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.jp-recent-date   { color: var(--text-muted); width: 80px; flex-shrink: 0; font-family: var(--font-num); }
.jp-recent-county { font-weight: var(--weight-bold); width: 60px; flex-shrink: 0; }
.jp-recent-store  { color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jp-recent-amount { font-family: var(--font-num); font-weight: var(--weight-bold); flex-shrink: 0; }
.jp-recent-amount.gold { color: var(--lotto-gold); }
.jp-recent-amount.red  { color: var(--power-red); }

/* ── Prize Table ─────────────────────────── */
.prize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}
.prize-table th {
  text-align: center;
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
}
.prize-table td {
  text-align: center;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.prize-table tr:last-child td { border-bottom: none; }
.prize-table tr:hover td { background: rgba(255,255,255,0.02); }
.prize-count {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.3;
}
.prize-amt {
  display: block;
  font-family: var(--font-num);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  color: var(--lotto-gold);
  line-height: 1.3;
}
.prize-table.power-mode .prize-amt { color: var(--power-red); }
.jackpot-accumulating {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: #ff6b35;
  background: rgba(255, 107, 53, 0.15);
  border: 1px solid rgba(255, 107, 53, 0.4);
  border-radius: 4px;
  padding: 1px 6px;
  animation: jackpot-pulse 2s ease-in-out infinite;
}
@keyframes jackpot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
