/* 彩研 CaiYan —— 响应式样式
   移动优先：手机用底部 Tab 栏，≥900px 切换为左侧导航。
   全部为原生 CSS，无框架、无 CDN、无外部字体。 */

:root {
  --bg: #0b1220;
  --bg-elev: #131c2e;
  --bg-elev-2: #1a2438;
  --line: #24314a;
  --text: #e7edf7;
  --text-dim: #93a3bd;
  --text-faint: #64748b;
  --accent: #4f8cff;
  --accent-soft: #1e3a6d;
  --red: #ff6b6b;
  --blue: #4dabf7;
  --green: #37b679;
  --amber: #e0a83c;
  --purple: #a78bfa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* 这条规则必须带 !important。
 *
 * 踩过的真实坑：浏览器默认样式里的 [hidden] { display: none } 优先级低于任何类选择器。
 * 下面 .auth-overlay 那样的类一旦声明 display: flex，就会把 hidden 属性彻底架空——
 * 认证遮罩从页面加载起就一直显示，看起来像「服务端要求令牌」，
 * 而实际上服务端根本没有开启鉴权。加上 !important 后，无论规则写在何处都能生效。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 6px; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--blue));
  align-self: center;
}
.brand-name { font-weight: 700; letter-spacing: .06em; font-size: 17px; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .12em; text-transform: uppercase; }

.game-picker { margin-left: auto; }
.game-picker select {
  appearance: none;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 30px 8px 12px;
  font-size: 14px;
  font-family: inherit;
  min-height: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  max-width: 46vw;
}

