:root {
  --bg0: #0b1220;
  --bg1: #121a2b;
  --bg2: #1a2438;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef8;
  --muted: #93a4bd;
  --accent: #3dd6c6;
  --accent2: #f0b429;
  --win: #3ecf8e;
  --lose: #f07178;
  --card: rgba(18, 26, 43, 0.88);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
  line-height: 1.45;
}

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(61, 214, 198, 0.18), transparent 60%),
    radial-gradient(700px 420px at 90% 0%, rgba(240, 180, 41, 0.12), transparent 55%),
    linear-gradient(180deg, #0b1220 0%, #0e1626 45%, #0b1220 100%);
}

.top {
  display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between;
  align-items: flex-end;
  padding: 28px 28px 12px;
  max-width: 1360px; margin: 0 auto;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #2a9d8f);
  color: #06201d; box-shadow: var(--shadow);
}
h1 { margin: 0; font-size: 1.55rem; font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  flex: 1; justify-content: flex-end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.field.grow { flex: 1; min-width: 220px; }
.field span { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; }
.field input, .field select {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit;
}
.field input:focus, .field select:focus {
  outline: none; border-color: rgba(61, 214, 198, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 214, 198, 0.12);
}

.btn {
  border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: rgba(61, 214, 198, 0.45); }
.btn.primary {
  background: linear-gradient(135deg, #2bb8aa, #1f8f84);
  border-color: transparent; color: #041614; font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: wait; }

.status-bar {
  max-width: 1360px; margin: 0 auto;
  padding: 8px 28px 18px;
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted); font-size: 0.9rem;
}
.status-bar .ok { color: var(--accent); }
.status-bar .err { color: var(--lose); }

main {
  max-width: 1360px; margin: 0 auto;
  padding: 0 28px 40px;
  display: grid; gap: 18px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: 0.85rem; }

.team-groups { padding: 4px 16px 16px; display: grid; gap: 16px; }
.league-block { display: grid; gap: 10px; }
.league-label {
  font-size: 0.78rem; letter-spacing: 0.08em; color: var(--muted);
  text-transform: uppercase; padding-left: 2px;
}
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.team-card {
  display: flex; flex-direction: row; gap: 10px; align-items: center;
  text-align: left; cursor: pointer;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit;
  transition: border-color .15s, transform .15s, background .15s;
}
.team-card:hover {
  border-color: rgba(61, 214, 198, 0.45);
  transform: translateY(-1px);
}
.team-card.active {
  border-color: rgba(61, 214, 198, 0.75);
  background: rgba(61, 214, 198, 0.12);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.25);
}
.team-logo-wrap {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  overflow: hidden;
}
.team-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  display: block;
}
.team-logo-fallback {
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  letter-spacing: 0.02em;
}
.team-meta {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.team-card strong { font-size: 1.0rem; line-height: 1.2; }
.team-card .team-meta > span { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.team-card small { color: var(--accent); font-size: 0.72rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 12px; text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; vertical-align: middle;
}
th {
  font-size: 0.75rem; color: var(--muted); font-weight: 600;
  background: rgba(255,255,255,0.02);
}
tbody tr { cursor: pointer; transition: background 0.15s; }
tbody tr:hover { background: rgba(61, 214, 198, 0.06); }
tbody tr.active { background: rgba(61, 214, 198, 0.1); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; cursor: default; }
.empty.soft { padding: 16px; }

.player-cell { display: flex; flex-direction: column; gap: 2px; }
.player-cell strong { font-weight: 600; }
.player-cell small { color: var(--muted); font-size: 0.8rem; }
.mono { font-family: var(--mono); font-size: 0.86rem; }
.tier { font-weight: 600; }
.tier.challenger { color: #7dd3fc; }
.tier.grandmaster { color: #f87171; }
.tier.master { color: #c084fc; }
.tier.empty { color: var(--muted); font-weight: 400; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; border: 1px solid var(--line); color: var(--muted);
}
.pill.none { opacity: 0.7; }
.lp { font-family: var(--mono); color: var(--accent2); }
.muted { color: var(--muted); }
a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.form { display: inline-flex; gap: 3px; flex-wrap: wrap; max-width: 220px; }
.form i {
  font-style: normal; width: 18px; height: 18px; border-radius: 4px;
  display: inline-grid; place-items: center; font-size: 0.68rem; font-weight: 700;
}
.form i.w { background: rgba(62, 207, 142, 0.2); color: var(--win); }
.form i.l { background: rgba(240, 113, 120, 0.2); color: var(--lose); }
.form i.n { background: rgba(148,163,184,0.15); color: var(--muted); }

.delta { font-family: var(--mono); font-weight: 600; }
.delta.up { color: var(--win); }
.delta.down { color: var(--lose); }
.delta.flat { color: var(--muted); }

#detailBody { padding: 8px 18px 18px; }
.summary-grid {
  display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 8px;
}
.stat {
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat span { color: var(--muted); font-size: 0.78rem; }
.stat strong { font-size: 1.05rem; }
.sec-title {
  margin: 18px 0 10px; font-size: 0.95rem; color: var(--text);
  border-left: 3px solid var(--accent); padding-left: 10px;
}
.lp-list { display: grid; gap: 6px; }
.lp-item {
  display: grid; grid-template-columns: 150px 1fr 90px 70px;
  gap: 10px; align-items: center;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  font-size: 0.9rem;
}

.matches { display: grid; gap: 8px; }

.champion-toolbar {
  margin-bottom: 10px;
}
.champion-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  transition: border-color 0.15s;
}
.champion-search:focus-within {
  border-color: rgba(61, 214, 198, 0.55);
  background: rgba(61, 214, 198, 0.05);
}
.champion-search .search-icon {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  flex: 0 0 auto;
}
.champion-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 11px 0;
  font-size: 0.88rem;
  outline: none;
}
.champion-search input::placeholder { color: var(--muted); }
.champion-search input::-webkit-search-cancel-button { display: none; }
.champion-search-clear {
  flex: 0 0 auto;
  border: none;
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.champion-search-clear:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.28);
}

.champion-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.champ-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: normal;
  text-align: left;
}
.champ-tab .tab-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.25;
  min-width: 0;
}
.champ-tab:hover { border-color: rgba(61, 214, 198, 0.45); }
.champ-tab.active {
  border-color: var(--accent);
  background: rgba(61, 214, 198, 0.14);
  color: #d7fff8;
}
.champ-tab .tab-meta {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}
.champ-tab.active .tab-meta { color: rgba(167, 243, 232, 0.9); }
.champ-tab-empty {
  grid-column: 1 / -1;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
}

.champion-stats-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.champ-stats-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.champ-stats-head .btn.tiny {
  padding: 4px 10px;
  font-size: 0.76rem;
  min-height: 0;
}
.champ-stats-wrap {
  max-height: 320px;
  overflow: auto;
}
.champ-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.champ-stats-table th,
.champ-stats-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.champ-stats-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.02);
  position: sticky;
  top: 0;
  z-index: 1;
}
.champ-stat-row { cursor: pointer; transition: background 0.12s; }
.champ-stat-row:hover { background: rgba(61, 214, 198, 0.08); }
.champ-stat-row.active { background: rgba(61, 214, 198, 0.14); }
.champ-stats-table .wr-good { color: var(--win); font-weight: 600; }
.champ-stats-table .wr-bad { color: var(--lose); font-weight: 600; }
.champ-stats-empty { padding: 14px 12px; }

