/* =========================================================
   Тема: нежный пастельно-розовый.
   Здесь живут все анимации.
   ========================================================= */

:root {
  --bg1: #ffe3ef;
  --bg2: #ffd0e4;
  --bg3: #fff2f8;
  --bg4: #ffe6d4;

  --pink: #ff84b0;
  --pink-deep: #ff5e9a;
  --rose: #ff9ec4;
  --gold: #ffd27d;

  --card-bg: rgba(255, 255, 255, 0.55);
  --card-border: rgba(255, 255, 255, 0.75);

  --text: #6f3f53;
  --text-soft: #a06d83;
  --white: #ffffff;

  --shadow-soft: 0 18px 40px rgba(255, 94, 154, 0.22);
  --shadow-btn: 0 10px 24px rgba(255, 94, 154, 0.38);

  --app-h: 100vh;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1), var(--bg3) 35%, var(--bg2) 70%, var(--bg4));
  position: relative;
  user-select: none;
  perspective: 1200px;
}

@keyframes bgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* мягкое розовое свечение, медленно дышит */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(40% 35% at 25% 20%, rgba(255, 158, 196, 0.5), transparent 70%),
    radial-gradient(45% 40% at 80% 75%, rgba(255, 210, 125, 0.35), transparent 70%);
  filter: blur(10px);
  animation: glow 12s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes glow {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 1;   transform: scale(1.08); }
}

/* ---------- плавающие сердечки ---------- */
.hearts-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.float-heart {
  position: absolute;
  bottom: -40px;
  font-size: 22px;
  will-change: transform, opacity;
  animation: floatUp linear forwards;
}

@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) scale(0.5) rotate(0deg); opacity: 0; }
  12%  { opacity: 0.95; }
  50%  { transform: translateY(-55vh) translateX(var(--drift)) scale(1) rotate(var(--rot)); }
  100% { transform: translateY(-115vh) translateX(calc(var(--drift) * -1)) scale(1.05) rotate(calc(var(--rot) * 2)); opacity: 0; }
}

/* ---------- конфетти ---------- */
#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

/* ---------- прогресс ---------- */
.progress {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 0;
  right: 0;
  display: flex;
  gap: 7px;
  justify-content: center;
  z-index: 5;
}

.progress .dot {
  font-size: 13px;
  line-height: 1;
  opacity: 0.32;
  transform: scale(0.8);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.progress .dot.on {
  opacity: 1;
  transform: scale(1.2);
  filter: drop-shadow(0 2px 5px rgba(255, 94, 154, 0.55));
}

/* ---------- звук ---------- */
.sound-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 14px;
  z-index: 7;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-soft);
  font-size: 17px;
  cursor: pointer;
}

/* ---------- сцена и карточки ---------- */
.stage {
  position: relative;
  z-index: 2;
  height: var(--app-h);
  width: 100%;
  will-change: transform;
}

.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 64px 26px 48px;
  overflow-y: auto;
}

.card-enter { animation: cardIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.card-exit  { animation: cardOut 0.4s ease both; }

@keyframes cardIn {
  0%   { opacity: 0; transform: translateY(30px) scale(0.96); }
  100% { opacity: 1; transform: none; }
}
@keyframes cardOut {
  0%   { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-26px) scale(0.97); }
}

/* появление содержимого карточки по очереди.
   Делаем через transition (не animation), чтобы не конфликтовать
   с собственными анимациями элементов (bob у эмодзи, pulse у кнопки). */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.reveal.in {
  opacity: 1;
  transform: none;
}
/* keyframe оставляем, им пользуются строки финального сообщения */
@keyframes reveal {
  to { opacity: 1; transform: none; }
}

/* ---------- типографика ---------- */
.title {
  font-family: "Comfortaa", "Nunito", sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 6.5vw, 32px);
  margin: 0;
  line-height: 1.25;
  color: var(--text);
  text-wrap: balance;
}

.title.script {
  font-family: "Pacifico", "Comfortaa", cursive;
  font-weight: 400;
  font-size: clamp(30px, 8vw, 40px);
  color: var(--pink-deep);
}

.text {
  font-size: clamp(16px, 4.4vw, 18px);
  line-height: 1.55;
  margin: 0;
  max-width: 30ch;
  color: var(--text-soft);
}

.emoji-xl {
  font-size: clamp(56px, 16vw, 76px);
  line-height: 1;
  filter: drop-shadow(0 10px 16px rgba(255, 94, 154, 0.25));
  animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-12px) rotate(4deg); }
}

/* ---------- кнопки ---------- */
.btn {
  font-family: "Comfortaa", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 15px 34px;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.25s ease;
}
.btn:active { transform: scale(0.95); }

.btn-pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 24px rgba(255, 94, 154, 0.35); transform: translateY(0); }
  50%      { box-shadow: 0 16px 36px rgba(255, 94, 154, 0.55); transform: translateY(-3px); }
}

