/* ============================================
   RANKINGS PAGE STYLES
   Compact tabular layout - single viewport
   ============================================ */

/* ============================================
   VIEWPORT LOCK
   ============================================ */

.page-content:has(.rankings-section) {
  height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Hide the page-header if it still exists */
.page-content:has(.rankings-section) .page-header {
  display: none;
}

/* ============================================
   RANKINGS SECTION
   ============================================ */

.rankings-section {
  padding: 16px 0 0;
  position: relative;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rankings-section > * {
  position: relative;
  z-index: 1;
}

.rankings-section > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ============================================
   RANKINGS HEADER (tabs)
   ============================================ */

.rankings-header {
  flex-shrink: 0;
  margin-bottom: 14px;
}

.rankings-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}

.rank-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: rgba(106, 61, 232, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(106, 61, 232, 0.15);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.rank-tab i {
  font-size: 0.85rem;
}

.rank-tab:hover {
  background: rgba(106, 61, 232, 0.2);
  color: var(--text-color);
  border-color: rgba(106, 61, 232, 0.35);
}

.rank-tab.active {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(106, 61, 232, 0.4);
}

/* ============================================
   RANKINGS CARD (main container)
   ============================================ */

.rankings-card {
  background: rgba(26, 26, 46, 0.75);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(106, 61, 232, 0.2);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ============================================
   TABLE HEADER (column labels)
   ============================================ */

.rankings-table-header {
  display: grid;
  grid-template-columns: 50px 1.5fr 1fr 1fr repeat(3, 0.7fr);
  align-items: center;
  padding: 10px 20px;
  background: rgba(106, 61, 232, 0.08);
  border-bottom: 1px solid rgba(106, 61, 232, 0.15);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.rankings-table-header .th-rank {
  text-align: center;
}

.rankings-table-header .th-stat {
  text-align: right;
}

.rankings-table-header .th-guild {
  padding-left: 4px;
}

/* ============================================
   RANKING ROWS (individual players)
   ============================================ */

.ranking-cards-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(106, 61, 232, 0.25) transparent;
}

.ranking-cards-list::-webkit-scrollbar {
  width: 5px;
}
.ranking-cards-list::-webkit-scrollbar-track {
  background: transparent;
}
.ranking-cards-list::-webkit-scrollbar-thumb {
  background: rgba(106, 61, 232, 0.25);
  border-radius: 3px;
}
.ranking-cards-list::-webkit-scrollbar-thumb:hover {
  background: rgba(106, 61, 232, 0.45);
}

.ranking-row {
  display: grid;
  grid-template-columns: 50px 1.5fr 1fr 1fr repeat(3, 0.7fr);
  align-items: center;
  padding: 9px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease;
  animation: fadeInRow 0.3s ease-out backwards;
}

.ranking-row:hover {
  background: rgba(106, 61, 232, 0.08);
}

@keyframes fadeInRow {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.ranking-cards-list > .ranking-row:nth-child(1) { animation-delay: 0.05s; }
.ranking-cards-list > .ranking-row:nth-child(2) { animation-delay: 0.08s; }
.ranking-cards-list > .ranking-row:nth-child(3) { animation-delay: 0.11s; }
.ranking-cards-list > .ranking-row:nth-child(n+4) { animation-delay: 0.14s; }

/* ============================================
   RANK POSITION (CSS medals)
   ============================================ */

.rank-pos {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  margin: 0 auto;
}

.rank-pos.medal-gold {
  background: linear-gradient(135deg, #ffd700, #f0a500);
  color: #1a1a2e;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.rank-pos.medal-silver {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  color: #1a1a2e;
  box-shadow: 0 0 10px rgba(192, 192, 192, 0.3);
}

.rank-pos.medal-bronze {
  background: linear-gradient(135deg, #cd7f32, #b06a2a);
  color: #1a1a2e;
  box-shadow: 0 0 10px rgba(205, 127, 50, 0.3);
}

/* Row medal highlights */
.ranking-row.rank-1 {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.06), transparent 60%);
  border-left: 2px solid rgba(255, 215, 0, 0.4);
}
.ranking-row.rank-2 {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.04), transparent 60%);
  border-left: 2px solid rgba(192, 192, 192, 0.3);
}
.ranking-row.rank-3 {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.04), transparent 60%);
  border-left: 2px solid rgba(205, 127, 50, 0.3);
}

/* ============================================
   ROW CONTENT
   ============================================ */

.row-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-color);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-row.rank-1 .player-name {
  color: #ffd700;
}

