:root {
  --bg: #0b0e13;
  --bg-2: #11161d;
  --bg-3: #171e27;
  --line: #232c38;
  --line-2: #2d3948;
  --fg: #e7ebf0;
  --fg-2: #a8b3c2;
  --fg-3: #6d7a8b;
  --gold: #e0b45c;
  --gold-2: #f2d38a;
  --win: #4fc38a;
  --loss: #e0655c;
  --challenger: #7ad7f0;
  --grandmaster: #ef7d6e;
  --master: #b98cf5;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Be Vietnam Pro", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--gold-2); }
button, select, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---- header ---- */
.top { position: sticky; top: 0; z-index: 10; background: rgba(11,14,19,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; }
.top-nav { display: flex; align-items: center; gap: 10px; }
.nav-link { color: var(--fg-2); font-weight: 500; padding: 6px 10px; border-radius: 8px; }
.nav-link:hover { background: var(--bg-3); color: var(--fg); }
select, .lang-btn, .input {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; color: var(--fg);
}
select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.lang-btn { cursor: pointer; font-family: var(--mono); font-size: 12px; font-weight: 600; min-width: 44px; }
.lang-btn:hover { border-color: var(--gold); }

/* ---- generic ---- */
main { min-height: 60vh; padding: 28px 16px 60px; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 800; }
h2 { font-size: 20px; margin: 32px 0 12px; letter-spacing: -.01em; }
.muted { color: var(--fg-2); }
.dim { color: var(--fg-3); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-2); white-space: nowrap; }
.tier { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.tier.CHALLENGER { color: var(--challenger); border-color: rgba(122,215,240,.35); }
.tier.GRANDMASTER { color: var(--grandmaster); border-color: rgba(239,125,110,.35); }
.tier.MASTER { color: var(--master); border-color: rgba(185,140,245,.35); }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; color: var(--fg-3); font-size: 13px; margin-bottom: 14px; }
.crumbs a { color: var(--fg-2); }
.crumbs a:hover { color: var(--gold-2); }
.empty { padding: 40px 20px; text-align: center; color: var(--fg-2); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty strong { color: var(--fg); }
.loading { color: var(--fg-3); padding: 40px 0; text-align: center; }
.notice { border-left: 3px solid var(--gold); background: var(--bg-2); padding: 10px 14px; border-radius: 0 8px 8px 0; color: var(--fg-2); font-size: 14px; margin: 14px 0; }

/* ---- hero ---- */
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 24px; align-items: end; margin-bottom: 22px; }
.hero p.lead { color: var(--fg-2); font-size: 16px; margin: 0; max-width: 56ch; }
.formula { font-family: var(--mono); font-size: 14px; color: var(--gold-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: inline-block; margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1.1; }
.stat .l { color: var(--fg-3); font-size: 12px; margin-top: 4px; }

/* ---- toolbar ---- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 14px; }
.input { flex: 1 1 260px; min-width: 200px; }
.input:focus { outline: none; border-color: var(--gold); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 12px; cursor: pointer; color: var(--fg-2); font-weight: 500; }
.seg button.on { background: var(--bg-3); color: var(--fg); }

/* ---- champion grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card { display: flex; gap: 12px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--gold); transform: translateY(-1px); color: inherit; }
.card img { width: 48px; height: 48px; border-radius: 10px; background: var(--bg-3); flex: none; }
.card .t { font-weight: 700; line-height: 1.2; }
.card .s { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.card .s b { color: var(--fg-2); font-weight: 600; }
.card .n { margin-left: auto; text-align: right; }
.card .n .v { font-family: var(--mono); font-weight: 600; font-size: 18px; }
.card .n .l { font-size: 11px; color: var(--fg-3); }

/* ---- champion header ---- */
.champ-head { position: relative; overflow: hidden; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-2); padding: 22px; margin-bottom: 18px; min-height: 150px; display: flex; align-items: flex-end; gap: 18px; }
.champ-head .splash { position: absolute; inset: 0; background-size: cover; background-position: center 20%; opacity: .32; mask-image: linear-gradient(90deg, rgba(0,0,0,.2), rgba(0,0,0,1) 60%); -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,.2), rgba(0,0,0,1) 60%); }
.champ-head::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,14,19,.1), rgba(11,14,19,.85)); }
.champ-head > * { position: relative; z-index: 1; }
.champ-head img { width: 72px; height: 72px; border-radius: 14px; border: 2px solid var(--gold); }
.champ-head .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---- table ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { background: var(--bg-3); color: var(--fg-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; }
th.on { color: var(--gold-2); }
th .arr { font-size: 10px; margin-left: 4px; }
tbody tr:hover { background: rgba(224,180,92,.05); }
td.r, th.r { text-align: right; }
.rank { font-family: var(--mono); font-weight: 600; color: var(--fg-2); width: 44px; }
tr.top1 .rank { color: var(--gold); }
tr.top2 .rank { color: #cfd6df; }
tr.top3 .rank { color: #d09a6c; }
.who { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.who img { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-3); flex: none; }
.who .nm { font-weight: 600; }
.who .tg { color: var(--fg-3); font-size: 12px; font-weight: 400; }
.wr { display: flex; align-items: center; gap: 8px; }
.bar { width: 80px; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--win); }
.wr.lo .bar i { background: var(--loss); }
.score { font-family: var(--mono); font-weight: 600; font-size: 15px; color: var(--gold-2); }
.wl b { color: var(--win); font-weight: 600; } .wl span { color: var(--loss); }
.small { font-size: 12px; color: var(--fg-3); }

/* ---- player page ---- */
.player-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.player-head img { width: 64px; height: 64px; border-radius: 14px; border: 2px solid var(--line-2); }

/* ---- about ---- */
.prose { max-width: 76ch; }
.prose h2 { margin-top: 30px; }
.prose li { margin: 6px 0; }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--bg-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.prose table { font-size: 14px; }
.prose th { position: static; cursor: default; }

/* ---- footer ---- */
.foot { border-top: 1px solid var(--line); color: var(--fg-3); font-size: 12px; padding: 22px 0 40px; }
.foot p { margin: 0 0 8px; }
.foot a { color: var(--fg-2); }

/* ---- search results ---- */
.results { display: grid; gap: 8px; margin-top: 12px; }
.res { display: flex; align-items: center; gap: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.res:hover { border-color: var(--gold); }
.res img { width: 36px; height: 36px; border-radius: 8px; }
.res .n { margin-left: auto; color: var(--fg-3); font-size: 12px; text-align: right; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 24px; }
  .top-row { height: 54px; }
  .brand span { display: none; }
  .top-nav { gap: 6px; min-width: 0; }
  .region-picker { min-width: 0; }
  #regionSelect { max-width: 170px; text-overflow: ellipsis; }
  .nav-link { padding: 6px 8px; white-space: nowrap; }
  .champ-head { padding: 16px; }
  .bar { width: 56px; }
}
