:root {
  --bg: #0b0221;
  --glass: rgba(22, 9, 48, 0.58);
  --glass-strong: rgba(24, 10, 52, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #fbf7ff;
  --muted: rgba(236, 226, 255, 0.7);
  --faint: rgba(236, 226, 255, 0.45);
  --pink: #ff2d95;
  --red: #ff1f4b;
  --orange: #ff7a3d;
  --gold: #ffd23f;
  --cyan: #2ee6ff;
  --violet: #9b5cff;
  --good: #3dffa8;
  --bad: #ff7b8f;
  --radius: 18px;
  --font-display: 'Unbounded', system-ui, sans-serif;
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
b { font-weight: 800; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }
.labels-layer { position: absolute; inset: 0; pointer-events: none; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 40px rgba(5, 0, 20, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.muted { color: var(--muted); font-size: 12px; font-weight: 600; }
.up { color: var(--good); }
.down { color: var(--bad); }

/* ---------- раскладка ---------- */

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px;
  pointer-events: none;
}
#hud > *, .topbar > * { pointer-events: auto; }
.topbar { pointer-events: none !important; }

.topbar { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 14px; }

.top-left { justify-self: start; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; max-width: 100%; }
.demo-bar { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 14px; }
.demo-bar[hidden] { display: none; }
.demo-bar .seg { padding: 2px; }
.demo-bar .seg button { padding: 5px 9px; }
.channel { display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; max-width: 100%; }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
  background: linear-gradient(135deg, var(--red), var(--pink) 50%, var(--violet));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 0 20px rgba(255, 45, 149, 0.5);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.ch-meta { min-width: 0; }
.ch-handle, .ch-status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { max-width: 240px; }
.ch-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.ch-handle { font-size: 12px; color: var(--faint); font-weight: 600; }
.ch-status { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.dot[data-kind='ok'] { background: var(--good); box-shadow: 0 0 10px var(--good); animation: blink 1.6s ease-in-out infinite; }
.dot[data-kind='demo'] { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.dot[data-kind='error'] { background: var(--bad); box-shadow: 0 0 10px var(--bad); }

/* ---------- главный счётчик ---------- */

.counter { justify-self: center; text-align: center; padding: 12px 36px 14px; min-width: 340px; position: relative; }
.counter::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: linear-gradient(110deg, var(--pink), var(--gold), var(--cyan), var(--violet), var(--pink));
  background-size: 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: flow 6s linear infinite;
}
.counter.bump { animation: bump 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
.odometer {
  display: flex; justify-content: center; margin: 6px 0 4px;
  font-family: var(--font-display); font-weight: 800; font-size: clamp(44px, 5.4vw, 78px);
  line-height: 1; height: 1em; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  filter: drop-shadow(0 0 18px rgba(255, 45, 149, 0.65));
}
.odo-digit { display: block; height: 1em; overflow: hidden; -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); }
.odo-strip { display: flex; flex-direction: column; transition: transform 1.2s cubic-bezier(0.18, 1.1, 0.3, 1); will-change: transform; }
.odo-strip > span { display: block; height: 1em; text-align: center; }
.odo-sep { width: 0.28em; }
.counter-sub { display: flex; justify-content: center; gap: 14px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- кнопки ---------- */

.toolbar { justify-self: end; display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn.accent { background: linear-gradient(135deg, rgba(255, 45, 149, 0.5), rgba(155, 92, 255, 0.5)); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 14px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-strong);
  transition: background 0.2s, transform 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.15); }
.btn:active { transform: scale(0.97); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.gold { background: rgba(255, 210, 63, 0.16); border-color: rgba(255, 210, 63, 0.5); }
.btn.primary { background: linear-gradient(135deg, var(--pink), var(--violet)); border-color: transparent; box-shadow: 0 6px 24px rgba(255, 45, 149, 0.4); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { padding: 14px 28px; font-size: 16px; border-radius: 14px; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); gap: 2px; }
.seg button, .seg label { padding: 7px 14px; border-radius: 9px; border: 0; background: none; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on, .seg label:has(input:checked) { background: linear-gradient(135deg, rgba(255, 45, 149, 0.55), rgba(155, 92, 255, 0.55)); color: var(--text); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg.wide { display: flex; }
.seg.wide label { flex: 1; text-align: center; }

/* ---------- левая колонка ---------- */

.stats { grid-column: 1; grid-row: 2; pointer-events: none !important; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; scrollbar-width: none; transition: opacity 0.4s, transform 0.4s; }
.stats::-webkit-scrollbar { display: none; }
.stats > * { pointer-events: auto; }
.card { padding: 12px 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { padding: 8px 11px; border-radius: 12px; background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.06); min-width: 0; }
.tile.wide { grid-column: span 2; }
.tile.bump { animation: tile-flash 0.8s ease-out; }
.t-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.t-value { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile.wide .t-value { font-size: 23px; }
.tile.slim { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; }
.tile.slim .t-value { font-size: 17px; grid-row: span 2; margin: 0; }
.tile.slim .t-delta { min-height: 0; }
.t-delta { font-size: 11px; color: var(--faint); font-weight: 700; margin-top: 2px; min-height: 14px; }
.t-delta.up { color: var(--good); }
.t-delta.down { color: var(--bad); }

.lv { display: grid; grid-template-columns: 104px 1fr; grid-template-rows: auto 1fr; column-gap: 10px; color: inherit; text-decoration: none; }
.lv[href]:hover .lv-title { color: var(--cyan); }
.lv-thumb { grid-row: span 2; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: linear-gradient(135deg, #3a0f6e, #ff2d95 60%, #ff7a3d); display: grid; place-items: center; }
.lv-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lv-play { width: 34px; height: 24px; border-radius: 8px; background: var(--red); display: grid; place-items: center; font-size: 11px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.lv-title { font-weight: 700; font-size: 12px; margin: 0 0 4px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lv-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); font-weight: 700; }

.hint { font-size: 12px; color: var(--faint); margin: 10px 0 0; font-weight: 600; }

/* ---------- награды ---------- */

.rewards { grid-column: 3; grid-row: 2; align-self: start; max-height: 100%; padding: 14px; display: flex; flex-direction: column; min-height: 0; transition: opacity 0.4s, transform 0.4s; }
.pill { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: rgba(255, 210, 63, 0.16); color: var(--gold); }
.reward-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; margin-right: -6px; padding-right: 6px; }
.reward {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; cursor: pointer;
  padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07);
  transition: transform 0.2s, background 0.3s, border-color 0.3s, opacity 0.3s;
}
.reward:hover { transform: translateX(-3px); background: rgba(255, 255, 255, 0.08); }
.reward.flash { animation: tile-flash 1s ease-out; }
.rw-badge { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: rgba(255, 255, 255, 0.07); }
.rw-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rw-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rw-top b { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.rw-status { font-size: 11px; font-weight: 700; color: var(--faint); white-space: nowrap; }
.rw-title { font-weight: 800; font-size: 13px; }
.rw-prize { font-size: 12px; color: var(--muted); line-height: 1.35; }
.rw-bar { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: 6px; display: none; }
.rw-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--gold)); transition: width 1s; }
.reward[data-state='done'] { border-color: color-mix(in srgb, var(--tier) 55%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--tier) 18%, transparent), rgba(255, 255, 255, 0.03)); }
.reward[data-state='done'] .rw-badge { background: color-mix(in srgb, var(--tier) 30%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--tier) 50%, transparent); }
.reward[data-state='done'] .rw-status { color: var(--good); }
.reward[data-state='next'], .reward[data-state='close'] { border-color: rgba(255, 210, 63, 0.55); background: rgba(255, 210, 63, 0.07); }
.reward[data-state='next'] .rw-bar, .reward[data-state='close'] .rw-bar { display: block; }
.reward[data-state='next'] .rw-status, .reward[data-state='close'] .rw-status { color: var(--gold); }
.reward[data-state='close'] { animation: glow-gold 1.4s ease-in-out infinite; }
.reward[data-state='locked'] { opacity: 0.6; }
.reward[data-state='locked'] .rw-badge { filter: grayscale(0.85); }

/* ---------- тосты ---------- */

.toasts { grid-column: 2; grid-row: 2; align-self: end; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none !important; padding-bottom: 6px; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 10px; border-radius: 99px;
  font-weight: 800; font-size: 14px; background: rgba(20, 8, 44, 0.8); border: 1px solid var(--line-strong);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: toast-in 0.4s cubic-bezier(0.2, 1.4, 0.4, 1); max-width: min(560px, 90vw);
}
.toast .ti { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: rgba(255, 255, 255, 0.1); flex: none; }
.toast.subs { border-color: rgba(255, 45, 149, 0.7); box-shadow: 0 0 20px rgba(255, 45, 149, 0.35); }
.toast.likes { border-color: rgba(255, 79, 163, 0.5); }
.toast.views { border-color: rgba(46, 230, 255, 0.5); }
.toast.video { border-color: rgba(255, 210, 63, 0.6); }
.toast.unsubs { border-color: rgba(255, 123, 143, 0.5); color: var(--bad); }
.toast.error { border-color: rgba(255, 123, 143, 0.7); font-weight: 700; font-size: 13px; }
.toast.info { font-weight: 700; font-size: 13px; }
.toast.bump { animation: bump 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }
.toast.out { animation: toast-out 0.35s ease-in forwards; }

/* ---------- нижняя панель ---------- */

.goal {
  grid-column: 1 / -1; grid-row: 3;
  display: grid; grid-template-columns: minmax(290px, 1.15fr) minmax(320px, 2fr) minmax(240px, 1fr);
  gap: 28px; padding: 16px 22px; align-items: center;
}
.next { display: flex; gap: 16px; align-items: center; min-width: 0; }
.next-badge {
  --tier: var(--gold);
  flex: none; width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center; font-size: 38px;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--tier) 55%, transparent), color-mix(in srgb, var(--tier) 10%, transparent));
  border: 1px solid color-mix(in srgb, var(--tier) 60%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--tier) 35%, transparent);
}
.goal[data-close='true'] .next-badge { animation: glow-gold 1.1s ease-in-out infinite; }
.next-info { flex: 1; min-width: 0; }
.next-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-title span { font-family: var(--font); font-weight: 800; color: var(--muted); font-size: 15px; }
.next-left { font-size: 14px; color: var(--muted); font-weight: 600; margin: 2px 0 8px; }
.next-left b { color: var(--text); font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.bar { position: relative; height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; overflow: hidden; background: linear-gradient(90deg, var(--pink), var(--orange), var(--gold)); box-shadow: 0 0 16px rgba(255, 45, 149, 0.6); transition: width 1s cubic-bezier(0.2, 0.9, 0.3, 1); }
.bar i::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent); transform: translateX(-100%); animation: shimmer 2.2s ease-in-out infinite; }
.goal[data-close='true'] .bar i { background: linear-gradient(90deg, var(--orange), var(--gold), #fff2a8); box-shadow: 0 0 22px rgba(255, 210, 63, 0.8); }
.next-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.next-meta span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nextPct { font-family: var(--font-display); color: var(--text); }
.goal[data-close='true'] #nextHint { color: var(--gold); }

.route-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.route-track { position: relative; height: 62px; margin: 10px 20px 0; }
.route-line { position: absolute; left: 0; right: 0; top: 15px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); }
.route-line i { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #ff2d95, #ff7a3d, #ffd23f, #2ee6ff, #9b5cff); box-shadow: 0 0 14px rgba(255, 45, 149, 0.5); clip-path: inset(0 100% 0 0 round 99px); transition: clip-path 1s cubic-bezier(0.2, 0.9, 0.3, 1); }
.route-start { position: absolute; left: 0; top: 18px; width: 12px; height: 12px; translate: -50% -50%; border-radius: 50%; background: var(--pink); box-shadow: 0 0 10px var(--pink); }
.node { position: absolute; top: 0; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: 0; padding: 0; cursor: pointer; }
.node-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: #1a0a35; border: 2px solid rgba(255, 255, 255, 0.18); transition: transform 0.2s, box-shadow 0.3s, border-color 0.3s; }
.node:hover .node-dot { transform: scale(1.12); }
.node-label { font-family: var(--font-display); font-size: 11px; font-weight: 700; color: var(--muted); }
.node[data-state='done'] .node-dot { border-color: var(--tier); background: color-mix(in srgb, var(--tier) 30%, #1a0a35); box-shadow: 0 0 14px color-mix(in srgb, var(--tier) 70%, transparent); }
.node[data-state='done'] .node-label { color: var(--text); }
.node[data-state='next'] .node-dot, .node[data-state='close'] .node-dot { border-color: var(--gold); animation: ring 1.6s ease-out infinite; }
.node[data-state='locked'] .node-dot { filter: grayscale(0.85) brightness(0.8); }
.route-me { position: absolute; top: 18px; width: 14px; height: 14px; translate: -50% -50%; border-radius: 50%; background: #fff; z-index: 2; pointer-events: none; box-shadow: 0 0 0 4px rgba(255, 31, 75, 0.55), 0 0 18px var(--red); transition: left 1s cubic-bezier(0.2, 0.9, 0.3, 1); }

.trend { min-width: 0; }
.chart { position: relative; height: 78px; margin-top: 6px; cursor: crosshair; }
.chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-svg .axis { stroke: rgba(255, 255, 255, 0.12); stroke-width: 1; }
.chart-svg .trend-line { fill: none; stroke: var(--pink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .lbl { fill: var(--faint); font: 700 10px var(--font); }
.chart-svg .cross { stroke: rgba(255, 255, 255, 0.4); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .dot { fill: var(--pink); stroke: #1a0a35; stroke-width: 2; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--faint); font-weight: 600; }
.chart-empty[hidden] { display: none; }
.chart-tip { position: absolute; top: -30px; padding: 4px 9px; border-radius: 8px; white-space: nowrap; font-size: 12px; font-weight: 700; background: rgba(10, 3, 25, 0.92); border: 1px solid var(--line-strong); pointer-events: none; }
.forecast { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.forecast b { color: var(--text); }

/* ---------- 3D-подписи ---------- */

.gate-label {
  --tier: var(--gold);
  display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 99px;
  background: rgba(14, 4, 32, 0.74); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff;
  white-space: nowrap; cursor: pointer; pointer-events: auto; user-select: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.4s, box-shadow 0.4s, transform 0.25s;
}
.gate-label:hover { transform: scale(1.07); }
.gl-badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: rgba(255, 255, 255, 0.08); }
.gl-text { display: flex; flex-direction: column; line-height: 1.15; }
.gl-text b { font-family: var(--font-display); font-size: 15px; font-weight: 800; }
.gl-text small { font-size: 11px; color: var(--muted); font-weight: 700; }
.gate-label[data-state='done'] { border-color: var(--tier); box-shadow: 0 0 20px color-mix(in srgb, var(--tier) 55%, transparent); }
.gate-label[data-state='done'] .gl-badge { background: color-mix(in srgb, var(--tier) 35%, transparent); }
.gate-label[data-state='next'] { border-color: rgba(255, 210, 63, 0.7); }
.gate-label[data-state='close'] { border-color: var(--gold); animation: glow-gold 1s ease-in-out infinite; }
.gate-label[data-state='locked'] .gl-badge { filter: grayscale(0.9); }
.gate-label.flash { animation: label-flash 1s ease-out; }

.pop span {
  display: block; font-family: var(--font-display); font-weight: 900; font-size: 26px; color: #fff;
  text-shadow: 0 0 14px var(--pink), 0 2px 0 rgba(0, 0, 0, 0.3);
  animation: pop-rise 1.8s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

/* ---------- праздник ---------- */

.celebrate {
  --tier: var(--gold);
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(20, 5, 45, 0.2), rgba(6, 1, 16, 0.78));
  opacity: 0; transition: opacity 0.45s;
}
.celebrate[hidden] { display: none; }
.celebrate.show { opacity: 1; }
.rays {
  position: absolute; left: 50%; top: 45%; width: 170vmax; height: 170vmax; translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--tier) 32%, transparent) 0deg 7deg, transparent 7deg 20deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 52%);
  mask-image: radial-gradient(circle, #000 0%, transparent 52%);
  animation: spin 40s linear infinite;
}
.cel-card {
  position: relative; text-align: center; padding: 30px 44px 30px; border-radius: 28px; max-width: min(540px, 92vw);
  background: rgba(22, 8, 48, 0.85); border: 1px solid color-mix(in srgb, var(--tier) 65%, transparent);
  box-shadow: 0 0 90px color-mix(in srgb, var(--tier) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(0.6) translateY(40px); transition: transform 0.7s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.celebrate.show .cel-card { transform: none; }
.cel-kicker { font-family: var(--font-display); letter-spacing: 0.2em; text-transform: uppercase; font-size: 13px; font-weight: 700; color: var(--gold); }
.cel-emoji { font-size: 112px; line-height: 1.15; margin: 6px 0 2px; filter: drop-shadow(0 0 30px var(--tier)); animation: float 2.6s ease-in-out infinite; }
.cel-value {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(28px, 5vw, 46px); line-height: 1.1;
  background: linear-gradient(90deg, #fff, var(--tier), #fff); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: flow 3s linear infinite;
}
.cel-title { font-size: 20px; font-weight: 800; margin-top: 6px; }
.cel-prize { margin: 18px auto 22px; padding: 12px 18px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); border: 1px dashed rgba(255, 255, 255, 0.28); font-weight: 700; font-size: 15px; }
.cel-prize .kicker { display: block; margin-bottom: 4px; }
.cel-prize[hidden] { display: none; }

/* ---------- настройки ---------- */

dialog.settings {
  width: min(780px, 94vw); max-height: 88vh; padding: 0; color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
dialog.settings::backdrop { background: rgba(5, 1, 15, 0.6); backdrop-filter: blur(4px); }
.settings form { display: flex; flex-direction: column; max-height: 88vh; }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px; }
.dlg-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.dlg-foot { justify-content: flex-end; border-top: 1px solid var(--line); }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 24px 12px; }
.dlg-body section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dlg-body section:last-child { border-bottom: 0; }
.dlg-body h3 { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
.live-fields { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; transition: opacity 0.3s; }
.settings:not([data-mode='server']) .server-only,
.settings:not([data-mode='demo']) .demo-only,
.settings:not([data-mode='live']) .live-only { display: none; }
.mode-note { margin-top: 10px; }
.admin-field { margin-top: 14px; max-width: 320px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.input-row { display: flex; gap: 8px; }
.settings input[type='text'], .settings input[type='password'], .settings input[type='number'], .settings input:not([type]) {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; outline: none; min-width: 0;
}
.settings input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(46, 230, 255, 0.18); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.test-result { font-size: 13px; font-weight: 700; }
.test-result.ok { color: var(--good); }
.test-result.err { color: var(--bad); }
.note { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }
.note .warn { color: var(--bad); font-weight: 700; }
.howto { font-size: 13px; color: var(--muted); }
.howto summary { cursor: pointer; font-weight: 800; color: var(--cyan); }
.howto ol { padding-left: 20px; line-height: 1.6; }
.howto a { color: var(--cyan); }
code, kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); }
.ms-head, .ms-row { display: grid; grid-template-columns: 110px 60px 1fr 1.4fr 34px; gap: 8px; align-items: center; }
.ms-head { font-size: 11px; font-weight: 800; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.ms-row { margin-bottom: 6px; }
.ms-emoji { text-align: center; font-size: 18px !important; padding-inline: 4px !important; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pink); }
.form-error { flex: 1; color: var(--bad); font-size: 13px; font-weight: 700; }

/* ---------- загрузка ---------- */

#loading {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 60%, #3a0f6e, #0b0221 65%); transition: opacity 0.9s;
}
#loading.hide { opacity: 0; pointer-events: none; }
.ld { text-align: center; padding: 0 16px; }
.ld-logo { width: 96px; animation: float 1.6s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255, 31, 75, 0.7)); }
.ld-title { font-family: var(--font-display); font-weight: 900; font-size: 32px; margin-top: 18px; }
.ld-text { color: var(--muted); font-weight: 600; margin-top: 8px; line-height: 1.5; }

/* ---------- режим трансляции ---------- */

body.clean .stats { opacity: 0; transform: translateX(-30px); pointer-events: none; }
body.clean .rewards { opacity: 0; transform: translateX(30px); pointer-events: none; }
body.clean .toolbar { opacity: 0.12; transition: opacity 0.3s; }
body.clean .toolbar:hover { opacity: 1; }

/* ---------- адаптив ---------- */

@media (max-width: 1240px) {
  #hud { grid-template-columns: 250px minmax(0, 1fr) 260px; }
  .goal { grid-template-columns: minmax(270px, 1fr) minmax(300px, 1.6fr); }
  .trend { display: none; }
}

/* награды дублируются точками маршрута внизу — на средних экранах прячем колонку */
@media (max-width: 1100px) {
  #hud { grid-template-columns: 250px minmax(0, 1fr); }
  .rewards { display: none; }
  .toasts { grid-column: 2; }
  .demo-bar .kicker { display: none; }
}

@media (max-width: 860px) {
  #hud { grid-template-columns: minmax(0, 1fr); padding: 10px 16px; gap: 10px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .counter { grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%; padding: 10px 16px; }
  .channel { padding: 6px 12px 6px 6px; }
  .demo-bar .kicker, .demo-bar [data-add] { display: none; }
  .avatar { width: 40px; height: 40px; font-size: 18px; }
  .ch-handle { display: none; }
  .ch-title { max-width: 150px; font-size: 13px; }
  .toolbar { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
  #btnClean { display: none; }
  .stats, .rewards { display: none; }
  .toasts { grid-column: 1; }
  .toast { font-size: 12px; padding: 5px 12px 5px 6px; }
  .toast .ti { width: 22px; height: 22px; font-size: 12px; }
  .goal { grid-template-columns: 1fr; gap: 12px; padding: 12px 14px; }
  .next-badge { width: 56px; height: 56px; font-size: 30px; border-radius: 16px; }
  .route-track { margin-inline: 16px; }
  .grid3 { grid-template-columns: 1fr; }
  .ms-head { display: none; }
  .ms-row { grid-template-columns: 90px 54px 1fr 34px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .ms-prize { grid-column: 1 / -2; }
}

/* ---------- анимации ---------- */

@keyframes flow { to { background-position: 300% 0; } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes tile-flash { 0% { background: rgba(255, 45, 149, 0.35); } 100% { background: rgba(255, 255, 255, 0.045); } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
@keyframes glow-gold { 50% { box-shadow: 0 0 26px rgba(255, 210, 63, 0.75); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.6); } 100% { box-shadow: 0 0 0 12px rgba(255, 210, 63, 0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(0.95); } }
@keyframes pop-rise { 0% { opacity: 0; transform: translateY(10px) scale(0.5); } 15% { opacity: 1; transform: translateY(0) scale(1.15); } 100% { opacity: 0; transform: translateY(-70px) scale(1); } }
@keyframes label-flash { 0% { transform: scale(1); } 30% { transform: scale(1.35); box-shadow: 0 0 40px var(--tier); } 100% { transform: scale(1); } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes float { 50% { transform: translateY(-10px); } }

@media (prefers-reduced-motion: reduce) {
  .rays, .counter::before, .bar i::after, .cel-emoji, .ld-logo { animation: none; }
}

/* ======================================================================
   Тема «Матрица»
   ====================================================================== */

.ld-matrix { display: none; }

html[data-theme='matrix'] {
  --bg: #000;
  --glass: rgba(0, 12, 4, 0.74);
  --glass-strong: rgba(0, 10, 3, 0.95);
  --line: rgba(0, 255, 65, 0.2);
  --line-strong: rgba(0, 255, 65, 0.45);
  --text: #d6ffe0;
  --muted: rgba(120, 255, 160, 0.74);
  --faint: rgba(120, 255, 160, 0.46);
  --pink: #00ff41;
  --red: #ff2b2b;
  --orange: #39ff88;
  --gold: #c6ff00;
  --cyan: #00ffa3;
  --violet: #00b84d;
  --good: #00ff41;
  --bad: #ff5c5c;
  --radius: 6px;
  --font-display: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --font: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

/* строки развёртки и виньетка, как на старом мониторе */
html[data-theme='matrix'] body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.22) 2px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55));
}
html[data-theme='matrix'] body { text-shadow: 0 0 6px rgba(0, 255, 65, 0.28); }
html[data-theme='matrix'] .glass {
  box-shadow: 0 0 0 1px rgba(0, 255, 65, 0.05), 0 0 24px rgba(0, 255, 65, 0.08), inset 0 0 30px rgba(0, 255, 65, 0.04);
}
html[data-theme='matrix'] .kicker::before { content: '> '; color: var(--pink); }
html[data-theme='matrix'] .counter .kicker::after { content: '_'; animation: caret 1s steps(1) infinite; }
html[data-theme='matrix'] .counter::before { background: linear-gradient(110deg, #00ff41, #003d10, #c8ffd9, #003d10, #00ff41); background-size: 300% 100%; }

/* счётчик-«дешифратор» */
html[data-theme='matrix'] .odometer { filter: drop-shadow(0 0 16px rgba(0, 255, 65, 0.75)); color: #c8ffd9; letter-spacing: 0; }
.dc { display: inline-block; width: 0.62em; text-align: center; }
.dc.scr { color: var(--pink); opacity: 0.85; }
.dc-sep { display: inline-block; width: 0.3em; }

html[data-theme='matrix'] .avatar { background: #000; color: var(--pink); box-shadow: 0 0 0 1px var(--pink), 0 0 16px rgba(0, 255, 65, 0.5); }
html[data-theme='matrix'] .icon-btn.accent,
html[data-theme='matrix'] .btn.primary,
html[data-theme='matrix'] .seg button.on,
html[data-theme='matrix'] .seg label:has(input:checked) {
  background: rgba(0, 255, 65, 0.16);
  border: 1px solid rgba(0, 255, 65, 0.7);
  color: #d6ffe0;
  box-shadow: 0 0 14px rgba(0, 255, 65, 0.3);
}
html[data-theme='matrix'] .btn.gold { background: rgba(198, 255, 0, 0.1); border-color: rgba(198, 255, 0, 0.5); }
html[data-theme='matrix'] .tile { background: rgba(0, 255, 65, 0.035); border-color: rgba(0, 255, 65, 0.1); }
html[data-theme='matrix'] .t-label { font-size: 11px; }
html[data-theme='matrix'] .t-value { font-size: 16px; }
html[data-theme='matrix'] .tile.wide .t-value { font-size: 21px; }
html[data-theme='matrix'] .t-delta { font-size: 10px; }
html[data-theme='matrix'] .ch-title { font-size: 14px; }
html[data-theme='matrix'] .next-title span, html[data-theme='matrix'] .next-left { font-size: 13px; }
html[data-theme='matrix'] .lv-thumb { background: #001a08; border: 1px solid var(--line); }
html[data-theme='matrix'] .pill { background: rgba(198, 255, 0, 0.12); }

html[data-theme='matrix'] .bar i { background: linear-gradient(90deg, #00802b, #00ff41, #c8ffd9); box-shadow: 0 0 16px rgba(0, 255, 65, 0.7); }
html[data-theme='matrix'] .goal[data-close='true'] .bar i { background: linear-gradient(90deg, #00ff41, #c6ff00, #f4ffc0); box-shadow: 0 0 22px rgba(198, 255, 0, 0.8); }
html[data-theme='matrix'] .route-line i { background: linear-gradient(90deg, #00802b, #00ff41, #7dff9a, #00ffa3, #c8ffd9); box-shadow: 0 0 14px rgba(0, 255, 65, 0.6); }
html[data-theme='matrix'] .route-start { background: var(--pink); box-shadow: 0 0 10px var(--pink); }
html[data-theme='matrix'] .route-me { background: #ff2b2b; box-shadow: 0 0 0 4px rgba(255, 43, 43, 0.35), 0 0 16px #ff2b2b; border-radius: 99px; width: 22px; height: 11px; }
html[data-theme='matrix'] .node-dot { background: #000; }
html[data-theme='matrix'] .node[data-state='done'] .node-dot { background: color-mix(in srgb, var(--tier) 22%, #000); }
html[data-theme='matrix'] .toast { background: rgba(0, 10, 3, 0.86); }
html[data-theme='matrix'] .toast.subs { border-color: rgba(0, 255, 65, 0.75); box-shadow: 0 0 20px rgba(0, 255, 65, 0.3); }
html[data-theme='matrix'] .toast.likes { border-color: rgba(255, 59, 59, 0.6); }
html[data-theme='matrix'] .gate-label { background: rgba(0, 8, 2, 0.82); border-color: rgba(0, 255, 65, 0.3); border-radius: 6px; }
html[data-theme='matrix'] .gl-badge { border-radius: 4px; }
html[data-theme='matrix'] .pop span { color: #e8fff0; text-shadow: 0 0 14px #00ff41, 0 0 2px #00ff41; }
html[data-theme='matrix'] .next-badge,
html[data-theme='matrix'] .rw-badge { border-radius: 8px; }
html[data-theme='matrix'] .reward,
html[data-theme='matrix'] .tile,
html[data-theme='matrix'] .icon-btn,
html[data-theme='matrix'] .btn { border-radius: 6px; }
html[data-theme='matrix'] .seg,
html[data-theme='matrix'] .seg button,
html[data-theme='matrix'] .seg label { border-radius: 5px; }
html[data-theme='matrix'] .tile.bump,
html[data-theme='matrix'] .reward.flash { animation-name: tile-flash-green; }

/* праздник — «доступ открыт» */
html[data-theme='matrix'] .celebrate { background: radial-gradient(circle at 50% 45%, rgba(0, 20, 6, 0.25), rgba(0, 0, 0, 0.85)); }
html[data-theme='matrix'] .rays { background: repeating-conic-gradient(from 0deg, rgba(0, 255, 65, 0.16) 0deg 3deg, transparent 3deg 12deg); }
html[data-theme='matrix'] .cel-card { background: rgba(0, 8, 2, 0.9); border-radius: 8px; border-color: rgba(0, 255, 65, 0.7); box-shadow: 0 0 90px rgba(0, 255, 65, 0.35), inset 0 0 40px rgba(0, 255, 65, 0.06); }
html[data-theme='matrix'] .cel-kicker { color: var(--pink); }
html[data-theme='matrix'] .cel-value { background: none; color: #e8fff0; -webkit-background-clip: border-box; background-clip: border-box; text-shadow: 0 0 22px rgba(0, 255, 65, 0.9); animation: none; letter-spacing: -0.02em; }
html[data-theme='matrix'] .cel-prize { border-color: rgba(0, 255, 65, 0.4); background: rgba(0, 255, 65, 0.05); }

/* заставка: «Проснись, Нео…» */
html[data-theme='matrix'] #loading { background: #000; }
html[data-theme='matrix'] .ld-matrix { display: block; font: 500 clamp(18px, 2.4vw, 28px) var(--font); color: #00ff41; text-shadow: 0 0 10px rgba(0, 255, 65, 0.8); padding: 0 24px; }
html[data-theme='matrix'] .ld-cursor { display: inline-block; width: 0.6em; height: 1.1em; margin-left: 2px; vertical-align: -0.15em; background: #00ff41; box-shadow: 0 0 10px #00ff41; animation: caret 1s steps(1) infinite; }
html[data-theme='matrix'] #loading { display: grid; grid-template-rows: auto auto; align-content: center; justify-items: start; padding-left: max(24px, 12vw); }
html[data-theme='matrix'] .ld { text-align: left; padding: 0 24px; }
html[data-theme='matrix'] .ld-logo,
html[data-theme='matrix'] .ld-title { display: none; }
html[data-theme='matrix'] .ld-text:not(.err) { display: none; }
html[data-theme='matrix'] .ld-text { color: var(--bad); }

@keyframes caret { 50% { opacity: 0; } }
@keyframes tile-flash-green { 0% { background: rgba(0, 255, 65, 0.3); } 100% { background: rgba(0, 255, 65, 0.035); } }