.row-class {
  font-size: 0.75rem;
  color: #7eb3ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-guild {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.row-guild-emblem {
  width: 16px;
  height: 16px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.guild-label {
  font-size: 0.75rem;
  color: #d8a5f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-guild {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 0.75rem;
}

/* ============================================
   STAT VALUES (semantic colors)
   ============================================ */

.row-stat {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-color);
  text-align: right;
}

.stat-kills {
  color: #ff6b6b !important;
}

.stat-deaths {
  color: #6b7b8d !important;
}

.stat-ratio {
  color: #4ade80 !important;
}

.stat-zeny {
  color: #ffd700 !important;
}

/* ============================================
   SCROLL FADE INDICATOR
   ============================================ */

.scroll-fade-bottom {
  position: absolute;
  bottom: 50px; /* above pagination */
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, rgba(26, 26, 46, 0.9));
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.3s ease;
}

/* ============================================
   GUILD CARD LAYOUT (Redesigned)
   ============================================ */

.guild-layout {
  gap: 10px;
  padding: 14px 18px;
}

/* Guild layout needs to be scrollable like the other rankings */
.guild-layout .guild-row {
  flex-shrink: 0;
}

.guild-card {
  background: linear-gradient(135deg, rgba(40, 40, 65, 0.7), rgba(28, 28, 50, 0.7));
  border: 1px solid rgba(106, 61, 232, 0.2);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  animation: fadeInRow 0.35s ease-out backwards;
  flex-shrink: 0;
}

.guild-card:hover {
  border-color: rgba(106, 61, 232, 0.5);
  box-shadow: 0 4px 20px rgba(106, 61, 232, 0.15);
}

/* #1 - Champion guild: strong visual presence */
.guild-card.rank-1 {
  border: 2px solid rgba(255, 215, 0, 0.5);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.07), rgba(40, 40, 65, 0.7) 40%);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.1);
}
.guild-card.rank-1:hover {
  border-color: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}
.guild-card.rank-1 .gc-name {
  color: #ffd700;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.guild-card.rank-2 {
  border: 1.5px solid rgba(192, 192, 192, 0.35);
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.04), rgba(40, 40, 65, 0.7) 40%);
}

.guild-card.rank-3 {
  border: 1.5px solid rgba(205, 127, 50, 0.35);
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.04), rgba(40, 40, 65, 0.7) 40%);
}

/* --- GC Top: rank + name + castles --- */
.gc-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 10px;
}

.gc-emblem {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.gc-identity {
  flex: 1;
  min-width: 0;
}

.gc-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Castle icons visual */
.gc-castles {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}

.gc-castle-icon {
  font-size: 0.8rem;
  color: var(--accent-color);
  filter: drop-shadow(0 0 4px rgba(0, 217, 255, 0.3));
}

.guild-card.rank-1 .gc-castle-icon {
  color: #ffd700;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.4));
}

.gc-castle-extra {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-color);
}

.gc-castle-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 6px;
}

/* --- GC Stats bar --- */
.gc-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 18px;
  background: rgba(106, 61, 232, 0.05);
  border-top: 1px solid rgba(106, 61, 232, 0.08);
  border-bottom: 1px solid rgba(106, 61, 232, 0.08);
}

.gc-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 0;
}

.gc-stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(106, 61, 232, 0.15);
  flex-shrink: 0;
}

.gc-stat-val {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-color);
}

