* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #07050d;
  color: #f1edf7;
  font-family: 'Manrope', system-ui, sans-serif;
  overflow-x: hidden;
  color-scheme: dark;
}

body {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* --- фоновые свечения, как на референсе --- */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

.bg-glow--1 {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -150px;
  background: radial-gradient(circle, #7b5cff 0%, transparent 70%);
  animation: drift1 22s ease-in-out infinite;
}

.bg-glow--2 {
  width: 700px;
  height: 700px;
  bottom: -250px;
  right: -200px;
  background: radial-gradient(circle, #4f2cc9 0%, transparent 70%);
  animation: drift2 26s ease-in-out infinite;
}

.bg-glow--3 {
  width: 420px;
  height: 420px;
  top: 35%;
  right: -120px;
  background: radial-gradient(circle, #e08bff 0%, transparent 70%);
  opacity: 0.3;
  animation: drift3 30s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.08); }
}

@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.1); }
}

@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-40px, 50px) scale(0.92); }
}

.bg-orb {
  position: fixed;
  bottom: -55vw;
  left: 50%;
  transform: translateX(-50%);
  width: 160vw;
  height: 160vw;
  max-width: 1800px;
  max-height: 1800px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 0%, #1a1030 0%, #050308 60%);
  box-shadow: 0 -40px 160px rgba(123, 92, 255, 0.35);
  pointer-events: none;
  z-index: 0;
}

.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  bottom: -10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(201, 182, 255, 0.55);
  box-shadow: 0 0 8px rgba(201, 182, 255, 0.7);
  animation: rise linear infinite;
}

@keyframes rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-100vh) translateX(var(--drift, 20px)); opacity: 0; }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  position: relative;
  background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  padding: 40px 30px;
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 70px -20px rgba(80, 40, 200, 0.5), inset 0 1px 0 rgba(255,255,255,0.12);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(201,182,255,0.4), transparent 40%, transparent 70%, rgba(201,182,255,0.15));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: #b8a4ff;
  margin: 0 0 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b8a4ff);
}

.title {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
  background: linear-gradient(120deg, #ffffff, #c9b6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text {
  font-size: 16px;
  line-height: 1.6;
  color: #d7cdf0;
  margin: 0 0 16px;
}

.text--accent {
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
}

.btn {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 16px;
  padding: 17px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: linear-gradient(135deg, #9a6cff, #5b2ce0);
  color: #fff;
  box-shadow: 0 14px 34px -8px rgba(138, 92, 255, 0.65);
  margin-top: 8px;
}

.btn--primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}

.btn--primary:not(:disabled):hover::after {
  left: 140%;
}

.btn--primary:not(:disabled):hover {
  box-shadow: 0 16px 40px -8px rgba(138, 92, 255, 0.8);
  transform: translateY(-1px);
}

.btn--primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--ghost {
  background: rgba(255,255,255,0.05);
  color: #d7cdf0;
  border: 1px solid rgba(255,255,255,0.12);
  margin-top: 14px;
}

.btn--ghost:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.2);
}

/* --- прогресс (сердечки) --- */
.progress-hearts {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  min-height: 20px;
}

.progress-heart {
  font-size: 13px;
  color: rgba(255,255,255,0.15);
  line-height: 1;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.progress-heart.filled {
  color: #c9b6ff;
  text-shadow: 0 0 8px rgba(201,182,255,0.9);
}

.progress-heart.pop {
  animation: heartPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.8); }
  100% { transform: scale(1); }
}

/* --- карточка вопроса --- */
.card--question {
  display: flex;
  flex-direction: column;
}

.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 22px;
  background: linear-gradient(160deg, #2a1a55, #120a26);
  box-shadow: 0 20px 50px -16px rgba(80, 40, 200, 0.6), inset 0 0 0 1px rgba(255,255,255,0.1);
}

.photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.5s ease, transform 0.6s ease;
}

.photo.is-visible {
  opacity: 1;
  transform: scale(1);
}

.photo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 800;
  color: rgba(255,255,255,0.18);
  background: radial-gradient(circle at 30% 20%, rgba(138,92,255,0.35), transparent 60%);
}

.q-counter {
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b8a4ff;
  font-weight: 700;
  margin: 0 0 8px;
}

.q-text {
  font-family: 'Fraunces', serif;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 22px;
  color: #fff;
}

.q-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.q-option {
  position: relative;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 14px 16px 14px 44px;
  color: #e9e3fa;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  opacity: 0;
  animation: optionIn 0.4s ease forwards;
}

.q-option::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  transition: border-color 0.15s ease, background 0.15s ease;
}

@keyframes optionIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.q-option:hover {
  background: rgba(255,255,255,0.09);
  transform: translateY(-1px);
}

.q-option.selected {
  background: linear-gradient(135deg, rgba(138,92,255,0.35), rgba(91,44,224,0.35));
  border-color: #8a5cff;
  box-shadow: 0 8px 22px -8px rgba(138,92,255,0.6);
}

.q-option.selected::before {
  border-color: #c9b6ff;
  background: radial-gradient(circle, #c9b6ff 40%, transparent 45%);
}

.q-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 8px;
}

