/* ============ 基础变量 ============ */
:root {
  --bg: #e8f4ef;
  --bg-card: #ffffff;
  --bg-soft: #f0faf5;
  --bg-mask: rgba(0, 0, 0, 0.5);
  --border: #d0e8dc;
  --border-light: #e0f0e8;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --primary: #00c896;
  --primary-dark: #00a766;
  --primary-light: #e6f7ef;
  --primary-gradient: linear-gradient(135deg, #00d4aa 0%, #00a766 100%);
  --dan: #00a766;
  --dan-bg: #e6f7ef;
  --shuang: #e54d42;
  --shuang-bg: #fdecea;
  --red: #e54d42;
  --radius: 20px;
  --radius-sm: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #d8ede4 0%, #eaf5f0 30%, #f5faf7 100%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 12px 40px;
}

/* ============ Hero ============ */
.hero {
  padding: 8px 8px 14px;
}

.eyebrow {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  letter-spacing: 1px;
}

.hero h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1a2e2a;
  margin-bottom: 8px;
}

.refresh-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  font-size: 12px;
  color: var(--primary-dark);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* ============ Cycle Tabs ============ */
.cycle-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding: 0 4px;
  scrollbar-width: none;
}

.cycle-tabs::-webkit-scrollbar { display: none; }

.cycle-tab {
  flex-shrink: 0;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  color: #5a7a70;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cycle-tab:hover {
  background: #fff;
}

.cycle-tab.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 167, 102, 0.3);
}

/* ============ Range Tabs ============ */
.range-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.range-tab {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  color: #5a7a70;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.range-tab:hover {
  background: #fff;
}

.range-tab.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 167, 102, 0.3);
}

.range-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 8px 12px;
  line-height: 1.5;
}

/* ============ 数据范围卡片 ============ */
.scope-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0, 167, 102, 0.05);
}

.scope-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 700;
  color: #1a2e2a;
}

.scope-icon {
  color: var(--primary);
  font-size: 16px;
}

.scope-detail {
  font-size: 13px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* ============ 统计卡片 ============ */
.stats-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0, 167, 102, 0.05);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-item {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
}

.stat-value.primary { color: var(--primary-dark); }
.stat-value.dan { color: var(--dan); }
.stat-value.shuang { color: var(--shuang); }
.stat-value.shuang-red { color: var(--red); }

/* ============ 连对统计表格 ============ */
.streak-table-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 167, 102, 0.05);
}

.streak-table-header {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  background: var(--bg-soft);
  font-size: 15px;
  font-weight: 700;
}

.header-left {
  padding: 14px;
  text-align: center;
  color: var(--dan);
}

.header-right {
  padding: 14px;
  text-align: center;
  color: var(--shuang);
}

.header-divider {
  background: var(--border);
}

.streak-table-body {
  display: flex;
  flex-direction: column;
}

.streak-row {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  border-bottom: 1px solid var(--border-light);
}

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

.divider-col {
  background: var(--border-light);
}

.streak-cell {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
  gap: 10px;
}

.streak-cell.clickable:active {
  background: var(--primary-light);
}

.streak-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.streak-time {
  font-size: 12px;
  color: var(--primary);
  background: rgba(0,181,120,0.1);
  padding: 4px 8px;
  border-radius: 8px;
  text-align: center;
  line-height: 1.3;
  justify-self: center;
}

.streak-time small {
  font-size: 10px;
  color: #7a9688;
  font-weight: 400;
}

.streak-count {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 14px;
}
/* ============ 其他区块 ============ */
.section-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0, 167, 102, 0.05);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #1a2e2a;
}

