/* ── Токены ─────────────────────────────────────────────── */
:root {
  --bg: #0a0d13;
  --bg-glow: #18202f;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --muted: #8a94a6;
  --gold: #f0b43c;
  --gold-soft: #f4cf7d;
  --red: #ff4655;
  --font-display: 'Russo One', 'Arial Black', sans-serif;
  --font-body: 'Manrope', 'Helvetica Neue', Arial, sans-serif;
  --radius: 14px;
  --z-controls: 50;
  --z-modal: 100;
  --rainbow: conic-gradient(from var(--ang, 0deg),
    #ff5f5f, #ffb74d, #ffe66d, #6ee7a0, #5fd4f5, #b28bf7, #ff8ad4, #ff5f5f);
}

/* угол для вращения радужной рамки Божеств */
@property --ang {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* ── База ───────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; scrollbar-color: #2a3345 transparent; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: radial-gradient(80% 48% at 50% -8%, var(--bg-glow) 0%, var(--bg) 62%) fixed, var(--bg);
  min-height: 100dvh;
}

body.modal-open { overflow: hidden; }

::selection { background: rgba(240, 180, 60, 0.3); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

header, .controls, main, footer, .empty { position: relative; z-index: 1; }

/* ── Шапка ──────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 56px 16px 26px;
}

.overline {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* компенсирует трекинг последней буквы при центровке */
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 76px);
  line-height: 1.05;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  background: linear-gradient(180deg, #ffe9b0 0%, #e8b64c 55%, #a97817 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 28px rgba(232, 182, 76, 0.22));
}

.tagline {
  max-width: 460px;
  margin: 10px auto 0;
  font-size: 14.5px;
  color: var(--muted);
}

.stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 36px;
  margin-top: 26px;
}

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

