body.page-index .section { padding: 2rem 0; }

body.page-index .stats-panel {
  background: linear-gradient(180deg, var(--panel), var(--card)); 
  border: 1px solid var(--border);   
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow); 
  margin-bottom: 2rem;
}

body.page-index .stats-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0.6rem 0;
  margin-bottom: 1rem;
  background: transparent;
  border-bottom: 2px solid var(--accent);
}
body.page-index .stats-panel .stat-controls { display: none !important; }

body.page-index .stats-title {
  font-family: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Inter, sans-serif;
  color: var(--accent);
  font-weight: 800;
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0;
  display: inline-block;
}

body.page-index .kpi-grid { gap: 0.9rem; }
body.page-index .kpi-grid + .kpi-grid { margin-top: 0.9rem; }

body.page-index .kpi-grid .card.kpi.kpi-row {
  border-radius: 6px; 
  padding: 0.85rem 0.95rem;
  background: linear-gradient(180deg, var(--card-2, rgba(21,26,40,0.92)), var(--card, rgba(8,10,18,0.88)));
  border: 1px solid rgba(255,255,255,0.02);
  box-shadow: 0 6px 14px rgba(0,0,0,0.36);
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transition: box-shadow 0.18s ease, transform 0.12s ease, border-color 0.12s ease;
}
body.page-index .kpi-grid .card.kpi.kpi-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.32);
  border-color: rgba(111,75,230,0.08);
}

body.page-index .kpi-grid .kpi-icon {
  width: 44px;
  height: 44px;
  min-width: 44px; min-height: 44px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: inline-block;
  flex-shrink: 0;
  opacity: 0.98;
}

body.page-index .kpi-grid .kpi-body { display:flex; flex-direction:column; gap:0.08rem; min-width: 0; }
body.page-index .kpi-grid .kpi-body .value {
  font-weight: 900;
  font-size: 1.12rem;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.page-index .kpi-grid .kpi-body .label {
  font-size: 0.92rem;
  color: var(--accent);
  margin-top: 4px;
  font-weight: 700;
  letter-spacing: 0.2px;
  opacity: 0.95;
}

body.page-index .kpi-activity .kpi-body .kpi-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
  white-space: nowrap;
}
body.page-index .card.kpi.kpi-row.kpi-activity { align-items: flex-start; }

.kpi-icon.icon-members{ background-image:url("https://i.imgur.com/5cvU7k4.png"); }
.kpi-icon.icon-homeworld{ background-image:url("https://i.imgur.com/4W0ezBr.png"); }
.kpi-icon.icon-activity{ background-image:url("images/Leaderboards/monthlylight.png"); font-size:1.2rem; }
.kpi-icon.icon-avgxp{ background-image:url("https://i.imgur.com/6yMlDy1.png"); }
.kpi-icon.icon-maxed{ background-image:url("https://i.imgur.com/hCmEEd0.png"); }
.kpi-icon.icon-maxed-combat{ background-image:url("https://i.imgur.com/OuaGWkf.png"); }
.kpi-icon.icon-avgoverall{ background-image:url("https://i.imgur.com/yejPmHa.png"); }

body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row {
  min-height: 100px;
  padding: 1.05rem;
  border-radius: 6px;
}
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-icon {
  width: 52px; height: 52px; min-width:52px; min-height:52px;
}
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-body .value {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.02;
}
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-body .label {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 6px;
}

.monthly-earners {
  margin: 0;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(180deg, var(--panel), var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  align-self: start;
  color: var(--text);
}

.monthly-earners-header {
  background: transparent;
  padding: 0;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0.9rem;
}

.monthly-earners-inner {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
  justify-content: stretch;
}

.earner-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: linear-gradient(180deg, var(--card-2, rgba(21,26,40,0.92)), var(--card));
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 8px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.35);
  flex: 1 1 0;
  min-width: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  color: var(--text);
}
.earner-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);
}

.monthly-earners .earner-icon-small {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}

