body.page-leaderboards {
  --lb-col1: 56px;   
  --lb-col3: 160px;  
}

body.page-leaderboards .section {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

body.page-leaderboards .filters {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
body.page-leaderboards .filters div { display: flex; flex-direction: column; align-items: center; }
body.page-leaderboards .filters .buttons { display: flex; gap: 0.5rem; align-items: flex-end; }

body.page-leaderboards .filters .btn {
  padding: 0.5rem 1rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
  transition: all 0.2s ease;
}
body.page-leaderboards .filters .btn:hover { transform: translateY(-1px); }

body.page-leaderboards select {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  min-width: 150px;
}

body.page-leaderboards #leaderboardCard {
  background: linear-gradient(180deg, var(--panel), var(--card));
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 700px;
  margin: 2rem auto;
  padding: 0; 
  box-shadow: var(--shadow);
}

body.page-leaderboards #metricsHeader {
  display: grid;
  grid-template-columns: var(--lb-col1) 1fr var(--lb-col3);
  align-items: center;
  font-weight: 700;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, var(--panel), var(--card));
  gap: 0.5rem;
}

body.page-leaderboards #metricsHeader .position {  }
body.page-leaderboards #metricsHeader .username {
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  justify-self: start; 
  padding-left: 6px;
  letter-spacing: 1px;
}

body.page-leaderboards #metricsHeader .metric-label {
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  justify-self: center; 
  letter-spacing: 1px;
}

body.page-leaderboards #gainsList {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem; 
}

body.page-leaderboards #gainsList .row {
  display: grid;
  grid-template-columns: var(--lb-col1) 1fr var(--lb-col3);
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  background: linear-gradient(180deg, var(--card-2), var(--card));
}

body.page-leaderboards #gainsList .row:nth-child(odd) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-2) 88%, rgba(0,0,0,0.06) 12%), var(--card));
}
body.page-leaderboards #gainsList .row:nth-child(even) {
  background: linear-gradient(180deg, var(--card-2), color-mix(in srgb, var(--card) 92%, rgba(0,0,0,0.03) 8%));
}

body.page-leaderboards #gainsList .row:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }

body.page-leaderboards #gainsList .position {
  justify-self: end;
  color: var(--muted);
  font-weight: 600;
  min-width: 2rem;
  text-align: right;
  padding-right: 0.4rem;
}
body.page-leaderboards #gainsList .name {
  justify-self: start; 
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.page-leaderboards #gainsList .pill {
  justify-self: center; 
  display: inline-block;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  text-align: center;
}

body.page-leaderboards .gold { background: var(--gold); color: var(--panel); }
body.page-leaderboards .silver { background: var(--silver); color: var(--panel); }
body.page-leaderboards .bronze { background: var(--bronze); color: var(--panel); }

body.page-leaderboards .blue-pill { background: #3b82f6; color: #fff; }

body.page-leaderboards .tabs .tab-btn {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Inter, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 10px 10px 0 0;
  letter-spacing: 0.45px;
  transition: all 160ms ease;
  border-bottom: none;
}
body.page-leaderboards .tabs .tab-btn.active,
body.page-leaderboards .tabs .tab-btn[aria-selected="true"] {
  color: var(--panel);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-strong);
  transform: translateY(-1px);
}

body.page-leaderboards #loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  color: var(--gold);
}
body.page-leaderboards #loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
body.page-leaderboards .spinner {
  width: 48px;
  height: 48px;
  border: 6px solid #222;
  border-top: 6px solid var(--gold);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.page-leaderboards #main-grid {
  display: flex !important; 
  justify-content: center !important; 
  align-items: flex-start !important; 
  gap: 30px !important;
  flex-wrap: nowrap !important;
  margin-top: 40px;
  flex-direction: row !important;
}

body.page-leaderboards #top-members {
  background: #483e34; 
  border: 5px solid #151815; 
  border-radius: 14px;
  padding: 0.5rem 1.25rem 1rem 1.25rem; 
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  text-align: center; 
  max-width: 300px; 
  font-family: "RuneScape", system-ui, sans-serif; 
  display: flex; 
  flex-direction: column; 
  height: 768px;
  min-width: 300px;
}

body.page-leaderboards #top-members h3 {
  font-size: 1.75rem; 
  color: var(--gold); 
  text-transform: uppercase; 
  letter-spacing: 0.5px;
  margin: 0.5rem 0 0.75rem 0; 
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.25rem; 
  flex-shrink: 0;
}

body.page-leaderboards #top-members .pill {
  display: block;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  width: 100%;
  word-wrap: break-word;
  white-space: normal;
  text-align: left;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: white;
}

body.page-leaderboards #top-members .pill .member-value {
  font-family: "RuneScape", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;                 
  line-height: 1;
  color: #ffffff;                    
  font-weight: 800;
  -webkit-font-smoothing: antialiased;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45); 
  display: inline-block;
  min-width: 3.5rem;                
  text-align: right;
}

body.page-leaderboards #top-members .pill.gold .member-value,
body.page-leaderboards #top-members .pill.silver .member-value,
body.page-leaderboards #top-members .pill.bronze .member-value {
  text-shadow: 0 2px 6px rgba(0,0,0,0.65);
}

body.page-leaderboards #top-members .pill .member-name {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Inter, sans-serif;
  color: inherit;
  text-shadow: none;
}

body.page-leaderboards #top-members .pill .member-name {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Inter, sans-serif;
}

body.page-leaderboards #top-members .pill.gold { background: var(--gold); color: var(--panel) !important; }
body.page-leaderboards #top-members .pill.silver { background: var(--silver); color: var(--panel) !important; }
body.page-leaderboards #top-members .pill.bronze { background: var(--bronze); color: var(--panel) !important; }

