:root {
  --bg: #0b0c14;
  --bg-2: #11121d;
  --card: #171827;
  --card-2: #1e1f31;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --text: #eef0f8;
  --muted: #8d91ab;
  --t: #ff9f1c;
  --ct: #5b78ff;
  --smoke: #d5dbea;
  --flash: #ffe45c;
  --molotov: #ff5b36;
  --he: #6fdc84;
  --danger: #ff5470;
  --fav: #ffc93c;
  --brand: linear-gradient(115deg, #ff8a00 0%, #a13fc4 52%, #2d1fff 100%);
  --radius: 16px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: -20vh -20vw auto;
  height: 60vh;
  background: radial-gradient(60% 60% at 15% 0%, rgba(255, 138, 0, .12), transparent 70%),
              radial-gradient(60% 60% at 85% 0%, rgba(45, 31, 255, .16), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
svg { width: 1em; height: 1em; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #8f7bff; outline-offset: 2px; }

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 16px;
  background: rgba(11, 12, 20, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-back { margin-left: -8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { border-radius: 10px; display: block; }
.brand-name { font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: 16px; line-height: 1.05; }
.brand-name small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: none; color: var(--muted); }
.premium-badge {
  display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 999px; vertical-align: 2px;
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .06em;
}
.top-spacer { flex: 1; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 22px;
  color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); }
html.tg .top-back { display: none !important; }

main { max-width: 1280px; margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-b)); }

.boot { display: grid; place-items: center; height: 60vh; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: #b98cff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Map select ---------- */
.page-title { margin: 8px 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.page-sub { margin: 0 0 20px; color: var(--muted); }
.maps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 4 / 3;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
  text-align: left;
  isolation: isolate;
  transition: transform .15s ease, border-color .15s ease;
}
.map-card img {
  position: absolute; inset: -10%; width: 120%; height: 120%;
  object-fit: cover; opacity: .55; z-index: -2;
  transition: transform .4s ease;
}
.map-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 30%, rgba(11, 12, 20, .92));
}
.map-card.active { border-color: transparent; background: var(--brand) border-box; }
.map-card.active::before {
  content: ""; position: absolute; inset: 1px; border-radius: calc(var(--radius) - 1px);
  background: var(--card); z-index: -3;
}
.map-card.active:hover { transform: translateY(-2px); }
.map-card.active:hover img { transform: scale(1.04); }
.map-card .map-name { font-size: 20px; font-weight: 800; }
.map-card .map-meta { color: var(--muted); font-size: 13px; }
.map-card.soon { cursor: default; opacity: .55; }
.map-card.soon .map-meta::before { content: "🔒 "; }

/* ---------- Map view ---------- */
.mapview { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.mapview > * { min-width: 0; }
@media (min-width: 960px) {
  .mapview { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .panel { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100dvh - var(--header-h) - 32px); overflow: auto; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.map-title { font-size: 22px; font-weight: 800; margin: 0 auto 0 0; }

.seg {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
}
.seg button {
  padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { color: #fff; }
.seg button.t[aria-pressed="true"] { background: var(--t); color: #1b1000; }
.seg button.ct[aria-pressed="true"] { background: var(--ct); }
.seg.floors button[aria-pressed="true"] { background: var(--card-2); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 960px) { .chips { margin: 0; padding: 0; width: 100%; } }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
}
.chip svg { font-size: 16px; }
.chip[aria-pressed="true"] { background: var(--card-2); border-color: var(--line-2); color: var(--text); }
.chip .count { font-size: 12px; opacity: .6; font-variant-numeric: tabular-nums; }
.chip[data-g="smoke"] svg { color: var(--smoke); }
.chip[data-g="flash"] svg { color: var(--flash); }
.chip[data-g="molotov"] svg { color: var(--molotov); }
.chip[data-g="he"] svg { color: var(--he); }
.chip[data-g="fav"] svg { color: var(--fav); }

.radar-wrap { display: flex; justify-content: center; }
.radar {
  position: relative;
  width: min(100%, calc((100dvh - var(--header-h) - 180px) * var(--ar, 1)));
  min-width: min(100%, 340px);
  aspect-ratio: var(--ar, 1);
  border-radius: 20px;
  background: #000;
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: pan-x pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.radar.zoomed { touch-action: none; cursor: grab; }
.radar.panning { cursor: grabbing; }
.radar-stage { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.radar-stage > img { position: absolute; inset: 2%; width: 96%; height: 96%; pointer-events: none; -webkit-user-drag: none; }
.zoom-reset {
  position: absolute; right: 10px; bottom: 10px; z-index: 6;
  padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 700;
  background: rgba(11, 12, 20, .85); color: #fff; border: 1px solid var(--line-2);
}
.zoom-reset[hidden] { display: none; }
.radar .layer { position: absolute; inset: 2%; }
.radar svg.lines { position: absolute; inset: 2%; width: 96%; height: 96%; pointer-events: none; overflow: visible; }
.lines line {
  stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linecap: round;
  stroke-dasharray: 6 6; animation: dash 1s linear infinite;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, .8));
}
.lines line.active { stroke-dasharray: none; stroke-width: 3.5; }
@keyframes dash { to { stroke-dashoffset: -12; } }

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 17px;
  transition: opacity .2s, transform .15s;
}
.marker::before { /* увеличенная зона нажатия для пальца */
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
}
.marker.target {
  color: var(--c);
  background: rgba(11, 12, 20, .85);
  border: 2px solid var(--c);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent), 0 4px 10px rgba(0, 0, 0, .5);
}
.marker.target:hover { transform: translate(-50%, -50%) scale(1.12); }
.marker.target.dim { opacity: .28; }
.marker.target.selected { transform: translate(-50%, -50%) scale(1.2); z-index: 3; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent), 0 4px 10px rgba(0, 0, 0, .5); }
  100% { box-shadow: 0 0 0 14px transparent, 0 4px 10px rgba(0, 0, 0, .5); }
}
.marker .badge-count {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: #fff; color: #111; font-size: 11px; font-weight: 800; line-height: 17px; text-align: center;
}
.marker.throw {
  width: 26px; height: 26px; z-index: 4;
  background: var(--c); color: #fff; font-size: 13px; font-weight: 800;
  border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .6);
  animation: pop .25s ease-out both;
}
.marker.throw.t { color: #1b1000; }
.marker.throw.active { transform: translate(-50%, -50%) scale(1.25); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0); } }

