/* Экран входа: рама зала с погашенным экраном. Разметка — auth/gate.html, поведение — auth/gate.js. */
/* ── Токены зала (те же значения, что в css/style.css) ───────────────── */
:root {
  --bg-paper: #f6f4ef;
  --bg-inner: #ffffff;
  --ink: #111111;
  --ink-muted: #555550;
  --border-heavy: 3px solid #111111;
  --border-thin: 1px solid #111111;
  --font-text: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Inter', 'Segoe UI', Arial, sans-serif;
  --font-black-lat: 'UnifrakturMaguntia', 'Cormorant Garamond', serif;
  --font-black-cyr: 'Ruslan Display', 'Cormorant Garamond', serif;
  /* Экран всегда тёмный — как сцена плеера в зале. */
  --screen: #050505;
  --light: #eae6df;
  --light-muted: #b9b5ad;
  --light-dim: #8f8b84;
  --light-faint: #6a6a70;
  --screen-rule: #37373b;
  --screen-err: #f0776e;
  --gold: #d4af37; /* единственный цвет на сайте — только для короля */
  color-scheme: light;
}
body.night-mode {
  --bg-paper: #0b0b0c;
  --bg-inner: #111113;
  --ink: #eae6df;
  --ink-muted: #a5a199;
  --border-heavy: 3px solid #eae6df;
  --border-thin: 1px solid #55555b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-paper);
  color: var(--ink);
  font-family: var(--font-text);
  transition: background-color .35s ease, color .35s ease;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ── Каркас: та же рама, что у зала ──────────────────────────────────── */
.gate-wrap {
  width: min(520px, 100%);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  container-type: inline-size;
}
.gate-top, .gate-frame { --u: 2.2cqw; }

.gate-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.u-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: var(--border-thin);
  background: var(--bg-inner);
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
  transition: background-color .2s, color .2s;
}
.u-btn:hover { background: var(--ink); color: var(--bg-inner); }

.gate-frame {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "banner" "card" "bottom";
  border: var(--border-heavy);
  background: var(--bg-inner);
  --m: var(--ink);
  --g: var(--bg-inner);
  transition: background-color .35s ease, border-color .35s ease;
}
.banner {
  grid-area: banner;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-bottom: var(--border-heavy);
  -webkit-touch-callout: none;
  user-select: none;
}
.dragon-svg { display: block; width: 100%; height: auto; max-height: 100%; }
.corner-rosette, .side-pillar { display: none; }
.bottom-frieze {
  grid-area: bottom;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-top: var(--border-heavy);
  overflow: hidden;
}
.bottom-svg { display: block; width: 100%; height: auto; }
body.night-mode .bottom-frieze .band { --m: var(--bg-inner); --g: var(--ink); } /* как в зале: лента остаётся тёмной */

/* ── Экран ───────────────────────────────────────────────────────────── */
.gate-card {
  --title: calc(var(--u) * 7.4);
  --cell: calc(var(--u) * 6.6);
  grid-area: card;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--u) * 4.2) calc(var(--u) * 2.4);
  background: var(--screen);
  color: var(--light);
  text-align: center;
}
.gate-card :focus-visible { outline-color: var(--light); }

