/* Legends page */

.legends-toolbar {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(17, 17, 17, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.filter-bar {
  width: 100%;
  max-width: 600px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Desktop filter toggle button */
.filter-toggle {
  background: none;
  border: none;
  color: #757575;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}

.filter-toggle:hover {
  color: #a0a0a0;
}

.filter-toggle.active {
  color: #D4A373;
}

/* Filters panel — slides in from left */
.filters-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.25s ease;
  flex-shrink: 0;
}

.filters-panel.open {
  max-width: 300px;
  opacity: 1;
}

.filter-toggle.hidden {
  display: none;
}

.role-filters {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.role-filter {
  background: none;
  border: none;
  color: #757575;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'Noto Sans', sans-serif;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  padding: 0 4px;
  white-space: nowrap;
}

.rf-short {
  display: none;
}

.role-filter:hover {
  color: #a0a0a0;
}

.role-filter.active {
  color: #D4A373;
}

.role-filter {
  position: relative;
}

.role-filter::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: rgba(17, 17, 17, 0.95);
  color: #f8f5f4;
  font-size: 0.65rem;
  font-weight: 400;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}

.role-filter:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sort */
.sort-wrap {
  position: relative;
  flex-shrink: 0;
}

.sort-toggle {
  background: none;
  border: none;
  color: #757575;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s;
}

.sort-toggle:hover {
  color: #a0a0a0;
}

.sort-toggle.active {
  color: #D4A373;
}

.sort-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #242525;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-direction: column;
  min-width: 160px;
  z-index: 100;
}

.sort-dropdown.open {
  display: flex;
}

.sort-option {
  background: none;
  border: none;
  color: #757575;
  font-size: 0.8rem;
  font-family: 'Noto Sans', sans-serif;
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.sort-option:hover {
  color: #a0a0a0;
  background: rgba(255, 255, 255, 0.04);
}

.sort-option.active {
  color: #D4A373;
}

.filter-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.filter-input {
  background: #242525;
  border: none;
  padding: 8px 36px 8px 16px;
  color: #f8f5f4;
  font-size: 0.9rem;
  font-family: 'Noto Sans', sans-serif;
  outline: none;
  width: 100%;
  transition: box-shadow 0.15s;
}

.filter-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #575757;
  font-size: 1.2rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.15s;
}

.filter-clear.visible {
  display: flex;
}

.filter-clear:hover {
  color: #f8f5f4;
}

.filter-input::placeholder {
  color: #757575;
}

.filter-input:focus {
  box-shadow: 0 0 0 2px rgba(212, 163, 115, 0.3);
}

/* Main area */
.legends-main {
  --gap: 6px;
  background: #1d1e1e;
  padding: calc(136px + var(--gap)) 20px 40px;
}

body:has(.legends-main) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #1d1e1e;
}

body:has(.legends-main) .legends-main {
  flex: 1;
}

body:has(.legends-main) footer {
  flex-shrink: 0;
}

/* Head grid */
.head-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 72px);
  gap: var(--gap);
  max-width: 1200px;
  margin: 0 auto;
  justify-content: center;
}

/* Individual head */
.head-cell {
  width: 72px;
  height: 72px;
  position: relative;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.5);
  image-rendering: pixelated;
}

.head-cell.visible {
  animation: head-pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards;
}

@keyframes head-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.head-cell img {
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  transition: transform 0.15s, filter 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 1;
}

.head-cell:hover {
  z-index: 50;
}

.head-cell:hover img {
  transform: scale(1.25);
}

/* Pagination — mobile only */
.legends-pagination {
  display: none;
  padding: 20px 0 0;
  justify-content: center;
}

.legends-pagination.active {
  display: flex;
}

.legends-pg-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.legends-pg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #757575;
  background: #1d1e1e;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.legends-pg-num:hover {
  background: #313131;
  color: #fff;
}

.legends-pg-num.active {
  background: #D4A373;
  color: #1a1a1a;
  cursor: default;
}

.legends-pg-num.active:hover {
  background: #D4A373;
  color: #1a1a1a;
}

.legends-pg-num.pg-dots {
  pointer-events: none;
  color: #5a5a5a;
  background: transparent;
  cursor: default;
}

.legends-pg-num.pg-dots:hover {
  background: transparent;
  color: #5a5a5a;
}

/* Role borders with glow */
.head-cell.role-admin img {
  box-shadow: 0 0 0 2px rgba(255, 112, 67, 0.85), 0 0 10px 2px rgba(255, 112, 67, 0.4);
}
.head-cell.role-mod img {
  box-shadow: 0 0 0 2px rgba(100, 180, 255, 0.85), 0 0 10px 2px rgba(100, 180, 255, 0.4);
}
.head-cell.role-sponsor img {
  box-shadow: 0 0 0 2px rgba(255, 195, 50, 0.9), 0 0 12px 3px rgba(255, 185, 30, 0.5);
}
.head-cell.role-banned img {
  box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.9), 0 0 10px 2px rgba(229, 57, 53, 0.45);
}

