/* SMPTiers — inspired by the subtiers.net ranking layout, with a silver/green identity. */

:root {
  --bg: #1a1a1a;
  --bg-deep: #111214;
  --header: #262626;
  --panel: #333333;
  --row: #262626;
  --row-alt: #2a2a2a;
  --row-hover: #1e1e1e;
  --rank-panel: #404040;
  --rank-panel-alt: #464646;
  --surface: #272727;
  --surface-2: #2f2f2f;
  --surface-3: #3a3a3a;
  --input: #343434;
  --line: #424242;
  --text: #ffffff;
  --muted: #8c8c8c;
  --muted-2: #666666;
  --silver: #c0c6cf;
  --accent: #3ddc84;
  --accent-dark: #22a765;
  --accent-ink: #07150d;
  --danger: #ff6a6e;
  --gold: #fbb03b;
  --silver-rank: #b3b3b3;
  --bronze: #e38d4f;
  --high: #3ddc84;
  --low: #c0c6cf;
  --none: #3b3b3b;
  --na: #ff6a6e;
  --eu: #6aff6e;
  --sa: #f90;
  --au: #f6b26b;
  --me: #ffd966;
  --as: #c27ba0;
  --af: #674ea7;
  --shadow: 0 18px 60px rgba(0, 0, 0, .45);
  --radius: 12px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #e9ecef;
  --bg-deep: #dfe4e8;
  --header: #d4dae0;
  --panel: #d8dde2;
  --row: #f7f8f9;
  --row-alt: #eef1f3;
  --row-hover: #e2e7eb;
  --rank-panel: #c4cbd2;
  --rank-panel-alt: #bcc4cc;
  --surface: #f2f4f6;
  --surface-2: #e6eaee;
  --surface-3: #d6dce2;
  --input: #ffffff;
  --line: #c3cbd3;
  --text: #14181c;
  --muted: #5d6671;
  --muted-2: #6d7681;
  --silver: #69737f;
  --accent: #17975a;
  --accent-dark: #0f7445;
  --accent-ink: #ffffff;
  --high: #1caa66;
  --low: #8d99a6;
  --none: #d5dbe1;
  --shadow: 0 18px 60px rgba(22, 30, 38, .22);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { color: inherit; }
img { border: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 6px;
  left: 6px;
  z-index: 3000;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  width: 100%;
  height: 50px;
  background: var(--header);
  color: var(--muted-2);
  user-select: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .18);
}

.header-inner {
  width: 100%;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.brand-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  min-width: 0;
}

