@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

:root {
  --bg: #030309;
  --ink: #ece4d6;
  --blue: #7aa8ff;
  --violet: #b07cff;
  --pink: #ff6fb0;
  --amber: #ffab55;
  --gold: #ffd08a;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-cine: cubic-bezier(.77, 0, .18, 1);
  --reserve: 230px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(120% 90% at 50% 60%, #0d0b1c 0%, #06060f 45%, #020206 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* iOS: чтобы тап по «пустому» месту гарантированно давал click */
@media (hover: none) { body { cursor: pointer; } }

::selection { background: rgba(255, 111, 176, .35); color: #fff; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Слои ---------- */

canvas {
  position: fixed;
  inset: 0;
  display: block;
  pointer-events: none;
}
#sky  { z-index: 2; }
#dust { z-index: 4; }

.nebula {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  opacity: .8;
  transition: opacity 3s ease;
}
.playing .nebula { opacity: 1; }

.nebula i {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  will-change: transform;
}
.n1 {
  width: 75vmax; height: 58vmax; left: -22vmax; top: -12vmax;
  background: radial-gradient(closest-side, rgba(60, 90, 215, .30), rgba(40, 50, 140, .12) 55%, transparent);
  animation: drift1 46s ease-in-out infinite alternate;
}
.n2 {
  width: 68vmax; height: 52vmax; right: -24vmax; top: 8vmax;
  background: radial-gradient(closest-side, rgba(255, 140, 60, .20), rgba(160, 70, 30, .08) 55%, transparent);
  animation: drift2 52s ease-in-out infinite alternate;
}
.n3 {
  width: 62vmax; height: 46vmax; left: 18vmax; bottom: -26vmax;
  background: radial-gradient(closest-side, rgba(225, 70, 165, .22), rgba(120, 40, 140, .08) 55%, transparent);
  animation: drift3 58s ease-in-out infinite alternate;
}
.n4 {
  width: 42vmax; height: 30vmax; left: 30vmax; top: -12vmax;
  background: radial-gradient(closest-side, rgba(150, 110, 255, .16), transparent);
  animation: drift1 64s ease-in-out infinite alternate-reverse;
}
@keyframes drift1 { to { transform: translate3d(8vmax, 5vmax, 0) scale(1.15) rotate(15deg); } }
@keyframes drift2 { to { transform: translate3d(-7vmax, -4vmax, 0) scale(1.2) rotate(-12deg); } }
@keyframes drift3 { to { transform: translate3d(-6vmax, -6vmax, 0) scale(1.1) rotate(20deg); } }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, .6) 100%);
}

.grain {
  position: fixed;
  inset: -50%;
  z-index: 5;
  pointer-events: none;
  opacity: .07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-4%, 3%); }
  40%  { transform: translate(3%, -2%); }
  60%  { transform: translate(-2%, -4%); }
  80%  { transform: translate(4%, 2%); }
  100% { transform: translate(0, 0); }
}

/* ---------- Сцена ---------- */

.stage {
  position: relative;
  z-index: 3;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(56px + env(safe-area-inset-top)) 0 calc(120px + env(safe-area-inset-bottom));
}

.poster {
  position: relative;
  flex: none;
  width: min(94vw, 1560px, calc((100vh - var(--reserve)) * 1.7778));
  width: min(94vw, 1560px, calc((100svh - var(--reserve)) * 1.7778));
  aspect-ratio: 16 / 9;
  will-change: transform;
}

.poster-inner {
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(ellipse closest-side at 50% 50%, #000 60%, rgba(0,0,0,.75) 78%, transparent 100%);
          mask-image: radial-gradient(ellipse closest-side at 50% 50%, #000 60%, rgba(0,0,0,.75) 78%, transparent 100%);
  opacity: 0;
  transform: scale(1.08);
  filter: blur(16px) brightness(.3);
  transition:
    opacity 2.6s ease .9s,
    transform 4.2s var(--ease-out) .9s,
    filter 3s ease .9s;
}
.ready .poster-inner {
  opacity: 1;
  transform: none;
  filter: blur(0) brightness(1);
}

.poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: breathe 16s ease-in-out infinite alternate;
}
@keyframes breathe {
  from { transform: scale(1); }
  to   { transform: scale(1.03) translateY(-.4%); }
}

.poster-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(38% 34% at 50% 58%, rgba(255, 110, 180, .55), rgba(255, 140, 70, .22) 45%, transparent 75%),
    radial-gradient(30% 15% at 50% 23%, rgba(140, 170, 255, .45), transparent 70%),
    radial-gradient(40% 10% at 50% 86%, rgba(255, 170, 80, .40), transparent 70%);
  opacity: calc(.1 + var(--beat, 0) * .75);
  will-change: opacity;
}