.badge {
  padding: 3px 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.badge-btn {
  cursor: pointer;
  transition: all 0.15s;
}

.badge-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ============ 实时走势 ============ */
.trend-card .section-title { margin-bottom: 14px; }

.live-trend {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.live-current {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f0f9f4 0%, #e8f4ef 100%);
  border-radius: 12px;
}

.live-current-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.live-current-number {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-top: 4px;
}

.live-current-block {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.live-current-result {
  font-size: 20px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 24px;
  text-align: center;
}

.live-current-result.dan {
  background: var(--dan);
  color: #fff;
}

.live-current-result.shuang {
  background: var(--shuang);
  color: #fff;
}

.live-countdown {
  text-align: right;
}

.live-countdown-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.live-countdown-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.live-countdown-block {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* 路珠走势图 */
.trend-grid {
  display: grid;
  gap: 3px;
  align-content: start;
  min-height: 200px;
  padding: 10px;
  background: #f7fbf9;
  border: 2px solid #d5e8df;
  border-radius: 12px;
  overflow-x: auto;
}

.trend-grid.big {
  gap: 4px;
  min-height: 240px;
  padding: 12px;
}

.trend-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  cursor: default;
  transition: transform 0.15s;
}

.trend-cell:hover {
  transform: scale(1.15);
  z-index: 1;
}

.trend-cell.empty {
  background: transparent;
  border: none;
  visibility: hidden;
}

.trend-cell.dan {
  background: var(--dan);
  color: #fff;
  box-shadow: 0 2px 5px rgba(0, 167, 102, 0.3);
}

.trend-cell.shuang {
  background: var(--shuang);
  color: #fff;
  box-shadow: 0 2px 5px rgba(229, 77, 66, 0.3);
}

/* ============ 历史记录 ============ */
.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
}

.history-item:last-child { border-bottom: none; }

.history-block {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.history-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.history-num {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  border-radius: 8px;
}

.history-num.dan {
  background: var(--dan-bg);
  color: var(--dan);
}

.history-num.shuang {
  background: var(--shuang-bg);
  color: var(--shuang);
}

.btn-sm {
  padding: 5px 14px;
  background: var(--primary-light);
  border: none;
  border-radius: 10px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sm:hover {
  background: var(--primary);
  color: #fff;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-mask);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-light);
  font-size: 16px;
  font-weight: 700;
  color: #1a2e2a;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--shuang-bg);
  color: var(--shuang);
}

.modal-grid {
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-item {
  background: var(--bg-soft);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: center;
}

.modal-idx {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
}

.modal-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

/* 长连详情列表 */
.long-streak-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  padding: 4px 0 !important;
}

.long-streak-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 10px;
}

.long-streak-ds {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.long-streak-ds.dan {
  background: var(--dan);
  color: #fff;
}

.long-streak-ds.shuang {
  background: var(--shuang);
  color: #fff;
}

.long-streak-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.long-streak-gap {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.long-streak-time {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 连对表格的详细时间 */
.streak-latest {
  font-size: 12px;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.streak-latest small {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 3px;
}

.streak-count.dan { color: var(--dan); }
.streak-count.shuang { color: var(--shuang); }

/* ============ 当前间隔计数 ============ */
.current-gap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 20px 0 10px;
}

.current-gap-num {
  font-size: 56px;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.current-gap-label {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.current-gap-info {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 10px;
}

.current-gap-info .highlight {
  color: var(--primary-dark);
  font-weight: 600;
}

/* ============ 间隔统计 ============ */
.gap-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gap-col {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.gap-col-title {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  background: rgba(255,255,255,0.6);
}

.gap-col-title.dan { color: var(--dan); }
.gap-col-title.shuang { color: var(--shuang); }

.gap-list {
  padding: 6px 10px;
  max-height: 300px;
  overflow-y: auto;
}

.gap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 13px;
}

.gap-item:last-child { border-bottom: none; }

.gap-item .gap-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.gap-item .gap-count {
  font-weight: 700;
  font-size: 14px;
}

.gap-count.dan { color: var(--dan); }
.gap-count.shuang { color: var(--shuang); }

.gap-empty {
  text-align: center;
  padding: 16px 8px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ============ Footer ============ */
.footer {
  text-align: center;
  margin-top: 12px;
  padding-top: 12px;
}

.footer p {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ 响应式 ============ */
@media (max-width: 380px) {
  .hero h1 { font-size: 18px; }
  .stat-value { font-size: 22px; }
  .stat-item { padding: 10px 12px; }
  .trend-grid { grid-template-columns: repeat(8, 1fr); }
  .cycle-tab { padding: 8px 14px; font-size: 13px; }
  .range-tab { padding: 10px 12px; font-size: 14px; }
}

