:root {
  --bg-deep: #140808;
  --bg-slate: #221010;
  --bg-card: #2a1414;
  --brand-red: #c41e3a;
  --brand-red-light: #e63950;
  --brand-yellow: #f0c030;
  --brand-cream: #f5e6c8;
  --text-primary: #f5ebe8;
  --text-muted: #b8a0a0;
  --border: #5c2828;
  --glow: rgba(196, 30, 58, 0.4);
  --overlay: 20, 8, 8;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(196, 30, 58, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(240, 192, 48, 0.1) 0%, transparent 40%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Header */
.header {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 2px solid var(--border);
  background: linear-gradient(180deg, var(--bg-slate) 0%, var(--bg-deep) 100%);
}

.header__emblem {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--glow));
}

.header__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-yellow);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.header__subtitle {
  font-size: 0.95rem;
  color: var(--brand-cream);
  margin-top: 0.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header__count {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Filters */
.filters {
  border-bottom: 1px solid var(--border);
  background: rgba(var(--overlay), 0.6);
  position: sticky;
  top: 0;
  z-index: 15;
  backdrop-filter: blur(10px);
}

.filters__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filters__label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-input {
  flex: 0 1 340px;
  width: 340px;
  max-width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-slate);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--brand-red-light);
  box-shadow: 0 0 0 3px var(--glow);
}

.search-input::placeholder { color: var(--text-muted); }

.select-filter, .number-filter {
  padding: 0.5rem 0.75rem;
  background: var(--bg-slate);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}

.select-filter:focus, .number-filter:focus {
  border-color: var(--brand-red-light);
}

.number-filter { width: 80px; }

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-field__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn-clear {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--brand-yellow);
  border-radius: 4px;
  color: var(--brand-yellow);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: var(--brand-yellow);
  color: var(--bg-deep);
}

.btn-clear--end {
  margin-left: auto;
}

.filter-field--end {
  margin-left: auto;
}

/* Main content */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.status-message {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.status-message--loading {
  padding: 3rem 1rem;
}

.status-message__spinner {
  display: inline-block;
  vertical-align: middle;
}

.status-message--error { color: #f87171; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
}

.card {
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  background-color: var(--bg-card);
  background-size: cover;
  background-position: center top;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card--clickable {
  cursor: pointer;
}

.card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  border-color: var(--brand-red-light);
}

.card--clickable:focus-visible {
  outline: 2px solid var(--brand-yellow);
  outline-offset: 2px;
}

.card:has(.alt-badge:hover),
.card:has(.alt-badge:focus-visible) {
  z-index: 20;
}

.card__overlay {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0.85rem;
  min-height: 100%;
  background: linear-gradient(
    180deg,
    rgba(var(--overlay), 0.45) 0%,
    rgba(var(--overlay), 0.88) 50%,
    rgba(var(--overlay), 0.96) 100%
  );
}

.card__top {
  display: flex;
  flex: 1;
  gap: 0.75rem;
  align-items: flex-start;
}

.card__avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 0.35rem;
  transition: transform 0.2s;
}

.card__avatar {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  z-index: 2;
}

.card__portrait {
  position: absolute;
  display: block;
  width: 75px;
  height: 75px;
  top: 0%;
  left: 0%;
  transform: translate(-25%, -25%);
  border-radius: 50%;
  z-index: 1;
}

.card__portrait--custom {
  object-fit: cover;
}

.portrait-sprite {
  background-repeat: no-repeat;
}

.card__ring {
  position: absolute;
  inset: 0;
  width: 150%;
  height: 150%;
  z-index: 2;
  pointer-events: none;
  top: -36px;
  left: -36px;
}

.card__dragon {
  position: absolute;
  inset: 0;
  width: 140%;
  height: 140%;
  z-index: 3;
  pointer-events: none;
  top: -36px;
  left: -46px;
}

.card__identity {
  flex: 1;
  min-width: 0;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-red-light);
  box-shadow: 0 4px 16px var(--glow);
}

.card:hover .card__avatar-block {
  transform: translate(3px, 3px);
}

.card--guildmaster {
  border-color: rgba(240, 192, 48, 0.55);
}

