/* ============================================================
 *  RANKINGS PAGE
 * ============================================================ */

.page-head {
  text-align: center;
  margin-bottom: 36px;
}
.page-head-desc {
  max-width: 580px; margin: 12px auto 0;
  color: var(--ranmelle-text-soft);
  font-size: 14px; line-height: 1.6;
}

/* ===== Tabs ===== */
.rank-tabs {
  display: flex; justify-content: center; gap: 10px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.rank-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 999px;
  background: var(--ranmelle-panel);
  border: 1.5px solid rgba(255, 244, 220, .15);
  color: var(--ranmelle-text-soft);
  font-weight: 700; font-size: 14px;
  transition: all .25s;
}
.rank-tab:hover {
  border-color: rgba(241, 185, 79, .35);
  color: var(--cream);
}
.rank-tab.active {
  background: linear-gradient(180deg, var(--maple-orange) 0%, var(--maple-red) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(100, 148, 232, .35);
}

/* ===== Job filter chips ===== */
.job-filter {
  display: flex; justify-content: center; align-items: center;
  gap: 8px; flex-wrap: wrap;
  margin-bottom: 30px;
}
.job-filter-label {
  font-weight: 700; font-size: 13px;
  color: var(--maple-gold);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-right: 4px;
}
.job-chip {
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--ranmelle-text-soft);
  background: rgba(11, 10, 35, .4);
  border: 1.5px solid rgba(255, 244, 220, .1);
  transition: all .25s;
}
.job-chip:hover {
  border-color: rgba(241, 185, 79, .35);
  color: var(--cream);
}
.job-chip.active {
  background: rgba(241, 185, 79, .15);
  border-color: var(--maple-gold);
  color: var(--maple-gold);
}

/* ===== Podium ===== */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: end; gap: 12px;
  margin-bottom: 36px;
  padding: 0 20px;
}
.podium-spot {
  position: relative;
  padding: 20px 16px;
  text-align: center;
  background: var(--ranmelle-panel);
  border: 1.5px solid rgba(255, 244, 220, .1);
  border-radius: 16px 16px 8px 8px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: podiumIn .6s cubic-bezier(.2,.8,.2,1) backwards;
}
@keyframes podiumIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.podium-1 {
  border-color: var(--maple-gold);
  box-shadow: 0 0 0 4px rgba(241, 185, 79, .12), 0 16px 36px rgba(241, 185, 79, .25);
  padding-bottom: 38px;
  animation-delay: .2s;
}
.podium-2 {
  border-color: rgba(209, 213, 219, .5);
  padding-bottom: 28px;
  animation-delay: 0s;
}
.podium-3 {
  border-color: rgba(217, 119, 6, .5);
  padding-bottom: 24px;
  animation-delay: .1s;
}
.podium-crown {
  font-size: 36px; line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 10px rgba(241, 185, 79, .4));
}
.podium-1 .podium-crown { font-size: 48px; }

/* ===== Podium avatar (lớn) ===== */
.podium-avatar-wrap {
  width: 96px; min-height: 100px;
  margin: 0 auto 12px;
  display: flex; align-items: flex-end; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(241, 185, 79, .18) 0%, transparent 70%);
  border-radius: 12px;
  position: relative;
  padding: 6px;
}
.podium-1 .podium-avatar-wrap {
  width: 110px; min-height: 116px;
  background: radial-gradient(circle at 50% 40%, rgba(241, 185, 79, .35) 0%, transparent 70%);
}
/* Image hiển thị ở kích thước tự nhiên, không bị scale */
.podium-avatar {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}
.podium-name {
  font-family: 'Bungee', cursive;
  font-size: 18px;
  color: var(--cream); margin-bottom: 4px;
}
.podium-1 .podium-name {
  font-size: 22px;
  background: linear-gradient(180deg, #fff4dc 0%, var(--maple-gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.podium-job {
  font-size: 12px; font-weight: 600;
  color: var(--maple-gold);
  margin-bottom: 10px;
}
.podium-value {
  font-size: 16px; font-weight: 700;
  color: rgba(255, 244, 220, .9);
}
.podium-base {
  position: absolute; bottom: 8px; left: 0; right: 0;
  font-family: 'Bungee', cursive;
  font-size: 22px;
  color: rgba(255, 244, 220, .2);
}

/* ===== Rankings table ===== */
.rankings-panel { margin-bottom: 30px; }
.panel-info {
  font-size: 12px; font-weight: 600;
  color: rgba(168, 189, 216, 0.55);
}

.rank-table-wrap {
  overflow-x: auto;
  margin: 0 -8px;
}
.rank-table {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
}
.rank-table thead th {
  padding: 12px 14px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--maple-gold);
  text-align: left;
  border-bottom: 1.5px solid rgba(241, 185, 79, .2);
}
.rank-table .th-pos { width: 60px; text-align: center; }
.rank-table .th-avatar { width: 72px; padding: 0; }
.rank-table .th-value { text-align: right; padding-right: 18px; }

