/* ============================================================
   GNZ48 队伍积分 · 电脑版
   纯色扁平（无渐变）
   ============================================================ */

:root {
  color-scheme: light;

  /* 以票数最多的队伍为代表色（由 JS 按数据切换；默认 G 队） */
  --team-bg: #9fbf40;
  --team-fg: #ffffff;
  --team-ink: #5d7a18;
  --team-soft: #f2f7e5;
  --team-line: #dbe8bb;
  --team-shadow: rgba(159, 191, 64, 0.24);
  --team-muted: rgba(255, 255, 255, 0.72);
  --team-muted-2: rgba(255, 255, 255, 0.62);
  --team-box: rgba(255, 255, 255, 0.12);
  --team-divider: rgba(255, 255, 255, 0.16);
  --team-mark: rgba(255, 255, 255, 0.06);
  --team-border: transparent;

  /* 行内队伍自身的浅色（由行内联变量覆盖） */
  --row-soft: var(--team-soft);
  --row-line: var(--team-line);
  --row-ink: var(--team-ink);
  /* 占比条的浅色轨道：深色主色用白色半透明，浅色主色用深色半透明 */
  --track: rgba(255, 255, 255, 0.18);

  --bg: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #f7f5ee;
  --surface-3: #efebe1;
  --line: #e4ded1;
  --line-soft: #f0ece3;
  --text: #1b1a17;
  --text-2: #555047;
  --text-3: #857e71;
  /* G 队代表色：R=159 G=191 B=64（鲜绿） */
  --green: #9fbf40;
  --green-2: #9fbf40;
  --green-soft: #f2f7e5;
  --green-line: #dbe8bb;
  --gold: #b8872a;
  --red: #d9484d;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-sm: 0 1px 2px rgba(21, 19, 15, 0.04);
  --shadow-md: 0 14px 40px rgba(21, 19, 15, 0.07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: var(--green-soft); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none;
}
.shell { width: min(1120px, calc(100% - 64px)); margin-left: auto; margin-right: auto; }

/* 顶部 */
.site-hd {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 4px 0 var(--team-bg);
  transition: box-shadow 0.3s ease;
}
.hd-in { height: 76px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.08; }
.brand-name b { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.brand-name small { margin-top: 3px; color: var(--text-3); font-size: 10.5px; letter-spacing: 1.2px; }
.hd-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.sync {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text-3); font-size: 11.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sync-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--team-bg);
  box-shadow: 0 0 0 3px var(--team-soft), inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.sync.is-loading .sync-dot { background: var(--text-3); box-shadow: 0 0 0 3px var(--surface-3); }
.sync.is-error .sync-dot { background: var(--red); box-shadow: 0 0 0 3px #fbeceb; }
.sync.is-error { color: var(--red); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn:active { transform: scale(0.94); }
/* 刷新图标随票数最多的队伍换色 */
.icon-btn#refreshBtn { color: var(--team-ink); transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.12s ease; }
.icon-btn#refreshBtn:hover { background: var(--team-soft); border-color: var(--team-line); }

.icon-btn.is-busy .i { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 主视觉 */
.hero {
  position: relative;
  margin-top: 24px;
  padding: 36px 40px 28px;
  border-radius: 24px;
  background: var(--team-bg);
  color: var(--team-fg);
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px 44px;
  align-items: end;
}
.hero-copy { position: relative; z-index: 1; }
.eyebrow {
  color: var(--team-muted-2);
  font-size: 12px; font-weight: 600; letter-spacing: 1.4px;
}
.hero h1 {
  margin-top: 8px;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 14px;
  font-size: 43px; font-weight: 800;
  letter-spacing: -1.3px; line-height: 1.12;
}
.hero h1 small {
  font-size: 0.62em; font-weight: 750; letter-spacing: -0.4px;
  opacity: 0.92;
}
.lede {
  margin-top: 10px; max-width: 590px;
  color: var(--team-muted);
  font-size: 13px; line-height: 1.7;
}
.hero-stats { display: flex; align-items: flex-end; gap: 28px; position: relative; z-index: 1; }
.hstat { min-width: 80px; }
.hstat span { display: block; color: var(--team-muted-2); font-size: 11px; }
.hstat b {
  display: block; margin-top: 4px; color: var(--team-fg);
  font-size: 31px; font-weight: 800; letter-spacing: -1px;
  line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.hero-split { grid-column: 1 / -1; position: relative; z-index: 1; margin-top: 8px; }
.split-bar {
  display: flex; height: 10px; border-radius: 5px;
  overflow: hidden; background: var(--track);
  transition: background 0.3s ease;
}
.split-bar i { display: block; height: 100%; min-width: 2px; }
.split-bar i + i { border-left: 3px solid var(--team-bg); }
.split-legend {
  display: flex; flex-wrap: wrap; gap: 7px 26px;
  margin-top: 10px; color: var(--team-muted);
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.split-legend .lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.split-legend .lg i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.split-legend .lg b { color: var(--team-fg); font-weight: 650; }
.hero-mark {
  position: absolute; right: 10px; bottom: -58px;
  font-size: 220px; font-weight: 800; letter-spacing: -14px; line-height: 1;
  color: var(--team-mark);
  pointer-events: none; user-select: none;
}

/* 主体 */
.layout {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(330px, 0.78fr);
  gap: 22px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.teams-panel { overflow: hidden; }
.panel-hd {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-hd h2 { font-size: 20px; font-weight: 750; letter-spacing: -0.3px; }
.panel-sub { margin-top: 3px; color: var(--text-3); font-size: 11.5px; }
.count { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }

.team-list { padding: 4px 20px 0; }
.team-row {
  --row-soft: #f2f5ee;
  --row-line: #e3e8da;
  --row-ink: #555047;
  display: grid;
  grid-template-columns: 38px 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 14px;
  padding: 15px 6px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.team-row:last-child { border-bottom: 0; }
.team-row.is-merge {
  margin: 0 -6px;
  padding-left: 12px;
  padding-right: 12px;
  background: var(--row-soft);
  border-bottom-color: var(--row-line);
  border-radius: 10px;
  transition: background 0.25s ease;
}
.team-rank {
  color: var(--text-3); font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums; text-align: center;
}

/* 联队单独一行，与原队伍区分 */
.team-row-merged {
  --row-soft: var(--team-soft);
  --row-line: var(--team-line);
  --row-ink: var(--team-ink);
  margin-top: 10px;
  padding-top: 16px;
  border-top: 2px dashed var(--line);
  border-bottom: 0;
}
.team-row-merged .team-rank {
  color: var(--team-ink); font-size: 11px; line-height: 1.2;
}
.team-badge-merged { font-size: 10px; letter-spacing: 0; }
.team-row-merged .team-badge {
  background: var(--team-soft);
  color: var(--team-ink);
}
.team-row-merged .team-name { font-weight: 800; }

/* 行内标记：编入联队 / 合并 */
.mark {
  flex: none; padding: 1px 6px; border-radius: 999px;
  font-style: normal; font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.2px; line-height: 1.5;
}
.mark-merge {
  background: var(--row-soft); color: var(--row-ink);
  border: 1px solid var(--row-line);
}
.mark-original {
  background: var(--team-bg); color: var(--team-fg);
  border: 1px solid var(--team-border);
}
.mark-union {
  background: var(--team-bg); color: var(--team-fg);
  transition: background 0.3s ease, color 0.3s ease;
}
.team-badge {
  width: 46px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; letter-spacing: 0.2px;
}
.team-row .team-badge {
  background: var(--row-soft);
  color: var(--row-ink);
  transition: background 0.25s ease, color 0.25s ease;
}
.team-info { min-width: 0; }
.team-name {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 16px; font-weight: 700; letter-spacing: 0.1px;
}
.team-meta { display: block; margin-top: 3px; color: var(--text-3); font-size: 11px; }
.team-score { text-align: right; font-variant-numeric: tabular-nums; }
.team-score b { font-size: 24px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; }
.team-score small { margin-left: 3px; color: var(--text-3); font-size: 10px; font-weight: 500; }
.team-sub {
  display: block; margin-top: 4px;
  color: var(--text-3); font-size: 10px; font-weight: 500;
  letter-spacing: 0; white-space: nowrap;
}
.team-bar {
  grid-column: 2 / -1;
  height: 6px; margin-top: 4px;
  border-radius: 3px; background: var(--surface-3); overflow: hidden;
}
.team-bar i { display: block; height: 100%; border-radius: 3px; min-width: 2px; }
.team-footnote {
  padding: 13px 24px 17px;
  color: var(--text-3); font-size: 11.5px;
  border-top: 1px solid var(--line-soft);
}

.side { display: flex; flex-direction: column; gap: 22px; }
.merge-card {
  position: relative;
  padding: 24px;
  border-radius: 18px;
  background: var(--team-bg);
  color: var(--team-fg);
  border: 1px solid var(--team-border);
  box-shadow: 0 14px 34px var(--team-shadow);
  overflow: hidden;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.merge-card .m-eyebrow {
  color: var(--team-muted-2);
  font-size: 11px; font-weight: 650; letter-spacing: 1.1px;
}
.merge-card h2 {
  margin-top: 6px;
  font-size: 21px; font-weight: 800; letter-spacing: -0.3px;
}
.merge-equation {
  display: flex; align-items: center; gap: 8px;
  margin-top: 0;
}
.merge-team {
  flex: 1; min-width: 0;
  padding: 12px 10px;
  border-radius: 10px;
  background: var(--team-box);
  text-align: center;
  transition: background 0.25s ease;
}
.merge-team b { display: block; font-size: 17px; font-weight: 800; }
.merge-team span {
  display: block; margin-top: 3px;
  color: var(--team-muted); font-size: 10.5px;
  line-height: 1.5; font-variant-numeric: tabular-nums;
}
.merge-op { color: var(--team-muted-2); font-size: 16px; font-weight: 600; }
.merge-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--team-divider);
}
.merge-label {
  display: block;
  margin-bottom: 8px;
  color: var(--team-muted-2);
  font-size: 11px; font-weight: 650;
  letter-spacing: 1.1px;
}
.merge-team-original { text-align: center; }
.merge-meta {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  margin-top: 10px;
  color: var(--team-muted); font-size: 11.5px;
}
.merge-meta b { color: var(--team-fg); font-weight: 750; }
.merge-empty { margin-top: 18px; color: var(--team-muted); font-size: 12px; line-height: 1.8; }

/* ---------- 各队 / 联队前八 ---------- */
.top8-section { margin-top: 30px; }
.top8-hd {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.top8-hd h2 { font-size: 20px; font-weight: 750; letter-spacing: -0.3px; }
.top8-hd p { margin-top: 3px; color: var(--text-3); font-size: 11.5px; }
.top8-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.top8-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 10px;
  overflow: hidden;
}
.t8-hd { display: flex; align-items: center; gap: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line-soft); }
.t8-badge {
  flex: none;
  width: 44px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--t8-soft);
  color: var(--t8-ink);
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.2px;
}
.t8-title { min-width: 0; }
.t8-title h3 { font-size: 15px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t8-title p { margin-top: 2px; color: var(--text-3); font-size: 10.5px; line-height: 1.5; }
.t8-list { list-style: none; margin: 4px 0 0; padding: 0; }
.t8-list li {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.t8-list li:last-child { border-bottom: 0; }
.t8-rank {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-3);
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.t8-rank.is-p1 { background: var(--gold); color: #fff; }
.t8-rank.is-p2 { background: #77808b; color: #fff; }
.t8-rank.is-p3 { background: #a2603a; color: #fff; }
.t8-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t8-team {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 8.5px; font-weight: 700;
}
.t8-mark {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.2px;
}
.t8-team.t-g { background: #f2f7e5; color: #5d7a18; }
.t8-team.t-niii { background: #fffce6; color: #7d6a00; }
.t8-team.t-z { background: #fdeef1; color: #a32c48; }
.t8-score { flex: none; text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t8-score small { margin-left: 2px; color: var(--text-3); font-size: 9px; font-weight: 500; }
.t8-empty { padding: 24px 0; color: var(--text-3); font-size: 12px; text-align: center; }
.top8-empty { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--text-3); font-size: 12.5px; }
.top8-card.is-skeleton { padding-bottom: 18px; }
.t8-sk-lines { display: flex; flex-direction: column; gap: 13px; padding: 14px 0 0; }

/* ---------- 第一阶段 16 人 ---------- */
.stage-section { margin-top: 30px; }
.stage-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 8px 22px;
}
.stage-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 34px;
}
.stage-group { min-width: 0; }
.stage-cols > .stage-group + .stage-group {
  border-left: 1px solid var(--line-soft);
  padding-left: 34px;
}
.stage-group-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line-soft);
}
.stage-group-badge {
  flex: none;
  width: 46px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--stage-soft, var(--surface-2));
  color: var(--stage-ink, var(--text-2));
  border: 1px solid var(--stage-line, var(--line));
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.2px;
}
.stage-group.is-union .stage-group-badge {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--line);
}
.stage-group-title { min-width: 0; }
.stage-group-title h3 { font-size: 15px; font-weight: 750; }
.stage-group-title p { margin-top: 2px; color: var(--text-3); font-size: 10.5px; }
.stage-list { list-style: none; margin: 2px 0 0; padding: 0; }
.stage-row {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.stage-row:last-child { border-bottom: 0; }
.stage-rank {
  flex: none; width: 23px; height: 23px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-3);
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stage-rank.is-p1 { background: var(--gold); color: #fff; }
.stage-rank.is-p2 { background: #77808b; color: #fff; }
.stage-rank.is-p3 { background: #a2603a; color: #fff; }
.stage-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 650;
}
.stage-score {
  flex: none; min-width: 52px;
  text-align: right;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stage-score small { margin-left: 2px; color: var(--text-3); font-size: 9px; font-weight: 500; }
.stage-sk { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.stage-empty { padding: 34px 0; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* 骨架 / 状态 */
.sk { display: block; height: 12px; border-radius: 6px; background: var(--surface-3); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.sk-team { padding: 19px 6px; border-bottom: 1px solid var(--line-soft); }
.sk-team .line { display: flex; align-items: center; gap: 14px; }
.sk-merge { margin-top: 18px; }
.sk-merge .sk { background: var(--team-divider); }
.state {
  padding: 40px 24px; text-align: center; color: var(--text-3);
}
.state .i { width: 30px; height: 30px; margin-bottom: 10px; }
.state h3 { color: var(--text); font-size: 15px; font-weight: 700; }
.state p { margin-top: 5px; font-size: 12.5px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 16px; margin-top: 14px;
  border-radius: 9px; background: var(--team-bg); color: var(--team-fg);
  border: 1px solid var(--team-border);
  font-size: 12.5px; font-weight: 650;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.btn:hover { filter: brightness(0.96); }

main { padding-bottom: 44px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  transform: translateX(-50%);
  padding: 10px 17px; border-radius: 10px;
  background: #1b1a17; color: #fff; font-size: 12.5px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 1100px) {
  .top8-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .hero h1 { font-size: 37px; }
}
@media (max-width: 700px) {
  .shell { width: calc(100% - 32px); }
  .hd-in { height: 66px; }
  .brand-name b { font-size: 18px; }
  .brand-name small { font-size: 9.5px; letter-spacing: 0.8px; }
  .sync { display: none; }
  .hero { margin-top: 16px; padding: 26px 24px 22px; border-radius: 20px; }
  .hero h1 { font-size: 31px; gap: 0 10px; }
  .hero-stats { flex-wrap: wrap; gap: 18px 26px; }
  .hstat b { font-size: 26px; }
  .hero-mark { font-size: 150px; bottom: -38px; }
  .layout { margin-top: 16px; }
  .side { grid-template-columns: 1fr; }
  .top8-section { margin-top: 22px; }
  .top8-grid { grid-template-columns: 1fr; }
  .top8-hd h2 { font-size: 18px; }
  .stage-cols { grid-template-columns: 1fr; gap: 0; }
  .stage-cols > .stage-group + .stage-group {
    border-left: 0; padding-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 6px;
  }
  .team-row { grid-template-columns: 28px 42px minmax(0, 1fr) auto; gap: 4px 9px; }
  .team-badge { width: 42px; height: 34px; font-size: 11px; }
  .team-name { font-size: 14.5px; }
  .team-score b { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
