:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --panel: #161f33;
  --panel-2: #1c2740;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #93a0bd;
  --primary: #1a3d96;
  --accent: #00a0ea;
  --danger: #e21111;
  --gold: #ffcc00;
  --red: #e53935;
  --blue: #1e88e5;
  --green: #43a047;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --fs-base: 16px;
  --fs-sm: 14px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-title: 26px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, -apple-system, sans-serif;
  font-size: var(--fs-base);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(0, 160, 234, 0.18), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(26, 61, 150, 0.28), transparent 45%),
    var(--bg);
  color: var(--text);
  /* 开奖球/筛选横向滚动时，避免整页被撑出横向条 */
  overflow-x: hidden;
}

body {
  line-height: 1.65;
  font-size: var(--fs-base);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app {
  /* 防止子元素（开奖球等）把整页撑出横向滚动 */
  max-width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px 24px 48px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom)));
  /* 勿用 overflow-x:clip/hidden，否则会打断 sticky 吸顶导航 */
  min-width: 0;
}

img,
video,
iframe {
  max-width: 100%;
}

/* 横向滚动容器通用 */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  background: linear-gradient(145deg, #d90011, #ff5a5a);
  box-shadow: 0 8px 20px rgba(217, 0, 17, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: var(--fs-title);
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: var(--fs-md);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #666;
  box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.5);
}

.live-dot.online {
  background: #43a047;
  animation: pulse 1.8s infinite;
}

.live-dot.error {
  background: #e53935;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(67, 160, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0); }
}

.clock {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

/* Site nav (shared) — 吸顶浮动，页面滚动时保持可见 */
.site-nav {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 4px 12px;
  background: rgba(11, 18, 32, 0.94);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  border-radius: 0 0 14px 14px;
}

.site-nav a {
  flex: 1 0 auto;
  min-width: max-content;
  text-align: center;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  transition: 0.15s;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
  border-color: rgba(0, 160, 234, 0.4);
  text-decoration: none;
}

.site-nav a.active {
  color: #fff;
  background: linear-gradient(180deg, #1a3d96, #122a6b);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(26, 61, 150, 0.35);
}

/* 菜单下方：本站主域名（读后台 primary_domain） */
.site-domain-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: -8px 0 16px;
  padding: 8px 12px 10px;
  border-radius: 0 0 12px 12px;
  background: rgba(11, 18, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top: none;
  font-size: 13px;
  line-height: 1.4;
}

.site-domain-bar[hidden] {
  display: none !important;
}

.site-domain-label {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.site-domain-label::after {
  content: "：";
}

.site-domain-link {
  color: var(--gold, #f0c14b);
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  text-decoration: none;
  word-break: break-all;
}

.site-domain-link:hover {
  text-decoration: underline;
  color: #ffe082;
}

/* Panels */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
  min-width: 0;
  max-width: 100%;
}

.draw-panel {
  overflow: hidden;
}

.draw-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  min-width: 0;
}

.draw-title {
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
}

.badge {
  display: inline-block;
  font-size: var(--fs-sm);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 160, 234, 0.15);
  color: var(--accent);
  border: 1px solid rgba(0, 160, 234, 0.35);
  margin-bottom: 8px;
}

.draw-title h2 {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
}

.period {
  display: inline-block;
  margin-left: 6px;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: #c5d4ff;
}

.period em,
.countdown-label em {
  font-style: normal;
  color: var(--gold);
}

.open-time {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--fs-md);
}

.countdown-box {
  text-align: right;
  min-width: 220px;
}

.countdown-label {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-bottom: 8px;
}

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

.cd-item {
  width: 32px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1a3d96, #122a6b);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.cd-split {
  color: var(--gold);
  font-weight: 700;
  margin: 0 2px;
}

.draw-status {
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--accent);
  min-height: 18px;
}

.draw-status.drawing {
  color: var(--gold);
  animation: blink 1s infinite;
}

.draw-status.done {
  color: #81c784;
}

@keyframes blink {
  50% { opacity: 0.45; }
}

/* Balls */
.balls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 12px 14px;
  padding: 12px 0 8px;
  min-height: 110px;
  /* flex 子项默认 min-width:auto 会撑破父级；配合横向滚动必须设 0 */
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.ball-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.25s, transform 0.25s, filter 0.25s;
  flex-shrink: 0;
  min-width: 0;
}

.ball-wrap.dim {
  opacity: 0.22;
  filter: grayscale(0.6);
  transform: scale(0.92);
}

