@font-face {
  font-family: "Neoneon Rus";
  src: url("../fonts/Neoneon-Rus.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: #050510;
  color: #e8f7ff;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "Neoneon Rus", sans-serif;
}

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050510;
  cursor: none;
}

.stage.is-loupe-off,
.stage.is-on-controls {
  cursor: auto;
}

/* Заливка чёрных полей по бокам (и сверху/снизу на узких экранах) */
.ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #050510;
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 55% 70% at 50% 50%, transparent 35%, rgba(5, 5, 16, 0.55) 100%),
    linear-gradient(90deg, rgba(5, 5, 16, 0.35), transparent 18%, transparent 82%, rgba(5, 5, 16, 0.35));
  pointer-events: none;
}

.ambient-video {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(32px) saturate(1.35) brightness(0.58);
  transform: scale(1.08);
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
}

.ambient-video.is-active {
  opacity: 1;
}

.frame {
  position: relative;
  z-index: 1;
  width: min(100vw, 100dvh);
  height: min(100vw, 100dvh);
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background: #050510;
  container-type: size;
  box-shadow: 0 0 0 1px rgba(80, 180, 255, 0.12), 0 0 48px rgba(0, 0, 0, 0.45);
}

.videos {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
}

.bg-video.is-active {
  opacity: 1;
}

.poem {
  --poem-left: 39.5%;
  --poem-top: 34.2%;
  --poem-w: 20.8%;
  --poem-h: 43.2%;
  --stanza-scale-x: 0.72;
  --stanza-tracking: 0.175em;
  position: absolute;
  z-index: 2;
  left: var(--poem-left);
  top: var(--poem-top);
  width: var(--poem-w);
  height: var(--poem-h);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  gap: 0.28em;
  padding: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 1;
  background: transparent;
}

.stanza {
  font-family: "Neoneon Rus", sans-serif;
  font-size: 1.1cqmin;
  line-height: 1.12;
  letter-spacing: var(--stanza-tracking);
  text-transform: uppercase;
  color: #f4fbff;
  width: 100%;
  flex: 0 0 auto;
  white-space: nowrap;
  transform: scaleX(var(--stanza-scale-x));
  transform-origin: center center;
  -webkit-text-stroke: 0.45px rgba(180, 235, 255, 0.9);
  paint-order: stroke fill;
  text-shadow:
    0 0 2px #9fe9ff,
    0 0 6px rgba(60, 190, 255, 0.9),
    0 0 12px rgba(40, 160, 255, 0.55);
}

.stanza--fin {
  color: #ffe6ff;
  -webkit-text-stroke: 0.45px rgba(255, 200, 240, 0.9);
  text-shadow:
    0 0 2px #ffc0ef,
    0 0 6px rgba(255, 80, 190, 0.9),
    0 0 12px rgba(255, 40, 160, 0.55);
}

.loupe {
  position: fixed;
  z-index: 20;
  width: min(42vmin, 280px);
  height: min(42vmin, 280px);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(120, 230, 255, 0.85);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(80, 200, 255, 0.55),
    inset 0 0 24px rgba(0, 40, 80, 0.35);
  overflow: hidden;
  will-change: left, top, opacity;
}

.loupe.is-on {
  opacity: 1;
}

.loupe__clip {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
}