.stat-num { font-family: var(--font-display); font-size: 26px; color: #fff; }

.stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* «Моя карточка» — постоянный вход под счётчиками */
.me-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.me-bar[hidden] { display: none; }

.me-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: #1a1206;
  background: linear-gradient(180deg, #ffd77a, var(--gold));
  box-shadow: 0 10px 26px -10px rgba(240, 180, 60, 0.6);
  text-decoration: none;
  transition: filter 0.15s, transform 0.15s;
}

.me-cta:hover { filter: brightness(1.06); transform: translateY(-1px); }

.me-cta-ghost {
  color: var(--gold-soft);
  background: rgba(240, 180, 60, 0.1);
  border: 1px solid rgba(240, 180, 60, 0.35);
  box-shadow: none;
}

/* ── Панель управления ──────────────────────────────────── */
.controls {
  position: sticky;
  top: 0;
  z-index: var(--z-controls);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 16px;
  background: rgba(10, 13, 19, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  min-height: 44px;
  padding: 0 15px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s;
}

.tab:hover { color: #fff; }

.tab[aria-pressed='true'] {
  background: rgba(240, 180, 60, 0.14);
  color: var(--gold-soft);
}

.search { position: relative; flex: 0 1 250px; min-width: 180px; }

.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 38px;
  font: inherit;
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.search input:focus {
  outline: none;
  border-color: rgba(240, 180, 60, 0.55);
  box-shadow: 0 0 0 3px rgba(240, 180, 60, 0.12);
}

.roles-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}

.roles-toggle:hover { color: #fff; }

.roles-toggle[aria-expanded='true'] {
  color: var(--gold-soft);
  border-color: rgba(240, 180, 60, 0.4);
}

.roles-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.roles-toggle[aria-expanded='true'] svg { transform: rotate(180deg); }

.roles-count {
  background: rgba(240, 180, 60, 0.18);
  color: var(--gold-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.roles-panel {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px 2px 4px;
}

.roles-panel[hidden] { display: none; }

.role-chip {
  min-height: 38px;
  padding: 5px 13px;
  font-size: 13px;
  color: #cfd6e2;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.role-chip b { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 2px; }

.role-chip:hover { color: #fff; border-color: rgba(255, 255, 255, 0.22); }

.role-chip[aria-pressed='true'] {
  background: rgba(240, 180, 60, 0.16);
  border-color: rgba(240, 180, 60, 0.55);
  color: var(--gold-soft);
}

.role-chip[aria-pressed='true'] b { color: inherit; }

.role-reset { color: #f08a8a; }
.role-reset:hover { color: #ffb3b3; border-color: rgba(255, 70, 85, 0.4); }

/* ── Секции и грид ──────────────────────────────────────── */
main { max-width: 1160px; margin: 0 auto; padding: 6px 16px 0; }

.roster-section { margin-top: 30px; }

.section-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.section-title::before {
  content: '';
  align-self: center;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--sc, var(--gold));
  box-shadow: 0 0 10px color-mix(in srgb, var(--sc, var(--gold)) 55%, transparent);
}

.section-deity .section-title::before {
  background: linear-gradient(180deg, #ff5f5f, #ffe66d, #6ee7a0, #5fd4f5, #b28bf7);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

.section-count {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 2px 8px;
}

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

/* ── Маршруты ───────────────────────────────────────────── */
.routes { display: flex; flex-direction: column; gap: 12px; }

.route-card {
  position: relative;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  animation: card-in 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.route-epic {
  border-color: transparent;
  background:
    linear-gradient(180deg, #131826, #0e131d) padding-box,
    linear-gradient(100deg, rgba(255,95,95,.6), rgba(255,230,109,.6), rgba(110,231,160,.6), rgba(95,212,245,.6), rgba(178,139,247,.6)) border-box;
}

.route-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.route-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.25;
  color: #fff;
}

.route-run {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 2px 7px;
  vertical-align: 2px;
}

.route-num {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

.route-peaks { margin-top: 9px; }
.route-peaks .chip { font-size: 12px; padding: 4px 10px; }
.route-nopeak { margin-top: 8px; font-size: 12.5px; color: var(--muted); font-style: italic; }

.route-crew { margin-top: 12px; cursor: pointer; }

/* веер мини-карточек участников */
.fan { display: flex; flex-wrap: wrap; align-items: center; row-gap: 6px; padding-left: 4px; }

.fan-card {
  flex: 0 0 auto;
  width: 34px;
  height: 45px;
  margin-left: -10px;
  border-radius: 7px;
  border: 1.5px solid #0d1119;
  outline: 1px solid color-mix(in srgb, var(--rc) 55%, transparent);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, hsl(var(--h) 55% 30%), hsl(var(--h) 50% 14%));
  transform: rotate(-4deg);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), margin 0.22s, box-shadow 0.2s;
}

.fan-card:nth-child(even) { transform: rotate(4deg); }
.fan-card img { width: 100%; height: 100%; object-fit: cover; }

.fan-card span {
  font-family: var(--font-display);
  font-size: 12px;
  color: hsl(var(--h) 70% 85% / 0.95);
}

.fan-card.gone img, .fan-card.gone span { filter: grayscale(0.85) brightness(0.85); }

.route-crew:hover .fan-card, .route-crew.open .fan-card {
  margin-left: -2px;
  transform: rotate(0deg);
}

.fan-card:hover {
  transform: translateY(-4px) rotate(0deg) scale(1.12);
  box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--rc) 70%, transparent);
  z-index: 2;
}

.fan-rest {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.route-names {
  display: none;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 10px;
}

.route-crew.open .route-names { display: flex; }

.name-link {
  font-size: 12.5px;
  color: #b9c2d1;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
  padding: 1px 0;
}

.name-link:hover { color: var(--gold-soft); border-bottom-color: var(--gold); }

.route-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.route-count {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-right: auto;
}

.route-actions .btn { margin-top: 0; }

/* ── Карточка героя ─────────────────────────────────────── */
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.card {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0d1119;
  overflow: hidden;
  animation: card-in 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.3, 1), border-color 0.2s, box-shadow 0.2s;
  /* сила ауры и свечения самоцвета — задаётся рангом */
  --gs: 40%;
  --gg: 8px;
}

.card:hover, .card:focus-visible {
  transform: translateY(-4px) scale(1.045);
  border-color: color-mix(in srgb, var(--rc) 70%, transparent);
  box-shadow:
    0 10px 24px -12px rgba(0, 0, 0, 0.6),
    0 14px 34px -10px color-mix(in srgb, var(--rc) var(--gs), transparent),
    0 0 0 1px color-mix(in srgb, var(--rc) 25%, transparent);
  z-index: 2;
}

/* блик при наведении */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.09) 50%, transparent 58%);
  transform: translateX(-130%);
  transition: transform 0.55s ease-out;
  pointer-events: none;
  z-index: 2;
}

.card:hover::after { transform: translateX(130%); }

.card .art { position: absolute; inset: 0; }

.art {
  display: block;
  background: radial-gradient(
    130% 100% at 50% 0%,
    hsl(var(--h) 60% 30%) 0%,
    hsl(var(--h) 50% 16%) 52%,
    hsl(222 30% 7%) 100%
  );
}

.art-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%; /* лица обычно в верхней трети */
}

/* фото на карточке: плавный зум при наведении */
.card .art-photo {
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.card:hover .art-photo, .card:focus-visible .art-photo {
  transform: scale(1.09);
}

/* киношная виньетка поверх фото, чтобы карточка не была «сырой» */
.art:has(.art-photo)::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 8, 12, 0.22) 0%, transparent 28%, transparent 55%, rgba(6, 8, 12, 0.6) 100%);
  pointer-events: none;
}

/* в профиле фото медленно «дышит» (кен-бёрнс) */
@keyframes kenburns {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(1.08) translateY(-2%); }
}

.art-big .art-photo {
  animation: kenburns 14s ease-in-out infinite alternate;
}

.art-peaks {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 58%;
}

.art-peaks path { fill: hsl(var(--h) 50% 10%); }
.art-peaks .far { fill: hsl(var(--h) 45% 24% / 0.5); }

.art-initials {
  position: absolute;
  left: 50%;
  top: 38%;
  translate: -50% -50%;
  font-family: var(--font-display);
  font-size: 34px;
  color: hsl(var(--h) 75% 82% / 0.95);
  text-shadow: 0 0 26px hsl(var(--h) 80% 60% / 0.5);
}

/* самоцвет ранга */
.gem {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: var(--rc);
  box-shadow: 0 0 var(--gg) var(--rc);
  z-index: 3;
}

/* ── Лестница редкости ──────────────────────────────────── */
/* Новобранец: вообще не светится */
.rank-recruit { --gs: 0%; --gg: 0px; }

/* Путник: чуть-чуть, с аурой листвы при наведении */
.rank-pathfinder { --gs: 22%; --gg: 4px; }

.leaves { position: absolute; inset: 0; pointer-events: none; z-index: 2; }

.leaves i {
  position: absolute;
  bottom: 36%;
  width: 8px;
  height: 8px;
  background: #6ee7a0;
  border-radius: 0 70% 0 70%;
  opacity: 0;
}

.leaves i:nth-child(1) { left: 22%; }
.leaves i:nth-child(2) { left: 50%; }
.leaves i:nth-child(3) { left: 74%; }

@keyframes leaf {
  0% { opacity: 0; transform: translateY(0) rotate(0deg); }
  20% { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-36px) rotate(70deg); }
}

