/* ===== Базовые стили ===== */
:root {
  --bg-dark: #050505;
  --neon-pink: #ff2a6d;
  --neon-pink-soft: #ff6b9d;
  --neon-purple: #d300c5;
  --neon-purple-soft: #e84dd4;
  --neon-soft: #ff8fab;
  --text-glow: rgba(255, 42, 109, 0.85);
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-display: 'Montserrat', 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: clamp(14px, 2.5vw, 18px);
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-mono);
  background: var(--bg-dark);
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#matrixCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  transition: opacity 1.2s ease-in-out;
}

body.screen2-active #matrixCanvas,
body.screen3-active #matrixCanvas,
body.screen4-active #matrixCanvas,
body.screen5-active #matrixCanvas {
  opacity: 0.15;
}

body.intro-active #matrixCanvas {
  opacity: 0;
}

/* Подсказка: открыть в Яндекс.Браузере (при открытии из Telegram на iPhone) */
.tg-open-in-yandex {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: rgba(26, 10, 18, 0.98);
  border-bottom: 1px solid rgba(255, 42, 109, 0.3);
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #ffe0ec;
}
.tg-open-in-yandex[hidden] { display: none !important; }
.tg-open-in-yandex:not([hidden]) { display: flex !important; }
.tg-open-in-yandex p { margin: 0; flex: 1 1 100%; }
.tg-open-in-yandex a {
  padding: 0.5rem 1rem;
  background: rgba(255, 42, 109, 0.25);
  border: 1px solid #ff2a6d;
  border-radius: 999px;
  color: #ff2a6d;
  text-decoration: none;
  font-weight: 600;
}
.tg-open-in-yandex button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ===== Общие экраны ===== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s ease-in-out, visibility 1.2s ease-in-out;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Экран 0: Нажми, чтобы начать ===== */
.screen-intro {
  background: var(--bg-dark);
}

.screen-intro.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

.screen0-content {
  text-align: center;
  max-width: 90%;
}

.screen0-text {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.screen0-sub {
  font-size: 1rem;
  color: var(--neon-soft);
  margin-bottom: 2rem;
  opacity: 0.9;
}

.start-btn {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  padding: 1rem 2.5rem;
  background: transparent;
  border: 2px solid var(--neon-pink);
  border-radius: 999px;
  color: var(--neon-pink);
  cursor: pointer;
  transition: all 0.35s ease;
  box-shadow: 0 0 25px rgba(255, 42, 109, 0.25);
}

.start-btn:hover,
.start-btn:focus-visible {
  background: var(--neon-pink);
  color: var(--bg-dark);
  box-shadow: 0 0 40px var(--text-glow), 0 0 60px rgba(255, 42, 109, 0.4);
  transform: scale(1.05);
}

.start-btn:active {
  transform: scale(0.98);
}

@keyframes introFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Экран 1: Заставка ===== */
.screen1-content {
  text-align: center;
  z-index: 2;
}

.countdown-wrapper {
  position: relative;
  display: inline-block;
  min-width: 1.2em;
  min-height: 1.2em;
}

.countdown-wrapper.exploding .countdown {
  visibility: hidden;
}

.countdown {
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 700;
  color: var(--neon-pink);
  text-shadow:
    0 0 20px var(--text-glow),
    0 0 40px var(--text-glow),
    0 0 60px rgba(255, 42, 109, 0.5);
  animation: countdownPulse 1.8s ease-in-out infinite;
  display: block;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.countdown.visible {
  opacity: 1;
  transform: scale(1);
  animation: countdownPulse 1.8s ease-in-out infinite;
}

.countdown.countdown-transitioning {
  animation: none;
}

@keyframes countdownPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.02); filter: brightness(1.08); }
}

.launch-text {
  font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.95);
  text-shadow:
    0 0 15px var(--text-glow),
    0 0 30px rgba(255, 107, 157, 0.4);
  line-height: 1.9;
  margin-top: 1.5rem;
  letter-spacing: 0.02em;
}

.launch-text p {
  margin: 0.25rem 0;
}

.launch-text.show {
  animation: launchTextFadeIn 1.4s ease-out;
}

@keyframes launchTextFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

