/* 仿 tcrmnd35b 的多主题站点样式：卡片/号码球/主题切换，纯本地 CSS（不依赖 CDN）。 */

/* ---------------- 主题变量：168 活力橙（默认）、blue 专业蓝、simple 简洁模式均为浅色白底，
   只有 dark 暗夜是黑色背景（参考 tcrmnd35b） ---------------- */
:root,
html[data-theme="168"] {
  --bg: #f8fafc;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #f97316;
  --brand-2: #ea580c;
  --brand-3: #fb923c;
  --brand-soft: rgba(249, 115, 22, 0.12);
  --brand-border: rgba(249, 115, 22, 0.3);
  --brand-shadow: rgba(249, 115, 22, 0.16);
  --brand-glow: rgba(249, 115, 22, 0.08);
  --bg-glow-1: rgba(249, 115, 22, 0.07);
  --bg-glow-2: rgba(59, 130, 246, 0.05);
  --header-bg: rgba(255, 255, 255, 0.88);
  --line-soft: #f1f5f9;
  --row-hover: #fff7ed;
  --bar-track: #fed7aa;
  --bar-track-alt: #dcfce7;
  --ball-ring: rgba(0, 0, 0, 0.1);
  --ball-shadow: 0 6px 14px rgba(23, 35, 58, 0.18);
  --ok: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
  --green: #16a34a;
  --yellow: #d97706;
  --violet: #7c3aed;
  --shadow: 0 10px 24px rgba(23, 35, 58, 0.1);
  --color-scheme: light;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #0c0f1a;
  --bg-soft: #111522;
  --panel: #151929;
  --panel-2: #1b2036;
  --line: #24304a;
  --text: #e5f0ff;
  --muted: #94a3b8;
  --brand: #22d3ee;
  --brand-2: #06b6d4;
  --brand-3: #a5f3fc;
  --brand-soft: rgba(34, 211, 238, 0.14);
  --brand-border: rgba(34, 211, 238, 0.38);
  --brand-shadow: rgba(6, 182, 212, 0.28);
  --brand-glow: rgba(34, 211, 238, 0.14);
  --bg-glow-1: rgba(34, 211, 238, 0.1);
  --bg-glow-2: rgba(129, 140, 248, 0.08);
  --header-bg: rgba(12, 15, 26, 0.88);
  --line-soft: rgba(36, 48, 74, 0.7);
  --row-hover: rgba(34, 211, 238, 0.06);
  --bar-track: rgba(34, 211, 238, 0.22);
  --bar-track-alt: rgba(23, 164, 92, 0.22);
  --ball-ring: rgba(255, 255, 255, 0.16);
  --ball-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  --ok: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --green: #34d399;
  --yellow: #fbbf24;
  --violet: #a78bfa;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  --color-scheme: dark;
}

html[data-theme="blue"] {
  --bg: #eff6ff;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eff6ff;
  --line: #bfdbfe;
  --text: #1e3a5f;
  --muted: #64748b;
  --brand: #3b82f6;
  --brand-2: #2563eb;
  --brand-3: #60a5fa;
  --brand-soft: rgba(59, 130, 246, 0.12);
  --brand-border: rgba(59, 130, 246, 0.32);
  --brand-shadow: rgba(37, 99, 235, 0.18);
  --brand-glow: rgba(59, 130, 246, 0.1);
  --bg-glow-1: rgba(59, 130, 246, 0.12);
  --bg-glow-2: rgba(14, 165, 233, 0.08);
  --header-bg: rgba(255, 255, 255, 0.88);
  --line-soft: #dbeafe;
  --row-hover: #eff6ff;
  --bar-track: #bfdbfe;
  --bar-track-alt: #dcfce7;
  --ball-ring: rgba(0, 0, 0, 0.1);
  --ball-shadow: 0 6px 14px rgba(23, 35, 58, 0.18);
  --ok: #16a34a;
  --shadow: 0 10px 24px rgba(23, 35, 58, 0.1);
  --color-scheme: light;
}

html[data-theme="simple"] {
  --bg: #ffffff;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f4f4f5;
  --line: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --brand: #18181b;
  --brand-2: #3f3f46;
  --brand-3: #71717a;
  --brand-soft: rgba(24, 24, 27, 0.06);
  --brand-border: rgba(24, 24, 27, 0.16);
  --brand-shadow: rgba(24, 24, 27, 0.12);
  --brand-glow: rgba(24, 24, 27, 0.04);
  --bg-glow-1: rgba(0, 0, 0, 0);
  --bg-glow-2: rgba(0, 0, 0, 0);
  --header-bg: rgba(255, 255, 255, 0.94);
  --line-soft: #f4f4f5;
  --row-hover: #f4f4f5;
  --bar-track: #e4e4e7;
  --bar-track-alt: #e4e4e7;
  --ball-ring: rgba(0, 0, 0, 0.12);
  --ball-shadow: 0 6px 14px rgba(24, 24, 27, 0.14);
  --ok: #16a34a;
  --shadow: 0 8px 20px rgba(24, 24, 27, 0.08);
  --color-scheme: light;
}