.wordmark {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.wordmark .silver { color: var(--silver); }
.wordmark .green { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.site-nav a {
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
  border-color: var(--accent);
  outline: none;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.search-wrap {
  position: relative;
  width: 240px;
  color: var(--text);
}
.search-wrap input {
  width: 100%;
  height: 36px;
  padding: 10px 34px 10px 35px;
  color: var(--text);
  background: var(--input);
  border: 1px solid transparent;
  border-radius: 100px;
  outline: none;
  font-size: 14px;
}
.search-wrap input::placeholder { color: var(--muted); opacity: 1; }
.search-wrap input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-52%);
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
}
.search-arrow {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
}
.search-wrap:hover .search-arrow,
.search-wrap:focus-within .search-arrow { opacity: 1; }
.search-arrow:not(:disabled) { color: var(--accent); }
.search-arrow:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.search-arrow:disabled { cursor: default; }
.search-error {
  position: absolute;
  top: calc(100% + 6px);
  left: 12px;
  z-index: 5;
  color: var(--danger);
  font-size: 12px;
  white-space: nowrap;
}

.region-control {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.region-control select {
  width: 148px;
  padding: 6px 8px;
  color: var(--text);
  background: var(--header);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}
.region-control select:hover { background: var(--surface-2); }
.region-control select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.discord-link {
  padding: 6px 12px;
  border-radius: 100px;
  background: #5865f2;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.discord-link:hover { background: #4752c4; }

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Ranking page ---------- */

.ranking-page {
  width: 100%;
  max-width: 1420px;
  margin: 30px auto 44px;
  padding: 0 30px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ranking-navigation { position: relative; }

.mode-section {
  height: 65px;
  background: #1a1a1a;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
html[data-theme="light"] .mode-section { background: var(--bg-deep); }

.mode-tabs {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 50px;
  padding-left: 28px;
  width: max-content;
  min-width: 100%;
}

.mode-tab {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  margin: 0 22px;
  padding: 0 18px;
  min-width: 150px;
  border: 0;
  background: #4d4d4d;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mode-tab.first { margin-left: 0; }
.mode-tab::before,
.mode-tab::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 30px;
  height: 51px;
  background: #4d4d4d;
  border-top: 4px solid var(--bg-deep);
  box-sizing: content-box;
}
.mode-tab::before {
  left: -24px;
  border-left: 4px solid var(--bg-deep);
  border-radius: 10px 0 0;
  transform: skew(-16deg);
}
.mode-tab::after {
  right: -24px;
  border-right: 4px solid var(--bg-deep);
  border-radius: 0 10px 0 0;
  transform: skew(16deg);
}
.mode-section { background: var(--bg-deep); }

.mode-tab img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: 0 0 auto;
  image-rendering: auto;
}
.mode-tab span { display: inline; }

.mode-tab.selected,
.mode-tab.selected::before,
.mode-tab.selected::after { background: #666; }
.mode-tab.selected { color: var(--accent); }
.mode-tab.selected::after { box-shadow: inset -3px 0 0 var(--accent); }
.mode-tab.selected::before { box-shadow: inset 3px 0 0 var(--accent); }

.mode-tab:not(.selected):hover,
.mode-tab:not(.selected):hover::before,
.mode-tab:not(.selected):hover::after { background: #424242; }
.mode-tab:not(.selected):active,
.mode-tab:not(.selected):active::before,
.mode-tab:not(.selected):active::after { background: #353535; }
.mode-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.mode-baseline {
  position: relative;
  z-index: 10;
  height: 15px;
  background: #666;
  box-shadow: inset 0 3px 0 var(--accent);
}
html[data-theme="light"] .mode-baseline { background: var(--surface-3); }

.ranking-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 12px 25px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}
.ranking-toolbar strong {
  margin-right: auto;
  color: var(--text);
  font-size: 15px;
}
.ranking-count { color: var(--muted); white-space: nowrap; }
.ranking-legend { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.ranking-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--none);
}
.dot.high { background: var(--high); }
.dot.low { background: var(--low); }

.rankings-list {
  background: var(--panel);
  padding: 30px;
  min-height: 150px;
  flex-grow: 1;
}

.loading-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 220px;
  color: var(--muted);
}
.loading-state p { margin: 0; font-size: 14px; }
.loading-dots { display: inline-flex; gap: 7px; }
.loading-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  animation: dot-pulse .9s ease-in-out infinite alternate;
}
.loading-dots i:nth-child(2) { animation-delay: .15s; }
.loading-dots i:nth-child(3) { animation-delay: .3s; }
.loading-dots i:nth-child(4) { animation-delay: .45s; }
@keyframes dot-pulse { from { opacity: .25; transform: scale(.75); } to { opacity: 1; transform: scale(1); } }

.empty-state {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 20px;
}
.empty-state p { margin: 0; }

/* ---------- Player rows ---------- */

.player-row {
  position: relative;
  display: flex;
  width: 100%;
  height: 90px;
  background: var(--row);
  cursor: pointer;
  transition: background .1s;
}
.player-row.alternate { background: var(--row-alt); }
.player-row:hover { background: var(--row-hover); }
.player-row:active { background: var(--bg-deep); }
.player-row:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.rank-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  min-width: 150px;
  background: var(--rank-panel);
  border-radius: 0 11px 11px 0;
  transition: width .1s;
}
.player-row.alternate .rank-panel { background: var(--rank-panel-alt); }
.player-row:hover .rank-panel { width: 158px; }
.rank-panel h2 {
  flex-grow: 1;
  margin: 0;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
}
.player-row.gold .rank-panel { background: var(--gold); }
.player-row.silver .rank-panel { background: var(--silver-rank); }
.player-row.bronze .rank-panel { background: var(--bronze); }
.player-row.gold .rank-panel h2,
.player-row.silver .rank-panel h2,
.player-row.bronze .rank-panel h2 { color: #15181c; }

.rank-skin {
  width: 67px;
  height: 67px;
  margin: 15px 15px 15px 0;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  flex: 0 0 auto;
}
.rank-skin img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
}
.rank-skin .head-initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--silver);
  font-size: 24px;
  font-weight: 800;
}