.earner-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
  overflow: hidden;
}

.earner-label-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.earner-rank-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
  background: transparent;
  filter: none;
}

.earner-label-small {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  padding-left: 0;
}

.earner-value-small {
  font-size: 0.95rem;
  font-weight: 400; 
  color: var(--success);
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  display: inline-block;
}
.earner-value-small::before {
  content: "+";
  margin-right: 0.18rem;
  color: var(--success);
  font-weight: 400;
  font-size: 0.92em;
  vertical-align: baseline;
}

.monthly-ranks-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
  margin: 1rem 0;
}

.ranks-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  align-self: start;
  background: linear-gradient(180deg, var(--panel), var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.ranks-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("images/logo2.png");
  background-repeat: no-repeat;
  background-position: center 32px;
  background-size: 180px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

.ranks-card > header,
.ranks-card .ranks-chart-wrap,
.ranks-card .chart-container {
  position: relative;
  z-index: 1;
}

.ranks-header {
  background: transparent;
  padding: 0;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ranks-controls {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}
.ranks-controls .chart-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--accent);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.ranks-controls .chart-arrow:hover {
  background: rgba(111, 75, 230, 0.08);
  transform: translateY(-2px);
}

.ranks-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--accent);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.ranks-btn:hover { background: rgba(111, 75, 230, 0.08); transform: translateY(-2px); }

.ranks-chart-container {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 8px;
  padding: 0.75rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ranks-card .chart-wrapper {
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
}
.ranks-card canvas#ranksChart {
  width: 100% !important;
  max-width: 520px;
  height: auto !important;
  display: block;
}

:root{
  --list-row-height: 56px;
  --list-left-w: 180px;
  --list-mid-w: 1fr;
  --list-right-w: 180px;
}

.pill-section { display:grid; grid-template-columns: repeat(2, 1fr); gap:1rem; align-items:start; }

.pill-card {
  background: linear-gradient(180deg, var(--panel), var(--card));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem;
  box-shadow: var(--shadow);
}

.pill-card > header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0.65rem 0 0.6rem 0;
  margin-bottom: 0.6rem;
  background: transparent;
  border-bottom: 2px solid var(--accent);
}
.pill-card .pill-title, .pill-title {
  font-family: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Inter, sans-serif;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 1.5rem;
  margin: 0;
}

.pill-card .pillar-controls,
.pill-card .controls,
.pill-card .pill-controls {
  display:inline-flex;
  gap:0.45rem;
  align-items:center;
  justify-content:flex-end;
}
.pill-card .controls .control-btn,
.pill-card .pill-controls .control-btn,
.pill-card .pillar-controls .control-btn {
  width:36px;
  height:32px;
  border-radius:8px;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  cursor:pointer;
}
.pill-card .controls .control-btn:hover {
  background: rgba(111,87,255,0.06);
  transform: translateY(-2px);
}

.card.list {
  background: transparent;
  border: none;
  padding: 0;
  max-height: 340px;
  overflow: hidden;
  position: relative;
}

.card.list .scroll-content {
  display:flex;
  flex-direction:column;
  padding: 8px;
  animation-name: scrollList;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}

.card.list .row, #lootListHome .row, #achListHome .row {
  display: grid;
  grid-template-columns: var(--list-left-w) var(--list-mid-w) var(--list-right-w);
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  font-size: 0.95rem;
  color: var(--text);
  background: linear-gradient(180deg, var(--card-2, rgba(21,26,40,0.92)), var(--card));
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 8px;
  margin: 0 0 0.6rem 0;
  min-height: var(--list-row-height);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.35);
  position: relative;
  overflow: hidden;
}

.card.list .row:last-child { margin-bottom: 0; }

.row .left { display:flex; align-items:center; gap:0.6rem; min-width:0; overflow:hidden; justify-self: start; }
.row .rank-icon { width:20px; height:20px; object-fit:contain; flex-shrink:0; border-radius:4px; }
.row .rank-spacer { width:20px; height:20px; display:inline-block; }

