*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #080808;
  --surface: #101010;
  --surface2: #161616;
  --border: #2e0e0e;
  --accent: #e02222;
  --accent-glow: rgba(220,34,34,0.18);
  --text: #f2eaea;
  --muted: #8a6060;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: transparent;
  padding: 0 2rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .75rem auto 0;
  padding: .6rem 1.25rem;
  position: relative;
  background: linear-gradient(180deg, #141414 0%, #0e0e0e 100%);
  border: 1px solid #2e0e0e;
  border-radius: 14px;
  box-shadow: 0 2px 24px rgba(0,0,0,0.7), 0 1px 0 rgba(220,34,34,0.08);
  max-width: 1440px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-nav a {
  color: #9a7070;
  text-decoration: none;
  font-size: .95rem;
  font-weight: 500;
  padding: .4rem .9rem;
  border-radius: 6px;
  transition: color .2s, background .2s;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.header-nav a img {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.header-nav a img[src*="home"] {
  filter: invert(1);
}

.header-nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.header-nav .discord-btn {
  border-radius: 6px;
  padding: .4rem .9rem;
}

.logo { width: 48px; height: 48px; image-rendering: pixelated; }

.search-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #181818;
  border: 1px solid #2e2020;
  border-radius: 8px;
  padding: .4rem .85rem;
  color: var(--muted);
  transition: border-color .2s;
}
.search-bar:focus-within {
  border-color: #5a2020;
  box-shadow: 0 0 0 2px rgba(220,34,34,0.1);
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .9rem;
  width: 160px;
}

.search-bar input::placeholder { color: var(--muted); }

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

/* ── Tabs ── */
nav#tabs {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 1.5rem;
  justify-content: center;
  margin-top: 120px;
  margin-left: auto;
  margin-right: auto;
  max-width: 1440px;
  background: linear-gradient(180deg, #0e0e0e 0%, #0a0a0a 100%);
  border-bottom: 1px solid #2a0a0a;
}

nav#tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #7a5555;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, border-color .2s, background .2s;
  border-radius: 6px 6px 0 0;
}

.tab-btn img { width: 24px; height: 24px; image-rendering: pixelated; opacity: 0.7; transition: opacity .2s; }

.tab-btn:hover { color: #d0b0b0; background: rgba(255,255,255,0.03); }
.tab-btn:hover img { opacity: 1; }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(220,34,34,0.06);
  text-shadow: 0 0 12px rgba(220,34,34,0.4);
}
.tab-btn.active img { opacity: 1; }

/* ── Main ── */
main { max-width: 1440px; margin: 0 auto; padding: 1rem 2rem 2.5rem; }

/* ── Leaderboard ── */
#leaderboard h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 1rem;
}

.lb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
}

.lb-table tbody {
  overflow: visible;
}