/* ---------- варианты ответа ---------- */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin-top: 4px;
}

.option {
  font-family: "Nunito", sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  text-align: center;
  border: 2px solid var(--card-border);
  border-radius: 18px;
  padding: 15px 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(255, 94, 154, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.option:active { transform: scale(0.97); }

.option.correct {
  border-color: #8fd9a8;
  background: linear-gradient(135deg, #d8f6e2, #b9efcd);
  color: #2f7a4f;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.option.wrong {
  border-color: #ffb3c6;
  background: rgba(255, 220, 230, 0.8);
}

.shake { animation: shake 0.5s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

@keyframes pop {
  0%   { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- всплывающая подсказка ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translate(-50%, 20px);
  z-index: 8;
  max-width: 80vw;
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(111, 63, 83, 0.92);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(111, 63, 83, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* подсказка в reflect-вопросах */
.hint {
  font-size: 14px;
  color: var(--text-soft);
  opacity: 0.85;
  margin: -4px 0 2px;
  font-style: italic;
}

/* =========================================================
   Игровые шаги: убегающая кнопка и тапалка
   ========================================================= */
.runaway {
  position: fixed;
  z-index: 7;
  margin: 0;
  touch-action: manipulation;
  transition: left 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              top 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.12s ease;
}
.btn-ghost {
  background: linear-gradient(135deg, #c9ccd6, #aeb2c0);
  box-shadow: 0 8px 18px rgba(120, 120, 140, 0.3);
}

.tap-counter {
  font-family: "Comfortaa", sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--pink-deep);
}
.tap-target {
  font-size: clamp(64px, 18vw, 92px);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  filter: drop-shadow(0 8px 14px rgba(255, 94, 154, 0.3));
}
.pop-tap { animation: popTap 0.16s ease; }
@keyframes popTap {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* =========================================================
   Пионы: плавающие в фоне + распускающиеся
   ========================================================= */
.float-peony {
  position: absolute;
  bottom: -60px;
  display: block;
  will-change: transform, opacity;
  animation: floatUp linear forwards;
}

.peony-bloom {
  width: clamp(96px, 26vw, 128px);
  height: clamp(96px, 26vw, 128px);
  animation: peonyBloom 1s cubic-bezier(0.2, 1.3, 0.4, 1) both;
  filter: drop-shadow(0 10px 18px rgba(255, 110, 170, 0.32));
}
.peony-bloom img {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
  animation: spinSlow 22s linear infinite;
}
@keyframes peonyBloom {
  0%   { transform: scale(0) rotate(-45deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(6deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes spinSlow { to { transform: rotate(360deg); } }

.peony-pair { display: flex; gap: 4px; align-items: flex-end; }
.peony-pair .peony-bloom { width: 76px; height: 76px; }
.peony-pair .peony-bloom:nth-child(2) { width: 58px; height: 58px; animation-delay: 0.15s; }

/* ---------- bloom: подержи пион, и он распустится ---------- */
.bloom-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.bloom-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--pink-deep) calc(var(--p, 0) * 1%), rgba(255, 158, 196, 0.18) 0);
  -webkit-mask: radial-gradient(circle, transparent 61%, #000 62%);
  mask: radial-gradient(circle, transparent 61%, #000 62%);
}
.bloom-flower {
  width: 116px;
  height: 116px;
  transition: opacity 0.12s linear;
  filter: drop-shadow(0 6px 12px rgba(255, 110, 170, 0.3));
}
.bloom-flower img { display: block; width: 100%; height: 100%; will-change: transform; }
.bloom-flower.bloomed { animation: bloomPop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes bloomPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------- scratch: сотри слой и прочитай ---------- */
.scratch-box {
  position: relative;
  width: min(86%, 320px);
  height: 124px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.scratch-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  font-family: "Comfortaa", sans-serif;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
  color: var(--pink-deep);
  background: #fff7fb;
}
.scratch-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}

/* =========================================================
   Ворота: поле пароля и обратный отсчёт
   ========================================================= */
.pw-input {
  font-family: "Nunito", sans-serif;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  color: var(--text);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 13px 18px;
  width: min(80%, 280px);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  box-shadow: 0 8px 20px rgba(255, 94, 154, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.pw-input::placeholder { color: var(--text-soft); opacity: 0.7; }
.pw-input:focus {
  border-color: var(--rose);
  box-shadow: 0 10px 26px rgba(255, 94, 154, 0.22);
}

.countdown {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}
.cd-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 10px 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(255, 94, 154, 0.14);
}
.cd-num {
  font-family: "Comfortaa", sans-serif;
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  color: var(--pink-deep);
  font-variant-numeric: tabular-nums;
}
.cd-lbl {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 3px;
}

/* =========================================================
   Параллакс / 3D + поле желания + вторичная кнопка
   ========================================================= */
.parallax {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.px-layer { position: absolute; inset: 0; will-change: transform; }
.px-blob {
  position: absolute;
  opacity: 0.5;
  background-size: contain;
  background-repeat: no-repeat;
  filter: blur(12px) saturate(1.15);
  will-change: transform;
}

.wish-input {
  font-family: "Nunito", sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 12px 16px;
  width: min(86%, 320px);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  resize: none;
  box-shadow: 0 8px 20px rgba(255, 94, 154, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.wish-input::placeholder { color: var(--text-soft); opacity: 0.7; }
.wish-input:focus { border-color: var(--rose); box-shadow: 0 10px 26px rgba(255, 94, 154, 0.22); }

.btn-link {
  background: none;
  color: var(--text-soft);
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  margin-top: 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:active { transform: scale(0.97); }

/* =========================================================
   ФИНАЛ: большое число, торт, поздравление
   ========================================================= */
.big-num {
  font-family: "Pacifico", cursive;
  font-size: clamp(70px, 22vw, 104px);
  line-height: 1;
  background: linear-gradient(135deg, var(--pink-deep), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: numPop 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) both, numFloat 4s ease-in-out infinite 0.9s;
  filter: drop-shadow(0 6px 12px rgba(255, 94, 154, 0.3));
}
@keyframes numPop {
  0%   { transform: scale(0) rotate(-18deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes numFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ---- торт ---- */
.cake {
  position: relative;
  width: 210px;
  height: 168px;
  margin: 8px auto 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.cake:active { transform: scale(0.97); }
.cake.done { cursor: default; }

.cake .plate {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  height: 20px;
  background: linear-gradient(#ffffff, #ffe0ee);
  border-radius: 50%;
  box-shadow: 0 10px 22px rgba(255, 94, 154, 0.28);
}
.cake .layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 16px;
}
.cake .layer-bottom {
  bottom: 16px;
  width: 178px;
  height: 74px;
  background: linear-gradient(#ffb3d1, #ff8fbb);
  box-shadow: inset 0 -8px 14px rgba(255, 94, 154, 0.25);
}
.cake .layer-top {
  bottom: 84px;
  width: 144px;
  height: 56px;
  background: linear-gradient(#ffc7df, #ff9ec4);
}
.cake .icing {
  position: absolute;
  bottom: 122px;
  left: 50%;
  transform: translateX(-50%);
  width: 144px;
  height: 22px;
  background: #fff6fb;
  border-radius: 14px;
}
.cake .icing::before,
.cake .icing::after {
  content: "";
  position: absolute;
  top: 12px;
  width: 22px;
  height: 18px;
  background: #fff6fb;
  border-radius: 0 0 14px 14px;
}
.cake .icing::before { left: 24px; }
.cake .icing::after  { right: 24px; }

/* сахарные шарики */
.cake .sprinkle {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  z-index: 2;
}

.cake .candle {
  position: absolute;
  bottom: 132px;
  width: 11px;
  height: 36px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #ff7eb3 0 6px, #fff 6px 12px);
  z-index: 3;
}
.cake .candle.c1 { left: calc(50% - 28px); }
.cake .candle.c2 { left: calc(50% + 17px); }

.cake .flame {
  position: absolute;
  top: -19px;
  left: 50%;
  width: 14px;
  height: 21px;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  background: radial-gradient(circle at 50% 75%, #fff 0 18%, var(--gold) 40%, #ff9a3d 78%);
  border-radius: 50% 50% 50% 50% / 62% 62% 40% 40%;
  box-shadow: 0 0 18px 5px rgba(255, 180, 80, 0.8);
  animation: flicker 0.9s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(-3deg); opacity: 0.95; }
  50%      { transform: translateX(-50%) scale(1.14, 1.2) rotate(3deg); opacity: 1; }
}

.candle.out .flame { animation: blowOut 0.5s forwards; }
@keyframes blowOut {
  0%   { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(0.2); box-shadow: none; }
}

/* дымок после задувания */
.smoke {
  position: absolute;
  top: -22px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(170, 150, 160, 0.6);
  transform: translateX(-50%);
  animation: smoke 1.1s ease-out forwards;
}
@keyframes smoke {
  0%   { opacity: 0.7; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(2.4); }
}

.hint-blow {
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* ---- финальное сообщение ---- */
.finale-msg {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 32ch;
}
.finale-msg.hidden { display: none; }

.msg-line {
  margin: 0;
  font-size: clamp(16px, 4.4vw, 18px);
  line-height: 1.55;
  color: var(--text);
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.sign {
  margin-top: 8px;
  font-family: "Pacifico", cursive;
  font-size: 20px;
  color: var(--pink-deep);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; }
}
