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

:root {
  --bg: #fdfaf8;
  --bg-glow: rgba(255, 100, 0, 0.02); 
  
  /* FROSTED GLASS VARIABLES */
  --surface: rgba(255, 253, 253, 0.55); /* Header, Table */
  --surface-2: rgba(255, 245, 240, 0.55); 
  --border: rgba(221, 208, 208, 0.5);
  --input-bg: rgba(255, 253, 253, 0.75);
  --glass-edge: rgba(255, 253, 253, 0.5);
  
  --border-strong: #e0c5b4;
  --text: #1a1512;
  --text-2: #5c4d45;
  --text-3: #998073;
  --accent: #ff5100;
  --accent-soft: rgba(255, 81, 0, 0.08);
  --accent-2: #ff8400;
  --gold: #f59e0b;
  --silver: #94a3b8;
  --bronze: #cd7f32;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --red: #ef4444;
  --red-soft: #fff5f5;
  --shadow: 0 4px 16px rgba(255, 81, 0, 0.04), 0 8px 32px rgba(0,0,0,0.04);
  --radius: 12px;

  --tier-1: #10b981; /* Green */
  --tier-2: #eab308; /* Light Yellow/Gold */
  --tier-3: #ff8400; /* Orange */
  --tier-4: #ff5100; /* Red-Orange */
  --tier-5: #991b1b; /* Dark Red */
}

[data-theme="dark"] {
  --bg: #0a0504; 
  --bg-glow: rgba(255, 75, 20, 0.04); 
  --surface: rgba(26, 19, 16, 0.55); /* FROSTED OPACITY VARIABLE */
  --surface-2: rgba(14, 10, 8, 0.5);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 98, 26, 0.15); 
  --text: #fdfaf8;
  --text-2: #c4b5ae;
  --text-3: #8a786f;
  --accent: #ff621a;
  --accent-soft: rgba(255, 98, 26, 0.15);
  --accent-2: #ff9d00;
  --green: #3fb950;
  --green-soft: rgba(46, 160, 67, 0.15);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, 0.1);
  --input-bg: rgba(15, 10, 8, 0.6);
  --shadow: 0 16px 40px rgba(0,0,0,0.8);
  --glass-edge: rgba(255, 255, 255, 0.08); 
  --tier-1: #3fb950; /* Green */
  --tier-2: #facc15; /* Bright Yellow */
  --tier-3: #ff7300; /* Orange */
  --tier-4: #ff351a; /* Red-Orange */
  --tier-5: #c71212; /* Dark Red */
}

/* SIDEWAYS SCROLL FIX: Changed 100vw to 100% */
html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

body::before {
  content: ''; 
  position: fixed; 
  inset: 0; 
  z-index: -2; 
  background-color: var(--bg);
  background-image: radial-gradient(circle at 15% 50%, var(--bg-glow), transparent 40%), radial-gradient(circle at 85% 30%, var(--bg-glow), transparent 40%);
  /* Animation and scaling completely removed to save CPU */
}

/* Light Mode Background Image */
body:not([data-theme="dark"])::before {
  content: ''; position: fixed; inset: 0; z-index: -2;
  background-color: var(--bg);
  background-image: 
    linear-gradient(rgba(255, 234, 219, 0.4), rgba(253, 250, 248, 0.85)), 
    url('../../img/lq-bg-embers-light.jpg');
  background-size: cover; 
  background-position: center; 
  filter: blur(16px) grayscale(10%);
  transform: scale(1.02); 
  animation: none; 
  pointer-events: none;
}

/* DARK MODE: Obsidian Glass Background */
body[data-theme="dark"]::before {
  background-color: #040201; 
  background-image: 
    linear-gradient(rgba(0, 0, 0, 0.7), rgba(4, 2, 1, 0.85)), 
    url('../../img/lq-bg-embers.jpg');
  background-size: cover; 
  background-position: center; 
  filter: blur(20px) grayscale(40%); /* Unblurred so the foreground glass works */
  transform: scale(1.02); 
  animation: none; 
  pointer-events: none;
}

body[data-theme="dark"]::after {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(circle at 20% 10%, rgba(255, 81, 0, 0.08), transparent 40vw), radial-gradient(circle at 80% 80%, rgba(255, 157, 0, 0.05), transparent 40vw), radial-gradient(circle at 50% 50%, rgba(255, 60, 0, 0.04), transparent 60vw);
  animation: emberPulseBg 6s infinite alternate ease-in-out; pointer-events: none;
}

