:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --text: #18202c;
  --muted: #667180;
  --border: #dce2e9;
  --red: #d54236;
  --blue: #2f64c6;
  --gold: #b8750a;
  --pink: #c33f73;
  --teal: #167d72;
  --danger: #b92d3a;
  --shadow: 0 6px 18px rgba(24, 32, 44, 0.08);
  --radius: 8px;
  --touch: 44px;
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; letter-spacing: 0; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; }
body.detail-open { overflow: hidden; }
img { display: block; max-width: 100%; }
button { border: 0; color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 4px; background: var(--blue); color: #fff; }
.skip-link:focus { top: 12px; }
.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: 20; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; padding: 12px 14px; }
.brand { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.brand-badge { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border-radius: var(--radius); background: var(--red); color: #fff; font-weight: 800; }
.brand-kicker, .meta-line, .stat-label, .stat-hint, .section-note, .chart-caption { color: var(--muted); font-size: 12px; }
.brand-kicker, .meta-line, .stat-label, .stat-hint, .section-note, .chart-caption, .brand h1, .section-title { margin: 0; }
.brand h1 { max-width: 18em; margin-top: 2px; font-size: 16px; line-height: 1.35; font-weight: 800; }
.status-block { flex: 0 0 auto; max-width: 120px; text-align: right; }
.status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 8px; border: 1px solid; border-radius: 6px; font-size: 12px; font-weight: 700; }
.status-ok { background: #e6f5f0; color: #11665d; border-color: #91cfc4; }
.status-delayed { background: #fff3da; color: #8c5909; border-color: #e7bc68; }
.status-error, .status-waiting { background: #fae9eb; color: #9d2834; border-color: #dda2aa; }
.meta-line { margin-top: 4px; overflow-wrap: anywhere; }
.meta-line.subtle { display: none; }

.page { max-width: 1180px; margin: 0 auto; padding: 14px 14px 72px; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
.stat-card { min-width: 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card.primary { grid-column: 1 / -1; border-left: 5px solid var(--red); }
.stat-value { margin: 4px 0 2px; font-size: 24px; line-height: 1.2; font-weight: 800; }
.stat-card.primary .stat-value { color: var(--red); font-size: 32px; }
.section-title { font-size: 17px; line-height: 1.3; font-weight: 800; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.podium-section, .chart-section, .board-section { margin-bottom: 28px; }

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.podium-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.podium-card.rank-1 { border-top: 4px solid var(--gold); }
.podium-card.rank-2 { border-top: 4px solid var(--blue); }
.podium-card.rank-3 { border-top: 4px solid var(--pink); }
.podium-image { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--surface-soft); }
.podium-avatar { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 24px; font-weight: 800; }
.podium-rank { position: absolute; left: 7px; top: 7px; z-index: 2; display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; background: var(--blue); color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 800; }
.rank-1 .podium-rank { background: var(--gold); }
.rank-3 .podium-rank { background: var(--pink); }
.podium-copy { padding: 9px 8px 10px; }
.podium-name, .podium-votes { margin: 0; overflow-wrap: anywhere; }
.podium-name { font-size: 14px; font-weight: 800; }
.podium-votes { margin-top: 2px; color: var(--red); font-family: var(--mono); font-size: 15px; font-weight: 800; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: #e5eaf0; border-radius: 7px; }
.seg-btn { min-width: 68px; min-height: 38px; padding: 7px 10px; background: transparent; border-radius: 5px; color: var(--muted); font-size: 13px; font-weight: 700; }
.seg-btn.active { background: var(--surface); color: var(--blue); box-shadow: 0 1px 3px rgba(24, 32, 44, 0.15); }
.chart-card { position: relative; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
#trend-chart, #detail-chart { display: block; width: 100%; height: 240px; touch-action: manipulation; }
#detail-chart { height: 210px; }
.chart-caption { min-height: 18px; margin-top: 8px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.legend-swatch { width: 18px; height: 4px; border-radius: 2px; }

.zone-label { display: flex; align-items: center; gap: 7px; margin: 12px 0 8px; font-size: 13px; font-weight: 800; }
.zone-dot { width: 9px; height: 9px; border-radius: 50%; }
.zone-dot.qualify { background: var(--blue); }
.zone-dot.eliminate { background: #7d8794; }
.rank-list { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; }
.rank-row { display: grid; grid-template-columns: 32px 46px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 68px; padding: 8px 10px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: var(--radius); }
.rank-row.eliminated { border-left-color: #9da6b1; }
.rank-row.flash { background: #edf4ff; border-color: #83a8ed; }
.rank-row:focus-visible, .seg-btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(47, 100, 198, 0.35); outline-offset: 2px; }
.rank-num { color: var(--blue); font-family: var(--mono); font-weight: 800; text-align: center; }
.eliminated .rank-num { color: #697481; }
.avatar-shell { position: relative; width: 44px; height: 44px; overflow: hidden; border-radius: 50%; background: var(--surface-soft); }
.rank-avatar { position: relative; z-index: 1; width: 44px; height: 44px; object-fit: cover; }
.avatar-shell .avatar-fallback { font-size: 15px; }
.rank-main { min-width: 0; }
.rank-name-row, .rank-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rank-name-row, .rank-sub { flex-wrap: wrap; }
.rank-name { margin: 0; overflow: hidden; color: var(--text); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: 0 0 auto; padding: 1px 5px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-qualify { background: #e6edfb; color: #234f9f; }
.badge-eliminate { background: #e9edf1; color: #5f6975; }
.rank-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.delta-up { color: #116f63; font-weight: 700; }
.delta-down { color: var(--danger); font-weight: 700; }
.delta-flat { color: var(--muted); }
.rank-votes-block { min-width: 60px; text-align: right; }
.rank-votes { margin: 0; font-family: var(--mono); font-size: 16px; font-weight: 800; }
.bar-track { grid-column: 1 / -1; height: 5px; overflow: hidden; background: #e8ecf1; border-radius: 3px; }
.bar-fill { width: 0; height: 100%; background: var(--blue); border-radius: 3px; transition: width 240ms ease-out; }
.eliminated .bar-fill { background: #87919d; }
.cutoff-banner { margin: 14px 0; padding: 10px 8px; background: #fff4dd; border: 1px solid #e7bd6f; border-radius: var(--radius); text-align: center; }
.cutoff-line { display: none; }
#cutoff-text { margin: 0; color: #835209; font-size: 13px; font-weight: 800; }

.detail-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(13, 19, 27, 0.56); }
.detail-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 88dvh; padding: 8px 14px calc(18px + env(safe-area-inset-bottom)); overflow: auto; background: var(--surface); border-radius: 8px 8px 0 0; box-shadow: 0 -12px 32px rgba(13, 19, 27, 0.24); }
.detail-handle { width: 44px; height: 4px; margin: 2px auto 10px; background: #c8cfd7; border-radius: 2px; }
.detail-header, .detail-identity { display: flex; align-items: center; }
.detail-header { justify-content: space-between; gap: 12px; }
.detail-identity { min-width: 0; gap: 10px; }
.detail-avatar { width: 56px; height: 56px; object-fit: cover; border-radius: 50%; background: var(--surface-soft); }
.detail-rank, #detail-title { margin: 0; }
.detail-rank { color: var(--muted); font-size: 12px; font-weight: 700; }
#detail-title { font-size: 18px; }
.icon-btn { display: grid; width: var(--touch); height: var(--touch); place-items: center; background: #e9edf1; border-radius: var(--radius); font-size: 24px; }
.detail-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.detail-stats > div { padding: 10px; background: var(--surface-soft); border-radius: var(--radius); }
.detail-stats .mono { margin: 3px 0 0; font-size: 21px; font-weight: 800; }
.detail-range { margin-bottom: 10px; }
.noscript { margin: 12px; padding: 12px; color: var(--danger); background: #fae9eb; border: 1px solid #dda2aa; border-radius: var(--radius); }
[hidden] { display: none !important; }

@media (min-width: 640px) {
  .topbar-inner, .page { padding-left: 22px; padding-right: 22px; }
  .brand h1 { font-size: 19px; }
  .status-block { max-width: 220px; }
  .meta-line.subtle { display: block; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .stat-card.primary { grid-column: auto; }
  .podium-image { aspect-ratio: 16 / 11; }
}

@media (min-width: 940px) {
  .desktop-split { display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(480px, 1.18fr); gap: 20px; align-items: start; }
  .detail-panel { left: auto; right: 20px; bottom: 20px; width: 430px; max-height: calc(100dvh - 40px); border-radius: var(--radius); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