.player-name {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 170px;
  max-width: 330px;
  margin: 5px 5px 5px 20px;
  text-align: left;
  white-space: nowrap;
}
.player-name strong {
  overflow: hidden;
  color: var(--text);
  font-size: 23px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
}
.player-name span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.player-row.gold .player-name strong { color: var(--gold); }
.player-row.silver .player-name strong { color: var(--silver-rank); }
.player-row.bronze .player-name strong { color: var(--bronze); }

.rank-data {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  flex-grow: 1;
  min-width: 0;
  gap: 10px;
  padding: 10px 0;
}

.region-box,
.points-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px;
  font-size: 17px;
  font-weight: 600;
  flex: 0 0 auto;
}
.region-box { width: 80px; margin-left: 20px; }
.points-box {
  min-width: 98px;
  color: var(--muted);
  white-space: nowrap;
}
.points-box strong { color: var(--text); font-weight: 700; }
.points-box strong::before { content: "Points: "; color: var(--muted); font-weight: 600; }

.region-box .na { color: var(--na); }
.region-box .eu { color: var(--eu); }
.region-box .as { color: var(--as); }
.region-box .au { color: var(--au); }
.region-box .sa { color: var(--sa); }
.region-box .me { color: var(--me); }
.region-box .af { color: var(--af); }
.region-box .unknown { color: var(--muted); }

.tiers-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.tier-badge {
  display: flex;
  align-items: center;
  overflow: hidden;
  flex: 1 1 0;
  min-width: 66px;
  max-width: 130px;
  height: 30px;
  margin: 0 4px;
  border-radius: 20px;
  background: var(--none);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}
.tier-badge img {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0 4px;
  object-fit: contain;
}
.tier-badge .tier-text {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  min-width: 0;
}
.tier-badge.high { background: var(--high); color: var(--accent-ink); }
.tier-badge.low { background: var(--low); color: #0b1116; }
html[data-theme="light"] .tier-badge.low { color: #fff; }
.tier-badge.unranked { background: var(--none); color: var(--muted); }

.mode-tier-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
  height: 50px;
  margin-right: 4px;
  padding: 0 14px;
  border-radius: 20px;
  background: var(--none);
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
  justify-content: center;
}
.mode-tier-badge img { width: 30px; height: 30px; object-fit: contain; }
.mode-tier-badge.high { background: var(--high); color: var(--accent-ink); }
.mode-tier-badge.low { background: var(--low); color: #0b1116; }
html[data-theme="light"] .mode-tier-badge.low { color: #fff; }

/* Retired players keep their peak tier, prefixed with R (e.g. RLT2). */
.tier-badge.retired,
.mode-tier-badge.retired {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .42);
}
html[data-theme="light"] .tier-badge.retired,
html[data-theme="light"] .mode-tier-badge.retired {
  box-shadow: inset 0 0 0 2px rgba(20, 24, 28, .35);
}

.tier-tooltip {
  position: fixed;
  z-index: 1600;
  max-width: min(280px, calc(100vw - 16px));
  padding: 7px 10px;
  border-radius: 9px;
  background: #0b1116;
  color: #f3f6fa;
  border: 1px solid rgba(192, 198, 207, .38);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .48);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: .01em;
  white-space: nowrap;
  pointer-events: none;
}
html[data-theme="light"] .tier-tooltip {
  background: #14181c;
  color: #fff;
}

.ranking-sentinel { height: 1px; width: 100%; }

/* ---------- Information / Team / Legal ---------- */

.info-section {
  width: 100%;
  max-width: 1420px;
  margin: 0 auto;
  padding: 70px 30px 10px;
}
.section-heading {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--line);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -.03em;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.info-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.info-card h3 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 18px;
}
.info-card p {
  margin: 0 0 12px;
  color: var(--silver);
  font-size: 14px;
  line-height: 1.7;
}
.info-card p:last-child { margin-bottom: 0; }