html { color-scheme: var(--color-scheme); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 85% 0%, var(--bg-glow-2), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; font-size: 12px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ---------------- 页头 ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--brand), var(--brand-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.site-nav { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.nav-link {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: rgba(255, 255, 255, 0.15);
}
/* 移动端彩种下拉导航：桌面端不占位，只在窄屏断点内显示（见文件末尾 @media）。 */
.mobile-nav { display: none; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 1.8s infinite;
}

/* ---------------- 主题切换（页头右上角） ---------------- */
.theme-switch { position: relative; flex: none; }
.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.theme-switch-btn:hover,
.theme-switch-btn[aria-expanded="true"] { border-color: var(--brand-border); color: var(--brand); }
.theme-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px var(--line);
}
.theme-dot-168 { background: linear-gradient(135deg, #f97316, #ea580c); }
.theme-dot-dark { background: linear-gradient(135deg, #22d3ee, #0c0f1a); }
.theme-dot-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.theme-dot-simple { background: linear-gradient(135deg, #ffffff, #b6c2d2); }
.theme-switch-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 152px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  gap: 2px;
}
.theme-switch-menu.is-open { display: flex; }
.theme-switch-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.theme-switch-menu button:hover { background: var(--panel-2); }
.theme-switch-menu button[aria-checked="true"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---------------- 布局 ---------------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 18px 60px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--brand); }

.hero { text-align: center; margin: 18px 0 26px; }
.hero-title {
  font-size: clamp(26px, 4vw, 40px);
  margin: 0 0 8px;
  font-weight: 900;
  letter-spacing: 1px;
}
.hero-sub { color: var(--muted); margin: 0; font-size: 14px; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.panel-title { font-size: 17px; margin: 0 0 12px; font-weight: 800; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.game-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-card-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-border);
  white-space: nowrap;
}
.btn {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 6px 18px var(--brand-shadow);
}
.btn:hover { filter: brightness(1.08); }

/* ---------------- 号码球 ---------------- */
.balls-row, .detail-balls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px 0;
}
.lottery-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  border: 2px solid var(--ball-ring);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.28), var(--ball-shadow);
  animation: ballIn 0.35s ease;
}
.detail-balls .lottery-ball { width: 62px; height: 62px; font-size: 26px; }
.history-balls { display: flex; gap: 6px; flex-wrap: nowrap; }
.history-balls .lottery-ball { width: 30px; height: 30px; font-size: 14px; border-width: 1px; box-shadow: none; }
@keyframes ballIn { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ball-red { background: radial-gradient(circle at 32% 28%, #ff7b7b, var(--red)); }
.ball-blue { background: radial-gradient(circle at 32% 28%, #7aa8ff, var(--blue)); }
.ball-green { background: radial-gradient(circle at 32% 28%, #5fe39b, var(--green)); }
.ball-yellow { background: radial-gradient(circle at 32% 28%, #ffe17a, var(--yellow)); color: #2b2100; }
.ball-violet { background: radial-gradient(circle at 32% 28%, #c6a4ff, var(--violet)); }

/* ---------------- 详情面板 ---------------- */
.detail-panel { position: relative; overflow: hidden; }
.detail-panel::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--brand-glow), transparent 65%);
  pointer-events: none;
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.text-title { font-size: 24px; font-weight: 900; margin: 0 0 6px; }
.issue-line { color: var(--muted); margin: 0; font-size: 14px; }
.issue-line b { color: var(--brand); font-size: 16px; }
.issue { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.issue b { color: var(--brand); }

.countdown-chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: right;
  min-width: 150px;
}
.countdown-display {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.countdown-display.is-drawing { color: var(--ok); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.countdown-label { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.detail-stats {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.detail-stats li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.detail-stats li span { color: var(--muted); font-size: 12px; }
.detail-stats li b { font-size: 16px; }

.kv { margin: 12px 0 0; display: grid; gap: 6px; font-size: 13px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------------- 统计 ---------------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.stat-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
}
.stat-box h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 700; }
.stat-box p { margin: 8px 0 0; color: var(--muted); }
.bar { height: 10px; border-radius: 999px; background: var(--bar-track); overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; }
.bar-alt { background: var(--bar-track-alt); }
.bar-alt span { background: linear-gradient(90deg, #34d399, #0f766e); }

/* ---------------- 历史表 ---------------- */
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.history-date-form { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.history-date-form input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  color-scheme: var(--color-scheme);
}
.history-date-form button {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 0;
  color: #fff;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.table-wrap { overflow-x: auto; margin-top: 12px; border-radius: 12px; border: 1px solid var(--line); }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.history-table thead th {
  text-align: left;
  padding: 11px 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.history-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.history-table tbody tr:hover { background: var(--row-hover); }
.history-table .col-issue { color: var(--brand); font-weight: 700; }
.history-table .col-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-table tr.is-new { animation: rowFlash 2.4s ease; }
@keyframes rowFlash { from { background: rgba(34, 197, 94, 0.22); } to { background: transparent; } }

/* ---------------- 页脚/加载 ---------------- */
.site-footer { border-top: 1px solid var(--line); padding: 26px 18px 40px; }
.footer-inner { max-width: 1120px; margin: 0 auto; font-size: 13px; color: var(--muted); }
.footer-inner p { margin: 4px 0; }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s;
}
.page-loader.is-hidden { opacity: 0; visibility: hidden; }
.loader-mark { font-weight: 900; font-size: 22px; margin-bottom: 14px; color: var(--brand); }
.loader-bar { width: 180px; height: 4px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.loader-bar span { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-3)); animation: load 1s infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

@media (max-width: 720px) {
  /* 5 球彩种（澳洲幸运5/河内五分彩）在窄屏也必须保持单行：
     球径随视口宽度收缩。可用宽度 = 视口 - 页面左右留白 76px - 4 个球间距 24px，
     再留出滚动条与取整余量后按 5 等分计算；48px 封顶，320px 视口约 40px。 */
  .balls-row, .detail-balls {
    gap: 6px;
    --ball-size: clamp(30px, calc((100vw - 120px) / 5), 48px);
  }
  .balls-row .lottery-ball,
  .detail-balls .lottery-ball {
    width: var(--ball-size);
    height: var(--ball-size);
    font-size: max(14px, calc(var(--ball-size) * 0.42));
    border-width: 1px;
  }
  /* 历史开奖表在窄屏改成卡片纵向排列：所有字段直接可见，不再需要左右滑动。
     字段名靠模板/脚本写入的 data-label 显示（表头在窄屏隐藏）。 */
  .table-wrap { overflow-x: visible; border: 0; border-radius: 0; margin-top: 8px; }
  .history-table { display: block; width: 100%; min-width: 0; font-size: 12px; }
  .history-table thead { display: none; }
  .history-table tbody { display: block; }
  .history-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 6px 8px;
    padding: 10px 11px;
    margin: 0 0 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
  }
  .history-table td { display: block; padding: 0; border: 0; white-space: normal; }
  .history-table td.col-issue { grid-column: 1; font-size: 13px; }
  .history-table td.col-issue::before {
    content: attr(data-label) " ";
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
  }
  .history-table td.col-time {
    grid-column: 2;
    text-align: right;
    font-size: 11px;
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .history-table td.col-time::before { content: attr(data-label) " "; font-size: 10px; }
  .history-table td.col-balls { grid-column: 1 / -1; }
  .history-table .history-balls { gap: 5px; }
  .history-table td.col-stat {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
  }
  .history-table td.col-stat::before { content: attr(data-label); color: var(--muted); font-size: 11px; }
  .history-table td[colspan] { grid-column: 1 / -1; text-align: center; }
  .history-table tr.is-new { animation: cardFlash 2.4s ease; }
  @keyframes cardFlash {
    from { background: rgba(34, 197, 94, 0.2); border-color: var(--ok); }
    to { background: var(--panel-2); border-color: var(--line); }
  }
  /* 页头在窄屏改成“logo + 彩种下拉 + 主题”一行：
     原来的 3 个彩种链接放不下会各占一行，把首屏挤到 150px 以上。
     下拉框用原生 select（系统选择器，最稳），选中项由服务端打标记。 */
  .header-inner { flex-wrap: nowrap; gap: 8px; padding: 10px 12px; }
  .logo { font-size: 18px; }
  .site-nav { display: none; }
  .mobile-nav {
    display: flex;
    position: relative;
    flex: 1;
    min-width: 0;
    align-items: center;
  }
  .mobile-nav-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-width: 0;
    padding: 8px 30px 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .mobile-nav-select:focus-visible { outline: 2px solid var(--brand-border); outline-offset: 1px; }
  .mobile-nav-caret {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted);
    font-size: 11px;
    line-height: 1;
  }
  .header-meta { display: none; }
  .theme-switch { margin-left: 0; }
  .theme-switch-btn { padding: 7px 10px; font-size: 12px; gap: 5px; }
  /* 首页卡片网格原来是 minmax(320px, 1fr)，320px 视口下可用宽度只有 296px，
     整页会被撑出横向滚动（实测 innerWidth 被顶到 338px），窄屏改成单列。 */
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .wrap { padding: 14px 12px 48px; }
}