.q-textarea::placeholder {
  color: rgba(255,255,255,0.35);
}

.q-textarea:focus, .q-option:focus {
  outline: 2px solid #8a5cff;
}

/* --- экран пароля --- */
.card--lock {
  text-align: center;
}

.lock-photo-frame {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 20px;
  border: 2px solid rgba(168,85,247,0.4);
  box-shadow: 0 0 24px rgba(168,85,247,0.3);
}

.lock-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lock-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 16px;
  color: #fff;
  font-size: 18px;
  letter-spacing: 0.2em;
  text-align: center;
  font-family: inherit;
  margin-top: 6px;
  margin-bottom: 10px;
}

.lock-input::placeholder {
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.2em;
}

.lock-input:focus {
  outline: 2px solid #8a5cff;
}

.lock-error {
  color: #ff9a9a;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
}

/* --- финальный экран --- */
.card--final {
  text-align: center;
}

.gift-frame {
  position: relative;
  width: 188px;
  height: 188px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.gift-frame.is-revealed {
  animation: giftBounceIn 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes giftBounceIn {
  0% { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.gift-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #8a5cff, #e08bff, #c9b6ff, #5b2ce0, #8a5cff);
  animation: spin 6s linear infinite;
  filter: blur(0.5px);
}

.gift-ring::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #0a0610;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.gift-frame > .gift-img,
.gift-frame > .gift-fallback {
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  z-index: 1;
}

.gift-img {
  object-fit: cover;
  display: block;
  box-shadow: 0 0 50px rgba(138,92,255,0.6);
  animation: pulse 2.4s ease-in-out infinite;
}

.gift-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: radial-gradient(circle at 30% 25%, rgba(138,92,255,0.5), rgba(20,12,40,0.9));
  box-shadow: 0 0 50px rgba(138,92,255,0.6);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 50px rgba(138,92,255,0.55); }
  50% { box-shadow: 0 0 75px rgba(138,92,255,0.85); }
}

.final-title {
  font-family: 'Fraunces', serif;
  font-size: 27px;
  font-weight: 600;
  margin: 0 0 20px;
  background: linear-gradient(120deg, #ffffff, #c9b6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.final-text {
  text-align: left;
  font-size: 15px;
  line-height: 1.7;
  color: #d7cdf0;
}

.final-text p {
  margin: 0 0 14px;
}

.final-text__signature {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.love-sent {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 700;
  color: #c9b6ff;
}

/* --- оверлей ошибки --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 2, 10, 0.75);
  backdrop-filter: blur(6px);
  padding: 24px;
}

.overlay__card {
  background: linear-gradient(160deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(80, 40, 200, 0.6);
  animation: popIn 0.25s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.overlay__text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 20px;
}

/* --- переходы между экранами --- */
.screen.is-exiting {
  animation: screenExit 0.28s ease forwards;
  pointer-events: none;
}

@keyframes screenExit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-18px); }
}

/* --- индикатор набора текста --- */
.typing-indicator {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 18px 0;
}

.typing-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(201,182,255,0.5);
  box-shadow: 0 0 8px rgba(201,182,255,0.6);
  animation: typingBounce 1.1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* --- конфетти-сердечки --- */
.confetti-heart {
  position: fixed;
  bottom: -50px;
  pointer-events: none;
  z-index: 200;
  user-select: none;
  animation: heartFloat linear forwards;
}

@keyframes heartFloat {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  80% { opacity: 0.9; }
  100% { transform: translateY(-115vh) rotate(var(--spin, 25deg)); opacity: 0; }
}

/* --- тряска при неверном ответе --- */
.card--question.shake {
  animation: shake 0.42s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  45% { transform: translateX(10px); }
  65% { transform: translateX(-7px); }
  82% { transform: translateX(7px); }
}

/* --- ссылки в финальном тексте --- */
.final-text a {
  color: #c9b6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(201,182,255,0.35);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.final-text a:hover {
  color: #fff;
  text-decoration-color: rgba(255,255,255,0.6);
}

/* --- мобильная оптимизация --- */
@media (max-width: 480px) {
  #app {
    padding: 14px;
  }

  .card {
    padding: 24px 18px;
    border-radius: 20px;
  }

  .title {
    font-size: 26px;
    margin-bottom: 16px;
  }

  .text {
    font-size: 15px;
  }

  .q-text {
    font-size: 19px;
  }

  .final-title {
    font-size: 22px;
  }

  .gift-frame {
    width: 150px;
    height: 150px;
  }

  .gift-ring::after {
    inset: 5px;
  }

  .gift-frame > .gift-img,
  .gift-frame > .gift-fallback {
    width: 124px;
    height: 124px;
  }

  .progress-heart {
    font-size: 11px;
    gap: 4px;
  }

  .q-option {
    font-size: 14px;
    padding: 13px 14px 13px 40px;
  }

  .btn {
    padding: 15px 20px;
    font-size: 15px;
  }

  .overlay__card {
    padding: 28px 20px;
  }
}