.poster-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(105deg,
    transparent 42%,
    rgba(255, 210, 170, .06) 47%,
    rgba(255, 255, 255, .16) 50%,
    rgba(255, 170, 220, .06) 53%,
    transparent 58%);
  background-size: 260% 100%;
  background-position: 120% 0;
  animation: sheen 12s ease-in-out 5s infinite;
}
@keyframes sheen {
  0%       { background-position: 120% 0; }
  35%, 100% { background-position: -20% 0; }
}

/* ---------- Кнопка ---------- */

.cta-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: clamp(-40px, -2.6vw, -6px);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.6s ease 2.4s, transform 1.8s var(--ease-out) 2.4s;
}
.ready .cta-wrap { opacity: 1; transform: none; }

.cta-wrap::before,
.cta-wrap::after {
  content: '';
  width: clamp(36px, 9vw, 150px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 180, 120, .55));
}
.cta-wrap::after { transform: scaleX(-1); }

.cta {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 18px 30px 18px 38px;
  border-radius: 999px;
  color: #f6efe4;
  text-decoration: none;
  font: 500 12px/1 'Manrope', sans-serif;
  letter-spacing: .42em;
  text-transform: uppercase;
  background: radial-gradient(120% 160% at 50% 0%, rgba(255, 160, 110, .12), rgba(8, 7, 18, .6) 60%);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  transition: transform .6s var(--ease-out);
  cursor: pointer;
}

.cta::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle),
    rgba(255,255,255,.10), #7aa8ff, #b07cff, #ff6fb0, #ffab55,
    rgba(255,255,255,.10) 72%, rgba(255,255,255,.10));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: spin 6s linear infinite;
}

.cta::after {
  content: '';
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), transparent, #7aa8ff, #ff6fb0, #ffab55, transparent 72%);
  filter: blur(16px);
  opacity: .35;
  animation: spin 6s linear infinite;
  transition: opacity .6s ease;
}
@keyframes spin { to { --angle: 360deg; } }

.cta-label {
  background: linear-gradient(90deg, #efe4d4 0%, #efe4d4 38%, #fff 48%, #ffd2a6 52%, #efe4d4 62%, #efe4d4 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -150% 0; }
}

.cta-arrow {
  width: 26px;
  height: 10px;
  color: var(--gold);
  transition: transform .6s var(--ease-out);
}

.cta:hover { transform: translateY(-2px); }
.cta:hover::after { opacity: .85; }
.cta:hover .cta-arrow { transform: translateX(6px); }
.cta:active { transform: translateY(0) scale(.98); }
.cta:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; }

/* ---------- Звук ---------- */