.hidden.show {
  opacity: 1;
  visibility: visible;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

/* ===== Экран 2: Анализ ===== */
.screen2-content {
  max-width: 90%;
  width: 520px;
  min-height: 280px;
  background: rgba(5, 5, 5, 0.85);
  border: 1px solid var(--neon-pink);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 0 30px rgba(255, 42, 109, 0.2), inset 0 0 60px rgba(255, 42, 109, 0.05);
}

.terminal {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--neon-soft);
}

.terminal .cursor::after {
  content: '▌';
  animation: blink 0.8s step-end infinite;
  color: var(--neon-pink);
}

@keyframes blink {
  50% { opacity: 0; }
}

.terminal .highlight {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--text-glow);
}

.terminal .result-name {
  color: #fff;
  font-weight: 600;
}

/* ===== Экран 3: Сердце ===== */
#heartCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.screen3-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.screen3-title {
  font-size: 1.25rem;
  color: var(--neon-pink);
  text-shadow: 0 0 15px var(--text-glow);
  margin-bottom: 1rem;
  animation: fadeInUp 0.8s ease;
}

.screen3-date,
.screen3-event {
  font-size: 1rem;
  color: var(--neon-soft);
  margin: 0.5rem 0;
  animation: fadeInUp 0.8s ease backwards;
}

.screen3-date { animation-delay: 0.2s; }
.screen3-event { animation-delay: 0.4s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Экран 4: Поздравление ===== */
#screen4 {
  background: rgba(0, 0, 0, 0.75);
}

.screen4-content {
  max-width: 90%;
  width: 560px;
  text-align: center;
}

.greeting-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.95);
}

.greeting-text .greeting-cursor {
  color: var(--neon-pink);
  animation: typewriterBlink 0.7s step-end infinite;
}

.greeting-text .line {
  display: block;
  opacity: 0;
  animation: greetingFadeIn 1.2s ease-out forwards;
}

@keyframes greetingFadeIn {
  to { opacity: 1; }
}

/* ===== Экран 5: Финал ===== */
#screen5 {
  background: linear-gradient(165deg,
    #1a0a12 0%,
    #2d0f1f 25%,
    #1e0a18 50%,
    #250d1c 75%,
    #150810 100%);
  align-items: flex-start;
  justify-content: flex-start;
}

.screen5-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 100%;
  width: 100%;
  min-height: min(100%, 100vh);
  min-height: min(100%, 100dvh);
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom)) 1rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  box-sizing: border-box;
  justify-content: flex-start;
}

.hearts-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.final-title {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.3;
  color: #ffe0ec;
  text-shadow: 0 0 25px var(--text-glow), 0 0 50px rgba(255, 42, 109, 0.4);
  margin-bottom: 0.35rem;
  margin-top: 0;
  animation: fadeInUp 0.8s ease;
  max-width: 92%;
  word-wrap: break-word;
  flex-shrink: 0;
}

.final-title .typewriter-cursor {
  color: var(--neon-pink);
  animation: typewriterBlink 0.7s step-end infinite;
}

@keyframes typewriterBlink {
  50% { opacity: 0; }
}

.final-subtitle {
  font-size: clamp(1rem, 4vw, 1.2rem);
  color: var(--neon-soft);
  margin-bottom: 1rem;
  animation: fadeInUp 0.8s ease 0.2s backwards;
}

/* Альбом-книга с перелистыванием страниц (StPageFlip) */
.album-wrap {
  width: 100%;
  max-width: 360px;
  margin-bottom: 1rem;
  flex-shrink: 0;
  animation: fadeInUp 0.8s ease 0.3s backwards;
}

.album-wrap.hidden {
  display: none !important;
}

.album-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.album-container {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.album-book {
  width: 280px;
  height: 340px;
  margin: 0 auto;
}

.album-book canvas,
.album-book .stf__block {
  border-radius: 8px;
}

.album-book .stf__parent {
  margin: 0 auto;
  min-height: 340px;
}

.album-book .stf__wrapper {
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 42, 109, 0.15);
}

.album-placeholder {
  width: 100%;
  max-width: 280px;
  min-height: 280px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 42, 109, 0.2);
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.album-placeholder-inner {
  text-align: center;
  padding: 1rem;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}

.album-placeholder-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.album-placeholder-inner p {
  margin: 0.35rem 0;
}

.album-placeholder-inner strong {
  color: var(--neon-soft);
}

