:root {
  --bg: #05030b;
  --panel-strong: rgba(12, 9, 25, 0.97);
  --text: #f5f2ff;
  --muted: rgba(226, 219, 255, 0.64);
  --line: rgba(220, 207, 255, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
}

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(100, 63, 186, 0.14), transparent 28%),
    radial-gradient(circle at 82% 73%, rgba(33, 121, 169, 0.10), transparent 31%),
    linear-gradient(180deg, #07040e 0%, #040208 58%, #05030b 100%);
}

#viewport.is-dragging {
  cursor: grabbing;
}

#space {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#world {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
  z-index: 2;
}

.connections {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}

.connection-halo,
.connection-line {
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
}

.connection-halo {
  stroke: rgba(145, 101, 255, 0.10);
  stroke-width: 7;
}

.connection-line {
  stroke: rgba(190, 171, 255, 0.30);
  stroke-width: 1.15;
}

.creator {
  --size: 116px;
  --x: 0px;
  --y: 0px;
  position: absolute;
  left: 0;
  top: 0;
  width: var(--size);
  height: var(--size);
  transform:
    translate3d(
      calc(var(--x) - (var(--size) / 2)),
      calc(var(--y) - (var(--size) / 2)),
      0
    );
  transition:
    width 560ms cubic-bezier(.2,.8,.2,1),
    height 560ms cubic-bezier(.2,.8,.2,1),
    transform 900ms cubic-bezier(.16,.84,.22,1);
  contain: layout style;
  z-index: 2;
}

.creator-link {
  position: absolute;
  inset: 0;
  display: block;
  border: 0;
  border-radius: 50%;
  text-decoration: none;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}

.creator-orbit,
.creator-core,
.creator-avatar,
.creator-fallback {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.creator-orbit {
  inset: -10%;
  opacity: 0.55;
  border: 1px solid rgba(213, 194, 255, 0.24);
  box-shadow:
    0 0 18px rgba(133, 92, 255, 0.16),
    inset 0 0 18px rgba(172, 125, 255, 0.08);
  transition:
    opacity 220ms ease,
    transform 400ms cubic-bezier(.2,.8,.2,1),
    border-color 220ms ease,
    box-shadow 220ms ease;
}

.creator-core {
  overflow: hidden;
  background:
    radial-gradient(circle at 35% 25%, rgba(255,255,255,.12), transparent 34%),
    linear-gradient(145deg, rgba(126, 83, 212, .78), rgba(20, 15, 45, .92));
  border: 2px solid rgba(235, 226, 255, 0.62);
  box-shadow:
    0 0 0 5px rgba(156, 111, 255, 0.08),
    0 0 30px rgba(145, 92, 255, 0.28),
    0 10px 35px rgba(0, 0, 0, 0.42);
  transition:
    transform 280ms cubic-bezier(.16,.84,.22,1),
    box-shadow 280ms ease,
    border-color 280ms ease;
  will-change: transform;
}

.creator-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 300ms ease;
}

.creator-avatar.is-loaded {
  opacity: 1;
}

.creator-fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: calc(var(--size) * .23);
  letter-spacing: -0.04em;
  color: rgba(255,255,255,.94);
  text-shadow: 0 2px 14px rgba(0,0,0,.32);
}

.creator-stat {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  min-width: 118px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,.96);
}

.creator-stat-count {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(12px, calc(var(--size) * .105), 17px);
  line-height: 1.05;
  font-weight: 800;
  color: rgba(255,255,255,.94);
  white-space: nowrap;
}

.creator-stat-label {
  font-size: 9px;
  line-height: 1;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(211, 201, 239, .55);
}

.creator-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 20px);
  min-width: 205px;
  max-width: 300px;
  padding: 12px 14px;
  transform: translate(-50%, 9px) scale(.96);
  transform-origin: 50% 100%;
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(221, 210, 255, 0.18);
  border-radius: 14px;
  background: rgba(12, 9, 25, 0.93);
  backdrop-filter: blur(18px) saturate(130%);
  box-shadow:
    0 14px 38px rgba(0, 0, 0, 0.42),
    0 0 24px rgba(125, 80, 230, 0.13);
  transition:
    opacity 180ms ease,
    transform 220ms cubic-bezier(.2,.8,.2,1);
  z-index: 20;
}

.creator-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 10px;
  height: 10px;
  background: rgba(12, 9, 25, 0.93);
  border-right: 1px solid rgba(221, 210, 255, 0.18);
  border-bottom: 1px solid rgba(221, 210, 255, 0.18);
  transform: translate(-50%, -5px) rotate(45deg);
}

.tooltip-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 760;
  color: #fff;
}