.gc-stat-lbl {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Semantic colors for guild context */
.gc-val-kills { color: var(--primary-light); }
.gc-val-deaths { color: #6b7b8d; }
.gc-val-ratio { color: #4ade80; }
.gc-val-breaks { color: var(--accent-color); }

/* --- GC Top Killers (inline) --- */
.gc-killers {
  padding: 8px 18px 10px;
}

.gc-killers-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.gc-killers-label i {
  color: var(--accent-color);
  margin-right: 3px;
}

.gc-killers-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gc-killer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.gc-killer:hover {
  background: rgba(106, 61, 232, 0.06);
}

.gc-killer-mvp {
  background: rgba(255, 215, 0, 0.04);
}

.gc-killer-mvp:hover {
  background: rgba(255, 215, 0, 0.08);
}

.gc-killer-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-color);
  min-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gc-killer-mvp .gc-killer-name {
  color: #ffd700;
}

.gc-killer-class {
  font-size: 0.7rem;
  color: #7eb3ff;
  min-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gc-killer-stats {
  font-size: 0.72rem;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.gc-ks-kills { color: var(--primary-light); font-weight: 700; }
.gc-ks-sep { color: var(--text-muted); opacity: 0.4; }
.gc-ks-deaths { color: #6b7b8d; font-weight: 600; }
.gc-ks-ratio { color: #4ade80; font-weight: 700; font-size: 0.68rem; }

/* ============================================
   GUILD ROWS (4+ positions - compact: name + castles)
   ============================================ */

.guild-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease;
  animation: fadeInRow 0.3s ease-out backwards;
}

.guild-row:hover {
  background: rgba(106, 61, 232, 0.08);
}

.gr-guild {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.gr-emblem {
  width: 20px;
  height: 20px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.gr-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-color);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gr-castles-compact {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  font-size: 3rem;
  color: var(--primary-light);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--text-color);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ============================================
   PAGINATION (compact)
   ============================================ */

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  flex-shrink: 0;
  border-top: 1px solid rgba(106, 61, 232, 0.12);
  background: rgba(106, 61, 232, 0.03);
}

.pagination-info {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background-color: rgba(106, 61, 232, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(106, 61, 232, 0.2);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.78rem;
}

.page-link:hover {
  background-color: rgba(106, 61, 232, 0.25);
  color: var(--text-color);
  border-color: var(--primary-color);
}

.page-link.active {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-color: transparent;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 10px rgba(106, 61, 232, 0.35);
}

.page-link i {
  font-size: 0.75rem;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 992px) {
  .ranking-row,
  .rankings-table-header {
    grid-template-columns: 44px 1.3fr 1fr 1fr repeat(3, 0.7fr);
    padding-left: 12px;
    padding-right: 12px;
  }

}

@media (max-width: 768px) {
  .rankings-section {
    padding: 10px 0 0;
  }

  .rank-tab span {
    display: none;
  }

  .rank-tab {
    padding: 8px 14px;
  }

  .rankings-table-header {
    grid-template-columns: 36px 1fr repeat(3, 0.7fr);
    padding: 8px 12px;
  }

  .rankings-table-header .th-class,
  .rankings-table-header .th-guild {
    display: none;
  }

  .ranking-row {
    grid-template-columns: 36px 1fr repeat(3, 0.7fr);
    padding: 8px 12px;
  }

  .row-class,
  .row-guild {
    display: none;
  }

  .player-name {
    font-size: 0.8rem;
  }

  .row-stat {
    font-size: 0.75rem;
  }

  /* Guild card responsive */
  .gc-top {
    flex-wrap: wrap;
    padding: 10px 12px 8px;
    gap: 8px;
  }

  .gc-castles {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }

  .gc-stats {
    padding: 6px 12px;
  }

  .gc-stat-val {
    font-size: 0.82rem;
  }

  .gc-killers {
    padding: 6px 12px 8px;
  }

  .gc-killer-class {
    display: none;
  }

}

@media (max-width: 576px) {
  .rankings-nav {
    gap: 4px;
  }

  .rank-tab {
    padding: 7px 12px;
    font-size: 0.9rem;
  }

  .rankings-table-header {
    grid-template-columns: 32px 1fr repeat(2, 0.7fr);
    font-size: 0.62rem;
  }

  .rankings-table-header .th-stat:nth-child(5) {
    display: none;
  }

  .ranking-row {
    grid-template-columns: 32px 1fr repeat(2, 0.7fr);
    padding: 7px 10px;
  }

  .ranking-row .row-stat:nth-child(6) {
    display: none;
  }

  .rank-pos {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
    border-radius: 6px;
  }

  .pagination-container {
    padding: 8px 12px;
  }

  .page-link {
    min-width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }

  .gc-name {
    font-size: 0.9rem;
  }

  .gc-stats {
    padding: 5px 10px;
  }

  .gc-stat-val {
    font-size: 0.78rem;
  }

  .gc-killer-stats {
    font-size: 0.68rem;
  }

  .guild-row {
    padding: 7px 10px;
    gap: 8px;
  }

  .gr-name {
    font-size: 0.78rem;
  }
}

/* ============================================
   FALLING PARTICLES (kept for background fx)
   ============================================ */

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  5% { opacity: 0.5; }
  90% { opacity: 0.5; }
  100% { transform: translateY(calc(100vh + 100px)) rotate(15deg); opacity: 0; }
}

@keyframes fall-slow {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  5% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translateY(calc(100vh + 100px)) rotate(-10deg); opacity: 0; }
}

@keyframes fall-medium {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  5% { opacity: 0.45; }
  90% { opacity: 0.45; }
  100% { transform: translateY(calc(100vh + 100px)) rotate(20deg); opacity: 0; }
}