.card--guildmaster:hover {
  border-color: var(--brand-yellow);
  box-shadow: 0 6px 24px rgba(240, 192, 48, 0.2), 0 4px 16px var(--glow);
}

.confetti {
  position: fixed;
  width: 8px;
  height: 12px;
  pointer-events: none;
  z-index: 9999;
  border-radius: 2px;
  will-change: transform, opacity;
  transform: translate(-50%, -50%);
  opacity: 0.95;
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card__name {
  font-size: 1.1rem;
  font-weight: 600;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.card__level {
  font-size: 0.85rem;
  color: var(--brand-yellow);
  font-weight: 700;
  white-space: nowrap;
}

.card__class-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
  z-index: 3;
  position: relative;
  top: -32px;
  left: -30px;
}

.card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card__class + .card__rank::before {
  content: " · ";
}

.card__rank:has(+ .card__status)::after {
  content: " · ";
}

.card__class {
  color: var(--text-muted);
}

.card__quote-row {
  margin-top: 0.25rem;
  min-width: 0;
}

.card__quote::before {
  content: open-quote;
}

.card__quote::after {
  content: close-quote;
}

.card__quote {
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--text-muted);
  min-width: 0;
}

.card__quote-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card__quote-link:hover {
  color: inherit;
}

.card__rank {
  color: var(--text-muted);
  font-weight: 700;
}

.card__meta .card__status {
  margin-top: 0;
}

.card__status {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: rgba(196, 30, 58, 0.25);
  color: var(--brand-red-light);
  cursor: default;
}

.card__status--alt {
  cursor: help;
  border-bottom: 1px dotted var(--brand-red-light);
}

.card__linked {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.alt-badge {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 0;
}

.alt-badge__avatar {
  position: relative;
  display: block;
  width: 30px;
  height: 30px;
}

.alt-badge__portrait {
  position: absolute;
  display: block;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;
}

.alt-badge__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.alt-badge__dragon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.alt-badge__tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 30;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.55rem;
  white-space: nowrap;
  line-height: 1.2;
  background: rgba(34, 16, 16, 0.97);
  border: 1px solid var(--brand-red-light);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.alt-badge__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(34, 16, 16, 0.97);
  filter: drop-shadow(0 1px 0 var(--brand-red-light));
}

.alt-badge__prefix {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.alt-badge__name {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.alt-badge__level {
  font-size: 0.68rem;
  color: var(--brand-yellow);
  font-weight: 700;
  line-height: 1.2;
  flex-shrink: 0;
}

@media (hover: hover) {
  .alt-badge:hover .alt-badge__tip,
  .alt-badge:focus-visible .alt-badge__tip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }

  .alt-badge:hover .alt-badge__avatar,
  .alt-badge:focus-visible .alt-badge__avatar {
    filter: brightness(1.15);
  }
}

.card__online {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.card__online-now {
  color: #7ee787;
  font-weight: 700;
}

.card__online-stale {
  color: #ff2d2d;
  font-weight: 700;
}

.card__professions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(92, 40, 40, 0.6);
}

.prof-badge {
  display: inline-flex;
  align-items: stretch;
  gap: 0.3rem;
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.65rem;
  padding: 0.25rem 0.35rem;
  border-radius: 3px;
  background: rgba(196, 30, 58, 0.2);
  border: 1px solid rgba(230, 57, 80, 0.35);
  color: var(--text-primary);
}

.prof-icon {
  flex: 0 0 auto;
  align-self: stretch;
  aspect-ratio: 1;
  width: auto;
  min-height: 2.5em;
  background-image: url('../images/wow-classic-profs.png');
  background-repeat: no-repeat;
  background-size: 500% 200%;
  background-position:
    calc(var(--prof-col) * 100% / 4)
    calc(var(--prof-row) * 100%);
}

.prof-badge__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  line-height: 1.15;
}

.prof-badge__name {
  word-break: break-word;
}

.prof-badge__level {
  font-size: 0.72rem;
  color: var(--brand-yellow);
  font-weight: 700;
  line-height: 1;
}

.prof-badge--none {
  background: rgba(148, 163, 184, 0.1);
  border-color: var(--border);
  color: var(--text-muted);
  font-style: italic;
}