.screen-glow, .screen-grain, .screen-rule { position: absolute; pointer-events: none; }
.screen-glow {
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(58% 40% at 50% 27%, rgba(234, 230, 223, .16), transparent 72%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .7) 100%);
  transition: opacity .6s ease;
}
.screen-grain {
  inset: -40%;
  z-index: -1;
  opacity: .1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.screen-rule {
  inset: calc(var(--u) * 1.3);
  border: 1px solid var(--screen-rule);
}
.screen-rule i {
  position: absolute;
  width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: max(14px, calc(var(--u) * 1.7));
  line-height: 1;
  color: var(--light);
  background: var(--screen);
  transition: color .6s ease, opacity .6s ease;
}
.screen-rule i:nth-child(1) { top: -.8em; left: -.8em; }
.screen-rule i:nth-child(2) { top: -.8em; right: -.8em; }
.screen-rule i:nth-child(3) { bottom: -.8em; left: -.8em; }
.screen-rule i:nth-child(4) { bottom: -.8em; right: -.8em; }

.gate-title {
  margin: 0;
  font-family: var(--font-black-lat);
  font-weight: 400;
  font-size: var(--title);
  line-height: 1;
  letter-spacing: .02em;
  color: #f5f3ee;
  text-shadow: 0 0 calc(var(--u) * 2.6) rgba(234, 230, 223, .3);
}
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1.1);
  margin: calc(var(--u) * 2.6) 0 calc(var(--u) * 2.6);
  color: var(--light-dim);
  font-size: max(11px, calc(var(--u) * 1.2));
  line-height: 1;
}
.divider span { width: calc(var(--u) * 7); height: 1px; background: linear-gradient(90deg, transparent, var(--light-faint)); }
.divider span:last-child { transform: scaleX(-1); }
.divider-star { display: inline-block; font-weight: 400; transition: transform .6s cubic-bezier(.3, 1.4, .4, 1), color .4s; }

.pin-form { display: flex; flex-direction: column; align-items: center; margin: 0; }
.pin-label, .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pin-field { position: relative; }
.pin-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* меньше 16px — iOS приближает страницу при фокусе */
  cursor: pointer;
  caret-color: transparent;
}
.pin-input:disabled { cursor: default; }

/* Четыре кадра киноплёнки */
.pin-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  gap: calc(var(--u) * .7);
  padding: calc(var(--u) * 1.8) calc(var(--u) * 1);
  border: 1px solid var(--light-faint);
  background: #0c0c0d;
  transition: opacity .4s ease, border-color .3s;
}
.pin-strip::before, .pin-strip::after {
  content: "";
  position: absolute;
  left: calc(var(--u) * .55);
  right: calc(var(--u) * .55);
  height: calc(var(--u) * .62);
  background-image: repeating-linear-gradient(90deg, var(--light-dim) 0 calc(var(--u) * .82), transparent calc(var(--u) * .82) calc(var(--u) * 1.7));
  background-size: calc(var(--u) * 1.7) 100%;
  opacity: .8;
}
.pin-strip::before { top: calc(var(--u) * .59); }
.pin-strip::after { bottom: calc(var(--u) * .59); }
.pin-input:focus-visible + .pin-strip { border-color: var(--light-muted); }