.row .player-link { color: var(--accent); font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:100%; }

.row .mid { display:flex; align-items:center; justify-content:center; gap:0.6rem; min-width:0; text-align:center; justify-self: center; }
.row .mid .tag { white-space:nowrap; display:inline-block; max-width: 160px; overflow:hidden; text-overflow:ellipsis; }

.row .item-icon { width:24px; height:24px; object-fit:contain; flex-shrink:0; }

.row .right { display:flex; flex-direction:column; align-items:flex-end; justify-self: end; text-align:right; color:var(--muted); font-size:0.92rem; line-height:1.18; min-width:0; }
#lootListHome .row .right { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#achListHome .row .right { white-space: normal; overflow-wrap: anywhere; }

.row .tag { display:inline-block; padding: 6px 10px; border-radius:999px; font-weight:700; font-size:0.78rem; border: 1px solid rgba(255,255,255,0.04); background: rgba(255,255,255,0.02); color: var(--accent); }
.row .tag.skill { background: rgba(46,204,113,0.10); color: var(--brand-2, var(--success)); border-color: rgba(46,204,113,0.12); }
.row .tag.pvm { background: rgba(255,99,132,0.08); color: #ff6b6b; border-color: rgba(255,99,132,0.09); }
.row .tag.activity { background: rgba(59,130,246,0.08); color: #3b82f6; border-color: rgba(59,130,246,0.10); }

.row .mid strong { font-weight:700; color:var(--text); display:block; }
.row .mid .ach-sub { font-size:0.9rem; color:var(--muted); margin-top:4px; display:block; }
.row .right strong { display:block; color: var(--text); font-weight:700; }
.row .right .ach-sub { color: var(--muted); margin-top:4px; }

.card.list .row:hover { transform: translateY(-2px); transition: transform 0.12s ease; box-shadow: 0 6px 18px rgba(0,0,0,0.45); }

#lootListHome:hover .scroll-content,
#lootListHome:focus-within .scroll-content,
#achListHome:hover .scroll-content,
#achListHome:focus-within .scroll-content {
  animation-play-state: paused !important;
}

@keyframes scrollList { 0% { transform: translateY(0); } 100% { transform: translateY(-50%); } }

.monthly-ranks-row { align-items: stretch; }

.monthly-ranks-row > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
}

.pill-card.upcoming-events {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: linear-gradient(180deg, var(--panel), var(--card));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem;
  box-shadow: var(--shadow);
}

.pill-card.upcoming-events .row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
  align-items: center;
  overflow: hidden;
  min-height: 0;
  height: auto;

  background: linear-gradient(180deg, var(--card-2, rgba(21,26,40,0.92)), var(--card));
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 8px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.35);
  position: relative;
}

.pill-card.upcoming-events .row .left {
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0;
  justify-self: start;
  text-align: left;
  flex: 1;
}
.pill-card.upcoming-events .row .left .player-link {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block;
  color: var(--text);
  font-weight: 700;
  width: 100%;
  margin: 0;
}

.pill-card.upcoming-events .row .left .player-link.tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0.95;
  pointer-events: none;
  z-index: 1000;
  max-width: 200px;
}