.points-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.points-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--silver);
  font-size: 13px;
  font-weight: 600;
}
.points-row b { color: var(--text); }

.community-links, .modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.link-group-label {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.partner-link { border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.partner-link span { color: var(--accent); font-size: 15px; line-height: 1; }
.muted-pill { color: var(--muted); }
.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.pill-link:hover { border-color: var(--accent); color: var(--accent); }
.pill-link img { width: 18px; height: 18px; object-fit: contain; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.team-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.team-avatar {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}
.team-avatar img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.team-name { margin: 0; font-size: 19px; }
.team-role {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 9px;
  border-radius: 100px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.legal-card {
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.legal-card h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 22px;
}
.legal-card > p {
  margin: 14px 0 0;
  color: var(--silver);
  font-size: 14px;
  line-height: 1.75;
  max-width: 900px;
}
.legal-card a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Footer ---------- */

.site-footer {
  display: flex;
  min-height: 200px;
  margin-top: 70px;
  padding: 50px 80px;
  background: var(--header);
  color: var(--muted-2);
}
.site-footer > div { flex: 1; }
.site-footer > div:last-child { text-align: right; }
.site-footer h3 { margin: 0 0 10px; color: var(--text); font-size: 16px; }
.site-footer p { margin: 0; font-size: 13px; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Profile modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .53);
  backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }

.player-modal {
  --popup-width: 35vw;
  --popup-min-width: 600px;
  --popup-min-height: 500px;
  --popup-radius: 30px;
  --popup-header-height: 100px;
  --popup-avatar-size: 160px;
  --popup-body-radius: 20px;
  --popup-tier-height: 65px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--popup-width);
  min-width: var(--popup-min-width);
  max-width: 760px;
  min-height: var(--popup-min-height);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  border-radius: var(--popup-radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  outline: none;
}

.modal-head {
  position: relative;
  flex: 0 0 var(--popup-header-height);
  width: 100%;
  background: #4d4d4d;
}
html[data-theme="light"] .modal-head { background: var(--surface-3); }

.modal-avatar {
  position: relative;
  width: 180px;
  height: 100%;
}
.avatar-frame {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--popup-avatar-size);
  height: var(--popup-avatar-size);
  overflow: hidden;
  border-radius: 50%;
  background: #2f2f2f;
}
html[data-theme="light"] .avatar-frame { background: var(--surface-3); }
.avatar-frame > * {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  max-width: 100%;
  height: 90%;
  object-fit: contain;
}
.avatar-frame canvas {
  width: 100% !important;
  height: 100% !important;
  transform: none;
  left: 0;
  bottom: 0;
}
.avatar-frame .avatar-head { height: 100%; width: 100%; object-fit: cover; image-rendering: pixelated; }
.avatar-loading {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: auto;
  color: var(--muted);
  font-size: 28px;
  letter-spacing: 4px;
}
.avatar-frame img[hidden],
.avatar-frame canvas[hidden],
.avatar-loading[hidden] { display: none; }

.modal-head button,
.modal-close {
  position: absolute;
  top: 25px;
  right: 30px;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #666;
  color: #4d4d4d;
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
}
.modal-close:hover { background: #595959; color: #fff; }
.modal-close:active { background: #3b3b3b; }
.modal-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.modal-spacer {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 35px 40px;
  background: var(--surface-2);
}

.modal-body {
  flex-grow: 1;
  margin: 0 30px 30px;
  padding: 20px;
  border-radius: var(--popup-body-radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  text-align: left;
}
.modal-name {
  margin: 0;
  color: var(--text);
  font-size: 25px;
  letter-spacing: -.02em;
}
.modal-subline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
}
.modal-region {
  padding: 4px 9px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--silver);
}
.modal-rank { color: var(--accent); font-weight: 800; }
.modal-points { color: var(--silver); }
.modal-body hr {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--line);
}
.modal-section-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.modal-tier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.modal-tier {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: var(--popup-tier-height);
  padding: 0 14px;
  border-radius: 20px;
  background: var(--surface-2);
}
.modal-tier > img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}
.modal-tier .meta { display: flex; flex-direction: column; min-width: 0; }
.modal-tier .mode { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.modal-tier .tier { color: var(--text); font-size: 21px; font-weight: 800; line-height: 1.1; }
.modal-tier.high { border-left: 4px solid var(--high); }
.modal-tier.low { border-left: 4px solid var(--low); }
.modal-tier.unranked { opacity: .72; }
.modal-tier.retired { border-left-style: dashed; }
.modal-tier.retired .tier { color: var(--silver); }
.modal-tier .peak { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }

.modal-help {
  margin: 18px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
}
.modal-meta { color: var(--silver); font-size: 12px; }
.modal-meta .pill-link { padding: 6px 10px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1500;
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
}
.toast[hidden] { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
  .header-inner { grid-template-columns: 220px minmax(0, 1fr) auto; }
  .site-nav { gap: 16px; }
  .search-wrap { width: 210px; }
  .ranking-page { padding: 0 0 0; }
  .rankings-list { padding: 30px 0; }
  .player-name { min-width: 140px; }
  .region-box { margin-left: 8px; }
  .tier-badge { min-width: 58px; margin: 0 3px; }
  .tier-badge img { width: 17px; height: 17px; margin: 0 3px; }
}

@media (max-width: 1080px) {
  .header-inner { grid-template-columns: 220px 1fr auto; }
  .tiers-box { max-width: 46%; }
  .points-box strong::before { content: ""; }
}

@media (max-width: 900px) {
  .site-header { height: auto; min-height: 64px; }
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "search controls"
      "brand brand";
    row-gap: 6px;
    padding: 8px 12px 10px;
  }
  .search-wrap { grid-area: search; width: min(62vw, 320px); }
  .brand-nav { grid-area: brand; justify-content: flex-start; }
  .header-controls { grid-area: controls; }
  .site-nav { display: flex; gap: 14px; overflow-x: auto; }
  .site-nav a { font-size: 12px; }
  .wordmark { font-size: 18px; }
  .discord-link { display: none; }
  .region-control { font-size: 12px; }
  .region-control select { width: 120px; padding: 5px 6px; }

  .ranking-page { margin: 8px auto 26px; max-width: 100%; }
  .mode-section { height: 66px; }
  .mode-tabs { gap: 8px; padding: 8px 10px; height: 66px; }
  .mode-tab,
  .mode-tab.first {
    min-width: 0;
    height: 50px;
    margin: 0;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13px;
  }
  .mode-tab::before,
  .mode-tab::after { display: none; }
  .mode-tab img { width: 24px; height: 24px; }
  .mode-baseline { height: 5px; box-shadow: inset 0 0 0 var(--accent); }

  .ranking-toolbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .ranking-legend { display: none; }
  .rankings-list { padding: 8px; }

  .player-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "rank name"
      "rank data";
    height: auto;
    min-height: 126px;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 12px;
    gap: 8px;
  }
  .rank-panel,
  .player-row:hover .rank-panel {
    grid-area: rank;
    align-self: start;
    width: 64px;
    min-width: 64px;
    height: 50px;
    border-radius: 8px;
  }
  .rank-panel h2 { font-size: 20px; }
  .rank-skin { display: none; }
  .player-name {
    grid-area: name;
    min-width: 0;
    max-width: none;
    margin: 0;
  }
  .player-name strong { font-size: 19px; }
  .player-name span { font-size: 11px; }
  .rank-data {
    grid-area: data;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    padding: 0;
    min-width: 0;
    width: 100%;
  }
  .region-box { width: auto; min-width: 0; height: 28px; margin: 0; padding: 4px 10px; font-size: 13px; }
  .points-box { min-width: 0; height: 28px; padding: 4px 10px; font-size: 13px; }
  .points-box strong::before { content: "Points: "; }
  .tiers-box {
    flex: 1 1 100%;
    max-width: none;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px;
    overflow: hidden;
  }
  .tier-badge {
    flex: 1 1 calc(25% - 4px);
    min-width: 52px;
    max-width: none;
    height: 28px;
    margin: 0;
    font-size: 11px;
  }
  .tier-badge img { width: 15px; height: 15px; }
  .mode-tier-badge { min-width: 130px; height: 40px; font-size: 18px; }
  .mode-tier-badge img { width: 24px; height: 24px; }

  .info-section { padding: 46px 12px 8px; }
  .info-grid, .team-grid { grid-template-columns: 1fr; }
  .site-footer { min-height: 160px; padding: 32px 20px; }
  .site-footer h3 { font-size: 14px; }

  .player-modal {
    --popup-min-width: 0px;
    --popup-width: calc(100vw - 20px);
    --popup-header-height: 74px;
    --popup-avatar-size: 100px;
    --popup-tier-height: 48px;
    --popup-radius: 20px;
    min-width: 0;
    max-width: 540px;
    max-height: calc(100dvh - 20px);
  }
  .modal-head { min-height: 74px; }
  .avatar-frame { top: 12px; left: 14px; }
  .modal-close { top: 15px; right: 14px; width: 44px; height: 44px; }
  .modal-spacer { flex-basis: 78px; padding: 16px 24px; }
  .modal-body { margin: 0 14px 14px; padding: 16px; }
  .modal-name { font-size: 23px; }
  .modal-tier-grid { gap: 8px; }
  .modal-tier { padding: 0 10px; }
  .modal-tier > img { width: 26px; height: 26px; }
  .modal-tier .tier { font-size: 18px; }
  .modal-tier .peak { display: none; }
}

@media (max-width: 520px) {
  .header-inner { grid-template-areas: "brand controls" "search search"; }
  .brand-nav { flex-wrap: wrap; justify-content: flex-start; gap: 2px 12px; min-width: 0; }
  .site-nav { flex-wrap: wrap; gap: 4px 12px; }
  .search-wrap { width: 100%; }
  .wordmark { font-size: 17px; }
  .site-nav a { font-size: 11px; }
  .header-controls { gap: 5px; }
  .region-control { font-size: 0; gap: 0; }
  .region-control select { width: 108px; font-size: 12px; }
  .theme-toggle { width: 30px; height: 30px; font-size: 15px; }
  .mode-tab span { display: none; }
  .mode-tab { padding: 0 10px; }
  .mode-tab img { width: 26px; height: 26px; }
  .info-card, .legal-card { padding: 18px; }
  .points-table { grid-template-columns: 1fr; }
  .modal-tier-grid { grid-template-columns: 1fr; }
  .site-footer { display: block; }
  .site-footer > div:last-child { margin-top: 18px; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