body.page-leaderboards #top-members-list {
  flex: 1; 
  overflow-y: auto; 
  margin-top: 0.5rem;
  display: flex; 
  flex-direction: column; 
  gap: 0.25rem; 
  padding-right: 12px;
}

body.page-leaderboards #top-members-list::-webkit-scrollbar { width: 8px; }
body.page-leaderboards #top-members-list::-webkit-scrollbar-track { background: #2a2a2a; border-radius: 6px; }
body.page-leaderboards #top-members-list::-webkit-scrollbar-thumb { background: #3b82f6; border-radius: 6px; }

body.page-leaderboards #top-members .pill,
body.page-leaderboards #top-members .pill * {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Inter, sans-serif;
}

body.page-leaderboards #top-members .pill .name,
body.page-leaderboards #top-members .pill .value,
body.page-leaderboards #top-members .pill .rank,
body.page-leaderboards #top-members .pill .member-name {
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Inter, sans-serif;
}

body.page-leaderboards .gold { background: var(--gold); color: var(--panel); }
body.page-leaderboards .silver { background: var(--silver); color: var(--panel); }
body.page-leaderboards .bronze { background: var(--bronze); color: var(--panel); }
body.page-leaderboards .blue-pill { background: #3b82f6; color: #fff; }

body.page-leaderboards #loot-grid-container {
  width: 1060px; 
  max-width: 100%; 
  height: 768px;
  background: url('../images/Leaderboards/browntemplate.png') no-repeat center top;
  background-size: contain; 
  position: relative; 
  overflow: hidden;
  border-radius: 14px; 
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

body.page-leaderboards .grid-wrap {
  position: absolute; 
  left: 45px; 
  right: 45px; 
  top: 180px; 
  bottom: 70px;
  display: flex; 
  justify-content: center; 
  align-items: flex-start; 
  pointer-events: none;
}

body.page-leaderboards #loot-grid {
  display: grid; 
  grid-template-columns: repeat(10, 64px); 
  grid-auto-rows: 64px;
  gap: 8px; 
  justify-content: center; 
  align-content: start; 
  pointer-events: auto;
  font-family: "RuneScape", system-ui, sans-serif;
}

body.page-leaderboards .cell { 
  position: relative; 
  width: 64px; 
  height: 64px; 
}

body.page-leaderboards .cell img { 
  width: 48px; 
  height: 48px; 
  image-rendering: pixelated; 
  display: block; 
  margin: auto; 
}

body.page-leaderboards .quantity {
  position: absolute; 
  bottom: -13px; 
  left: 50%; 
  transform: translateX(-52.5%);
  font-size: 18px; 
  font-weight: bold; 
  color: var(--gold); 
  text-shadow: 1px 1px 0 #000;
}

body.page-leaderboards .cell .tooltip {
  visibility: hidden; 
  max-width: 250px; 
  background-color: black; 
  color: yellow;
  text-align: left; 
  padding: 5px 8px; 
  border: 2px solid var(--gold); 
  border-radius: 4px;
  position: absolute; 
  z-index: 50; 
  bottom: 100%; 
  left: 50%; 
  transform: translateX(-50%);
  opacity: 0; 
  transition: opacity 0.1s ease;
  white-space: nowrap;
}

body.page-leaderboards .cell:hover .tooltip { 
  visibility: visible; 
  opacity: 1; 
}

body.page-leaderboards #loot-tabs { 
  position: absolute; 
  top: 69px; 
  left: 165px; 
  z-index: 20; 
}

body.page-leaderboards #loot-tabs .tab {
  position: absolute; 
  width: 90px; 
  height: auto; 
  cursor: pointer;
  transition: transform 0.15s ease;
}

body.page-leaderboards #loot-tabs .tab:hover { 
  transform: translateY(-2px); 
}

body.page-leaderboards #loot-tabs .tab:nth-child(1) { left: 4px; }
body.page-leaderboards #loot-tabs .tab:nth-child(2) { left: 88px; }
body.page-leaderboards #loot-tabs .tab:nth-child(3) { left: 172px; }
body.page-leaderboards #loot-tabs .tab:nth-child(4) { left: 256px; }
body.page-leaderboards #loot-tabs .tab:nth-child(5) { left: 340px; }

body.page-leaderboards #loot-grid-title {
  position: absolute; 
  font-family: "RuneScape", system-ui, sans-serif;
  font-size: 28px; 
  color: gold; 
  font-weight: bold; 
  pointer-events: none; 
  z-index: 30;
}

body.page-leaderboards #loading-overlay {
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,.8);
  display: flex; 
  justify-content: center; 
  align-items: center;
  z-index: 999; 
  color: var(--gold);
}

body.page-leaderboards #loading-overlay.hidden { 
  opacity: 0; 
  pointer-events: none; 
  transition: opacity .4s; 
}

body.page-leaderboards .spinner {
  width: 48px; 
  height: 48px; 
  border: 6px solid #222; 
  border-top: 6px solid var(--gold);
  border-radius: 50%; 
  animation: spin .9s linear infinite;
}

@keyframes spin { 
  to { transform: rotate(360deg); } 
}

body.page-leaderboards #mobile-notice {
  display: none;
}

@media (max-width: 1100px) {
  body.page-leaderboards #main-grid {
    display: none !important;
  }
  body.page-leaderboards #loading-overlay {
    display: none !important;
  }
  body.page-leaderboards #mobile-notice {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 1rem;
    min-height: 400px;
    text-align: center;
    padding: 2rem;
  }
}