.ball-wrap.highlight {
  transform: scale(1.08);
}

.ball-wrap.special .ball {
  box-shadow:
    0 0 0 3px rgba(255, 204, 0, 0.45),
    0 8px 18px rgba(0, 0, 0, 0.35);
}

.ball-plus {
  align-self: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  margin: 0 2px;
  padding-bottom: 22px;
  flex-shrink: 0;
}

.ball-tag {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.ball {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 -6px 10px rgba(0, 0, 0, 0.18),
    inset 0 4px 8px rgba(255, 255, 255, 0.35),
    0 8px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s;
}

.ball.pending {
  background: linear-gradient(160deg, #3a4663, #252f48);
  color: #9aa6c3;
  font-size: 16px;
}

.ball.spinning {
  animation: ballSpin 0.12s linear infinite;
  background: linear-gradient(160deg, #5c6b8a, #2f3a55);
}

.ball.red {
  background: radial-gradient(circle at 30% 28%, #ff8a80, var(--red) 55%, #b71c1c);
}

.ball.blue {
  background: radial-gradient(circle at 30% 28%, #90caf9, var(--blue) 55%, #0d47a1);
}

.ball.green {
  background: radial-gradient(circle at 30% 28%, #a5d6a7, var(--green) 55%, #1b5e20);
}

.ball.pop {
  animation: popIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes ballSpin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes popIn {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

.zodiac {
  font-size: var(--fs-md);
  font-weight: 600;
  color: #d7def3;
}

/* Actions */
.draw-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.draw-actions .btn {
  flex-shrink: 0;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, #2488e8, #1367c4);
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: var(--fs-md);
  font-weight: 600;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 9px 14px;
  font-size: var(--fs-sm);
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-md);
  margin-left: auto;
  user-select: none;
  white-space: nowrap;
}

/* 开奖通知开关 */
.notify-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.notify-toggle.on {
  color: #a5d6a7;
  border-color: rgba(67, 160, 71, 0.45);
  background: rgba(67, 160, 71, 0.12);
}

/* 移动端汉堡导航 */
.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: 0.2s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* 手机端：澳门 / 香港快捷切换（桌面隐藏） */
.lottery-switch {
  display: none;
}

@media (max-width: 860px) {
  .lottery-switch {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 0;
    margin: 0 0 14px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(18, 26, 43, 0.92);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .lottery-switch-item {
    flex: 1 1 33.33%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 8px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .lottery-switch-item:hover {
    text-decoration: none;
    color: var(--text);
  }

  .lottery-switch-item.is-active {
    color: #fff;
    background: linear-gradient(180deg, #1a8cff, #0d5fc0);
    box-shadow: 0 6px 16px rgba(13, 95, 192, 0.4);
  }

  /* 香港页激活色 */
  html[data-lottery="hk"] .lottery-switch-item.is-active {
    background: linear-gradient(180deg, #e53935, #b71c1c);
    box-shadow: 0 6px 16px rgba(183, 28, 28, 0.4);
  }

  /* 资料页激活色 */
  html[data-lottery="ziliao"] .lottery-switch-item.is-active {
    background: linear-gradient(180deg, #7e57c2, #5e35b1);
    box-shadow: 0 6px 16px rgba(94, 53, 177, 0.4);
  }

  .lottery-switch-short {
    display: none;
  }

  .lottery-switch-full {
    display: inline;
  }

  .nav-toggle {
    display: flex;
    order: 3;
  }

  .header .brand {
    order: 1;
  }

  .header-meta {
    order: 2;
  }

  .site-nav {
    display: none;
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    top: max(64px, calc(12px + env(safe-area-inset-top) + 52px));
    z-index: 95;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow: auto;
    max-height: min(75vh, 520px);
    padding: 10px;
    border-radius: 16px;
    background: linear-gradient(180deg, #1a243c, #121a2b);
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    gap: 6px;
  }

  .site-nav.nav-open {
    display: flex;
  }

  .site-nav a {
    width: 100%;
    margin-left: 0;
    flex: none;
    min-width: 0;
    padding: 12px 14px;
    text-align: left;
    font-size: 15px;
  }

  .site-nav .nav-auth {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .site-nav .nav-auth a,
  .site-nav .nav-auth button {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
    padding: 11px 8px;
  }

  body.nav-drawer-open {
    overflow: hidden;
  }

  body.nav-drawer-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.45);
  }
}

/* 全局登录态导航 */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-auth a,
.nav-auth button {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.nav-auth a:hover,
.nav-auth button:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.nav-auth-user {
  color: var(--gold) !important;
  border-color: rgba(255, 204, 0, 0.35) !important;
}

.nav-auth-logout {
  color: #ef9a9a !important;
}

/* PWA 添加到主屏幕 */
.pwa-fab {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #2488e8, #1367c4);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(19, 103, 196, 0.45);
  cursor: pointer;
  font-family: inherit;
}

.pwa-fab:active {
  transform: scale(0.98);
}

.pwa-fab-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.pwa-sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(5, 10, 20, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.pwa-sheet[hidden] {
  display: none !important;
}

.pwa-sheet-card {
  position: relative;
  width: min(480px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 20px 20px 16px 16px;
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  margin-bottom: env(safe-area-inset-bottom, 0);
}

.pwa-sheet-card h3 {
  margin: 0 36px 10px 0;
  font-size: 20px;
}

.pwa-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.pwa-steps ol {
  margin: 0 0 12px;
  padding-left: 1.3em;
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
}

.pwa-steps li {
  margin-bottom: 6px;
}

.pwa-key {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  font-weight: 700;
  text-align: center;
}

.pwa-tip {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.pwa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.pwa-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

body.pwa-sheet-open {
  overflow: hidden;
}

@media (min-width: 900px) {
  .pwa-fab-text {
    display: inline;
  }
}

/* Filters */
.filter-panel {
  padding: 12px 14px;
}

.filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filter-row .filter-label,
.filter-row .chip {
  flex-shrink: 0;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-label {
  min-width: 48px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: 700;
  background: #fff;
  color: var(--danger);
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: var(--fs-md);
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}

.chip:hover {
  border-color: rgba(0, 160, 234, 0.5);
}

.chip.active {
  background: rgba(0, 160, 234, 0.2);
  border-color: var(--accent);
  color: #9adfff;
  font-weight: 700;
}

.chip-reset {
  color: var(--gold);
  border-color: rgba(255, 204, 0, 0.35);
}

/* History */
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.history-head h3 {
  margin: 0;
  font-size: var(--fs-lg);
}

.search-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-box input {
  width: 180px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 10px 12px;
  font-size: var(--fs-md);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
}

.his-table {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.his-header,
.his-row {
  display: grid;
  grid-template-columns: 140px 180px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.his-header {
  background: rgba(26, 61, 150, 0.35);
  font-size: var(--fs-md);
  font-weight: 700;
  color: #c9d6ff;
}

.his-body {
  max-height: 620px;
  overflow: auto;
}

.his-row {
  border-top: 1px solid var(--border);
  font-size: var(--fs-md);
  transition: background 0.15s;
}

.his-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.his-row .expect {
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}

.his-row .time {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mini-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mini-ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  position: relative;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}

.mini-ball.red { background: var(--red); }
.mini-ball.blue { background: var(--blue); }
.mini-ball.green { background: var(--green); }

.mini-ball .z {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.mini-plus {
  color: var(--gold);
  font-weight: 700;
  margin: 0 2px 12px;
}

.mini-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 30px;
  transition: opacity 0.2s, filter 0.2s;
}

.mini-item.dim {
  opacity: 0.2;
  filter: grayscale(0.7);
}

.mini-item .zlabel {
  font-size: 12px;
  color: var(--muted);
}

.loading-box,
.empty-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 16px;
  color: var(--muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.history-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.hint {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
  padding: 8px 8px 0;
}

.footer p {
  margin: 0;
  line-height: 1.7;
}

/* ========== Responsive / Mobile ========== */
@media (max-width: 900px) {
  :root {
    --fs-base: 15px;
    --fs-sm: 13px;
    --fs-md: 15px;
    --fs-lg: 18px;
    --fs-xl: 20px;
    --fs-title: 20px;
  }

  .app {
    padding: 12px 12px 80px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(88px, calc(72px + env(safe-area-inset-bottom)));
  }

  .his-header,
  .his-row {
    grid-template-columns: 110px 140px 1fr;
  }
}

@media (max-width: 720px) {
  .header {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand {
    min-width: 0;
    flex: 1;
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .brand h1 {
    font-size: 17px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-meta {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    font-size: 12px;
    max-width: 46%;
  }

  .clock {
    font-size: 11px;
    padding: 3px 8px;
  }

  .notify-toggle {
    font-size: 11px;
    padding: 3px 8px;
  }

  .panel {
    padding: 14px 12px;
    border-radius: 14px;
    margin-bottom: 12px;
  }

  .draw-head {
    flex-direction: column;
    gap: 14px;
    width: 100%;
  }

  .draw-title {
    width: 100%;
  }

  .draw-title h2 {
    font-size: 17px;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .period {
    display: block;
    margin: 4px 0 0;
    font-size: 15px;
  }

  .open-time {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .countdown-box {
    text-align: left;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .countdown-label {
    font-size: 12px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .countdown {
    flex-wrap: wrap;
    max-width: 100%;
  }

  .cd-item {
    width: 28px;
    height: 36px;
    font-size: 17px;
    flex-shrink: 0;
  }

  /* 开奖球：一排 7 码 + 号全部装下，禁止横向滚动 */
  .balls-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2px;
    overflow: hidden;
    padding: 10px 0 12px;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .ball-wrap {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: none;
    gap: 4px;
  }

  /* 特码高亮缩放不溢出容器 */
  .ball-wrap.highlight {
    transform: none;
  }

  .ball-wrap.special .ball {
    box-shadow:
      0 0 0 2px rgba(255, 204, 0, 0.45),
      0 6px 12px rgba(0, 0, 0, 0.3);
  }

  .ball-wrap .meta-line {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .ball {
    width: 100%;
    max-width: 48px;
    height: auto;
    aspect-ratio: 1;
    font-size: clamp(12px, 3.6vw, 16px);
    margin: 0 auto;
  }

  .ball-plus {
    flex: 0 0 12px;
    width: 12px;
    min-width: 12px;
    margin: 0;
    padding-bottom: 1.4em;
    font-size: 14px;
    align-self: center;
  }

  .ball-tag,
  .zodiac {
    font-size: 10px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
  }

  .draw-actions {
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
    max-width: 100%;
  }

  .draw-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 8px);
    max-width: 100%;
    text-align: center;
    padding: 10px 12px;
  }

  .auto-refresh {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    white-space: normal;
    font-size: 13px;
  }

  /* 筛选：保持横向滑动，不挤换行 */
  .filter-row {
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 4px;
  }

  .filter-label {
    min-width: 40px;
    height: 32px;
    font-size: 12px;
  }

  .chip {
    padding: 7px 11px;
    font-size: 13px;
  }

  .opt-chip {
    font-size: 12px;
    padding: 6px 8px;
    white-space: nowrap;
  }

  /* 历史列表：卡片式 */
  .history-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .history-head h3 {
    font-size: 16px;
  }

  .search-box {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-box input,
  .search-box .year-select,
  .year-select {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .search-box .btn {
    flex: 1 1 calc(50% - 4px);
  }

  .his-table {
    border-radius: 10px;
  }

  .his-header {
    display: none;
  }

  .his-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .his-row .expect {
    font-size: 15px;
  }

  .his-row .time {
    font-size: 12px;
  }

  .mini-balls {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .mini-ball {
    width: 30px;
    height: 30px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .mini-item {
    flex-shrink: 0;
  }

  .col-codes {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .pwa-fab {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    padding: 11px 14px;
    font-size: 14px;
  }

  .pwa-fab-text {
    max-width: 7em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pwa-sheet {
    align-items: stretch;
    padding: 0;
  }

  .pwa-sheet-card {
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 85vh;
    overflow: auto;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .article-sheet {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    padding: 20px 16px max(24px, env(safe-area-inset-bottom));
  }

  .history-foot {
    flex-wrap: wrap;
  }

  .btn {
    min-height: 40px;
  }
}

/* 超小屏 */
@media (max-width: 380px) {
  .lottery-switch-full {
    display: none;
  }

  .lottery-switch-short {
    display: inline;
  }

  .brand h1 {
    font-size: 15px;
  }

  .draw-title h2 {
    font-size: 15px;
  }

  .period {
    font-size: 14px;
  }

  .balls-row {
    gap: 1px;
  }

  .ball {
    max-width: 42px;
    font-size: clamp(11px, 3.4vw, 14px);
  }

  .ball-plus {
    flex-basis: 10px;
    width: 10px;
    min-width: 10px;
    font-size: 12px;
  }

  .ball-tag,
  .zodiac {
    font-size: 9px;
  }

  .cd-item {
    width: 24px;
    height: 32px;
    font-size: 15px;
  }

  .header-meta .clock {
    display: none;
  }

  .app {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .panel {
    padding: 12px 10px;
  }
}