.lb-table thead tr {
  background: linear-gradient(90deg, #1c0a0a 0%, #181818 40%, #181818 100%);
}

.lb-table th {
  padding: 1rem 1.5rem;
  text-align: left;
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #9a6060;
}

.lb-table th:nth-child(3),
.lb-table td:nth-child(3) { text-align: center; }

.lb-table th:last-child,
.lb-table td:last-child { text-align: right; }

.tiers-cell { justify-content: flex-end; }

.lb-table tbody tr {
  transition: background .15s, transform .2s;
}

.lb-table tbody td {
  border-bottom: 6px solid var(--bg);
  background: #0f0f0f;
}

.lb-table tbody td:first-child { border-radius: 12px 0 0 12px; }
.lb-table tbody td:last-child  { border-radius: 0 12px 12px 0; }

.lb-table tbody tr:hover { transform: translateX(-12px); }
.lb-table tbody tr:hover td { background: #181212; }
.lb-table tbody tr:hover .banner-bg { filter: brightness(1.25); }
.lb-table tbody tr:hover .player-name { color: #ffdddd; }

.lb-table td {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  vertical-align: middle;
}

/* rank+skin banner column */
td.col-banner {
  padding: 0 !important;
  width: 210px;
  position: relative;
}

.banner-wrap {
  position: relative;
  height: 90px;
  overflow: visible;
}

.banner-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #2a2a2a, #1e1e1e);
  clip-path: polygon(0 0, 78% 0, 100% 100%, 0 100%);
}

td.pos-1 .banner-bg { background: linear-gradient(135deg, #c8960c, #8a6008); }
td.pos-2 .banner-bg { background: linear-gradient(135deg, #707070, #484848); }
td.pos-3 .banner-bg { background: linear-gradient(135deg, #8a4a18, #5a2e0a); }

.banner-num {
  position: absolute;
  bottom: .35rem;
  left: 1rem;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-weight: 900;
  font-size: 2.2rem;
  color: #ffffff;
  text-shadow: 0px 6px 0px rgba(0,0,0,0.9);
  line-height: 1;
  z-index: 1;
}

td.pos-1 .banner-num { color: #fff8dc; font-size: 2.5rem; }
td.pos-2 .banner-num { color: #f0f0f0; font-size: 2.3rem; }
td.pos-3 .banner-num { color: #ffe4c4; font-size: 2.2rem; }

.banner-wrap img.skin {
  position: absolute;
  bottom: 0;
  right: 18px;
  height: 100px;
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(-2px 0px 6px rgba(0,0,0,0.8));
  z-index: 2;
  image-rendering: pixelated;
}

/* player info column */
td.col-player {
  padding: .8rem 1.5rem;
  vertical-align: middle;
}

.player-name {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: .03em;
  color: #eedede;
  transition: color .2s;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: 1rem;
  font-weight: 400;
  margin-top: .25rem;
  color: #AAAAAA;
}

.rank-badge img { width: 20px; height: 20px; image-rendering: pixelated; }

.rank-pts { color: #555555; font-size: 1rem; }

/* tier badge */
.tier-badge {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .04em;
}

/* region badge */
.region-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: none;
  letter-spacing: .02em;
}

.region-NA { background: #3d1a1a; color: #e05555; }
.region-EU { background: #1a3d1a; color: #4aaa4a; }
.region-AS { background: #3d2a1a; color: #cc7733; }
.region-ME { background: #1a1a3d; color: #4466cc; }

/* tiers cell */
.tiers-cell {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-start;
}

.tier-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}

.tier-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid;
  background: #0e0e0e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow .2s;
}
.tier-card:hover .tier-icon-circle {
  filter: brightness(1.2);
}

.tier-icon-circle img {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}

.tier-entry { display: none; }

.tier-icon-circle--empty {
  border-style: dashed;
  border-color: #444 !important;
  opacity: 0.45;
}

.tier-icon-circle--empty img {
  filter: grayscale(1);
}

.tier-badge--empty {
  color: #555;
  font-size: .85rem;
  font-weight: 700;
}

/* tier tooltip */
.tier-card {
  position: relative;
}

.tier-tooltip {
  display: none;
  flex-direction: column;
  align-items: center;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1c;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  padding: .4rem .75rem;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}

.tier-card:hover .tier-tooltip { display: flex; }

.tt-tier {
  font-size: .95rem;
  font-weight: 800;
  color: #f0e8e8;
  letter-spacing: .04em;
}

.tt-pts {
  font-size: .8rem;
  color: #888;
  margin-top: .1rem;
}

.tier-gm-tag { display: none; }

/* empty state */
.empty { text-align: center; padding: 3rem; color: var(--muted); }

@media (max-width: 600px) {
  main { padding: 1rem .5rem; }
}

/* ── Profile Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: #121212;
  border: 1px solid #2a1010;
  border-radius: 20px;
  padding: 2.25rem 2.25rem 2rem;
  width: 480px;
  max-width: 95vw;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  box-shadow: 0 8px 48px rgba(0,0,0,0.8), 0 0 0 1px rgba(220,34,34,0.06);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #2a2a2a;
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.modal-close:hover { background: #3a3a3a; }

.profile-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: #1e2a2a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .4rem;
  border: 3px solid #2a3a3a;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.profile-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: #44ccff;
  letter-spacing: .02em;
}

.profile-rank-badge {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: #1e1e1e;
  border: 1px solid #2e2e2e;
  border-radius: 20px;
  padding: .35rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: .1rem;
}
.profile-rank-badge img { width: 20px; height: 20px; image-rendering: pixelated; }

.profile-region {
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #aaa;
  margin-top: .15rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.profile-namemc {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #bbb;
  text-decoration: none;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: .55rem 1.25rem;
  margin-top: .2rem;
  transition: color .2s, border-color .2s, background .2s;
}
.profile-namemc img { width: 20px; height: 20px; object-fit: contain; }
.profile-namemc:hover { color: var(--text); border-color: #444; background: #252525; }

.profile-section-title {
  align-self: flex-start;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: #555;
  margin-top: 1rem;
  text-transform: uppercase;
}

.profile-position-box {
  width: 100%;
  background: #1a1a1a;
  border-radius: 12px;
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: 1rem;
}

.profile-pos-num {
  font-family: 'Georgia', serif;
  font-style: italic;
  font-weight: 900;
  font-size: 2rem;
  color: #fff;
  min-width: 44px;
}

.profile-pos-label {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .05em;
}

.profile-pos-pts {
  color: #555;
  font-size: .9rem;
  margin-left: auto;
}

.profile-tiers-box {
  width: 100%;
  background: #1a1a1a;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  justify-content: center;
}

.profile-tiers-box .tier-icon-circle {
  width: 52px;
  height: 52px;
}

.profile-tiers-box .tier-icon-circle img {
  width: 32px;
  height: 32px;
}

.profile-tiers-box .tier-badge {
  font-size: .9rem;
}

.lb-table tbody tr { cursor: pointer; }