.season-matches {
  max-height: min(70vh, 720px);
  overflow-y: auto;
  padding-right: 4px;
}
.match {
  display: grid;
  grid-template-columns: 48px 1.3fr 0.9fr 0.9fr 1.1fr 0.6fr;
  gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  font-size: 0.92rem;
}
.match.dim { opacity: 0.75; }
.match.clickable { cursor: pointer; }
.match.clickable:hover { border-color: rgba(61, 214, 198, 0.45); background: rgba(61, 214, 198, 0.08); }
.match .res.WIN { color: var(--win); font-weight: 700; }
.match .res.LOSE { color: var(--lose); font-weight: 700; }
.hint-link { color: var(--accent); font-size: 0.78rem; margin-left: 4px; }

.team-block {
  margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.team-block.blue { border-left: 4px solid #60a5fa; }
.team-block.red { border-left: 4px solid #f87171; }
.team-block.won { background: rgba(62, 207, 142, 0.04); }
.team-block.lost { background: rgba(240, 113, 120, 0.04); }
.team-head {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.bans { padding: 8px 14px; font-size: 0.85rem; }
.player-table-wrap { overflow-x: auto; }
.player-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.player-table th, .player-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.player-table th { color: var(--muted); font-size: 0.72rem; background: rgba(255,255,255,0.02); }
.player-table tr.me { background: rgba(61, 214, 198, 0.12); }
.player-table .items {
  white-space: normal; min-width: 168px;
}
.icon-row {
  display: inline-flex; gap: 2px; align-items: center; flex-wrap: nowrap;
}
.game-icon {
  width: 22px; height: 22px; border-radius: 4px;
  object-fit: cover; background: #111; border: 1px solid rgba(255,255,255,0.12);
  vertical-align: middle;
}
.game-icon.item { width: 24px; height: 24px; border-radius: 3px; }
.game-icon.spell { width: 22px; height: 22px; border-radius: 4px; }
.game-icon.rune { width: 22px; height: 22px; border-radius: 50%; background: #0b0f14; }
.game-icon.champ { width: 28px; height: 28px; border-radius: 6px; }
.game-icon.match-champ { width: 26px; height: 26px; }
.game-icon.tab-champ { width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0; }
.champ-cell {
  display: inline-flex; gap: 8px; align-items: center;
}
.champ-tab .champ-cell { gap: 6px; }
.icon-empty {
  display: inline-block; width: 24px; height: 24px; border-radius: 3px;
  background: rgba(255,255,255,0.06); border: 1px dashed rgba(255,255,255,0.12);
}
.icon-fallback {
  display: inline-block; max-width: 72px; overflow: hidden; text-overflow: ellipsis;
  font-size: 0.72rem; color: var(--muted);
}
.icon-fallback.tiny { max-width: 12px; }
.tiny { font-size: 0.78rem; }
.tip { margin: 8px 0 0; }

.lb-controls {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}
.field-inline { display: flex; flex-direction: column; gap: 4px; }
.field-inline span { font-size: 0.72rem; color: var(--muted); }
.field-inline select {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 0.88rem;
}
.lb-rank { font-family: var(--mono); font-weight: 700; color: var(--accent); width: 28px; text-align: center; }
.team-tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600;
  background: rgba(61, 214, 198, 0.12); color: var(--accent);
  border: 1px solid rgba(61, 214, 198, 0.2);
}

.lp-chart-wrap { padding: 0 18px 18px; }
.lp-chart-wrap canvas { max-height: 260px; }

/* ── 骨架屏 ── */
.skeleton-row td { padding: 14px 12px; }
.skel {
  height: 14px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.08) 25%, rgba(148, 163, 184, 0.18) 50%, rgba(148, 163, 184, 0.08) 75%);
  background-size: 200% 100%;
  animation: skelShimmer 1.4s ease-in-out infinite;
}
@keyframes skelShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel.w-40 { width: 40px; }
.skel.w-50 { width: 50px; }
.skel.w-60 { width: 60px; }
.skel.w-67 { width: 67px; }
.skel.w-74 { width: 74px; }
.skel.w-80 { width: 80px; }
.skel.w-81 { width: 81px; }
.skel.w-88 { width: 88px; }
.skel.w-95 { width: 95px; }
.mt-4 { margin-top: 4px; }

/* ── 加载动画 ── */
.loading-pulse {
  text-align: center; padding: 36px 12px;
  color: var(--accent); font-size: 0.95rem;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ── 重试按钮 ── */
.btn-retry {
  display: inline-block; margin-left: 10px; padding: 3px 12px;
  background: rgba(240, 113, 120, 0.18); color: var(--lose);
  border: 1px solid rgba(240, 113, 120, 0.35);
  border-radius: 8px; font: inherit; font-size: 0.82rem;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-retry:hover {
  background: rgba(240, 113, 120, 0.28);
  border-color: rgba(240, 113, 120, 0.55);
}

/* ── 错误信息 ── */
.err-box {
  display: inline-flex; flex-direction: column; gap: 8px; align-items: center;
  padding: 8px 0;
}
.err-box small { font-weight: 400; opacity: 0.75; }
.err-box .btn-retry { margin: 6px 0 0; }
.err-tag {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  background: rgba(240, 113, 120, 0.12); color: var(--lose);
  font-size: 0.72rem; max-width: 160px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

footer {
  max-width: 1360px; margin: 0 auto;
  padding: 0 28px 48px; color: var(--muted); font-size: 0.82rem;
}
footer a { color: var(--accent); }
.visit-stats {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.visit-stats strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.footer-note { margin: 0 0 28px; }
.sponsor {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.08);
}
.sponsor-title { margin: 0; color: var(--text); font-size: 0.9rem; font-weight: 500; }
.sponsor-qr {
  width: 180px; height: 180px; object-fit: contain;
  border-radius: 12px; background: #fff; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.sponsor-caption { margin: 0; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 900px) {
  .top, .status-bar, main, footer { padding-left: 16px; padding-right: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .match { grid-template-columns: 48px 1fr 1fr; }
  .match span:nth-child(n+4) { display: none; }
  .lp-item { grid-template-columns: 1fr 1fr; }
  .sponsor-qr { width: 150px; height: 150px; }
}