/* Online indicator */
.head-cell[data-online="1"]::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  z-index: 9;
}

.head-cell[data-online="1"]::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #4caf50;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(76, 175, 80, 0.6);
  z-index: 10;
}

/* Nickname tooltip (below head) */
.head-name {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(17, 17, 17, 0.95);
  color: #D4A373;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 20;
  letter-spacing: 0.3px;
}

.head-cell:hover .head-name {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Player modal overlay */
.player-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 60px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.player-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.player-modal {
  background: #242525;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 32px 36px;
  max-width: 340px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.player-modal-overlay.open .player-modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #757575;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover {
  color: #f8f5f4;
}


.modal-head {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
}

.modal-name {
  color: #f8f5f4;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.modal-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.modal-role {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 10px;
}
.modal-role.role-admin {
  color: #ff7043;
  background: rgba(255, 112, 67, 0.15);
}
.modal-role.role-mod {
  color: #64b4ff;
  background: rgba(100, 180, 255, 0.15);
}
.modal-role.role-sponsor {
  color: #D4A373;
  background: rgba(212, 163, 115, 0.15);
}
.modal-role.role-banned {
  color: #e53935;
  background: rgba(229, 57, 53, 0.15);
}

.modal-online {
  color: #4caf50;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  width: 100%;
  margin-top: 8px;
}

.modal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.modal-stat-val {
  color: #D4A373;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-stat-label {
  color: #757575;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Role toast — mobile only */
.role-toast {
  display: none;
}

/* Search toggle button — hidden on desktop */
.search-toggle {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .filter-toggle {
    display: none;
  }

  .filters-panel {
    max-width: none;
    opacity: 1;
    overflow: visible;
  }

  .filter-bar {
    flex-wrap: wrap;
  }

  .rf-full {
    display: none;
  }

  .rf-short {
    display: inline;
  }

  .role-filter {
    width: 28px;
    padding: 0;
    font-size: 0.8rem;
  }

  .role-filter::after {
    display: none;
  }

  .sort-dropdown {
    min-width: 200px;
  }

  .sort-option {
    font-size: 0.95rem;
    padding: 12px 18px;
  }

  .role-toast {
    display: block;
    position: fixed;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(17, 17, 17, 0.85);
    color: #f8f5f4;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 14px 32px;
    pointer-events: none;
    z-index: 300;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
    letter-spacing: 0.5px;
  }

  .role-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .search-toggle {
    display: flex;
    background: none;
    border: none;
    color: #757575;
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
  }

  .search-toggle.active {
    color: #D4A373;
  }

  .legends-toolbar {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    padding: 14px 20px;
  }

  .legends-toolbar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .legends-main {
    --gap: 5px;
    padding: calc(80px + var(--gap)) 10px 30px;
    transition: padding-top 0.25s ease;
  }

  .legends-toolbar.visible ~ .legends-main {
    padding-top: calc(136px + var(--gap));
  }

  .head-grid {
    grid-template-columns: repeat(auto-fill, 80px);
  }

  .head-cell {
    width: 80px;
    height: 80px;
  }

  .head-cell img {
    width: 72px;
    height: 72px;
  }

}

@media (max-width: 480px) {
  .legends-main {
    --gap: 4px;
  }

  .head-grid {
    grid-template-columns: repeat(auto-fill, 72px);
  }

  .head-cell {
    width: 72px;
    height: 72px;
  }

  .head-cell img {
    width: 64px;
    height: 64px;
  }
}

/* Large screens (1440px+) */
@media (min-width: 1440px) {
  .legends-toolbar {
    top: 68px;
  }

  .legends-main {
    --gap: 8px;
    padding-top: calc(147px + var(--gap));
  }

  .head-grid {
    max-width: 1400px;
    grid-template-columns: repeat(auto-fill, 80px);
  }

  .head-cell {
    width: 80px;
    height: 80px;
  }

  .head-cell img {
    width: 72px;
    height: 72px;
  }

  .filter-bar {
    max-width: 640px;
  }

  .filter-input {
    font-size: 0.95rem;
    padding: 10px 40px 10px 18px;
  }
}

/* Extra-large screens (1920px+ / 2K) */
@media (min-width: 1920px) {
  .legends-toolbar {
    top: 72px;
  }

  .legends-main {
    --gap: 10px;
    padding-top: calc(153px + var(--gap));
  }

  .head-grid {
    max-width: 1600px;
    grid-template-columns: repeat(auto-fill, 88px);
  }

  .head-cell {
    width: 88px;
    height: 88px;
  }

  .head-cell img {
    width: 80px;
    height: 80px;
  }

  .filter-bar {
    max-width: 700px;
  }

  .filter-input {
    font-size: 1rem;
    padding: 12px 44px 12px 20px;
  }

  .player-modal {
    max-width: 380px;
    padding: 36px 40px;
  }

  .modal-head {
    width: 144px;
    height: 144px;
  }

  .modal-name {
    font-size: 1.3rem;
  }
}
