:root {
  --bg: #07070A;
  --fg: #F4F4F6;
  --muted: #A3A3B2;
  --line: #24242E;
  --a: #67E8F9;
  --b: #C084FC;
  --pad: clamp(16px, 4vw, 56px);
}
/* Палитры: magnets.js ставит data-pal на <html> (пасхалки). */
html[data-pal="sunset"] { --a: #FF8A4C; --b: #FF3DA5; }
html[data-pal="acid"]   { --a: #D4FF3A; --b: #3AFFB4; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Manrope', system-ui, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* ---- фон ---- */
.grid-bg {
  position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 28px 28px;
  animation: drift 6s linear infinite;
}
.glow {
  position: fixed; left: 0; top: 0; width: 620px; height: 620px; margin: -310px 0 0 -310px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--b) 19%, transparent) 0%, transparent 62%);
  transform: translate(74vw, 40vh);
  transition: transform .3s ease-out;
}

/* ---- шапка ---- */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px var(--pad);
}
.logo { display: inline-flex; flex-direction: column; gap: 7px; text-decoration: none; }
.logo span:first-child { font: 600 15px 'Unbounded', sans-serif; letter-spacing: .2em; }
.sheen {
  display: block; height: 3px; width: 100%;
  background-image: linear-gradient(90deg, var(--a), var(--b), var(--a));
  background-size: 200% 100%;
  animation: sheen 3s linear infinite;
}
.pill {
  padding: 12px 18px; border: 1px solid #2A2A35; border-radius: 999px;
  font-weight: 700; font-size: 14px; text-decoration: none;
}

