:root {
  --bg: #12141a;
  --surface: #1a1d26;
  --border: #2a3040;
  --text: #e8eaed;
  --muted: #9aa0ae;
  /* Monospace stack: clearer digit shapes for levels, tools, Δ, U */
  --font-numeric: ui-monospace, "Cascadia Mono", "Cascadia Code", "Segoe UI Mono",
    "Roboto Mono", Menlo, Consolas, monospace;
  --skill-col-width: 2.2rem;
  --skill-sort-gap: 0.4rem;
  --row-col-width: 2.25rem;
  --login-col-width: 7.6rem;
  --under-tools-col-width: 2.35rem;
  --player-col-max: calc(250px * 0.85);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
}

header.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.site-nav__link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav__link:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-nav__link[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  pointer-events: none;
  text-decoration: none;
}

.site-nav__sep {
  color: var(--border);
  user-select: none;
}

header.summary h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-value {
  font-weight: 600;
  font-size: 1.05rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.toolbar label {
  font-size: 0.85rem;
  color: var(--muted);
}

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.9rem;
}

.toggle-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.toggle-btn:hover {
  color: var(--text);
  border-color: #3d4458;
}

.toggle-btn:focus-visible {
  outline: 2px solid #5b8cff;
  outline-offset: 2px;
}

.toggle-btn--on {
  background: #252a38;
  color: var(--text);
  border-color: #4a5a8a;
}

.error-wrap {
  background: #3d2226;
  border: 1px solid #7a3e45;
  color: #f0d0d3;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.error-wrap code {
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #222631;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  background: #2a3140;
}

thead th.sortable:focus-visible {
  outline: 2px solid #6b9bd1;
  outline-offset: -2px;
}

thead th .sort-ind {
  display: inline-block;
  margin-left: 0.3em;
  min-width: 0.85em;
  opacity: 0.28;
  font-size: 0.72em;
  vertical-align: middle;
  color: var(--muted);
}

thead th.sorted-asc .sort-ind,
thead th.sorted-desc .sort-ind {
  opacity: 1;
  color: var(--text);
}

thead th.sorted-asc .sort-ind::after {
  content: '▲';
}

thead th.sorted-desc .sort-ind::after {
  content: '▼';
}

thead th.skill-col-header {
  text-align: center;
  vertical-align: bottom;
  padding: 0.45rem 0.15rem 0.5rem;
  width: var(--skill-col-width);
  min-width: var(--skill-col-width);
  max-width: var(--skill-col-width);
}

thead th.skill-col-header.skill-group-header {
  width: auto;
  min-width: 0;
  max-width: none;
}

thead th.skill-col-header .skill-header-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: var(--skill-sort-gap);
}

thead th.skill-col-header .skill-header-rot-wrap {
  flex: 0 1 auto;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

thead th.skill-col-header .skill-header-label {
  display: block;
  /* LTR scripts: flow runs bottom → top (first letter at the bottom). */
  writing-mode: sideways-lr;
  white-space: nowrap;
  line-height: 1.15;
  margin: 0;
}

@supports not (writing-mode: sideways-lr) {
  thead th.skill-col-header .skill-header-label {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    direction: rtl;
    unicode-bidi: isolate;
  }
}

thead th.skill-col-header .sort-ind {
  margin-left: 0;
  flex-shrink: 0;
  align-self: center;
  line-height: 1;
  padding: 0.05rem 0;
}

thead th.skill-sub-th {
  text-align: center;
  padding: 0.4rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

thead th.row-num-header,
thead th.player-col,
thead th.login-col,
thead th.under-tools-col {
  vertical-align: bottom;
}

thead th.row-num-header,
tbody td.row-num-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  width: var(--row-col-width);
  min-width: var(--row-col-width);
  max-width: var(--row-col-width);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}

thead th.player-col,
tbody td.player-cell {
  width: var(--player-col-max);
  max-width: var(--player-col-max);
  overflow: hidden;
  text-overflow: ellipsis;
}

thead th.login-col,
tbody td.login-cell {
  width: var(--login-col-width);
  min-width: var(--login-col-width);
  max-width: var(--login-col-width);
  white-space: nowrap;
}

thead th.under-tools-col,
tbody td.under-tools-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  width: var(--under-tools-col-width);
  min-width: var(--under-tools-col-width);
  max-width: var(--under-tools-col-width);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

tbody td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.player-cell {
  font-weight: 500;
  white-space: nowrap;
}

.skill-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #fff;
  width: var(--skill-col-width);
  min-width: var(--skill-col-width);
  max-width: var(--skill-col-width);
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.skill-meta-cell {
  font-family: var(--font-numeric);
  font-feature-settings: "tnum" 1, "lnum" 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  width: var(--skill-col-width);
  min-width: var(--skill-col-width);
  max-width: var(--skill-col-width);
  padding: 0.45rem 0.2rem;
  color: var(--text);
}

.skill-meta-skipped {
  color: rgba(154, 160, 174, 0.38);
  font-weight: 400;
  font-size: 0.62rem;
  line-height: 1;
}

/* Δ = 0: stronger de-emphasis so it fades into the grid. */
.skill-meta-cell.skill-meta-dimmed-zero {
  color: rgba(154, 160, 174, 0.42);
  font-weight: 400;
}

tbody td.skill-col-group-end {
  border-right: 2px solid var(--border);
}

.tier-1 { background: #636a74; }
.tier-2 { background: #875f45; }
.tier-3 { background: #556748; }
.tier-4 { background: #49619c; }
.tier-5 { background: #814f87; }
.tier-6 { background: #983a44; }
.tier-7 { background: #947014; }
.tier-8 { background: #538484; }
.tier-9 { background: #464953; }
.tier-10 { background: #96afbe; color: #1a1d26; }

.loading {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}