.pin-cell {
  position: relative;
  aspect-ratio: 10 / 11;
  display: grid;
  place-items: center;
  border: 1px solid var(--light-faint);
  border-radius: 2px;
  background: var(--screen);
  transition: border-color .2s, background-color .25s, box-shadow .25s;
}
.pin-cell::before {
  content: attr(data-n);
  position: absolute;
  z-index: 2;
  top: calc(var(--u) * .4);
  left: calc(var(--u) * .5);
  font-family: var(--font-ui);
  font-size: max(8px, calc(var(--u) * .78));
  letter-spacing: .1em;
  color: var(--light-faint);
}
.pin-cell::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 1.05);
  width: calc(var(--u) * 1.5);
  height: 1px;
  margin-left: calc(var(--u) * -.75);
  background: var(--light-faint);
}
.pin-cell.is-active {
  border-color: var(--light);
  box-shadow: 0 0 0 1px var(--light), 0 0 calc(var(--u) * 2.2) rgba(234, 230, 223, .2);
}
.pin-cell.is-active::after { background: var(--light); height: 2px; animation: caret 1.1s steps(1) infinite; }
.pin-cell.is-filled { border-color: var(--light); }
.pin-cell.is-filled::before { color: #8a867e; }
.pin-cell.is-filled::after { display: none; }

/* Сам .pin-star — засвеченный кадр. После удара в ::before светится звезда. */
.pin-star {
  position: absolute;
  inset: 0;
  border-radius: 1px;
  font-size: 0;
  background: var(--light);
}
.pin-star::before {
  content: "✦";
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: calc(var(--u) * 3.3);
  line-height: 1;
  color: #0a0a0a;
  transform: translate(-50%, -50%);
}
.pin-star.is-falling { animation: star-fall var(--fall-time, 760ms) linear var(--fall-delay, 0ms) both; }
.pin-star.is-falling::before { animation: star-drop var(--fall-time, 760ms) linear var(--fall-delay, 0ms) both; }
/* Полёт и взрыв рисует star-entry.js на холсте поверх страницы. В режиме difference
   метеор сам меняет цвет: тушью по бумаге, светом по тёмному экрану. */
.star-sky { position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: difference; }
.star-sky.is-plain { mix-blend-mode: normal; } /* королевский салют: золото без инверсии */

.noscript { margin: calc(var(--u) * 1.5) 0 0; font-family: var(--font-ui); font-size: 13px; color: var(--light-muted); }

/* ── Состояния ───────────────────────────────────────────────────────── */
.gate-card.is-pending .pin-strip::before, .gate-card.is-pending .pin-strip::after { animation: film-run .42s linear infinite; }
.gate-card.is-pending .pin-cell { animation: frame-pulse 1.2s ease-in-out infinite; }
.gate-card.is-pending .pin-cell:nth-child(2) { animation-delay: .12s; }
.gate-card.is-pending .pin-cell:nth-child(3) { animation-delay: .24s; }
.gate-card.is-pending .pin-cell:nth-child(4) { animation-delay: .36s; }
.gate-card.is-pending .screen-glow { animation: flicker .9s steps(1) infinite; }
.gate-card.is-shaking .pin-strip { animation: shake .42s cubic-bezier(.36, .07, .19, .97); border-color: var(--screen-err); }
.gate-card.is-success .screen-glow {
  background: radial-gradient(90% 70% at 50% 34%, rgba(245, 243, 238, .5), transparent 78%);
}
.gate-card.is-success .pin-strip::before, .gate-card.is-success .pin-strip::after { animation: film-run .3s linear infinite; }
.gate-card.is-locked .pin-strip { opacity: .45; border-color: var(--screen-err); }

/* ── Показывать, а не писать ─────────────────────────────────────────
   Четыре звезды по углам экрана — четыре попытки. Неверный код гасит одну. */
.gate-card[data-attempts="3"] .screen-rule i:nth-child(n+4),
.gate-card[data-attempts="2"] .screen-rule i:nth-child(n+3),
.gate-card[data-attempts="1"] .screen-rule i:nth-child(n+2),
.gate-card[data-attempts="0"] .screen-rule i { color: var(--screen-err); opacity: .5; }
.gate-card.is-shaking .pin-cell { animation: deny .55s ease-out; }
/* Блокировка: красная линия под кадрами тает, пока идёт время. */
.lock-timer {
  align-self: stretch;
  height: 2px;
  margin-top: calc(var(--u) * 1.1);
  background: var(--screen-err);
  transform: scaleX(0);
  transform-origin: 0 50%;
  opacity: 0;
}
.gate-card.is-locked .lock-timer { opacity: 1; animation: lock-drain var(--lock-time, 30s) linear both; }

/* ── Знак страже: шесть зон на драконе и фризе, одинаковых на телефоне и на широком экране ── */
.banner, .bottom-frieze { position: relative; }
.sign-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  background: #fff;
  opacity: 0;
  mix-blend-mode: difference; /* касание на миг выворачивает гравюру наизнанку */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
.sign-zone.is-hit { animation: sign-hit .32s ease-out; }
.zone-a { left: 0; width: 33.4%; }
.zone-b { left: 33.4%; width: 33.2%; }
.zone-c { left: 66.6%; width: 33.4%; }
.zone-l { left: 0; width: 24%; }
.zone-m { left: 24%; width: 52%; }
.zone-r { left: 76%; width: 24%; }

/* ── Король входит ───────────────────────────────────────────────────── */
.title-wrap { position: relative; display: inline-block; }
.crown {
  position: absolute;
  left: 50%;
  bottom: calc(100% - var(--u) * .2);
  width: calc(var(--u) * 9);
  margin-left: calc(var(--u) * -4.5);
  overflow: visible;
  opacity: 0;
  pointer-events: none;
}
.crown-body, .crown-band, .crown-pearls { fill: var(--gold); }
.crown-gems { fill: var(--screen); }
.crown-lines { fill: none; stroke: var(--screen); stroke-width: 1.2; stroke-linecap: round; }
.gate-card.is-royal .crown {
  animation: crown-descend 1.1s cubic-bezier(.2, 1.25, .4, 1) .55s both;
  filter: drop-shadow(0 0 calc(var(--u) * 1.2) rgba(212, 175, 55, .85));
}
.gate-card.is-royal .gate-title {
  color: #fbeec2;
  text-shadow: 0 0 calc(var(--u) * 3) rgba(212, 175, 55, .85);
  transition: color 1s ease .4s, text-shadow 1s ease .4s;
}
.gate-card.is-royal .screen-glow { background: radial-gradient(95% 75% at 50% 34%, rgba(230, 160, 44, .36), transparent 78%); }
.gate-card.is-royal .pin-star { background: #f3dfa0; transition: background-color .8s ease .3s; }
.gate-card.is-royal .pin-cell { border-color: var(--gold); box-shadow: 0 0 calc(var(--u) * 1.4) rgba(212, 175, 55, .5); }
.gate-card.is-royal .divider-star { color: var(--gold); transform: rotate(180deg) scale(1.6); }
.gate-card.is-royal .screen-light { background: radial-gradient(circle at 50% 34%, #fff1c2, var(--bg-inner) 62%); }
/* Рама присягает: розетки, знамя с драконом и фриз по очереди выворачиваются наизнанку. */
.gate-frame:has(.gate-card.is-royal) :is(.corner-rosette, .banner, .bottom-frieze) { animation: oath 1s ease both; }
.gate-frame:has(.gate-card.is-royal) .banner { animation-delay: .14s; }
.gate-frame:has(.gate-card.is-royal) .corner-rosette.right { animation-delay: .28s; }
.gate-frame:has(.gate-card.is-royal) .bottom-frieze { animation-delay: .5s; }

/* Свет заливает экран — дальше открывается зал. */
.screen-light {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--bg-inner);
  clip-path: circle(0% at 50% 34%);
  pointer-events: none;
}
html.is-unlocking .screen-light { clip-path: circle(150% at 50% 34%); transition: clip-path .95s cubic-bezier(.7, 0, .2, 1); }
html.is-unlocking .gate-card > :not(.screen-light) { opacity: 0; transition: opacity .5s ease; }


/* ── Широкий экран: розетки, дракон, стража ──────────────────────────── */
@media (min-width: 820px) and (min-height: 560px) {
  body { padding: 16px; }
  .gate-wrap { flex: none; width: min(1120px, 100vw - 32px, (100dvh - 64px) / .8); }
  .gate-top, .gate-frame { --u: 1cqw; }
  .gate-frame {
    flex: none;
    grid-template-columns: 15cqw minmax(0, 1fr) 15cqw;
    grid-template-rows: 15cqw calc(52.5cqw - 10px) auto;
    grid-template-areas: "rl banner rr" "pl card pr" "bottom bottom bottom";
  }
  .banner { padding: calc(var(--u) * .5) calc(var(--u) * 1.2); }
  .corner-rosette {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--u) * .9);
    border-bottom: var(--border-heavy);
    --m: var(--bg-inner);
    --g: var(--ink);
    background: var(--g);
  }
  body.night-mode .corner-rosette { --m: var(--ink); --g: var(--bg-inner); }
  .corner-rosette svg { display: block; width: 100%; height: 100%; }
  .corner-rosette.left { grid-area: rl; border-right: var(--border-heavy); }
  .corner-rosette.right { grid-area: rr; border-left: var(--border-heavy); }
  .side-pillar { display: block; overflow: hidden; }
  .side-pillar.left { grid-area: pl; border-right: var(--border-heavy); }
  .side-pillar.right { grid-area: pr; border-left: var(--border-heavy); }
  .knight-svg { display: block; width: 100%; height: 100%; overflow: visible; background: var(--bg-inner); }
  /* Стража. Оружие выходит за колонну и нависает над экраном, поэтому колонна — свой слой с фоном:
     внутри него difference перекрашивает оружие (тушь на бумаге, свет на тёмном экране). */
  .side-pillar { position: relative; z-index: 3; overflow: visible; background: var(--bg-inner); pointer-events: none; }
  .weapon {
    --m: #fff;
    --g: #000;
    mix-blend-mode: difference;
    transform-box: view-box;
    transform: rotate(var(--guard));
    animation: guard-raise 1s cubic-bezier(.3, 1.35, .5, 1) 1.6s backwards;
  }
  .weapon-sword { --guard: -135deg; --thrust: 16deg; transform-origin: 134.5px 269px; }
  .weapon-halberd { --guard: -31deg; --thrust: -13deg; transform-origin: 35.5px 270px; }
  .gate-frame:has(.gate-card.is-shaking) .weapon { animation: guard-raise 1s cubic-bezier(.3, 1.35, .5, 1) 1.6s backwards, guard-thrust .5s cubic-bezier(.3, .9, .4, 1); }
  /* Блокировка: стража держит оружие опущенным к проходу. */
  .gate-frame:has(.gate-card.is-locked) .weapon { transform: rotate(calc(var(--guard) + var(--thrust))); transition: transform .5s cubic-bezier(.3, 1.3, .5, 1); }
  /* Код принят: стража опускает оружие в ту стойку, в которой стоит в зале. */
  .gate-frame:has(.gate-card.is-success) .weapon { animation: none; transform: rotate(0deg); transition: transform .95s cubic-bezier(.3, 1.3, .5, 1); }
  /* Королю — «на караул»: оружие к небу, два удара о камень, и только потом стойка зала. */
  .gate-frame:has(.gate-card.is-royal) .weapon-sword { animation: royal-sword 3.4s cubic-bezier(.4, 0, .3, 1) both; transition: none; }
  .gate-frame:has(.gate-card.is-royal) .weapon-halberd { animation: royal-halberd 3.4s cubic-bezier(.4, 0, .3, 1) both; transition: none; }
  .gate-card { --title: calc(var(--u) * 8.7); --cell: calc(var(--u) * 5.8); padding: calc(var(--u) * 2.6) calc(var(--u) * 4); }
}

/* ── Появление ───────────────────────────────────────────────────────── */
.dragon-svg { animation: ink-in 1.5s cubic-bezier(.6, 0, .2, 1) .15s both; }
.corner-rosette svg { animation: turn-in 1.2s cubic-bezier(.2, .8, .2, 1) both; }
.side-pillar svg { animation: rise 1.1s ease .35s both; }
.bottom-svg { animation: rise 1s ease .5s both; }
.gate-title { animation: title-in 1.3s cubic-bezier(.2, .7, .2, 1) .55s both; }
.divider { animation: rise .8s ease 1.05s both; }
.pin-form { animation: rise .9s ease 1.15s both; }
.screen-glow { animation: flicker 6s steps(1) infinite; }
.screen-grain { animation: grain 1s steps(5) infinite; }

@keyframes deny {
  0% { border-color: var(--screen-err); background-color: rgba(240, 119, 110, .28); box-shadow: 0 0 calc(var(--u) * 1.8) rgba(240, 119, 110, .75); }
  100% { background-color: var(--screen); box-shadow: 0 0 0 rgba(240, 119, 110, 0); }
}
@keyframes lock-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes sign-hit { from { opacity: .95; } to { opacity: 0; } }
@keyframes crown-descend {
  from { opacity: 0; transform: translateY(calc(var(--u) * -3.6)) rotate(-9deg) scale(.7); }
  to { opacity: 1; transform: none; }
}
@keyframes oath { 0%, 100% { filter: invert(0); } 35%, 65% { filter: invert(1); } }
/* Удары приходятся на 28% и 46% — на них же литавры в star-sound.js (playRoyal). */
@keyframes royal-sword {
  0% { transform: translateY(0px) rotate(-135deg); }
  13%, 20% { transform: translateY(0px) rotate(-180deg); }
  25% { transform: translateY(-14px) rotate(-180deg); }
  28%, 38% { transform: translateY(0px) rotate(-180deg); }
  43% { transform: translateY(-14px) rotate(-180deg); }
  46%, 76% { transform: translateY(0px) rotate(-180deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}
@keyframes royal-halberd {
  0% { transform: translateY(0px) rotate(-31deg); }
  13%, 20% { transform: translateY(0px) rotate(0deg); }
  25% { transform: translateY(-14px) rotate(0deg); }
  28%, 38% { transform: translateY(0px) rotate(0deg); }
  43% { transform: translateY(-14px) rotate(0deg); }
  46%, 100% { transform: translateY(0px) rotate(0deg); }
}
@keyframes guard-raise { from { transform: rotate(0deg); } }
@keyframes guard-thrust {
  0%, 100% { transform: rotate(var(--guard)); }
  28% { transform: rotate(calc(var(--guard) + var(--thrust))); }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes title-in {
  from { opacity: 0; letter-spacing: .22em; filter: blur(8px); }
  to { opacity: 1; letter-spacing: .02em; filter: blur(0); }
}
@keyframes ink-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes turn-in { from { opacity: 0; transform: rotate(-90deg) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes caret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .15; } }
/* Удар приходится на 62% времени — то же число в star-sound.js (IMPACT). */
@keyframes star-fall { /* кадр: темно, вспышка, расходящийся ореол, ровный свет */
  0%, 61% { background-color: rgba(234, 230, 223, 0); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
  63% { background-color: #fff; box-shadow: 0 0 calc(var(--u) * 3.6) calc(var(--u) * .5) rgba(255, 255, 255, .95); }
  100% { background-color: var(--light); box-shadow: 0 0 calc(var(--u) * 1.2) calc(var(--u) * 2.6) rgba(255, 255, 255, 0); }
}
@keyframes star-drop { /* глиф: появляется в момент удара метеора и остывает в тушь */
  0%, 61% { opacity: 0; color: #fff; transform: translate(-50%, -50%) rotate(-40deg) scale(2.3); }
  62% {
    opacity: 1; color: #fff; text-shadow: 0 0 calc(var(--u) * 1.8) #fff;
    transform: translate(-50%, -50%) rotate(-24deg) scale(2);
    animation-timing-function: cubic-bezier(.2, .9, .3, 1);
  }
  76% { color: #0a0a0a; text-shadow: 0 0 0 rgba(255, 255, 255, 0); transform: translate(-50%, -50%) rotate(7deg) scale(.8); }
  88% { transform: translate(-50%, -50%) rotate(-2deg) scale(1.08); }
  100% { opacity: 1; color: #0a0a0a; text-shadow: 0 0 0 rgba(255, 255, 255, 0); transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}
@keyframes film-run { to { background-position-x: calc(var(--u) * -1.7); } }
@keyframes frame-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@keyframes flicker { 0%, 100% { opacity: 1; } 7% { opacity: .86; } 9% { opacity: 1; } 43% { opacity: .92; } 46% { opacity: 1; } 78% { opacity: .82; } 80% { opacity: .97; } }
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); } 40% { transform: translate(3%, -5%); }
  60% { transform: translate(-2%, -3%); } 80% { transform: translate(5%, 2%); } 100% { transform: translate(0, 0); }
}