/* ===== Character avatar — kích thước tự nhiên từ maplestory.io ===== */
/* Không ép width/height — image hiển thị ở native size (giữ sắc nét).
 * Chỉ dùng max-width/max-height để giới hạn nếu quá to. */
.char-avatar {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  opacity: 0;
  transition: opacity .35s ease;
  /* CRITICAL: pixel art rendering */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}
.char-avatar.loaded { opacity: 1; }
.char-avatar.error {
  opacity: 1;
  width: 32px; height: 32px;   /* fallback fixed size cho icon error */
  background: rgba(255, 244, 220, .04) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffc94a' opacity='0.4'><path d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/></svg>") center/60% no-repeat;
  border-radius: 8px;
}
.char-avatar:not(.loaded):not(.error) {
  width: 40px; height: 48px;   /* placeholder size khi loading */
  background: linear-gradient(90deg,
    rgba(255, 244, 220, .04) 0%,
    rgba(241, 185, 79, .1)  50%,
    rgba(255, 244, 220, .04) 100%
  );
  background-size: 200% 100%;
  animation: char-shimmer 1.4s linear infinite;
  border-radius: 8px;
}
@keyframes char-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.td-avatar {
  width: 72px;
  padding: 4px 0 4px 8px !important;
  text-align: center;
}
.td-avatar .char-avatar {
  margin: 0 auto;
}

.rank-row {
  transition: background .25s;
}
.rank-row:hover { background: rgba(241, 185, 79, .04); }
.rank-row td {
  padding: 14px;
  border-bottom: 1px solid rgba(255, 244, 220, .06);
}
.rank-row .td-pos {
  text-align: center;
  font-family: 'Bungee', cursive;
  font-size: 16px;
  color: rgba(255, 244, 220, .55);
}
.rank-row.top-1 .td-pos,
.rank-row.top-2 .td-pos,
.rank-row.top-3 .td-pos {
  font-size: 22px;
}
.rank-row .td-name {
  font-weight: 700; font-size: 15px;
  color: var(--cream);
}
.rank-row .td-job { color: var(--maple-gold); font-weight: 600; }
.rank-row .td-value {
  text-align: right; padding-right: 18px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700; font-size: 15px;
  color: var(--cream);
}
.exp-mini {
  display: block;
  font-size: 11px; font-weight: 500;
  color: rgba(168, 189, 216, 0.55);
  margin-top: 2px;
}

.guild-tag {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(96, 165, 250, .15);
  color: #93c5fd;
  font-size: 12px; font-weight: 600;
}
.muted { color: rgba(255, 244, 220, .3); font-size: 13px; }

/* ===== Pagination ===== */
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid rgba(255, 244, 220, .08);
}
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(11, 10, 35, .5);
  border: 1.5px solid rgba(255, 244, 220, .12);
  color: var(--ranmelle-text-soft);
  font-weight: 700; font-size: 14px;
  transition: all .2s;
}
.pg-btn:hover {
  border-color: var(--maple-gold);
  color: var(--maple-gold);
}
.pg-btn.active {
  background: linear-gradient(180deg, var(--maple-orange) 0%, var(--maple-red) 100%);
  border-color: transparent;
  color: #fff;
}
.pg-btn.disabled {
  opacity: .3; pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .podium { grid-template-columns: 1fr; gap: 10px; padding: 0; }
  .podium-1, .podium-2, .podium-3 { padding-bottom: 20px; }
  .rank-table .th-guild, .rank-row .td-guild { display: none; }
  .rank-tab { padding: 10px 16px; font-size: 13px; }
}