.tooltip-count {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tooltip-open {
  display: block;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: rgba(133, 224, 255, .76);
}

.creator-link:hover .creator-core,
.creator-link:focus-visible .creator-core {
  transform: scale(1.14);
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 7px rgba(182, 132, 255, 0.12),
    0 0 48px rgba(168, 104, 255, 0.62),
    0 0 70px rgba(83, 208, 255, 0.24),
    0 14px 42px rgba(0, 0, 0, 0.44);
}

.creator-link:hover .creator-orbit,
.creator-link:focus-visible .creator-orbit {
  opacity: 1;
  transform: scale(1.18) rotate(10deg);
  border-color: rgba(212, 186, 255, 0.58);
  box-shadow:
    0 0 30px rgba(156, 92, 255, 0.42),
    inset 0 0 18px rgba(172, 125, 255, 0.14);
}

.creator-link:hover .creator-tooltip,
.creator-link:focus-visible .creator-tooltip {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.topbar {
  position: fixed;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  right: max(20px, env(safe-area-inset-right));
  height: 58px;
  pointer-events: none;
}

.brand-block {
  position: absolute;
  left: 0;
  top: 0;
  height: 58px;
  display: flex;
  align-items: center;
}

.brand-block h1 {
  margin: 0;
  padding: 10px 12px;
  font-size: clamp(21px, 2vw, 32px);
  line-height: 1;
  font-weight: 790;
  letter-spacing: -0.048em;
  color: rgba(255,255,255,.96);
  text-shadow:
    0 2px 18px rgba(0,0,0,.8),
    0 0 34px rgba(158, 116, 255, .24);
  /* Фикс: текст иногда пропадал из-за глюка композитинга поверх canvas —
     выносим заголовок на собственный слой GPU. */
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

.total-followers {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  min-width: 240px;
  height: 58px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 5px 18px 7px;
  border: 1px solid rgba(225, 214, 255, 0.10);
  border-radius: 18px;
  background: rgba(10, 7, 21, 0.46);
  backdrop-filter: blur(16px) saturate(125%);
  box-shadow: 0 10px 36px rgba(0,0,0,.18);
}

.total-label {
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(213, 203, 241, .52);
}

.total-followers strong {
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1;
  letter-spacing: -0.045em;
  color: rgba(255,255,255,.96);
  text-shadow: 0 0 22px rgba(162, 116, 255, .20);
}

.total-coverage {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1;
  color: rgba(153, 220, 255, .60);
}

.controls {
  position: fixed;
  z-index: 45;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.round-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: rgba(245, 241, 255, 0.86);
  background: rgba(13, 10, 27, 0.68);
  border: 1px solid rgba(225, 214, 255, 0.16);
  border-radius: 50%;
  backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 8px 30px rgba(0,0,0,.24);
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.round-button:hover {
  transform: scale(1.07);
  color: #fff;
  background: rgba(29, 21, 55, 0.84);
  border-color: rgba(222, 205, 255, 0.3);
}

.round-button:focus-visible {
  outline: 2px solid rgba(145, 218, 255, 0.9);
  outline-offset: 4px;
}

.round-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.info-panel {
  position: fixed;
  z-index: 70;
  top: 0;
  right: 0;
  width: min(390px, calc(100vw - 28px));
  height: 100%;
  padding:
    max(76px, calc(env(safe-area-inset-top) + 62px))
    28px
    max(30px, env(safe-area-inset-bottom))
    28px;
  overflow: auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(128, 76, 235, .20), transparent 34%),
    var(--panel-strong);
  border-left: 1px solid rgba(222, 209, 255, 0.12);
  backdrop-filter: blur(28px) saturate(125%);
  box-shadow: -24px 0 70px rgba(0,0,0,.48);
  transform: translateX(102%);
  transition: transform 360ms cubic-bezier(.16,.84,.22,1);
}

.info-panel.is-open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.8);
  border: 1px solid rgba(225, 214, 255, 0.14);
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  cursor: pointer;
}

.panel-close svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.info-kicker {
  margin-bottom: 14px;
  color: rgba(183, 151, 255, 0.82);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.info-panel p {
  margin: 0;
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.38;
  letter-spacing: -0.025em;
}

.info-panel .info-lead {
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.42;
}

.info-panel .info-lead strong {
  font-weight: 780;
  color: rgba(255, 255, 255, .97);
}

.info-panel .info-lead-sub {
  margin-top: 14px;
}

.info-panel .info-links {
  margin-top: 20px;
  font-size: 14px;
  line-height: 1.8;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: rgba(224, 216, 248, .82);
}

.info-panel .info-links a {
  color: rgba(158, 208, 255, .95);
  text-decoration: none;
  border-bottom: 1px solid rgba(158, 208, 255, .35);
  transition: color 160ms ease, border-color 160ms ease;
}

.info-panel .info-links a:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, .6);
}

.info-panel .info-small {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.info-divider {
  height: 1px;
  margin: 24px 0;
  background: var(--line);
}

.avatar-credit {
  display: inline-block;
  margin-top: 22px;
  color: rgba(220, 211, 255, 0.58);
  font-size: 11px;
  text-decoration: none;
  border-bottom: 1px solid rgba(220, 211, 255, 0.18);
}

.panel-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(3, 1, 8, .42);
  backdrop-filter: blur(2px);
  transition: opacity 260ms ease;
}