.loupe__zoom {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.loupe__zoom .frame {
  /* размер задаёт JS = размер оригинального кадра */
  max-width: none;
  max-height: none;
}

/* Слой кнопок = размер видеокадра, но НЕ внутри #frame (frame клонируется в лупу) */
.hud {
  position: absolute;
  z-index: 28;
  width: min(100vw, 100dvh);
  height: min(100vw, 100dvh);
  max-width: 100vw;
  max-height: 100dvh;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.loupe-toggle,
.tg-link {
  position: absolute;
  z-index: 35;
  top: 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 4.2rem;
  height: 4.2rem;
  padding: 0.3rem;
  border-radius: 1rem;
  border: 2px solid rgba(120, 230, 255, 0.75);
  background: #07101f;
  color: #7cf0ff;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  box-shadow:
    0 0 18px rgba(60, 190, 255, 0.45),
    inset 0 0 14px rgba(40, 140, 255, 0.2);
  isolation: isolate;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.loupe-toggle {
  right: 0.55rem;
}

.tg-link {
  left: 0.55rem;
  color: #7fe0ff;
  border-color: rgba(80, 200, 255, 0.8);
}

.loupe-toggle:hover,
.loupe-toggle:focus-visible,
.tg-link:hover,
.tg-link:focus-visible {
  transform: scale(1.06);
  outline: none;
  background: #0a1830;
}

.loupe-toggle__icon,
.tg-link__icon {
  width: 2.1rem;
  height: 2.1rem;
  display: block;
}

.tg-link__icon {
  width: 2rem;
  height: 2rem;
}

.loupe-toggle__label,
.tg-link__label,
.board__btn[data-text],
.board__tab[data-text] {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: inherit;
}

.loupe-toggle__label,
.tg-link__label {
  font-size: 0.72rem;
}

.loupe-toggle__label::before,
.tg-link__label::before,
.board__btn[data-text]::before,
.board__tab[data-text]::before {
  content: attr(data-text);
}

.loupe-toggle.is-on {
  color: #7cf0ff;
  border-color: rgba(124, 240, 255, 0.95);
}

.loupe-toggle:not(.is-on) {
  color: rgba(180, 210, 230, 0.55);
  border-color: rgba(120, 160, 190, 0.35);
  box-shadow: none;
}

.loupe-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: max(0.85rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: #c8f0ff;
  background: #07101f;
  border: 1px solid rgba(120, 220, 255, 0.28);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.loupe-hint.is-gone {
  opacity: 0;
}

.board {
  position: absolute;
  z-index: 25;
  left: 0.45rem;
  right: 0.45rem;
  bottom: 3.15rem;
  width: auto;
  max-width: calc(100% - 0.9rem);
  box-sizing: border-box;
  transition: left 0.3s ease, right 0.3s ease, bottom 0.3s ease, width 0.3s ease;
  pointer-events: none;
}

.board.is-collapsed {
  right: auto;
  left: 0;
  width: auto;
  max-width: none;
}

.board__screen {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.85rem;
  max-width: 100%;
  padding: 0.4rem 0.4rem 0.4rem 0.7rem;
  border-radius: 0.35rem;
  background: #07101f;
  border: 1px solid rgba(100, 210, 255, 0.4);
  box-shadow:
    0 0 16px rgba(40, 160, 255, 0.25),
    inset 0 0 18px rgba(0, 40, 80, 0.35);
  pointer-events: auto;
  box-sizing: border-box;
  isolation: isolate;
}

.board.is-collapsed .board__screen {
  display: none;
}

.board__actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.3rem;
}

.board__btn {
  appearance: none;
  flex-shrink: 0;
  height: 1.9rem;
  min-width: 1.9rem;
  padding: 0 0.55rem;
  border: 1px solid rgba(120, 220, 255, 0.45);
  border-radius: 999px;
  background: #0a1830;
  color: #c8f0ff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.board__btn--close {
  width: 1.9rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 500;
}

.board__btn:hover,
.board__btn:focus-visible {
  background: rgba(0, 160, 255, 0.28);
  outline: none;
}

.board__tab {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 0 0.4rem 0.4rem 0;
  border: 1px solid rgba(100, 210, 255, 0.45);
  border-left: 0;
  background: #07101f;
  color: #7cf0ff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(40, 160, 255, 0.3);
  pointer-events: auto;
  isolation: isolate;
}

.board.is-collapsed .board__tab {
  display: flex;
}

.board__tab:hover,
.board__tab:focus-visible {
  background: rgba(8, 28, 48, 0.95);
  outline: none;
}

.board__line {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: "Neoneon Rus", sans-serif;
  font-size: clamp(0.82rem, 3.2cqmin, 1.45rem);
  line-height: 1.15;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: #f4fbff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(0.35em);
  transition: opacity 0.35s ease, transform 0.35s ease;
  -webkit-text-stroke: 0.4px rgba(180, 235, 255, 0.85);
  paint-order: stroke fill;
  text-shadow:
    0 0 2px #9fe9ff,
    0 0 8px rgba(60, 190, 255, 0.9),
    0 0 14px rgba(40, 160, 255, 0.45);
  pointer-events: none;
}

.board__line.is-on {
  opacity: 1;
  transform: translateY(0);
}

.board__line.is-fin {
  color: #ffe6ff;
  -webkit-text-stroke: 0.4px rgba(255, 200, 240, 0.85);
  text-shadow:
    0 0 2px #ffc0ef,
    0 0 8px rgba(255, 80, 190, 0.9),
    0 0 14px rgba(255, 40, 160, 0.45);
}

.controls {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: max(0.55rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: #07101f;
  border: 1px solid rgba(120, 220, 255, 0.25);
  isolation: isolate;
  cursor: auto;
}

.ctrl,
.dot {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #c8f0ff;
}

.ctrl {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(140, 230, 255, 0.35);
}

.ctrl:hover,
.ctrl:focus-visible {
  background: rgba(0, 180, 255, 0.18);
  outline: none;
}

.dots {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(160, 220, 255, 0.35);
}

.dot.is-active {
  background: #7cf0ff;
  transform: scale(1.25);
  box-shadow: 0 0 8px #7cf0ff;
}

/* Телефон: зона вывески как на ПК (не шире трубы), текст плотнее — иначе «уезжает» вправо */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .poem {
    --poem-left: 39.5%;
    --poem-top: 34.2%;
    --poem-w: 20.8%;
    --poem-h: 43.2%;
    --stanza-scale-x: 0.52;
    --stanza-tracking: 0.05em;
    padding-inline: 2%;
    box-sizing: border-box;
  }

  .stage {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .frame,
  .hud {
    max-width: 100%;
  }

  .board__line {
    font-size: clamp(0.7rem, 2.6cqmin, 1.1rem);
    letter-spacing: 0.04em;
  }
}

@media (hover: none) and (pointer: coarse) {
  .stage {
    cursor: auto;
  }

  .loupe {
    width: min(48vmin, 300px);
    height: min(48vmin, 300px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-video,
  .ambient-video,
  .loupe-hint,
  .board__line {
    transition: none;
  }
}