.pill-card.upcoming-events .row .right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-self: end;
  text-align: right;
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 0;
  width: 160px;
  overflow: hidden;
}
.pill-card.upcoming-events .row .right strong {
  display: block;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill-card.upcoming-events .row .right .ach-sub {
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-card.upcoming-events,
.pill-card.upcoming-events .row,
.pill-card.upcoming-events .row * { box-sizing: border-box; }

body.page-index section#home-stats .stats-panel > header { border-bottom: 2px solid var(--accent) !important; padding-bottom: 0.6rem !important; }
body.page-index section#home-stats .stats-title { color: var(--accent) !important; font-weight:900 !important; font-size:1.5rem !important; text-transform:uppercase !important; letter-spacing:0.6px !important; }

body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row { min-height:100px !important; padding:1.05rem !important; border-radius:8px !important; }
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-icon { width:52px !important; height:52px !important; min-width:52px !important; min-height:52px !important; }
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-body .value { font-size:1.45rem !important; font-weight:900 !important; line-height:1.02 !important; }
body.page-index section#home-stats .grid.cols-3.kpi-grid > .card.kpi.kpi-row .kpi-body .label { font-size:0.98rem !important; color:var(--accent) !important; font-weight:800 !important; margin-top:6px !important; }

body.page-index .monthly-earners { margin-top: 0 !important; align-self: start !important; }
body.page-index .ranks-card { align-self: start !important; }

/* Media Queries for Mobile Responsiveness */

@media (max-width: 768px) {
  body.page-index .stats-panel {
    padding: 1rem !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  body.page-index .kpi-grid {
    gap: 0.5rem !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  body.page-index .kpi-grid .card.kpi-row {
    padding: 0.8rem !important;
    border-radius: 10px !important;
    min-height: 90px !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  body.page-index .pill-section {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }

  body.page-index .pill-card {
    padding: 0.75rem !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  body.page-index .monthly-ranks-row {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    max-width: 100% !important;
  }

  body.page-index .ranks-card {
    padding: 1rem !important;
    margin-top: 0.5rem !important;
    margin-left: auto !important;
    margin-right: auto !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  body.page-index .ranks-card .chart-wrapper {
    max-width: 100% !important;
    padding: 0.5rem !important;
  }

  /* Force single-column grids for KPI sections */
  body.page-index .grid.cols-3.kpi-grid,
  body.page-index .grid.cols-4.kpi-grid {
    grid-template-columns: 1fr !important;
  }

  /* Adjust list rows for better mobile fit */
  body.page-index .card.list .row,
  #lootListHome .row,
  #achListHome .row {
    grid-template-columns: minmax(80px, 120px) 1fr minmax(80px, 120px) !important;
    gap: 0.5rem !important;
    padding: 0.6rem !important;
    max-width: 100% !important;
  }

  /* Allow text wrapping to prevent horizontal scroll */
  .row .player-link,
  .earner-label-small,
  .pill-card.upcoming-events .row .left .player-link {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .row .right,
  #lootListHome .row .right {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .pill-card.upcoming-events .row .right {
    width: auto !important;
    max-width: 120px !important;
  }

  /* Ensure scrolling animation runs on mobile */
  .card.list .scroll-content {
    animation-play-state: running !important;
  }
}

@media (max-width: 520px) {
  body.page-index .stats-panel {
    padding: 0.75rem !important;
    margin: 0 auto !important;
  }

  body.page-index .kpi-grid .card.kpi-row {
    padding: 0.75rem !important;
    margin: 0 auto !important;
  }

  body.page-index .ranks-card .chart-wrapper {
    padding: 0 !important;
    width: 100% !important;
  }

  body.page-index .pill-section {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
    max-width: 100% !important;
  }

  body.page-index .pill-card {
    padding: 0.5rem !important;
    margin: 0 auto !important;
    max-width: 100% !important;
  }

  /* Further reduce list row columns for very small screens */
  body.page-index .card.list .row,
  #lootListHome .row,
  #achListHome .row {
    grid-template-columns: 1fr !important;
    gap: 0.25rem !important;
    padding: 0.5rem !important;
  }

  body.page-index .earner-item {
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding: 0.5rem !important;
  }

  body.page-index .monthly-earners-inner {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  /* Allow text wrapping */
  .row .player-link,
  .earner-label-small,
  .pill-card.upcoming-events .row .left .player-link {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .row .right,
  #lootListHome .row .right {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .pill-card.upcoming-events .row .right {
    width: auto !important;
    max-width: 80px !important;
  }

  .row .mid .tag {
    white-space: normal !important;
    max-width: 100% !important;
  }

  /* Ensure scrolling animation runs on mobile */
  .card.list .scroll-content {
    animation-play-state: running !important;
  }
}