.rank-pathfinder:hover .leaves i, .rank-pathfinder:focus-visible .leaves i {
  animation: leaf 1.8s ease-out infinite;
}

.rank-pathfinder:hover .leaves i:nth-child(2) { animation-delay: 0.55s; }
.rank-pathfinder:hover .leaves i:nth-child(3) { animation-delay: 1s; }

/* Рыцарь → Легенда: свечение нарастает */
.rank-knight { --gs: 34%; --gg: 6px; }
.rank-mythic { --gs: 46%; --gg: 9px; }
.rank-legend { --gs: 60%; --gg: 12px; }

/* Божество: радужная рамка и аура — вау, но в пределах нормы */
@keyframes deity-spin { to { --ang: 360deg; } }

@keyframes deity-aura {
  0%   { box-shadow: 0 0 22px -6px rgba(255, 95, 95, 0.5); }
  17%  { box-shadow: 0 0 22px -6px rgba(255, 183, 77, 0.5); }
  34%  { box-shadow: 0 0 22px -6px rgba(255, 230, 109, 0.45); }
  50%  { box-shadow: 0 0 22px -6px rgba(110, 231, 160, 0.5); }
  67%  { box-shadow: 0 0 22px -6px rgba(95, 212, 245, 0.5); }
  84%  { box-shadow: 0 0 22px -6px rgba(178, 139, 247, 0.5); }
  100% { box-shadow: 0 0 22px -6px rgba(255, 95, 95, 0.5); }
}

