:root {
  --bg1: #2b0a4a;
  --bg2: #6a1b9a;
  --bg3: #c2185b;
  --accent: #ffd54f;
  --pink: #ff7eb3;
  --text: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  overflow: hidden;
}

body {
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 45%, var(--bg3) 100%);
  background-attachment: fixed;
}

/* ---------- Декоративный фон ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.balloon {
  position: absolute;
  bottom: -160px;
  width: 64px;
  height: 80px;
  border-radius: 50% 50% 48% 48%;
  opacity: 0.85;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.25));
  animation: float 16s linear infinite;
}
.balloon::after {
  content: "";
  position: absolute;
  bottom: -10px; left: 50%;
  width: 2px; height: 14px;
  background: rgba(255,255,255,.5);
  transform: translateX(-50%);
}
.b1 { left: 8%;  background: #ff5c8a; animation-duration: 18s; animation-delay: 0s; }
.b2 { left: 28%; background: #ffd54f; animation-duration: 22s; animation-delay: 3s; width: 52px; height: 66px;}
.b3 { left: 52%; background: #4fc3f7; animation-duration: 20s; animation-delay: 6s; }
.b4 { left: 72%; background: #81c784; animation-duration: 24s; animation-delay: 2s; width: 56px; height: 70px;}
.b5 { left: 88%; background: #ba68c8; animation-duration: 19s; animation-delay: 8s; }

@keyframes float {
  0%   { transform: translateY(0) translateX(0); }
  50%  { transform: translateY(-60vh) translateX(20px); }
  100% { transform: translateY(-120vh) translateX(-10px); }
}

.confetti { position: absolute; inset: 0; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px; height: 14px;
  border-radius: 2px;
  opacity: .9;
  animation: fall linear infinite;
}
@keyframes fall {
  0%   { transform: translateY(-20px) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Скролл по страницам ---------- */