.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- Panel / list ---------- */
.panel { display: flex; flex-direction: column; gap: 10px; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 17px; flex: 1; }
.panel-intro { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel-intro h2 { margin: 0 0 8px; font-size: 18px; }
.panel-intro ol { margin: 0; padding-left: 20px; color: var(--muted); }
.panel-intro li + li { margin-top: 4px; }
@media (max-width: 959px) { .panel-intro { display: none; } }

.lineup-list { display: grid; gap: 8px; }
.lineup-item {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center;
  padding: 8px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  text-align: left; transition: border-color .15s, background .15s;
}
.lineup-item:hover, .lineup-item.active { border-color: var(--line-2); background: var(--card-2); }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .num {
  position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--c); color: #fff; border: 1.5px solid #fff;
}
.thumb .num.t { color: #1b1000; }
.lineup-item .li-title { font-weight: 700; line-height: 1.25; }
.lineup-item .li-meta { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- Badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: rgba(255, 255, 255, .07); color: var(--text);
}
.badge.side-t { background: color-mix(in srgb, var(--t) 22%, transparent); color: var(--t); }
.badge.side-ct { background: color-mix(in srgb, var(--ct) 25%, transparent); color: #9aaeff; }
.badge.g svg { color: var(--c); font-size: 14px; }

/* ---------- Detail ---------- */
.detail { display: flex; flex-direction: column; gap: 14px; }
.player {
  position: relative; border-radius: 14px; overflow: hidden; background: #000;
  aspect-ratio: 16 / 9; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  -webkit-touch-callout: none; /* без меню «Сохранить видео» по долгому нажатию на iOS */
  user-select: none; -webkit-user-select: none;
}
.player:fullscreen { border-radius: 0; aspect-ratio: auto !important; width: 100%; height: 100%; }
.player:-webkit-full-screen { border-radius: 0; aspect-ratio: auto !important; width: 100%; height: 100%; }
.player video { pointer-events: none; } /* клики обрабатывает обёртка — у <video> не будет меню */
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.player .big-play {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px; color: #fff;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.player.paused .big-play { opacity: 1; }
.player .loading {
  position: absolute; inset: 0; margin: auto; width: 34px; height: 34px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff;
  animation: spin .8s linear infinite; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.player.waiting .loading { opacity: 1; }
.player-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px;
  padding: 18px 6px 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.player-bar .icon-btn { width: 36px; height: 36px; font-size: 18px; }
.player-bar .speed { width: auto; padding: 0 10px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.player-progress { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.player-progress i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; transform: scaleX(0); }

.detail h2 { margin: 0; font-size: 21px; line-height: 1.2; }
.route { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; }
.minimap { position: relative; aspect-ratio: var(--ar, 1); border-radius: 12px; background: #000; border: 1px solid var(--line); }
.minimap img { position: absolute; inset: 4%; width: 92%; height: 92%; }
.minimap svg { position: absolute; inset: 4%; width: 92%; height: 92%; overflow: visible; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.desc { margin: 0; white-space: pre-line; color: #d4d7e6; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 700;
  background: var(--card-2); border: 1px solid var(--line-2);
}
.btn:hover { background: #26283d; }
.btn.primary { background: var(--brand); border: 0; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.fav-btn svg { font-size: 18px; }
.btn.fav-btn[aria-pressed="true"] { color: var(--fav); border-color: color-mix(in srgb, var(--fav) 45%, transparent); background: color-mix(in srgb, var(--fav) 10%, var(--card-2)); }
.li-fav { color: var(--fav); margin-right: 5px; vertical-align: -2px; }
.more h3 { margin: 6px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* ---------- Bottom sheet (мобильные) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55);
  animation: fade .2s ease-out;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(20px + var(--safe-b));
  background: var(--bg-2); border-top: 1px solid var(--line-2);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5);
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet-grip { display: flex; justify-content: center; align-items: center; position: relative; height: 26px; margin: 0 -16px 6px; touch-action: none; cursor: grab; }
.sheet-grip::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
.sheet-grip .icon-btn { position: absolute; right: 8px; top: -2px; width: 34px; height: 34px; font-size: 18px; color: var(--muted); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

@media (min-width: 960px) {
  .sheet-backdrop { display: none !important; }
  .sheet {
    left: auto; right: max(16px, calc((100vw - 1280px) / 2 + 16px)); bottom: auto;
    top: calc(var(--header-h) + 16px); width: 400px; max-height: calc(100dvh - var(--header-h) - 32px);
    border: 1px solid var(--line-2); border-radius: 20px; padding: 8px 16px 18px;
    animation: fade .2s ease-out;
  }
  .sheet-grip { cursor: default; }
  .sheet-grip::before { display: none; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 60; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px; background: #fff; color: #111; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: fade .2s;
}
.noscript { text-align: center; padding: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