@keyframes deity-aura-hover {
  0%   { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(255, 95, 95, 0.75); }
  17%  { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(255, 183, 77, 0.75); }
  34%  { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(255, 230, 109, 0.7); }
  50%  { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(110, 231, 160, 0.75); }
  67%  { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(95, 212, 245, 0.75); }
  84%  { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(178, 139, 247, 0.75); }
  100% { box-shadow: 0 12px 30px -8px rgba(0,0,0,.6), 0 0 44px -2px rgba(255, 95, 95, 0.75); }
}

/* сверкание радужного ромба */
@keyframes deity-gem {
  0%   { box-shadow: 0 0 10px 2px rgba(255, 95, 95, 0.75); }
  20%  { box-shadow: 0 0 13px 3px rgba(255, 230, 109, 0.85); }
  40%  { box-shadow: 0 0 13px 3px rgba(110, 231, 160, 0.85); }
  60%  { box-shadow: 0 0 13px 3px rgba(95, 212, 245, 0.85); }
  80%  { box-shadow: 0 0 13px 3px rgba(178, 139, 247, 0.85); }
  100% { box-shadow: 0 0 10px 2px rgba(255, 95, 95, 0.75); }
}

.rank-deity {
  border: 2px solid transparent;
  background: linear-gradient(#0d1119, #0d1119) padding-box, var(--rainbow) border-box;
  animation: card-in 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) backwards,
             deity-spin 5s linear infinite,
             deity-aura 6s linear infinite;
}

.rank-deity:hover, .rank-deity:focus-visible {
  border-color: transparent;
  animation: deity-spin 3s linear infinite, deity-aura-hover 4s linear infinite;
}

.rank-deity .gem {
  background: conic-gradient(#ff5f5f, #ffb74d, #ffe66d, #6ee7a0, #5fd4f5, #b28bf7, #ff5f5f);
  animation: deity-spin 4s linear infinite, deity-gem 3.2s linear infinite;
  filter: hue-rotate(var(--ang, 0deg));
  transition: transform 0.2s;
}

/* при наведении ромб сверкает заметно сильнее */
.rank-deity:hover .gem, .rank-deity:focus-visible .gem {
  transform: rotate(45deg) scale(1.4);
  animation: deity-spin 2s linear infinite, deity-gem 1.1s linear infinite;
}

/* Создатель: красная полоса вместо самоцвета, жёсткая обводка */
.rank-creator {
  --gs: 65%;
  border-color: rgba(255, 70, 85, 0.65);
  box-shadow: 0 0 24px -8px rgba(255, 70, 85, 0.5);
}

@keyframes stripe-breathe {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 70, 85, 0.6); }
  50% { box-shadow: 0 0 24px rgba(255, 70, 85, 1); }
}

@keyframes stripe-gleam {
  0% { transform: translateX(-130%) skewX(-22deg); }
  45%, 100% { transform: translateX(340%) skewX(-22deg); }
}

.stripe {
  position: absolute;
  top: 17px;
  right: -32px;
  width: 110px;
  height: 13px;
  transform: rotate(45deg);
  background: linear-gradient(180deg, #ff6b78, var(--red) 60%, #c81e2e);
  box-shadow: 0 0 14px rgba(255, 70, 85, 0.8);
  z-index: 3;
  overflow: hidden;
  animation: stripe-breathe 2.6s ease-in-out infinite;
}

/* белая молния, пробегающая по ленте */
.stripe::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 36%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), transparent);
  animation: stripe-gleam 2.6s ease-in-out infinite;
}

/* нижняя плашка с именем */
.plate {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 26px 7px 9px;
  text-align: center;
  background: linear-gradient(180deg, transparent 0%, rgba(6, 8, 12, 0.94) 58%);
}

.plate-title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--rc);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s, transform 0.2s;
}

.card:hover .plate-title, .card:focus-visible .plate-title {
  opacity: 1;
  transform: none;
}

.plate-name {
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1.3;
  color: #fff;
}

.plate-name i { font-style: normal; color: rgba(244, 207, 125, 0.9); }

/* уехавшие: приглушены, оживают при наведении */
.card.gone .art { filter: grayscale(0.85) brightness(0.82); transition: filter 0.25s; }
.card.gone:hover .art, .card.gone:focus-visible .art { filter: none; }

