:root {
  --bg: #0b0a10;
  --surface: #16141f;
  --surface-alt: #1e1b29;
  --border: #2a2636;
  --text: #ede9e3;
  --text-muted: #8b87a0;
  --mythic: #ff5a33;
  --legendary: #ffcc66;
  --epic: #e14fe0;
  --rare: #6ec7ff;
  --radius: 10px;
  --font-display: "Cinzel", serif;
  --font-body: "Inter", -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

/* ---------- Topbar ---------- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #120f18, #0b0a10);
  position: sticky;
  top: 0;
  z-index: 20;
  transform: translateZ(0);
  will-change: transform;
  isolation: isolate;
}

.topbar__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand__mark {
  color: var(--legendary);
  font-size: 22px;
}

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--legendary);
}

.brand__tag {
  color: var(--text-muted);
  font-size: 14px;
}

.intro {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 0;
}

.intro__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.intro__text {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 720px;
  margin: 0;
  line-height: 1.6;
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  align-items: start;
}

/* мобильные фиксы вынесены в самый конец файла - см. ниже,
   чтобы гарантированно побеждать в каскаде независимо от
   порядка остальных правил */
/* ---------- Filters ---------- */

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 90px;
}

.filters__title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  letter-spacing: 0.03em;
}

.filters__title--spaced { margin-top: 20px; }

.filters__hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.hero-picker-wrap {
  position: relative;
}

.hero-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 6px;
  padding-bottom: 6px;
}

.hero-picker-fade {
  position: absolute;
  left: 0;
  right: 6px;
  bottom: 0;
  height: 24px;
  background: linear-gradient(180deg, transparent, var(--surface));
  pointer-events: none;
}

.hero-picker__loading {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 0;
}

.hero-chip {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.hero-chip:hover { transform: translateY(-2px); }

.hero-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-chip.is-selected {
  border-color: var(--legendary);
  box-shadow: 0 0 0 2px rgba(255, 204, 102, 0.35);
}

.price-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-range input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
}

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

.selected-heroes { margin-top: 16px; }

.selected-heroes__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.selected-heroes__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 8px 3px 3px;
  font-size: 12px;
}

.selected-chip img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.selected-chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.12s ease;
}

.btn:hover { filter: brightness(1.08); }

.btn--block { width: 100%; margin-top: 10px; }

.btn--primary {
  background: var(--legendary);
  color: #241a06;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

/* ---------- Results ---------- */

.results__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.results__count {
  color: var(--text-muted);
  font-size: 14px;
}

.sort-select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  border-top: 3px solid var(--rarity, var(--border));
}

.account-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.account-card__heroes {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.account-card__heroes img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.account-card__price {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--legendary);
}

.account-card__meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge--mythic { color: var(--mythic); }
.badge--legendary { color: var(--legendary); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.pagination button.is-active {
  background: var(--legendary);
  color: #241a06;
  border-color: var(--legendary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

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

.modal__panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.modal-heroes img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.modal-resources {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.resource-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.account-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 13px;
}

.btn-copy {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 8px 0 0;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 24px;
}

.site-footer__inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.site-footer__muted {
  color: var(--text-muted);
  opacity: 0.8;
}

/* ---------- Small polish ---------- */

.filters {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.account-card {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.hero-chip.is-selected {
  box-shadow: 0 0 0 2px rgba(255, 204, 102, 0.35), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.results__count {
  min-height: 18px;
}

/* ---------- Мобильные фиксы (специально в самом конце файла,
   чтобы гарантированно побеждать в каскаде) ---------- */

@media (max-width: 860px) {
  .layout {
    display: block;
  }
  .filters {
    position: static !important;
    top: auto;
    margin-bottom: 24px;
  }
  .topbar {
    position: static !important;
  }
  .hero-picker {
    max-height: none !important;
    overflow: visible !important;
  }
  .hero-picker-fade {
    display: none;
  }
}
