:root {
  --bg: #0f141b;
  --panel: #17202b;
  --panel2: #1e2a38;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --line: #263341;
  --sidebar-bg: #131b24;
  --sidebar-active: #1f2b3a;
  --green: #22c55e;
  --amber: #f59e0b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ─────────── Оболочка ─────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 92px; flex: 0 0 92px; background: var(--sidebar-bg);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: stretch; padding: 14px 6px; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.sidebar-brand { text-align: center; margin-bottom: 16px; }
.sidebar-brand img { width: 100%; max-width: 72px; height: auto; display: inline-block; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-foot { margin-top: auto; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 12px 4px; border-radius: 12px; text-decoration: none; position: relative;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 3px; background: var(--accent);
}
.nav-ico { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; }
.nav-logout:hover { color: #ff8080; }

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.burger { display: none; border: 0; background: transparent; color: var(--text); font-size: 22px; cursor: pointer; padding: 0 4px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

.content { padding: 18px 20px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 12-колоночная сетка */
.grid12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; align-items: start; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
@media (max-width: 900px) { .grid12 > [class*="span-"] { grid-column: span 12; } }

/* Профиль игрока - JS-masonry: карточки раскладываются по колонкам, каждая
   в самую короткую - пустота под короткими заполняется нижними карточками. */
#player-body.grid12 { display: block; }
.pmason { display: flex; gap: 14px; align-items: flex-start; }
.pmason-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* Карточка */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--text);
}
.card-head .geo-select { margin-left: auto; }
.card-body { padding: 16px; }
.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.ic { display: inline-flex; width: 20px; justify-content: center; }
.ic-blue { color: var(--accent); }
.ic-green { color: var(--green); }
.ic-amber { color: var(--amber); }

/* Датапойнты */
.datapoint { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 14px; }
.dp-l { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.datapoint b { color: var(--text); font-size: 15px; }
.dp-hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

.stub { color: var(--muted); text-align: center; padding: 48px 16px; border: 1px dashed var(--line); border-radius: 14px; }
.muted { color: var(--muted); }

/* Профиль игрока */
.player-search { display: flex; gap: 8px; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; }
.search-box .search { width: 100%; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.sug-item { padding: 9px 14px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sug-item:hover { background: var(--panel2); }
.sug-sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.search { flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.btn { border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 10px 18px; font-size: 14px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.cnt { margin-left: auto; background: var(--panel2); color: var(--muted); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-rest { margin-top: 6px; }
.btn-more { margin-top: 8px; border: 0; background: var(--panel2); color: var(--accent); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.btn-more:hover { background: var(--sidebar-active); color: #fff; }

/* Сессии игрока */
.sess-body { max-height: 360px; overflow-y: auto; }
.sess-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.sess-row:last-child { border-bottom: 0; }
.sess-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sess-top b { font-size: 14px; color: var(--text); }
.sess-dur { color: var(--green); font-size: 13px; font-weight: 600; white-space: nowrap; }
.sess-when { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sess-meta { color: var(--muted); font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 13px; color: var(--text); word-break: break-all; }
.chip-link { cursor: pointer; }
.chip-link:hover { border-color: var(--accent); color: #fff; }
.tw-cat { margin-bottom: 14px; }
.tw-cat:last-child { margin-bottom: 0; }
.tw-cat-h { display: flex; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* Таблица игроков */
.search-sm { flex: 0 1 200px; margin-left: auto; padding: 6px 10px; font-size: 13px; background: var(--panel2); }
.card-head .search-sm { margin-left: auto; }
.card-head .geo-select { margin-left: 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--panel2); }
.tr-idx { color: var(--muted); width: 34px; }
.tr-name { font-weight: 600; }
.tr-last { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* База: doughnut + бары */
.doughnut-wrap { position: relative; width: 100%; height: 200px; }
.doughnut-wrap canvas { width: 100% !important; height: 100% !important; }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-lbl { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--panel2); height: 6px; border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-val { color: var(--muted); text-align: right; min-width: 40px; }

/* Новые игроки по дням (режим «Новые за 3 дня» в Точках входа) */
.np-day { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.np-day:last-child { margin-bottom: 0; }
.np-day-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.np-day + .np-day { margin-top: 2px; }

/* Тепловая карта активности */
.heat { display: flex; flex-direction: column; gap: 3px; overflow-x: auto; }
.heat-row { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 3px; align-items: center; min-width: 620px; }
.heat-lbl { color: var(--muted); font-size: 12px; }
.heat-h { color: var(--muted); font-size: 10px; text-align: center; }
.heat-cell { height: 20px; border-radius: 3px; }
.heat-tip { position: fixed; z-index: 100; background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: 12px; padding: 5px 9px; border-radius: 8px; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.35); }

/* Инвентарь игрока (визуализация как в игре) */
.inv-note { color: var(--amber, #f59e0b); font-size: 12px; margin-bottom: 10px; }
.inv-nodata { color: #f87171; }
.inv-block { margin-bottom: 14px; }
.inv-h { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 6px; }
/* Броня и рука - в один ряд снизу, слоты того же фикс. размера, что инвентарь */
.inv-armorline { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.inv-grid { display: grid; gap: 3px; }
.inv-hotbar { margin-top: 5px; }
.inv-slot { position: relative; aspect-ratio: 1/1; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: default; }
.inv-slot.empty { background: rgba(120,132,148,0.06); border-style: dashed; }
/* Зачарование: ванильный фиолетовый glint поверх предмета (маска = форма предмета).
   Два диагональных блика разной скорости (как в игре), плавное движение. */
.inv-glint {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;
  width: 82%; height: 82%;
  background:
    linear-gradient(115deg, transparent 38%, rgba(190,110,255,.75) 47%, rgba(230,180,255,.95) 50%, rgba(190,110,255,.75) 53%, transparent 62%),
    linear-gradient(115deg, transparent 40%, rgba(150,70,230,.55) 49%, rgba(200,140,255,.8) 50%, rgba(150,70,230,.55) 51%, transparent 60%);
  background-size: 260% 260%, 200% 200%;
  mix-blend-mode: screen;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  pointer-events: none;
  /* медленно переливается туда-обратно (alternate + ease-in-out), без рывка */
  animation: glint-scroll 6.5s ease-in-out infinite alternate;
}
@keyframes glint-scroll {
  from { background-position: 150% -50%, -50% 150%; }
  to   { background-position: -50% 150%,  150% -50%; }
}
.inv-abbr { font-size: 8px; line-height: 1.05; text-align: center; color: var(--muted); padding: 2px; word-break: break-word; align-items: center; justify-content: center; width: 100%; height: 100%; }
.inv-img { width: 82%; height: 82%; object-fit: contain; image-rendering: pixelated; image-rendering: crisp-edges; }
.inv-count { position: absolute; bottom: 0; right: 2px; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #000; }
.inv-tip { position: fixed; z-index: 250; background: #14161c; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-size: 12px; pointer-events: none; max-width: 280px; box-shadow: 0 8px 22px rgba(0,0,0,.5); }
.inv-tip .it-name { font-weight: 700; margin-bottom: 2px; }
.inv-tip .it-sub { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.inv-tip .it-ench { color: #c9b3f0; }
.inv-tip .it-eff { color: #8fd4ff; }
.inv-tip .it-lore { color: #9aa4b2; }
.inv-tip .it-cont-h { color: var(--muted); font-size: 11px; margin: 6px 0 3px; }
.inv-tip .it-cont { display: grid; grid-template-columns: repeat(9, 22px); gap: 2px; }
.it-cont-slot { position: relative; width: 22px; height: 22px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.it-cont-slot img { width: 18px; height: 18px; object-fit: contain; image-rendering: pixelated; }
.it-cont-slot b { position: absolute; bottom: -2px; right: 1px; font-size: 9px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #000; }
.it-cont-txt { font-size: 6px; color: var(--muted); text-align: center; line-height: 1; }

/* Кликабельный контейнер (шалкер) + окно его содержимого */
.inv-container { cursor: pointer; }
.inv-container::before { content: ""; position: absolute; inset: 0; border: 1.5px solid rgba(96,165,250,.6); border-radius: 5px; pointer-events: none; z-index: 2; }
.cont-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.cont-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 14px 44px rgba(0,0,0,.55); }
.cont-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.cont-close { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.cont-close:hover { color: #fff; }
.cont-body .inv-grid { grid-template-columns: repeat(9, 40px) !important; gap: 4px; }

/* Панель поиска в разделе Игроки */
.players-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }

/* События (действия) */
.events { display: flex; flex-direction: column; gap: 6px; }
.event-row { display: grid; grid-template-columns: 110px 130px 1fr 120px; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.ev-type { color: var(--muted); }
.ev-player { font-weight: 600; }
.ev-desc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-ts { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
@media (max-width: 820px) {
  .event-row { grid-template-columns: 1fr auto; gap: 4px; }
  .ev-desc, .ev-ts { grid-column: 1 / -1; }
}

/* ─────────── Гео ─────────── */
.geo-summary { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.geo-select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.geo-map-canvas { position: relative; width: 100%; aspect-ratio: 1.8 / 1; }
.geo-map-canvas canvas { width: 100% !important; height: 100% !important; }
.geo-top { display: flex; flex-direction: column; gap: 4px; }
.geo-row { display: grid; grid-template-columns: 22px 1fr auto 70px 46px; align-items: center; gap: 8px; padding: 5px 2px; font-size: 14px; }
.geo-flag { display: inline-flex; }
.flag { width: 20px; height: 15px; border-radius: 2px; vertical-align: middle; object-fit: cover; }
.geo-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-count { color: var(--text); font-weight: 600; text-align: right; }
.geo-bar { background: var(--panel2); height: 6px; border-radius: 3px; overflow: hidden; }
.geo-bar-fill { display: block; height: 100%; background: var(--accent); }
.geo-pct { color: var(--muted); font-size: 12px; text-align: right; }

/* ─────────── Мобильный: сайдбар оверлеем ─────────── */
@media (max-width: 820px) {
  .burger { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; width: 200px; flex-basis: 200px;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 16px; }
  .nav-ico { font-size: 18px; }
  .nav-label { font-size: 14px; }
  .sidebar-brand { text-align: left; padding-left: 12px; }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25;
  }
  .content { padding: 14px 12px; }
}

/* ─────────── Логин / гейт ─────────── */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.login-box { text-align: center; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 24px; }
.login-logo { margin-bottom: 12px; }
.login-logo img { width: 100%; max-width: 240px; height: auto; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 20px; }
.login-err { color: #ff6b6b; font-size: 13px; margin-bottom: 16px; }
.login-btn-wrap { display: flex; justify-content: center; min-height: 46px; }

.gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; z-index: 50;
}
.gate-box { text-align: center; max-width: 320px; }
.gate-emoji { font-size: 44px; margin-bottom: 12px; }
.gate-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.gate-sub { color: var(--muted); font-size: 14px; line-height: 1.5; }