/* ── Пустой результат ───────────────────────────────────── */
.empty { text-align: center; padding: 70px 16px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: 0.45; margin-bottom: 10px; }

footer {
  text-align: center;
  padding: 48px 16px 30px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Модалка профиля ────────────────────────────────────── */
#modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.22s ease-out;
}

#modal[hidden] { display: none; }
#modal.open { opacity: 1; }

.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 86dvh;
  display: grid;
  grid-template-columns: 236px 1fr;
  grid-template-rows: minmax(0, 1fr); /* иначе контент обрезается вместо скролла */
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--rc) 40%, transparent);
  background: linear-gradient(180deg, #141a26 0%, #0e131d 100%);
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.7),
    0 0 44px -16px var(--rc);
  transform: scale(0.95) translateY(12px);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.3, 1.08);
}

#modal.open .modal-card { transform: none; }

.modal-card.rank-deity {
  border: 2px solid transparent;
  background: linear-gradient(180deg, #141a26 0%, #0e131d 100%) padding-box, var(--rainbow) border-box;
  animation: deity-spin 6s linear infinite, deity-aura 6s linear infinite;
}

.modal-card.rank-creator {
  border-color: rgba(255, 70, 85, 0.55);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 44px -14px var(--red);
}

.modal-art-slot { position: relative; }

.art-big { position: relative; width: 100%; height: 100%; min-height: 320px; }

.art-big .art-initials { font-size: 58px; top: 40%; }

.modal-body { padding: 24px 26px 26px; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(13, 17, 25, 0.75);
  color: #cfd6e2;
  transition: background-color 0.15s, color 0.15s;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.modal-close svg { width: 17px; height: 17px; }

.rank-pill {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: #0b0e14;
  background: var(--rc);
  border-radius: 999px;
  padding: 4px 11px;
  box-shadow: 0 0 16px -4px var(--rc);
}

.rank-deity .rank-pill {
  background: linear-gradient(90deg, #ff5f5f, #ffb74d, #ffe66d, #6ee7a0, #5fd4f5, #b28bf7);
  box-shadow: 0 0 16px -4px rgba(255, 255, 255, 0.5);
}

.rank-creator .rank-pill { background: var(--red); color: #fff; box-shadow: 0 0 16px -4px var(--red); }

.modal-name {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.2;
}

.modal-name i { font-style: normal; color: var(--gold-soft); }

.modal-title-line { margin-top: 2px; font-size: 14px; font-weight: 600; color: var(--gold); }

.modal-quote {
  margin: 13px 0 0;
  padding-left: 12px;
  border-left: 3px solid color-mix(in srgb, var(--rc) 65%, transparent);
  font-size: 14.5px;
  font-style: italic;
  color: #b9c2d1;
}

.modal-quote::before { content: '« '; }
.modal-quote::after { content: ' »'; }

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 4px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 11px 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tile-num { font-family: var(--font-display); font-size: 20px; color: #fff; }

.tile-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
}

.rank-place {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.rank-place b { color: var(--gold-soft); font-family: var(--font-display); font-weight: 400; }

.rating-bar {
  height: 6px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.rating-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 45%, #fff), var(--rc));
  box-shadow: 0 0 10px var(--rc);
  transform: scaleX(0); /* анимируем transform — без дёрганий на слабых телефонах */
  transform-origin: left;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.modal-sub {
  margin: 16px 0 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

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

.chip {
  padding: 5px 11px;
  font-size: 13px;
  color: #cfd6e2;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chip b { color: var(--gold-soft); }

.chip-role {
  color: #e6ebf3;
  background: color-mix(in srgb, var(--rc) 13%, transparent);
  border-color: color-mix(in srgb, var(--rc) 45%, transparent);
}

/* вершины 2000–2500 м — крепкие */
.chip-solid {
  border-color: rgba(240, 180, 60, 0.55);
  color: #f4cf7d;
}

/* вершины и маршруты 2500 м+ — эпик, радужная метка */
.chip-epic {
  border: 1px solid transparent;
  background: linear-gradient(#141824, #141824) padding-box,
    linear-gradient(100deg, #ff5f5f, #ffb74d, #ffe66d, #6ee7a0, #5fd4f5, #b28bf7) border-box;
  color: #fff;
}

.chip-epic b { color: #ffe66d; }

.peaks-empty { font-size: 13px; color: var(--muted); font-style: italic; }

.modal-status { margin-top: 18px; font-size: 13px; color: var(--muted); }

/* соцсети героя — рядом с именем */
.socials { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

.soc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #cfd6e2;
  font-size: 12.5px;
  font-weight: 700;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.soc-link svg { width: 14px; height: 14px; }

.soc-tg { border-color: rgba(42, 171, 238, 0.45); background: rgba(42, 171, 238, 0.12); color: #7cc8f5; }
.soc-tg:hover { background: rgba(42, 171, 238, 0.22); color: #a8dcfa; }

.soc-ig { border-color: rgba(225, 48, 108, 0.45); background: rgba(225, 48, 108, 0.1); color: #f087ac; }
.soc-ig:hover { background: rgba(225, 48, 108, 0.2); color: #ffabc8; }

.soc-tt { border-color: rgba(37, 244, 238, 0.35); background: rgba(37, 244, 238, 0.08); color: #6fe3e0; }
.soc-tt:hover { background: rgba(37, 244, 238, 0.16); color: #a2f1ef; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}

.dot-active { background: #46d17c; box-shadow: 0 0 8px rgba(70, 209, 124, 0.8); }
.dot-gone { background: #8b93a3; }

/* ── Адаптив ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero { padding-top: 40px; }
  .stats { gap: 10px 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 9px; }

  /* табы в одну строку с горизонтальным скроллом — их уже четыре */
  .tabs {
    flex: 1 1 100%;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 0 12px; font-size: 13px; }

  .fan-card { width: 30px; height: 40px; }

  #modal { padding: 0; align-items: flex-end; }

  .modal-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr); /* арт фиксирован, тело скроллится */
    width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    transform: translateY(30px);
  }

  .art-big { min-height: 175px; height: 175px; }
  .art-big:has(.art-photo) { min-height: 250px; height: 250px; } /* фото на телефоне — больше кадра */
  .art-big .art-initials { font-size: 44px; top: 42%; }
  .modal-body { padding: 18px 18px 26px; }
}

/* ── Кнопки, формы, шторка, тост ────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  transition: filter 0.15s, background-color 0.15s;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: linear-gradient(180deg, #ffd77a, var(--gold));
  color: #1a1206;
  width: 100%;
  margin-top: 18px;
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-sm { min-height: 38px; padding: 0 13px; font-size: 13px; margin-top: 8px; }

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

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.03em;
  color: #1a1206;
  background: linear-gradient(180deg, #ffd77a, var(--gold));
  box-shadow: 0 12px 32px -8px rgba(240, 180, 60, 0.6);
  transition: filter 0.15s, transform 0.15s;
}

.fab:hover { filter: brightness(1.06); transform: translateY(-1px); }
.fab svg { width: 18px; height: 18px; }
.fab[hidden] { display: none; }

.fab-set {
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  min-height: 46px;
  width: 46px;
  padding: 0;
  justify-content: center;
  background: rgba(24, 31, 44, 0.92);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.6);
}

.fab-set:hover { color: #fff; }
.fab-set svg { width: 19px; height: 19px; }

.f-hint { margin: 6px 0 2px; font-size: 12px; color: var(--muted); }

.role-manage { display: inline-flex; align-items: center; gap: 7px; padding-right: 6px; }
.role-manage b { color: var(--muted); font-size: 11px; }

.chip-x {
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  transition: color 0.15s, background-color 0.15s;
}

.chip-x:hover { color: #ffb3b3; }

.chip-x.armed {
  color: #fff;
  background: var(--red);
  font-size: 11px;
  padding: 0 8px;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.add-row .btn { margin-top: 0; }

/* вершины в форме хайка */
.peak-chip { display: inline-flex; align-items: center; gap: 6px; padding-right: 6px; }
.peak-chip b { font-size: 11px; font-weight: 700; opacity: 0.85; }

.hf-name-input { margin-top: 6px; }

.picker {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.picker[hidden] { display: none; }

.pk-list {
  max-height: 34dvh;
  overflow-y: auto;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pk-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

.pk-item:hover { background: var(--surface-2); }
.pk-item[hidden] { display: none; }
.pk-item b { font-size: 12px; white-space: nowrap; }

.pk-tier-epic { color: #ffe66d; }
.pk-tier-solid { color: var(--gold-soft); }
.pk-tier-base { color: var(--muted); }

.pk-alt-input { width: 110px; }

.hike-list { display: flex; flex-direction: column; gap: 6px; }

.hike-row-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  text-align: left;
}

.hike-row-btn b { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.hike-row-btn:hover { background: var(--surface-2); }

.btn-danger { width: 100%; margin-top: 10px; color: #f08a8a; }
.btn-danger.armed { background: var(--red); color: #fff; border-color: transparent; }

.hue-row { display: flex; flex-wrap: wrap; gap: 8px; }

.hue-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(var(--hd) 60% 45%);
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.hue-dot[aria-pressed='true'] {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 12px hsl(var(--hd) 70% 50% / 0.7);
}

.photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-row .btn { margin-top: 0; }
.photo-row .f-hint { margin: 0; }

/* кадрирование фото */
.crop-box {
  position: relative;
  max-width: 100%;
  /* пропорция и ширина задаются инлайном из cropStep — они всегда совпадают с выходным кадром */
  margin: 10px auto 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(240, 180, 60, 0.45);
  background: #000;
  touch-action: none;
  cursor: grab;
}

.crop-box:active { cursor: grabbing; }

.crop-box img {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.crop-zoom-row input[type='range'] { flex: 1; accent-color: var(--gold); }

.crop-actions { display: flex; gap: 8px; margin-top: 8px; }
.crop-actions .btn { margin-top: 0; flex: 1; }

.fs-btn {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.fs-btn:hover { color: #fff; }
.fs-btn svg { width: 17px; height: 17px; }
.fs-btn[hidden] { display: none; }

/* в полноэкранном режиме контент не должен лезть под статусбар */
body.tg-fullscreen .hero {
  padding-top: calc(56px + var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
}

body.tg-fullscreen .controls {
  top: calc(var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
}

#sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

#sheet[hidden] { display: none; }
#sheet.open { opacity: 1; }

.sheet-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #141a26 0%, #0e131d 100%);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  /* нижний запас = высота клавиатуры, чтобы последнее поле можно было поднять над ней */
  padding: 24px 22px calc(24px + var(--kb, 0px));
  transform: translateY(14px);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1.05);
}

#sheet.open .sheet-card { transform: none; }

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(13, 17, 25, 0.75);
  color: #cfd6e2;
}

.sheet-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sheet-close svg { width: 16px; height: 16px; }

.sheet-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 6px;
  padding-right: 44px;
}

.f-label {
  display: block;
  margin: 14px 0 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.f-input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  font: inherit;
  font-size: 16px; /* меньше 16px — iOS зумит страницу при фокусе */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.f-input:focus {
  outline: none;
  border-color: rgba(240, 180, 60, 0.55);
  box-shadow: 0 0 0 3px rgba(240, 180, 60, 0.12);
}

select.f-input { appearance: none; }

.peak-row {
  display: grid;
  grid-template-columns: 1fr 118px 42px;
  gap: 6px;
  margin-bottom: 6px;
}

.row-x {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
}

.row-x:hover { color: #ffb3b3; border-color: rgba(255, 70, 85, 0.4); }
.row-x svg { width: 14px; height: 14px; }

#hf-crew { margin-top: 2px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  translate: -50% 0;
  z-index: 140;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(24, 31, 44, 0.95);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: none; }
.toast[hidden] { display: none; }

@media (max-width: 640px) {
  /* шторка садится над клавиатурой, а не под ней */
  #sheet { padding: 0 0 var(--kb, 0px); align-items: flex-end; }
  .sheet-card {
    width: 100%;
    max-height: calc(92dvh - var(--kb, 0px));
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding-bottom: 24px;
  }
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .card:hover, .card:focus-visible { transform: none; }
  .card::after { display: none; }
  .rank-deity, .rank-deity:hover, .modal-card.rank-deity { animation: none; box-shadow: 0 0 22px -6px rgba(178, 139, 247, 0.5); }
  .rank-deity .gem { animation: none; }
  .leaves i { animation: none !important; }
  .stripe { animation: none; }
  .stripe::after { display: none; }
  .art-big .art-photo { animation: none; }
}