/* ---- hero ---- */
.hero {
  position: relative; z-index: 2; flex: 1;
  width: 100%; max-width: 1440px; margin: 0 auto;
  padding: 24px var(--pad) 56px;
  display: flex; flex-direction: column; justify-content: center; gap: 28px;
}
.badge {
  align-self: flex-start; margin: 0;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 14px; border: 1px solid #23232D; border-radius: 999px;
  font: 13px 'JetBrains Mono', monospace; color: #B4B4C2; background: rgba(7,7,10,.6);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a); animation: pulse 1.6s ease-in-out infinite; }

.title {
  margin: 0;
  font: 800 clamp(72px, 15vw, 220px)/.95 'Unbounded', sans-serif;
  letter-spacing: -.02em;
}
.title .line { display: flex; flex-wrap: wrap; }
.sheen-wide { height: 6px; width: min(440px, 70%); }
.lead { margin: 0; max-width: 560px; font-size: clamp(18px, 1.6vw, 22px); line-height: 1.5; color: #C9C9D4; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px;
  padding: 0 26px; border-radius: 999px;
  font-weight: 800; font-size: 16px; text-decoration: none;
}
.btn-primary { background-image: linear-gradient(90deg, var(--a), var(--b)); color: var(--bg); }
.btn-ghost { border: 1px solid #2E2E3A; background: rgba(7,7,10,.6); font-weight: 700; }

.hint { margin: 0; min-height: 44px; display: flex; align-items: center; font: 13px 'JetBrains Mono', monospace; color: #8A8A97; }
.remix { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.remix b { color: var(--a); }
.link-btn {
  min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--fg); text-decoration: underline; text-underline-offset: 3px;
}

/* ---- плитки (включает magnets.js) ---- */
.tile {
  display: inline-block; position: relative;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: color .25s ease;
}
.tile:hover { color: var(--a); }
[data-swap] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.is-dragging { cursor: grabbing !important; }
.is-dragging .tile, .is-dragging [data-swap] { cursor: grabbing; }
.lifted {
  z-index: 10; opacity: .9;
  filter: drop-shadow(0 18px 30px color-mix(in srgb, var(--b) 45%, transparent));
}
/* ---- разрезанные буквы и рисование (paint.js) ---- */
.tile.sliced .ghost { visibility: hidden; }
/* разрезанную букву хватают только за куски: у каждого свой clip-path, по нему и попадание */
.tile.sliced { pointer-events: none; }
.tile.sliced .piece { pointer-events: auto; cursor: grab; }
.tile .piece.dragging { transition: none; cursor: grabbing; filter: drop-shadow(0 14px 24px color-mix(in srgb, var(--b) 45%, transparent)); }
.tile .piece {
  position: absolute; inset: 0; pointer-events: none;
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.paint-layer { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.is-painting, .is-painting * { cursor: crosshair !important; }
.is-cutting, .is-cutting * { cursor: cell !important; }

.keys {
  margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px;
  font: 12px 'JetBrains Mono', monospace; color: #8A8A97;
}
.keys kbd {
  display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 4px;
  border: 1px solid #2A2A35; border-bottom-width: 2px; border-radius: 6px;
  font: inherit; color: var(--fg); text-align: center;
}
/* рисование и нож — с мышью и клавиатурой; на тач-экранах подсказку не показываем */
@media (hover: none), (pointer: coarse) { .keys { display: none; } }

.landed { animation: land .35s cubic-bezier(.2,.8,.2,1); }
.title.win .tile { animation: wave .9s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 60ms); }

/* ---- бегущая строка ---- */
.ticker {
  position: relative; z-index: 2; overflow: hidden; padding: 20px 0;
  border-block: 1px solid #1A1A22; background: rgba(7,7,10,.7);
}
.ticker-track { display: flex; width: max-content; animation: marquee 30s linear infinite; }
.ticker-track span {
  display: inline-flex; align-items: center; gap: 28px; padding-right: 28px;
  font: 800 28px 'Unbounded', sans-serif; white-space: nowrap;
}
.ticker-track span:nth-child(even) { color: #3A3A48; }
.ticker-track span::after { content: "✦"; color: var(--a); font-size: 20px; }

.foot {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  padding: 22px var(--pad); font: 12px 'JetBrains Mono', monospace; color: #8A8A97;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: #0E0E13; font: 13px 'JetBrains Mono', monospace;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes drift { to { background-position: 28px 28px; } }
@keyframes sheen { to { background-position: 200% 50%; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.7); } }
@keyframes land { 0% { transform: scale(1.15); } 100% { transform: none; } }
@keyframes wave { 40% { transform: translateY(-.18em) rotate(-4deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .top .actions { width: 100%; }
  .btn { min-height: 44px; padding: 0 18px; font-size: 14px; }
}

/* Кнопки верхней панели */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid transparent;
  min-height: 54px;
  border-radius: 18px;
  letter-spacing: -.025em;
  transition: transform .25s ease, box-shadow .3s ease, border-color .3s ease;
}
.btn-primary {
  background: linear-gradient(110deg, var(--a), #98A8FF, var(--b), var(--a));
  background-size: 300% 100%;
  animation: button-flow 8s ease infinite;
  box-shadow: inset 0 1px 0 #FFFFFF70, 0 4px 24px #67E8F918;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 25%, #FFFFFF30 48%, transparent 70%);
  transform: translateX(-140%);
  animation: button-glint 7s ease-in-out infinite;
}
.btn-ghost {
  background: linear-gradient(#111119, #0B0B11) padding-box,
    linear-gradient(110deg, #67E8F970, #C084FC90, #FFFFFF20, #67E8F970) border-box;
  background-size: 100% 100%, 300% 100%;
  animation: button-flow 8s ease infinite reverse;
  box-shadow: inset 0 1px 0 #FFFFFF0D, 0 4px 24px #C084FC0D;
}
.btn-ghost::before { animation-delay: 1.5s; opacity: .45; }
.btn svg { transition: transform .25s ease; }
@media (hover: hover) {
  .btn:hover { transform: translateY(-3px); }
  .btn-primary:hover { box-shadow: 0 8px 32px #67E8F930, 0 0 20px #C084FC20; }
  .btn-ghost:hover { box-shadow: 0 8px 28px #C084FC25; border-color: #C084FC80; }
  .btn:hover svg { transform: translateX(4px); }
}
.btn:active { transform: translateY(1px) scale(.97); }
@keyframes button-flow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes button-glint {
  0%, 65% { transform: translateX(-140%); }
  90%, 100% { transform: translateX(140%); }
}

/* Импульс при наведении */
.btn::after {
  content: ''; position: absolute; inset: -18px; border-radius: 28px;
  pointer-events: none; opacity: 0; z-index: -2;
  transition: opacity .25s ease;
}
@media (hover: hover) {
  .btn-primary:hover, .btn-primary:focus-visible {
    overflow: visible; transform: translateY(-4px) rotate(-2deg) scale(1.04);
    background-size: 300% 100%; animation: button-flow 1.2s ease infinite;
    box-shadow: 0 0 0 1px #FFFFFF80, 0 0 24px #67E8F980, 0 0 60px #C084FC50;
  }
  .btn-primary:hover::after, .btn-primary:focus-visible::after {
    opacity: 1; border: 1px solid #67E8F980;
    animation: neon-pulse 1.1s ease-out infinite;
  }
  .btn-primary:hover svg { transform: translateX(6px) rotate(-35deg) scale(1.25); }
}
@keyframes neon-pulse {
  from { transform: scale(.9); opacity: .9; }
  to { transform: scale(1.18, 1.5); opacity: 0; }
}

/* ---- живой слой: курсоры других посетителей (live.js) ---- */
.live-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 6; pointer-events: none; }
.live-cursor {
  position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 2px;
  color: var(--c); transition: transform .12s linear, opacity .4s;
}
.live-cursor span {
  margin-top: 14px; padding: 3px 8px; border-radius: 999px; background: var(--c); color: var(--bg);
  font: 700 11px 'JetBrains Mono', monospace; white-space: nowrap;
}
.live-cursor.idle { opacity: 0; }
[data-online] { color: var(--a); }
.btn-primary:hover::before,
.btn-primary:focus-visible::before { animation: none; opacity: 0; }

.radio-waves { position: absolute; inset: 0; pointer-events: none; z-index: -1; opacity: 0; transition: opacity .2s; }
.radio-waves i { position: absolute; inset: 0; border: 2px solid #67E8F9; border-radius: 20px; opacity: 0; }
@media (hover: hover) {
  .btn-primary:is(:hover, :focus-visible)::after { display: none; }
  .btn:is(:hover, :focus-visible) .radio-waves,
  .btn:is(:hover, :focus-visible) .radio-waves i { animation: radio-expand 2.1s linear infinite; }
  .radio-waves i:nth-child(2) { animation-delay: -.7s !important; }
  .radio-waves i:nth-child(3) { animation-delay: -1.4s !important; }
}
@keyframes radio-expand {
  0% { inset: -1px; opacity: .9; border-color: #67E8F9; }
  100% { inset: -50px -65px; opacity: 0; border-radius: 65px; border-color: #C084FC; }
}

@keyframes radio-expand {
  0% { inset: -1px; opacity: .85; border-color: #67E8F9; }
  65% { opacity: .45; }
  100% { inset: -170px -210px; opacity: 0; border-radius: 190px; border-color: #C084FC; }
}
.btn:is(:hover, :focus-visible) .radio-waves i { animation-duration: 3s; }
.radio-waves i:nth-child(2) { animation-delay: -1s !important; }
.radio-waves i:nth-child(3) { animation-delay: -2s !important; }