@keyframes subtleFire { 
  0% { transform: scale(1.2) translate(-2%, -2%); } 
  100% { transform: scale(1.2) translate(2%, 2%); } 
}
@keyframes emberPulseBg { 0% { opacity: 0.5; transform: scale(1); } 100% { opacity: 1; transform: scale(1.05); } }
@keyframes emberPulse { 0% { box-shadow: 0 0 8px rgba(255, 81, 0, 0.1); } 50% { box-shadow: 0 0 18px rgba(255, 81, 0, 0.5); } 100% { box-shadow: 0 0 8px rgba(255, 81, 0, 0.1); } }

/* SHARED HEADER & NAVIGATION */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--border);
}

.header-inner { max-width: 1100px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-text { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.header-controls { display: flex; align-items: center; gap: 16px; }

.nav-links { display: flex; gap: 8px; margin-right: auto; margin-left: 32px; }
.nav-btn { color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px; transition: 0.2s; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(255, 81, 0, 0.2); }

.mobile-menu-btn { display: none; background: transparent; border: none; font-size: 20px; color: var(--text); cursor: pointer; padding: 4px; border-radius: 6px; }
.mobile-menu-btn:hover { background: var(--surface-2); }
.mobile-nav { display: none; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px; gap: 8px; }
.mobile-nav.open { display: flex; }

@media (max-width: 768px) { .nav-links.desktop-nav { display: none; } .mobile-menu-btn { display: block; } }

.theme-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--accent); transform: scale(1.1) rotate(15deg); }

main { max-width: 1100px; margin: 0 auto; padding: 32px 24px 100px; flex: 1; display: flex; flex-direction: column; width: 100%; }

/* FIXED FOOTER SYSTEM */
.bottom-fade { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  width: 100%; /* Changed from 100vw to fix side scroll */
  height: 80px; 
  background: linear-gradient(to top, var(--bg) 10%, transparent); 
  pointer-events: none; 
  z-index: 90; 
}

.made-by-tag { 
  position: fixed !important; 
  bottom: 12px; 
  left: 16px; 
  font-size: 11px; 
  color: var(--text-3); 
  z-index: 9999 !important; /* Forced to the very top layer */
}
.made-by-tag a { color: var(--accent); text-decoration: none; font-weight: 600; cursor: help; position: relative; }
.made-by-tag a:hover { text-decoration: underline; }

.credits-tooltip {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 16px; min-width: 280px; width: max-content;
  background: var(--surface); backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--border-strong); border-radius: 12px; padding: 16px;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transition: 0.2s; pointer-events: none; text-align: left;
}
.made-by-tag:hover .credits-tooltip { opacity: 1; visibility: visible; transform: translateY(-5px); }

/* MINI LEADERBOARD ON PORTFOLIO (PLAYER LOOKUP) */
.mini-lb-wrapper {
  margin-top: 112px;
  width: 100%;
  max-width: 500px;
  text-align: left;
}

.mini-lb-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 12px;
  padding-left: 12px;
  font-weight: 700;
}

.mini-lb-fade-container {
  position: relative;
  max-height: 280px; 
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.fade-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 120px;
  background: linear-gradient(to bottom, transparent, var(--bg) 90%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  z-index: 10;
}

.view-more-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 24px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: 0.2s;
}

.view-more-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.mini-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.mini-row:last-child { border-bottom: none; }

.mini-row img { 
  width: 28px; 
  height: 28px; 
  border-radius: 6px; 
  margin-right: 12px; 
}

.mini-rank { 
  width: 28px; 
  font-weight: 700; 
  color: var(--text-3); 
  font-size: 14px;
}
.mini-row:nth-child(1) .mini-rank { color: var(--gold); }
.mini-row:nth-child(2) .mini-rank { color: var(--silver); }
.mini-row:nth-child(3) .mini-rank { color: var(--bronze); }

.mini-ap { 
  margin-left: auto; 
  font-family: 'DM Mono', monospace; 
  font-weight: 700; 
  color: var(--accent); 
  font-size: 14px;
}

/* --- TOP BANNER --- */
.top-banner {
  background: linear-gradient(90deg, var(--accent), #e23719);
  color: #fff;
  padding: 8px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  z-index: 2000;
  width: 100%;
}
.top-banner.emergency {
  background: #dc2626; /* Solid red */
}
.top-banner.hidden {
  display: none !important;
}
.banner-spacer { width: 60px; } /* Balances the X button width */
.banner-content {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.banner-btn {
  background: rgba(0,0,0,0.25);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
  transition: 0.2s;
  white-space: nowrap;
}
.banner-btn:hover { background: rgba(0,0,0,0.4); color: #fff; }
.banner-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 20px; /* Fat hitbox */
  height: 100%;
  opacity: 0.8;
}
.banner-close:hover { opacity: 1; transform: scale(1.1); }