.panel-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.hud {
  position: fixed;
  z-index: 25;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 36px);
  padding: 8px 11px;
  color: rgba(225, 218, 247, .55);
  background: rgba(8, 6, 16, .46);
  border: 1px solid rgba(221, 208, 255, .08);
  border-radius: 999px;
  backdrop-filter: blur(13px);
  pointer-events: none;
  white-space: nowrap;
}

.hud-hint,
.hud-dot,
.data-status {
  font-size: 10px;
  line-height: 1;
}

.hud-separator {
  width: 1px;
  height: 12px;
  background: rgba(222, 210, 255, .13);
}

.data-status {
  color: rgba(182, 230, 255, .68);
  overflow: hidden;
  text-overflow: ellipsis;
}

.noscript {
  position: fixed;
  inset: auto 20px 20px;
  z-index: 100;
  padding: 14px 16px;
  color: white;
  background: #201838;
  border-radius: 12px;
}

@media (max-width: 850px) {
  .topbar {
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    height: 92px;
  }

  .brand-block {
    top: 0;
    height: 44px;
  }

  .brand-block h1 {
    padding: 8px 6px;
    font-size: 22px;
  }

  .total-followers {
    top: 46px;
    left: 6px;
    transform: none;
    min-width: 190px;
    height: 48px;
    justify-items: start;
    padding: 5px 12px 6px;
    border-radius: 14px;
  }

  .total-followers strong {
    font-size: 21px;
  }

  .controls {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .round-button {
    width: 42px;
    height: 42px;
  }

  .hud {
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }

  .hud-hint,
  .hud-dot,
  .hud-separator {
    display: none;
  }

  .data-status {
    max-width: calc(100vw - 52px);
  }

  .info-panel {
    width: min(360px, calc(100vw - 14px));
    padding-inline: 23px;
  }
}

@media (max-width: 520px) {
  .creator-stat-label {
    display: none;
  }

  .creator-stat {
    top: calc(100% + 7px);
  }

  .creator-stat-count {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Общий счётчик: кликабельный, без обрезаний ---------- */

.total-followers {
  pointer-events: auto;
  cursor: pointer;
  min-width: 250px;
  max-width: min(440px, 62vw);
  padding: 6px 22px 8px;
  white-space: nowrap;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.total-followers:hover {
  transform: translateX(-50%) scale(1.03);
  background: rgba(20, 14, 40, 0.62);
  border-color: rgba(222, 205, 255, 0.26);
  box-shadow:
    0 10px 36px rgba(0, 0, 0, .26),
    0 0 26px rgba(145, 92, 255, .16);
}

.total-followers:focus-visible {
  outline: 2px solid rgba(145, 218, 255, 0.9);
  outline-offset: 4px;
}

@media (max-width: 850px) {
  .total-followers:hover {
    transform: scale(1.03);
  }
}

/* ---------- Панель статистики: рейтинг по подписчикам ---------- */

.stats-total {
  display: grid;
  justify-items: start;
  gap: 3px;
  margin: 0 0 18px;
  padding: 14px 16px 15px;
  border: 1px solid rgba(225, 214, 255, 0.12);
  border-radius: 16px;
  background:
    radial-gradient(circle at 0% 0%, rgba(128, 76, 235, .16), transparent 55%),
    rgba(255, 255, 255, 0.03);
}

.stats-total-label {
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(213, 203, 241, .55);
}

.stats-total strong {
  font-size: clamp(26px, 5vw, 32px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .97);
  text-shadow: 0 0 22px rgba(162, 116, 255, .22);
}

.stats-total-meta {
  font-size: 11px;
  line-height: 1;
  color: rgba(153, 220, 255, .68);
}

.stats-list {
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stats-link {
  display: grid;
  grid-template-columns: 24px 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  text-decoration: none;
  color: var(--text);
  transition: background 150ms ease, border-color 150ms ease;
}

.stats-link:hover,
.stats-link:focus-visible {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(225, 214, 255, 0.12);
}

.stats-rank {
  font-size: 11px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgba(211, 201, 239, .5);
}

.stats-item.is-top-1 .stats-rank { color: #ffd76a; }
.stats-item.is-top-2 .stats-rank { color: #cfd6e4; }
.stats-item.is-top-3 .stats-rank { color: #e5a06b; }

.stats-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(145deg, rgba(126, 83, 212, .6), rgba(20, 15, 45, .9));
  border: 1px solid rgba(235, 226, 255, 0.24);
}

.stats-name {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stats-handle {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-bar {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.stats-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #70efff, #c57dff);
  transition: width 600ms cubic-bezier(.2,.8,.2,1);
}

.stats-count {
  font-size: 13px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: rgba(255, 255, 255, .93);
}

.stats-item.is-missing .stats-count {
  font-size: 11px;
  font-weight: 550;
  color: rgba(211, 201, 239, .45);
}

.stats-item.is-missing .stats-bar {
  display: none;
}

.stats-item.is-missing .stats-avatar,
.stats-item.is-missing .stats-handle {
  opacity: .62;
}