/* Class colors */
.class-warrior { color: #C79C6E; }
.class-paladin { color: #F58CBA; }
.class-hunter { color: #ABD473; }
.class-rogue { color: #FFF569; }
.class-priest { color: #FFFFFF; }
.class-shaman { color: #0070DE; }
.class-mage { color: #3FC7EB; }
.class-warlock { color: #8788EE; }
.class-druid { color: #FF7D0A; }

@media (max-width: 600px) {
  .header__title { font-size: 1.5rem; }
  .grid { grid-template-columns: 1fr; }
  .filters__inner { padding: 0.75rem; gap: 0.6rem; }
  .filters__row { gap: 0.5rem; }
  .filter-field { flex: 1 1 140px; min-width: 0; }
  .select-filter { width: 100%; }
  .search-input { flex: 1 1 220px; width: auto; min-width: 0; }
  .btn-clear--end { margin-left: 0; }
  .filter-field--end { margin-left: 0; }
}

.footer {
  text-align: center;
  padding: 1.25rem 1rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer__updated {
  color: var(--brand-cream);
}

.footer__grm {
  margin-top: 0.25rem;
  font-size: 0.75rem;
}

.footer__grm--live {
  color: #7ee787;
  font-weight: 600;
}

.footer__grm--offline {
  color: var(--text-muted);
}

.footer__credit {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer__version {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.75;
}

.footer__author {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--brand-cream);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.footer__author:hover {
  color: var(--brand-yellow);
  text-decoration-color: var(--brand-yellow);
}

body.modal-open {
  overflow: hidden;
}

.member-modal[hidden] {
  display: none;
}

.member-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.member-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 4, 0.82);
  backdrop-filter: blur(2px);
}

.member-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  max-height: min(85vh, 640px);
  overflow: visible;
  padding: 1.25rem 1.35rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--bg-card);
  background-size: cover;
  background-position: center top;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.member-modal__dialog::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(var(--overlay), 0.45) 0%,
    rgba(var(--overlay), 0.88) 50%,
    rgba(var(--overlay), 0.96) 100%
  );
  pointer-events: none;
  z-index: 0;
}

.member-modal__dialog--guildmaster {
  border-color: rgba(240, 192, 48, 0.55);
}

.member-modal__header {
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.member-modal__body {
  margin-top: 1.1rem;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  position: relative;
  z-index: 1;
}

.member-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  z-index: 2;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.member-modal__close:hover {
  color: var(--brand-cream);
  background: rgba(255, 255, 255, 0.06);
}

.member-modal__header-inner {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.5rem 2rem 0 0.75rem;
  overflow: visible;
}

.member-modal__avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 0.35rem;
  overflow: visible;
}

.member-modal__avatar {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  overflow: visible;
}

.member-modal__portrait {
  position: absolute;
  display: block;
  width: 75px;
  height: 75px;
  top: 0;
  left: 0;
  transform: translate(-25%, -25%);
  border-radius: 50%;
  z-index: 1;
}

.member-modal__portrait--custom {
  object-fit: cover;
}

.member-modal__ring {
  position: absolute;
  inset: 0;
  width: 150%;
  height: 150%;
  z-index: 2;
  pointer-events: none;
  top: -36px;
  left: -36px;
}

.member-modal__dragon {
  position: absolute;
  inset: 0;
  width: 140%;
  height: 140%;
  z-index: 3;
  pointer-events: none;
  top: -36px;
  left: -46px;
}

.member-modal__class-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.member-modal__identity {
  flex: 1;
  min-width: 0;
  padding-top: 0.35rem;
}

.member-modal__title {
  font-size: 1.35rem;
  font-weight: 700;
}

.member-modal__subtitle {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.member-modal__quote-row {
  margin-top: 0.45rem;
  min-width: 0;
}

.member-modal__section + .member-modal__section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.member-modal__heading {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-yellow);
  margin-bottom: 0.65rem;
}

.member-modal__none-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.35rem 0;
  list-style: none;
}

.member-modal__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.member-modal__item {
  display: grid;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(92, 40, 40, 0.55);
}

.member-modal__when {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.member-modal__event {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.member-modal__meta {
  font-size: 0.82rem;
  color: var(--brand-cream);
}

.member-modal__meta--muted {
  color: var(--text-muted);
  font-style: italic;
}
