:root {
  --bg: #070a14;
  --surface: rgba(15, 20, 36, 0.78);
  --surface-strong: rgba(20, 26, 46, 0.92);
  --border: rgba(148, 163, 184, 0.14);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #f5b915;
  --silver: #cbd5e1;
  --bronze: #c77a3a;
  --accent: #7c5cff;
  --cyan: #38bdf8;
  --green: #34d399;
  --orange: #fb923c;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

.cosmos-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, #131936 0%, #070a14 65%);
}

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.35;
}

.nebula-1 {
  width: 520px;
  height: 520px;
  top: -160px;
  left: -100px;
  background: #5b3df5;
}

.nebula-2 {
  width: 480px;
  height: 480px;
  top: 120px;
  right: -140px;
  background: #0ea5e9;
  opacity: 0.22;
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.65), transparent),
    radial-gradient(1.5px 1.5px at 28% 42%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 45% 12%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 66% 29%, rgba(167,139,250,0.6), transparent),
    radial-gradient(1px 1px at 82% 15%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 91% 54%, rgba(56,189,248,0.5), transparent),
    radial-gradient(1.5px 1.5px at 18% 76%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 74% 81%, rgba(255,255,255,0.5), transparent);
  background-size: 420px 420px;
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.pixel-icon {
  image-rendering: pixelated;
  object-fit: contain;
  display: inline-block;
  flex-shrink: 0;
}

.xs-icon { width: 18px; height: 18px; }
.sm-icon { width: 22px; height: 22px; }
.lg-icon { width: 42px; height: 42px; }
.brand-icon { width: 28px; height: 28px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(7, 10, 20, 0.72);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.status-dot.offline {
  background: #ef4444;
}

.ip-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.24), rgba(56, 189, 248, 0.2));
  border: 1px solid rgba(124, 92, 255, 0.45);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.ip-btn:hover {
  transform: translateY(-1px);
  border-color: var(--cyan);
}

/* Hero */
.hero {
  text-align: center;
  padding: 48px 0 28px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.14);
  border: 1px solid rgba(124, 92, 255, 0.35);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #c4b5fd;
  margin-bottom: 16px;
}

.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.gradient-text {
  background: linear-gradient(90deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--muted);
  max-width: 580px;
  margin: 0 auto 28px;
  font-size: 0.98rem;
}

.search-box {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 6px 6px 14px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
}

.search-box:focus-within {
  border-color: rgba(124, 92, 255, 0.7);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.96rem;
  min-width: 0;
}

.search-submit {
  background: linear-gradient(135deg, #7c5cff, #4f46e5);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.search-submit:hover {
  opacity: 0.92;
}

.search-feedback {
  margin-top: 10px;
  min-height: 22px;
  font-size: 0.88rem;
  color: #fca5a5;
}

.suggestion-link {
  color: var(--cyan);
  text-decoration: underline;
  cursor: pointer;
  margin: 0 4px;
}

/* Player profile card */
.hidden {
  display: none !important;
}

.player-profile-section {
  margin: 12px 0 36px;
}

.profile-card {
  position: relative;
  background: var(--surface-strong);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.profile-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
}

.profile-close:hover {
  color: var(--text);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}

.profile-render-wrap {
  width: 120px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 60%, rgba(124, 92, 255, 0.25), transparent 72%);
  border-radius: 14px;
  border: 1px solid var(--border);
}

.profile-render {
  max-height: 150px;
  width: auto;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6));
}

.profile-summary {
  flex: 1;
  min-width: 260px;
}

.profile-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profile-title-row h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.7rem;
}

.profile-uuid {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: monospace;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
}

.stat-value.gold { color: var(--gold); }
.stat-value.cyan { color: var(--cyan); }
.stat-value.orange { color: var(--orange); }
.stat-value.green { color: var(--green); }

.profile-kits-wrap {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.profile-kits-wrap h3 {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.profile-kits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.kit-stat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
}

.kit-stat-card strong {
  display: block;
  font-size: 0.88rem;
  text-transform: uppercase;
}

.kit-stat-card span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Leaderboard Section */
.leaderboard-section {
  padding-bottom: 64px;
}

.section-header {
  text-align: center;
  margin-bottom: 18px;
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(245, 185, 21, 0.25);
}

.controls-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.pill-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.pill {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text);
}

.pill.active {
  background: rgba(124, 92, 255, 0.26);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.5);
}

.kit-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.kit-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kit-tab:hover {
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.35);
}

.kit-tab.active {
  color: var(--text);
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.5);
}

/* Podium */
.podium-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 28px;
}

.podium-grid {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 720px;
}

.podium-card {
  position: relative;
  width: 205px;
  border-radius: 16px;
  padding: 18px 14px 16px;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(22, 28, 48, 0.9), rgba(10, 14, 26, 0.95));
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.podium-card:hover {
  transform: translateY(-4px);
}

.podium-card.rank-1 {
  order: 2;
  width: 228px;
  min-height: 295px;
  border-color: rgba(245, 185, 21, 0.5);
  background: linear-gradient(180deg, rgba(245, 185, 21, 0.08) 0%, rgba(13, 17, 32, 0.96) 55%, rgba(245, 185, 21, 0.18) 100%);
  box-shadow: 0 18px 45px rgba(245, 185, 21, 0.12);
}

.podium-card.rank-2 {
  order: 1;
  min-height: 255px;
  border-color: rgba(203, 213, 225, 0.35);
  background: linear-gradient(180deg, rgba(203, 213, 225, 0.06) 0%, rgba(13, 17, 32, 0.96) 55%, rgba(203, 213, 225, 0.12) 100%);
}

.podium-card.rank-3 {
  order: 3;
  min-height: 235px;
  border-color: rgba(199, 122, 58, 0.4);
  background: linear-gradient(180deg, rgba(199, 122, 58, 0.08) 0%, rgba(13, 17, 32, 0.96) 55%, rgba(199, 122, 58, 0.14) 100%);
}

.podium-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-1 .podium-name { color: var(--gold); font-size: 1.15rem; }
.rank-2 .podium-name { color: #e2e8f0; }
.rank-3 .podium-name { color: #f4b183; }

.podium-skin {
  height: 118px;
  width: auto;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.65));
}

.rank-1 .podium-skin {
  height: 138px;
}

.podium-rank-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 6px;
}

.rank-1 .podium-rank-num { color: var(--gold); }
.rank-2 .podium-rank-num { color: var(--silver); }
.rank-3 .podium-rank-num { color: var(--bronze); }

.podium-metric {
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Rank List (#4+) */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

.rank-row {
  display: grid;
  grid-template-columns: 44px 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.rank-row:hover {
  border-color: rgba(124, 92, 255, 0.5);
  transform: translateX(3px);
}

.rank-num {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--muted);
  text-align: center;
}

.rank-avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  image-rendering: pixelated;
}

.rank-player {
  font-weight: 600;
  font-size: 0.96rem;
}

.rank-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.rank-stats strong {
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 620px;
  margin: 0 auto;
}

.empty-state p {
  margin-top: 12px;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
}

@media (max-width: 680px) {
  .podium-card.rank-1 { order: 1; width: 100%; max-width: 290px; }
  .podium-card.rank-2 { order: 2; width: 47%; min-width: 150px; }
  .podium-card.rank-3 { order: 3; width: 47%; min-width: 150px; }
  .rank-stats { gap: 8px; font-size: 0.78rem; }
}
