:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eaf0f7;
  --text: #14202e;
  --muted: #55657a;
  --line: #d5dfeb;
  --brand: #0a7f9c;
  --brand-ink: #ffffff;
  --gold: #8a6100;
  --gold-bg: #fdf1cc;
  --silver: #3d4a5c;
  --silver-bg: #e4e9f0;
  --bronze: #8a3f10;
  --bronze-bg: #fbe3d3;
  --focus: #0a7f9c;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1522;
    --surface: #132033;
    --surface-2: #1a2b42;
    --text: #e8eff8;
    --muted: #9db0c6;
    --line: #26394f;
    --brand: #35c3e3;
    --brand-ink: #06202a;
    --gold: #f3cb5a;
    --gold-bg: #3a2f10;
    --silver: #c8d3e2;
    --silver-bg: #2a3a50;
    --bronze: #f0a37a;
    --bronze-bg: #402214;
    --focus: #35c3e3;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1522; --surface: #132033; --surface-2: #1a2b42; --text: #e8eff8; --muted: #9db0c6;
  --line: #26394f; --brand: #35c3e3; --brand-ink: #06202a; --gold: #f3cb5a; --gold-bg: #3a2f10;
  --silver: #c8d3e2; --silver-bg: #2a3a50; --bronze: #f0a37a; --bronze-bg: #402214; --focus: #35c3e3;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: .08em; }
.brand small { font-weight: 600; letter-spacing: .04em; color: var(--muted); }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-weight: 900; }
nav { display: flex; gap: 4px; }
nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }

.sample { background: var(--gold-bg); color: var(--gold); text-align: center; padding: 8px 16px; font-size: .92rem; border-bottom: 1px solid var(--line); }

main { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; outline: none; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; margin: 0 0 6px; }
h2 { font-size: 1.3rem; margin: 28px 0 10px; }
h3 { font-size: 1.02rem; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.lede { color: var(--muted); margin: 0 0 20px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-left: auto; }
.seg .tab { border: 0; border-radius: 0; }
.tabrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-item a { display: grid; grid-template-columns: 44px 52px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.rank-item a:hover { border-color: var(--brand); }
.rank-no { font-size: 1.3rem; font-weight: 800; text-align: center; color: var(--muted); }
.rank-item:nth-child(1) .rank-no { color: var(--gold); }
.rank-item:nth-child(2) .rank-no { color: var(--silver); }
.rank-item:nth-child(3) .rank-no { color: var(--bronze); }
.pname { font-weight: 700; }
.pteam { color: var(--muted); font-size: .9rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; color: var(--muted); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 160px; height: 160px; font-size: 3rem; border-radius: var(--radius); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge.t1 { background: var(--gold-bg); color: var(--gold); }
.badge.t3 { background: var(--silver-bg); color: var(--silver); }
.badge.t5 { background: var(--bronze-bg); color: var(--bronze); }
.badge.pos { background: var(--surface-2); color: var(--muted); }

.empty { padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

.search { width: 100%; max-width: 420px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; padding: 0; list-style: none; }
.card a { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); height: 100%; }
.card a:hover { border-color: var(--brand); }
.card .avatar { width: 72px; height: 72px; }

.profile { display: grid; grid-template-columns: 160px 1fr; gap: 24px; align-items: start; margin-top: 8px; }
.profile .meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.stat { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin: 8px 8px 0 0; }
.stat b { display: block; font-size: 1.4rem; }
.acc-list { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 12px; }
.announcements { margin-bottom: 28px; }
.announcements h2 { margin-top: 0; }
.ann { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 4px 18px 14px; margin-bottom: 10px; }
.ann.pinned { border-left-color: var(--gold); }
.ann-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ann-head h3 { margin: 14px 0 6px; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 1.1rem; }
.ann-head time { margin-left: auto; font-size: .9rem; }
.ann p { margin: 0 0 8px; }
.history { columns: 2 220px; padding-left: 20px; margin: 0; }
.history li { margin-bottom: 4px; }

.rules { display: grid; grid-template-columns: 230px 1fr; gap: 32px; align-items: start; }
.toc { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.toc a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.toc a:hover { background: var(--surface-2); color: var(--text); }
.rule-sec { scroll-margin-top: 80px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 20px 20px; margin-bottom: 16px; }
.rule-sec ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.rtable { width: 100%; border-collapse: collapse; font-size: .96rem; }
.rtable th, .rtable td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.rtable td:first-child, .rtable th:first-child { width: 34%; font-weight: 600; }
.hide { display: none; }

.foot { border-top: 1px solid var(--line); padding-top: 16px; padding-bottom: 32px; color: var(--muted); font-size: .9rem; }

@media (max-width: 720px) {
  .profile { grid-template-columns: 1fr; }
  .rules { grid-template-columns: 1fr; }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .rank-item a { grid-template-columns: 36px 44px 1fr; }
  .rank-item .badges { grid-column: 1 / -1; justify-content: flex-start; }
  .avatar { width: 44px; height: 44px; }
  .seg { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
