@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg: #09090b; /* Very dark zinc */
  --bg-gradient: none;
  --panel: rgba(24, 24, 27, 0.7); /* Zinc 900 panel */
  --panel-hover: rgba(39, 39, 42, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #f97316; /* Vibrant orange */
  --accent-hover: #ea580c;
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.2);
  --silver: #cbd5e1;
  --silver-glow: rgba(203, 213, 225, 0.2);
  --bronze: #d97706;
  --bronze-glow: rgba(217, 119, 6, 0.2);
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Base Layout & Spacing */
.shell {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
}

/* Nav Bar */
.nav-shell {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 80px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand img {
  width: clamp(120px, 20vw, 150px);
  height: auto;
  max-height: 40px;
  object-fit: contain;
  display: block;
}

.brand span {
  display: none;
}

.links {
  display: none;
  gap: 24px;
  align-items: center;
  width: 100%;
  flex-direction: column;
}

.links a {
  padding: 12px 20px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  transition: background-color 0.2s, color 0.2s;
}

.links a:hover {
  background: var(--border);
  color: var(--text);
}

.links a.active {
  color: var(--accent);
  background: rgba(240, 139, 60, 0.1);
}

.actions {
  display: none;
  gap: 10px;
  align-items: center;
  width: 100%;
  flex-direction: column;
}

.search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.search:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background-color 0.2s, color 0.2s;
  cursor: pointer;
  border: none;
}

.btn-discord {
  background: #5865F2;
  color: #fff;
}
.btn-discord:hover {
  background: #4752C4;
}

.btn-store {
  background: var(--accent);
  color: #fff;
}
.btn-store:hover {
  background: var(--accent-hover);
}

.menu {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.2rem;
}

.menu:hover {
  background: var(--border);
}

.nav-shell.menu-open .links,
.nav-shell.menu-open .actions {
  display: flex;
}

@media (min-width: 900px) {
  .nav {
    flex-wrap: nowrap;
    padding: 0;
  }
  .links, .actions {
    display: flex;
    width: auto;
    flex-direction: row;
  }
  .search {
    width: 220px;
  }
  .btn {
    width: auto;
  }
  .menu {
    display: none;
  }
}

/* Hero Section */
.hero {
  padding: 60px 0 40px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  margin-bottom: 16px;
  background: rgba(240, 139, 60, 0.1);
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
}

.sub {
  margin: 16px auto 0;
  max-width: 600px;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Gamemode Tabs */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 40px 0;
  flex-wrap: wrap;
}

.mode-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Podium */
.podium {
  display: grid;
  gap: 20px;
  padding-bottom: 40px;
}

@media (max-width: 767px) {
  .podium-card.rank-1 { order: 1; }
  .podium-card.rank-2 { order: 2; }
  .podium-card.rank-3 { order: 3; }
}

@media (min-width: 768px) {
  .podium {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.podium-card {
  position: relative;
  text-align: center;
}

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

.podium-card.rank-1 {
  border-color: var(--gold);
  box-shadow: 0 8px 32px var(--gold-glow);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, var(--panel) 100%);
}

.podium-card.rank-2 {
  border-color: var(--silver);
  box-shadow: 0 8px 32px var(--silver-glow);
  background: linear-gradient(180deg, rgba(203, 213, 225, 0.1) 0%, var(--panel) 100%);
}

.podium-card.rank-3 {
  border-color: var(--bronze);
  box-shadow: 0 8px 32px var(--bronze-glow);
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.1) 0%, var(--panel) 100%);
}

.crown-icon {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: auto;
  z-index: 10;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
  animation: floatCrown 3s ease-in-out infinite;
}

@keyframes floatCrown {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); }
  50% { transform: translateX(-50%) translateY(-4px) rotate(4deg); }
}

.podium-rank-number {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

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

.podium-main {
  padding: 30px 20px 20px;
}

.podium-main.tall {
  padding-top: 40px;
}

.skin {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
}

.skin-lg {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-top: -35px;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.4));
  transition: transform 0.2s;
}
.skin-lg:hover {
  transform: scale(1.1);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
}