.album-placeholder-hint {
  font-size: 0.75rem !important;
  color: rgba(255, 255, 255, 0.5) !important;
}

.album-placeholder-hint {
  font-size: 0.75rem !important;
  color: rgba(255, 255, 255, 0.5) !important;
}

.album-placeholder-inner code {
  background: rgba(255, 42, 109, 0.2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

.album-counter {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.4rem;
}

.love-btn {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.1rem);
  padding: 0.85rem 1.75rem;
  min-height: 48px;
  min-width: 180px;
  background: transparent;
  border: 2px solid var(--neon-pink);
  border-radius: 999px;
  color: var(--neon-pink);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(255, 42, 109, 0.3);
  animation: fadeInUp 0.8s ease 0.4s backwards;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.love-btn:hover,
.love-btn:focus-visible {
  background: var(--neon-pink);
  color: var(--bg-dark);
  box-shadow: 0 0 35px var(--text-glow);
  transform: scale(1.05);
}

.love-btn:active {
  transform: scale(0.98);
}

.love-boost {
  margin-top: 1rem;
  animation: loveBoostIn 0.8s ease forwards;
  flex-shrink: 0;
}

.love-boost-inner {
  padding: 1.25rem 1.5rem;
  border-radius: 20px;
  background: rgba(255, 42, 109, 0.12);
  border: 1px solid rgba(255, 42, 109, 0.35);
  box-shadow: 0 0 40px rgba(255, 42, 109, 0.2), inset 0 0 30px rgba(255, 42, 109, 0.08);
}

.love-boost-text {
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  font-weight: 600;
  color: #ffe0ec;
  text-shadow: 0 0 20px var(--text-glow);
  margin-bottom: 0.75rem;
}

.big-heart {
  font-size: clamp(3.5rem, 18vw, 7rem);
  line-height: 1;
  color: var(--neon-pink);
  filter: drop-shadow(0 0 20px var(--text-glow)) drop-shadow(0 0 40px rgba(255, 42, 109, 0.5));
  animation: heartPulse 0.8s ease infinite;
}

@keyframes loveBoostIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ===== Частицы сердечек ===== */
.particle-heart {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0.7;
  pointer-events: none;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(360deg);
  }
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
  .screen {
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  }

  .screen5-content {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .album-container {
    min-height: 300px;
  }

  .album-book {
    width: 260px;
    height: 320px;
  }

  .album-book .stf__parent {
    min-height: 320px;
  }
}

@media (max-width: 480px) {
  .screen {
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  }

  .screen0-text {
    font-size: clamp(1.1rem, 5vw, 1.4rem);
  }

  .start-btn {
    padding: 0.9rem 2rem;
    min-height: 48px;
  }

  .countdown {
    font-size: clamp(3rem, 18vw, 5rem);
  }

  .screen2-content {
    padding: 1rem;
    min-height: 220px;
    width: 100%;
  }

  .terminal {
    font-size: 0.8rem;
  }

  .screen3-title {
    font-size: 1.1rem;
  }

  .screen3-date,
  .screen3-event {
    font-size: 0.9rem;
  }

  .greeting-text {
    font-size: 0.9rem;
  }

  .screen5-content {
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .final-title {
    font-size: clamp(1.25rem, 6.5vw, 1.75rem);
    padding-top: 0.25rem;
  }

  .final-subtitle {
    margin-bottom: 1rem;
  }

  .album-wrap {
    max-width: 100%;
    margin-bottom: 0.75rem;
  }

  .album-container {
    min-height: 260px;
  }

  .album-book {
    width: 220px;
    height: 280px;
  }

  .album-book .stf__parent {
    min-height: 280px;
  }

  .album-label {
    font-size: 0.85rem;
  }

  .love-btn {
    padding: 0.75rem 1.5rem;
    min-width: 160px;
  }

  .love-boost-inner {
    padding: 1rem 1.25rem;
  }

  .big-heart {
    font-size: clamp(2.5rem, 22vw, 5rem);
  }

  .particle-heart {
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .album-book {
    width: 200px;
    height: 260px;
  }

  .album-book .stf__parent {
    min-height: 260px;
  }

  .album-container {
    min-height: 240px;
  }
}

/* Предзагрузка шрифтов (опционально) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Montserrat:wght@400;600;700&display=swap');