.sound {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  right: calc(22px + env(safe-area-inset-right));
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  font: 500 10px/1 'Manrope', sans-serif;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(236, 228, 214, .45);
  cursor: pointer;
  opacity: 0;
  transition: opacity 1.6s ease 3s, color .5s ease;
}
.ready .sound { opacity: 1; }
.playing .sound { color: rgba(255, 220, 185, .85); }
.sound:hover { color: #fff; }
.sound:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; border-radius: 4px; }

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
.bars i {
  width: 2px;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(to top, var(--amber), var(--pink));
  transform-origin: bottom;
  transform: scaleY(.15);
  opacity: .6;
  transition: transform .5s ease, opacity .5s ease;
}
.playing .bars i { opacity: 1; animation: eq 1s ease-in-out infinite alternate; }
.playing .bars i:nth-child(2) { animation-duration: .8s; animation-delay: -.3s; }
.playing .bars i:nth-child(3) { animation-duration: 1.2s; animation-delay: -.6s; }
.playing .bars i:nth-child(4) { animation-duration: .7s; animation-delay: -.2s; }
.playing .bars i:nth-child(5) { animation-duration: 1.1s; animation-delay: -.5s; }
@keyframes eq { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

/* Реальный спектр, если доступен Web Audio */
.live.playing .bars i {
  animation: none;
  transform: scaleY(var(--h, .2));
  transition: transform .08s linear;
}

/* ---------- Подсказка ---------- */

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 7;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  font: italic 300 clamp(15px, 1.5vw, 18px)/1 'Cormorant Garamond', serif;
  letter-spacing: .05em;
  color: rgba(255, 222, 190, .78);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.ready .hint   { opacity: 1; transition-delay: 3.6s; }
.started .hint { opacity: 0; transition-delay: 0s; transition-duration: .8s; }

#hintText { animation: hintBreath 3.2s ease-in-out infinite; }
@keyframes hintBreath { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.hint-dot {
  position: relative;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold), 0 0 22px rgba(255, 140, 80, .6);
}
.hint-dot::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 208, 138, .6);
  animation: ping 2.4s var(--ease-out) infinite;
}
@keyframes ping {
  from { transform: scale(.3); opacity: 1; }
  to   { transform: scale(2.4); opacity: 0; }
}

/* ---------- Футер ---------- */

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 7;
  display: flex;
  justify-content: center;
  opacity: 0;
  transition: opacity 1.6s ease 3s;
}
.ready .footer { opacity: 1; }

.footer a {
  position: relative;
  padding: 8px 2px;
  font: 400 12px/1 'Manrope', sans-serif;
  letter-spacing: .3em;
  color: rgba(236, 228, 214, .5);
  text-decoration: none;
  transition: color .5s ease;
}
.footer a::after {
  content: '';
  position: absolute;
  left: 0;
  right: .3em;
  bottom: 2px;
  height: 1px;
  background: linear-gradient(90deg, var(--blue), var(--pink), var(--amber));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .7s var(--ease-out);
}
.footer a:hover { color: #fff; }
.footer a:hover::after { transform: scaleX(1); }
.footer a:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ---------- Вступление ---------- */

.curtain {
  position: fixed;
  left: 0;
  right: 0;
  height: 50.5%;
  z-index: 9;
  background: #020205;
  pointer-events: none;
  transition: transform 2.2s var(--ease-cine) .5s;
}
.curtain.top    { top: 0; }
.curtain.bottom { bottom: 0; }

.curtain::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(122,168,255,.85) 25%, rgba(255,111,176,.95) 50%, rgba(255,171,85,.85) 75%, transparent);
  box-shadow: 0 0 18px rgba(255, 120, 150, .7);
  opacity: 0;
  transition: opacity .6s ease .3s;
}
.curtain.top::after    { bottom: 0; }
.curtain.bottom::after { top: 0; }

.ready .curtain.top    { transform: translateY(-102%); }
.ready .curtain.bottom { transform: translateY(102%); }
.ready .curtain::after { opacity: 1; }

.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10;
  width: min(280px, 56vw);
  height: 1px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .07);
  pointer-events: none;
  transition: width 1.1s var(--ease-cine), opacity .7s ease .8s;
}
.loader i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--pink), var(--amber));
  box-shadow: 0 0 14px rgba(255, 140, 120, .85);
  transition: width .5s ease;
}
.ready .loader { width: 100vw; opacity: 0; }

/* ---------- Адаптив ---------- */

@media (max-aspect-ratio: 4/5) {
  .poster {
    width: min(128vw, calc((100vh - 260px) * 1.7778));
    width: min(128vw, calc((100svh - 260px) * 1.7778));
  }
  .cta-wrap { margin-top: 4px; gap: 14px; }
  .cta-wrap::before, .cta-wrap::after { width: 28px; }
  .cta { padding: 17px 24px 17px 30px; letter-spacing: .34em; font-size: 11px; }
  .hint { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

@media (max-height: 520px) {
  :root { --reserve: 140px; }
  .stage { padding-top: 16px; padding-bottom: 64px; }
  .cta { padding: 14px 24px 14px 30px; }
  .hint { display: none; }
  .footer { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .sound { top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .nebula i, .poster img, .poster-sheen, .grain, .cta-label, #hintText { animation: none !important; }
}