.topbar-meta {
  display: none;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ---------- 免责横幅 ---------- */

.banner {
  margin: 0;
  padding: 8px 14px;
  font-size: 12.5px;
  color: #cbd5e1;
  background: linear-gradient(90deg, rgba(224, 168, 60, .14), rgba(224, 168, 60, .04));
  border-bottom: 1px solid var(--line);
}

/* ---------- 导航 ---------- */

.sidenav { display: none; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(19, 28, 46, .97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 6px 4px;
  cursor: pointer;
}
.nav-btn.active { color: var(--accent); }
.nav-btn:active { background: rgba(79, 140, 255, .08); }

.ico {
  width: 18px; height: 18px;
  display: block;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}
.ico-home { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3l9 8h-3v9h-5v-6h-2v6H6v-9H3z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3l9 8h-3v9h-5v-6h-2v6H6v-9H3z'/%3E%3C/svg%3E"); }
.ico-chart { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20h16v2H2V2h2zm3-3V9h3v8zm5 0V4h3v13zm5 0v-6h3v6z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20h16v2H2V2h2zm3-3V9h3v8zm5 0V4h3v13zm5 0v-6h3v6z'/%3E%3C/svg%3E"); }
.ico-target { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 2a8 8 0 110 16 8 8 0 010-16zm0 4a4 4 0 110 8 4 4 0 010-8zm0 3a1 1 0 100 2 1 1 0 000-2z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm0 2a8 8 0 110 16 8 8 0 010-16zm0 4a4 4 0 110 8 4 4 0 010-8zm0 3a1 1 0 100 2 1 1 0 000-2z'/%3E%3C/svg%3E"); }
.ico-shield { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l8 3v6c0 5-3.4 9.3-8 11-4.6-1.7-8-6-8-11V5z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l8 3v6c0 5-3.4 9.3-8 11-4.6-1.7-8-6-8-11V5z'/%3E%3C/svg%3E"); }
.ico-ticket { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 7h18v3a2 2 0 000 4v3H3v-3a2 2 0 000-4zm6 2v6h2V9z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 7h18v3a2 2 0 000 4v3H3v-3a2 2 0 000-4zm6 2v6h2V9z'/%3E%3C/svg%3E"); }

/* 推荐页：号码卡片与对照表 */
.ticket-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.ticket-row:last-child { border-bottom: 0; }
.ticket-idx { font-size: 12px; color: var(--text-faint); min-width: 44px; font-family: var(--mono); }
.arm-block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.arm-block.system { border-color: rgba(79, 140, 255, .45); background: rgba(79, 140, 255, .06); }
.arm-block.random { border-color: rgba(148, 163, 184, .35); }
.arm-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.arm-sub { font-size: 12px; color: var(--text-faint); font-weight: 400; }

/* ---------- 主内容 ---------- */

.view {
  padding: 14px 14px calc(80px + env(safe-area-inset-bottom));
  max-width: 1100px;
}

.placeholder, .loading {
  color: var(--text-faint);
  text-align: center;
  padding: 40px 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.card-title .sub { font-size: 12px; font-weight: 400; color: var(--text-faint); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

.balls { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 5px;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
}
.ball.p0 { color: #ffd9d9; background: rgba(255, 107, 107, .16); border-color: rgba(255, 107, 107, .4); }
.ball.p1 { color: #d6ebff; background: rgba(77, 171, 247, .16); border-color: rgba(77, 171, 247, .4); }
.ball.small { min-width: 24px; height: 24px; font-size: 11.5px; border-radius: 6px; }
/* 结算时标出命中的号码 */
.ball.hit {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
  background: rgba(55, 182, 121, .28);
  color: #eafff5;
}

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td {
  text-align: right;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-family: var(--mono);
}
th { color: var(--text-faint); font-weight: 500; font-size: 12px; }
th:first-child, td:first-child { text-align: left; padding-left: 2px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.hot td { background: rgba(255, 107, 107, .06); }
tbody tr.cold td { background: rgba(77, 171, 247, .06); }

/* ---------- 控制条 ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.controls label { font-size: 12.5px; color: var(--text-faint); }
.controls select, .controls input {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13.5px;
  min-height: 38px;
}
.btn {
  appearance: none;
  background: var(--accent-soft);
  color: #dbeaff;
  border: 1px solid #2f5391;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13.5px;
  min-height: 38px;
  cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: progress; }

/* ---------- 统计小块 ---------- */

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.metric {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.metric .label { font-size: 12px; color: var(--text-faint); }
.metric .value { font-family: var(--mono); font-size: 17px; font-weight: 600; margin-top: 2px; }
.metric .note { font-size: 11.5px; color: var(--text-faint); }

.chart-box { position: relative; width: 100%; height: 190px; margin: 6px 0 2px; }
.chart-box.short { height: 150px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.chart-hint { font-size: 11.5px; color: var(--text-faint); }

/* ---------- 裁决横幅 ---------- */

.verdict {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.verdict.sig { border-color: rgba(55, 182, 121, .5); background: rgba(55, 182, 121, .1); }
.verdict.nosig { border-color: rgba(148, 163, 184, .4); background: rgba(148, 163, 184, .08); }
.verdict.warn { border-color: rgba(224, 168, 60, .5); background: rgba(224, 168, 60, .1); }
.verdict h3 { margin: 0 0 6px; font-size: 15px; }
.verdict p { margin: 4px 0 0; font-size: 13.5px; color: #cbd5e1; }
.verdict .big { font-family: var(--mono); font-size: 19px; font-weight: 700; color: #fff; }

/* ---------- 特征块 ---------- */

details.feature {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-elev-2);
  overflow: hidden;
}
details.feature > summary {
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  list-style: none;
  font-size: 14px;
}
details.feature > summary::-webkit-details-marker { display: none; }
details.feature > summary::before { content: "▸"; color: var(--text-faint); }
details.feature[open] > summary::before { content: "▾"; }
details.feature .body { padding: 0 12px 12px; }
.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
}
.tag.sig { color: #8ff0bf; border-color: rgba(55, 182, 121, .5); background: rgba(55, 182, 121, .12); }
.tag.nosig { color: var(--text-faint); }
.desc { font-size: 12.5px; color: var(--text-faint); margin: 2px 0 8px; }

ul.notes { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-dim); }
ul.notes li { margin-bottom: 4px; }

.issue {
  border-left: 3px solid var(--amber);
  background: rgba(224, 168, 60, .07);
  padding: 8px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 6px;
  font-size: 13px;
}
.issue .who { font-weight: 600; }
.issue .what { color: var(--text-dim); font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.issue.ok { border-left-color: var(--green); background: rgba(55, 182, 121, .07); }

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: #263449;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}

/* ---------- 令牌遮罩 ---------- */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 10, 18, .92);
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 8px; font-size: 17px; }
.auth-card p { margin: 0 0 12px; font-size: 13px; color: var(--text-dim); }
.auth-card input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 14px;
  min-height: 44px;
}
.auth-card button {
  width: 100%;
  margin-top: 10px;
  background: var(--accent);
  color: #04101f;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
}
.auth-hint { font-size: 12px !important; color: var(--text-faint) !important; margin-top: 10px !important; }
.auth-hint code { font-family: var(--mono); color: var(--text-dim); }

/* ---------- 桌面布局 ---------- */

@media (min-width: 900px) {
  body {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "top top"
      "side banner"
      "side view";
    min-height: 100vh;
  }
  .topbar { grid-area: top; padding-left: 20px; padding-right: 20px; }
  .topbar-meta { display: block; margin-left: 4px; }
  .game-picker { margin-left: auto; }
  .banner { grid-area: banner; padding: 9px 24px; }
  .sidenav {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 12px;
    border-right: 1px solid var(--line);
    background: var(--bg-elev);
  }
  .sidenav .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    font-size: 14px;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    gap: 0;
  }
  .sidenav .nav-btn.active { background: var(--accent-soft); color: #dbeaff; }
  .sidenav .ico { display: none; }
  .sidenav-foot {
    margin-top: auto;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.7;
    padding: 0 4px;
  }
  .tabbar { display: none; }
  .view { grid-area: view; padding: 20px 24px 48px; }
  .toast { bottom: 28px; }
  .chart-box { height: 240px; }
}

@media (min-width: 1200px) {
  .view { padding: 24px 32px 64px; }
}