.scroller {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100svh; /* гарантированно влезает при показанной адресной строке */
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.page {
  position: relative;
  height: 100vh;
  height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.content {
  text-align: center;
  max-width: 720px;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: rise .8s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hello {
  font-size: clamp(2.6rem, 11vw, 6rem);
  font-weight: 800;
  letter-spacing: -1px;
  text-shadow: 0 4px 24px rgba(0,0,0,.35);
  background: linear-gradient(90deg, #fff, var(--accent), var(--pink), #fff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 6s linear infinite;
}
@keyframes shine { to { background-position: 300% 0; } }

.big {
  font-size: clamp(2rem, 7.5vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.dots { color: var(--accent); }

.lead {
  margin-top: 14px;
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  opacity: .92;
}

/* ---------- Подсказка о пролистывании ---------- */
.scroll-hint {
  flex: 0 0 auto;
  margin-bottom: max(6px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: .85;
  animation: bob 1.8s ease-in-out infinite;
}
.chevron {
  width: 16px; height: 16px;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(45deg);
}
@keyframes bob {
  0%,100% { transform: translateY(0); opacity: .85; }
  50%     { transform: translateY(8px); opacity: 1; }
}

/* ---------- Страница ошибки ---------- */
.page-error { background: rgba(20, 0, 30, .35); }
.error-content { animation: glitch-in .5s ease both; }
@keyframes glitch-in {
  0% { opacity: 0; transform: scale(.9) translateY(10px); }
  60% { opacity: 1; transform: scale(1.02); }
  100% { transform: scale(1); }
}
.error-badge {
  display: inline-block;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ff5252;
  border: 2px solid #ff5252;
  border-radius: 10px;
  padding: 8px 18px;
  margin-bottom: 22px;
  background: rgba(255,82,82,.12);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: .35; } }
.struck {
  font-size: clamp(2.2rem, 9vw, 5rem);
  font-weight: 800;
  color: #ffd6d6;
  position: relative;
  display: inline-block;
}
.struck::after {
  content: "";
  position: absolute;
  left: -4%; right: -4%; top: 52%;
  height: 6px;
  background: #ff5252;
  border-radius: 3px;
  box-shadow: 0 0 12px #ff5252;
  transform: scaleX(0);
  transform-origin: left;
  animation: strike .5s .35s ease forwards;
}
@keyframes strike { to { transform: scaleX(1); } }
.error-sub { margin-top: 20px; font-size: clamp(1rem, 4vw, 1.4rem); opacity: .8; }

/* ---------- Взрыв на странице ошибки ---------- */
.boom-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.error-content { position: relative; z-index: 3; }

/* тряска всей страницы при взрыве */
.page-error.boom { animation: shake .55s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10% { transform: translate(-9px, 5px); }
  20% { transform: translate(8px, -8px); }
  30% { transform: translate(-10px, 4px); }
  40% { transform: translate(9px, 7px); }
  50% { transform: translate(-7px, -6px); }
  60% { transform: translate(7px, 5px); }
  70% { transform: translate(-5px, -4px); }
  80% { transform: translate(4px, 3px); }
  90% { transform: translate(-2px, 2px); }
  100% { transform: translate(0, 0); }
}

/* вспышка */
.flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,240,200,.95), rgba(255,150,40,.35) 35%, transparent 70%);
  opacity: 0;
}
.flash.go { animation: flash .5s ease-out forwards; }
@keyframes flash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

/* ударная волна */
.shockwave {
  position: absolute;
  left: 50%; top: 50%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 10px solid rgba(255,190,70,.9);
  box-shadow: 0 0 60px rgba(255,120,40,.85);
  opacity: 0;
}
.shockwave.go { animation: shock .75s ease-out forwards; }
@keyframes shock {
  0%   { transform: scale(0); opacity: 1; border-width: 14px; }
  100% { transform: scale(30); opacity: 0; border-width: 0; }
}

/* эмодзи-вспышка взрыва над текстом */
.boom-word {
  font-size: clamp(3rem, 16vw, 8rem);
  line-height: 1;
  margin-bottom: 6px;
  opacity: 0;
  transform: scale(0);
}
.page-error.boom .boom-word { animation: pop .6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop {
  0%   { opacity: 0; transform: scale(0) rotate(-20deg); }
  55%  { opacity: 1; transform: scale(1.25) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* осколки/искры */
.spark {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 2px;
  opacity: 0;
  will-change: transform, opacity;
}
.spark.go { animation: burst var(--dur, .8s) cubic-bezier(.15,.6,.3,1) forwards; }
@keyframes burst {
  0%   { transform: translate(0,0) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(.2) rotate(var(--rot)); opacity: 0; }
}

/* ---------- Таймер ---------- */
.timer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(4px, 1.5vw, 18px);
  margin: clamp(24px, 6vh, 56px) 0;
}
.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: clamp(58px, 20vw, 130px);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  padding: clamp(10px, 2.5vh, 22px) clamp(6px, 2vw, 14px);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.num {
  font-size: clamp(2.4rem, 13vw, 6.5rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 4px 18px rgba(0,0,0,.35);
}
.lbl {
  margin-top: 8px;
  font-size: clamp(.65rem, 2.6vw, 1rem);
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: .8;
}
.sep {
  font-size: clamp(2rem, 11vw, 5rem);
  font-weight: 800;
  line-height: 1;
  padding-top: clamp(6px, 1.5vh, 18px);
  opacity: .6;
}

/* ---------- Кнопка ---------- */
.next-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 16px 40px;
  border-radius: 999px;
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  font-weight: 700;
  text-decoration: none;
  color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  cursor: not-allowed;
  pointer-events: none;
  transition: all .4s ease;
  user-select: none;
}
.next-btn.active {
  color: #3a0d5e;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  border-color: transparent;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(255, 126, 179, .5);
  animation: pulse 1.6s ease-in-out infinite;
}
.next-btn.active:hover { transform: translateY(-2px); }
@keyframes pulse {
  0%,100% { box-shadow: 0 10px 30px rgba(255,126,179,.4); }
  50%     { box-shadow: 0 14px 44px rgba(255,213,79,.7); }
}
.btn-hint {
  margin-top: 14px;
  font-size: .85rem;
  opacity: .65;
}
.btn-hint.hidden { display: none; }

/* ---------- Телефоны: компактнее, чтобы всё влезало ---------- */
@media (max-width: 600px) {
  .page { padding: 18px 14px; }

  /* подсказка "листай вниз" — гарантированно над краем экрана */
  .scroll-hint {
    margin-bottom: max(14px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  /* таймер на 4-й странице делаем заметно компактнее */
  .page-timer .big { font-size: clamp(1.5rem, 6.5vw, 2.2rem); }
  .page-timer .lead { margin-top: 8px; font-size: clamp(1rem, 4vw, 1.3rem); }

  .timer {
    margin: clamp(16px, 3.5vh, 28px) 0;
    gap: 4px;
    width: 100%;
  }
  .unit {
    min-width: 0;
    flex: 1 1 0;
    padding: 10px 2px;
    border-radius: 12px;
  }
  .num { font-size: clamp(1.7rem, 11vw, 2.8rem); }
  .lbl { margin-top: 6px; font-size: clamp(.55rem, 2.4vw, .7rem); }
  .sep { font-size: clamp(1.4rem, 7vw, 2rem); padding-top: 10px; }

  .next-btn { margin-top: 4px; padding: 14px 32px; }
  .btn-hint { margin-top: 10px; }
}

/* ---------- Низкие экраны: ещё ужимаем вертикаль таймера ---------- */
@media (max-height: 700px) {
  .page-timer .big { font-size: clamp(1.4rem, 5.5vw, 2rem); }
  .timer { margin: 14px 0; }
  .unit { padding: 8px 2px; }
  .num { font-size: clamp(1.6rem, 9vw, 2.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation: none !important; }
  .scroller { scroll-behavior: auto; }
}