.stats > div {
  padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.stats > div:last-child {
  border-right: none;
}

.stats .label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.stats .value {
  margin-top: 4px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* List Rows */
.bar-list {
  display: grid;
  gap: 12px;
}

.player-bar {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
}

.player-bar:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
  transform: translateX(4px);
  box-shadow: -4px 0 0 var(--accent);
}

.player-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.player-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.player-elo {
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.player-elo strong {
  display: block;
  color: var(--text);
  font-size: 1.3rem;
}

.player-metrics {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metric {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric b {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

.player {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-name-btn {
  color: #fff;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.lb-name-btn:hover {
  text-decoration: underline;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.1rem;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-size: 1rem;
}

.loading-state {
  display: none;
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* Footer */
.footer {
  margin-top: 60px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.footer-grid {
  display: grid;
  gap: 30px;
  padding: 40px 0;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer h4 {
  margin: 0 0 16px;
  color: #fff;
  font-size: 1rem;
}

.footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.footer ul a {
  color: var(--muted);
}

.footer ul a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.footer-bottom-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (min-width: 768px) {
  .footer-bottom-inner {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Matches Grid */
.grid { 
  display: grid; 
  gap: 16px; 
  padding-bottom: 40px; 
}

.game-card { 
  display: flex; 
  flex-direction: column; 
  gap: 20px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  background: var(--panel); 
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px; 
  transition: border-color 0.2s, transform 0.2s;
}

.game-card:hover { 
  border-color: var(--border-hover); 
  transform: translateY(-2px);
}

.game-top { 
  display: flex; 
  align-items: flex-start; 
  justify-content: space-between; 
  gap: 16px; 
}

.game-id { 
  font-size: 1.5rem; 
  font-weight: 700; 
  color: #fff;
}

.game-mode { 
  margin-top: 8px; 
  display: flex; 
  flex-direction: column; 
}

.game-mode-main { 
  color: var(--accent); 
  font-weight: 700;
}

.game-mode-sub { 
  color: var(--muted); 
  font-size: 0.85rem; 
}

.game-time { 
  color: var(--muted); 
  font-size: 0.9rem; 
}

.duration { 
  display: inline-flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 0.95rem; 
  font-weight: 600; 
  color: var(--text); 
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.divider { 
  border-top: 1px solid var(--border); 
}

.game-bottom { 
  display: flex; 
  flex-direction: column; 
  gap: 20px; 
}

.stats-row { 
  display: flex; 
  gap: 24px; 
}

.stat-value { 
  font-size: 1.5rem; 
  font-weight: 700; 
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.stat-label { 
  color: var(--muted); 
  font-size: 0.8rem; 
  text-transform: uppercase;
}

.winners-wrap {
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.winners-title { 
  color: var(--muted); 
  font-size: 0.85rem; 
  font-weight: 700; 
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}

.winners-title img {
  width: 16px;
  height: 16px;
}

.winners-list { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  margin-top: 12px; 
}

.winner-chip { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  background: var(--panel); 
  padding: 4px 12px 4px 4px; 
  font-size: 0.9rem; 
  font-weight: 600; 
}

.winner-chip img { 
  width: 24px; 
  height: 24px; 
  border-radius: 4px; 
  object-fit: cover; 
}

.winner-chip-inferred { 
  border-style: dashed; 
  color: var(--muted); 
}

.icon-mark { 
  display: inline-block; 
  position: relative; 
  width: 1em; 
  height: 1em; 
  margin-right: 0.2em; 
  vertical-align: -0.1em; 
}

.icon-duration { 
  background-image: url('/clock.png'); 
  background-size: contain; 
  background-repeat: no-repeat; 
  background-position: center; 
}

.badges { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  margin-top: 12px; 
}

.badges .pill {
  font-size: 0.8rem;
  padding: 4px 10px;
}

@media (min-width: 900px) {
  .game-card { 
    flex-direction: row; 
    align-items: stretch; 
    gap: 30px; 
  }
  .game-top { 
    min-width: 240px; 
    flex-direction: column;
    justify-content: flex-start;
  }
  .divider { 
    border-top: 0; 
    border-left: 1px solid var(--border); 
  }
  .game-bottom { 
    flex: 1; 
    flex-direction: row; 
    align-items: center; 
    justify-content: space-between; 
    gap: 24px; 
  }
  .winners-wrap { 
    min-width: 300px; 
  }
}

/* Animations */
#podium, #content {
  transition: opacity .2s ease;
}

#podium.is-filtering, #content.is-filtering {
  opacity: .5;
}

/* Popup */
#player-popup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  padding: 20px;
}

#player-popup.open {
  display: flex;
}

.popup-card {
  width: min(500px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.popup-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.popup-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  align-items: start;
}

.mini {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg);
}

.mini .eyebrow {
  margin-bottom: 4px;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 0.75rem;
}

@media (max-width: 600px) {
  .popup-grid { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .popup-grid .mini { text-align: left; }
}
