:root {
  --bg: #0a0b0d;
  --panel: #12151a;
  --panel-2: #181c22;
  --line: #2a3038;
  --text: #f3f4f6;
  --muted: #8b939e;
  --gold: #e8ba3a;
  --tab: #1e2329;
  --tab-hover: #262c34;
  --tab-sel: #3a424c;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  --tier-hi: #e8eaed;
  --tier-mid: #a67c52;
  --tier-lo: #4a5562;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px clamp(14px, 3vw, 40px) 32px;
}

/* ── Header ─────────────────────────────────────────── */

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 300px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.search-icon {
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  opacity: 0.8;
}

.search-icon::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 2px;
  background: var(--muted);
  right: -5px;
  bottom: -1px;
  transform: rotate(45deg);
}

.search-wrap input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  min-width: 0;
}

.search-wrap input::placeholder {
  color: #66707c;
}

.search-arrow {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.search-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.brand {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}

.brand:hover {
  color: var(--text);
}

.ranking-controls {
  justify-self: end;
}

.controls-info {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.controls-info:hover {
  background: var(--panel-2);
}

/* ── Mode category pills ────────────────────────────── */

.ranking-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mode-section {
  position: relative;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
}

.mode-tab {
  appearance: none;
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  color: var(--text);
  background: linear-gradient(180deg, #1a1f26 0%, #14181e 100%);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.mode-tab-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0c0f13;
  border: 1px solid #2f3741;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.mode-tab-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.mode-tab.is-overall .mode-tab-icon {
  width: 38px;
  height: 38px;
  border-color: rgba(232, 186, 58, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 186, 58, 0.08);
}

.mode-tab.is-overall .mode-tab-icon img {
  width: 24px;
  height: 24px;
}

.mode-tab:hover {
  transform: translateY(-2px);
  border-color: #4a5562;
  background: linear-gradient(180deg, #222831 0%, #181d24 100%);
}

.mode-tab.selected {
  border-color: rgba(232, 186, 58, 0.65);
  background: linear-gradient(180deg, #2a3038 0%, #1c2229 100%);
  box-shadow:
    0 0 0 3px rgba(232, 186, 58, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.mode-tab.selected .mode-tab-label {
  color: var(--gold);
}

.mode-baseline {
  display: none;
}

/* ── Board ──────────────────────────────────────────── */

.mode-ranking-board {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 14px 22px;
  min-height: 440px;
}

.board-loading,
.board-empty {
  padding: 72px 20px;
  text-align: center;
  color: var(--muted);
}

.tier-headings {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.tier-heading {
  margin: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  animation: fadeUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.tier-heading.tier-1 {
  color: #111;
  background: linear-gradient(180deg, #f0d06a, #e8ba3a);
}

.tier-heading.tier-2 {
  color: #111;
  background: linear-gradient(180deg, #d7e3f4, #a8b8cc);
}

.tier-heading.tier-3 {
  color: #111;
  background: linear-gradient(180deg, #f8b07a, #e08a4a);
}

.tier-heading.tier-4 {
  color: #f2eef8;
  background: linear-gradient(180deg, #8f82a8, #655b79);
}

.tier-heading.tier-5 {
  color: #ece8f2;
  background: linear-gradient(180deg, #6f657f, #4d455a);
}

.tier-columns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  min-height: 340px;
}

.tier-column-wrap {
  display: flex;
  min-width: 0;
  animation: fadeUp 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.tier-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 10px;
}

.tier-divider {
  width: 1px;
  background: var(--line);
  margin: 6px 0;
  flex-shrink: 0;
  opacity: 0.85;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.player-chip {
  appearance: none;
  width: 100%;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
  animation: fadeUp 0.3s ease both;
}

/* HT = warmer / gold-tinted · LT = cooler / slate */
.player-chip--ht {
  background: rgba(232, 186, 58, 0.12);
  border-color: rgba(232, 186, 58, 0.28);
}

.player-chip--lt {
  background: rgba(90, 110, 140, 0.22);
  border-color: rgba(120, 140, 170, 0.3);
}

.player-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.player-chip--ht:hover {
  background: rgba(232, 186, 58, 0.18);
}

.player-chip--lt:hover {
  background: rgba(90, 110, 140, 0.3);
}

.player-chip img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #222;
  object-fit: cover;
  flex-shrink: 0;
}

.player-chip .name {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.player-chip .sub {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 560;
  margin-top: 1px;
}

/* ── Overall leaderboard ────────────────────────────── */

.overall-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 4px;
}

.overall-row {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: #0e1116;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 52px 44px minmax(120px, 180px) 1fr auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
  animation: fadeUp 0.35s ease both;
}

.overall-list .overall-row:nth-child(1) { animation-delay: 0ms; }
.overall-list .overall-row:nth-child(2) { animation-delay: 35ms; }
.overall-list .overall-row:nth-child(3) { animation-delay: 70ms; }
.overall-list .overall-row:nth-child(4) { animation-delay: 105ms; }
.overall-list .overall-row:nth-child(5) { animation-delay: 140ms; }
.overall-list .overall-row:nth-child(n + 6) { animation-delay: 160ms; }

.overall-row:hover {
  border-color: #4b5663;
  background: #141920;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.overall-pos {
  font-weight: 800;
  color: var(--gold);
  font-size: 1.05rem;
}

.overall-row > img.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  background: #222;
}

.overall-name {
  font-weight: 750;
  font-size: 1rem;
}

.overall-pts {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
  justify-self: end;
}

.mode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-start;
}

.mode-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 52px;
}

.mode-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--tier-lo);
  background: #0a0c10;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.mode-circle img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.mode-pill {
  min-width: 42px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1.5px solid var(--tier-lo);
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.2;
}

/* Tier accent families (match SubTiers-style overall strip) */
.tier-hi .mode-circle,
.tier-hi.mode-pill,
.mode-cell.tier-hi .mode-circle,
.mode-cell.tier-hi .mode-pill {
  border-color: var(--tier-hi);
  color: #fff;
}

.mode-cell.tier-mid .mode-circle,
.mode-cell.tier-mid .mode-pill {
  border-color: var(--tier-mid);
  color: #f0d5b8;
}

.mode-cell.tier-lo .mode-circle,
.mode-cell.tier-lo .mode-pill {
  border-color: var(--tier-lo);
  color: #c5ccd6;
}

/* Footer */

.site-footer {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.site-footer h3 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
}

/* Modal */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: min(86vh, 740px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-card--sm {
  width: min(380px, 100%);
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.profile-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.profile-head img {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0a0b0d;
  object-fit: cover;
}

.profile-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.profile-pts {
  margin: 6px 0 0;
  color: var(--gold);
  font-weight: 700;
}

.profile-ranks {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.rank-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0e1116;
  border: 1px solid var(--line);
}

.rank-line span {
  color: var(--muted);
}

.profile-sub {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-history {
  display: grid;
  gap: 6px;
}

.hist {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0c0f13;
  color: var(--muted);
  font-size: 0.86rem;
}

.info-lead {
  color: var(--muted);
  margin-top: 0;
}

.info-points {
  display: grid;
  gap: 6px;
}

.info-points div {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0e1116;
  border: 1px solid var(--line);
  font-weight: 600;
}

@media (max-width: 980px) {
  .overall-row {
    grid-template-columns: 44px 40px 1fr;
    grid-template-areas:
      'pos av name'
      'strip strip strip'
      'pts pts pts';
  }

  .overall-pos {
    grid-area: pos;
  }
  .overall-row > img.avatar {
    grid-area: av;
  }
  .overall-name {
    grid-area: name;
  }
  .mode-strip {
    grid-area: strip;
  }
  .overall-pts {
    grid-area: pts;
    justify-self: start;
  }

  .tier-headings,
  .tier-columns {
    min-width: 720px;
  }

  .mode-ranking-board {
    overflow-x: auto;
  }
}

@media (max-width: 720px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .brand,
  .ranking-controls {
    justify-self: start;
  }

  .mode-tab-label {
    display: none;
  }

  .mode-tab {
    padding: 8px;
  }

  .mode-tab.selected .mode-tab-label,
  .mode-tab.is-overall .mode-tab-label {
    display: inline;
  }

  .mode-tab.selected,
  .mode-tab.is-overall {
    padding: 8px 14px 8px 8px;
  }
}
