:root {
  /* Burton-Alice palette: near-void black, desaturated bone, one sickly
     acid-green, one deep wine-red, muted violet-grey, and antique ember
     gold saved ONLY for the finale so it still lands as warmth. */
  --void: #0a0710;
  --void-deep: #050308;
  --bone: #e4ddd0;
  --ash: #4d4358;
  --ash-light: #9186a3;
  --moss: #6f8a4a;
  --moss-glow: #9fc25c;
  --blood: #6b1830;
  --blood-glow: #9c2c49;
  --ember: #b9944f;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;
  --font-hand: "Caveat", cursive;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

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

html, body {
  height: 100%;
  background: var(--void);
  color: var(--bone);
  font-family: var(--font-body);
  overflow: hidden;
}

/* vignette: darkens the edges like a lantern-lit room */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0,0,0,0.6) 100%);
}

/* fine grain, like old film stock */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 120px 120px;
}

#motif-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.4,0,.2,1), visibility 0.9s;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}

.scene.falling-out {
  opacity: 0;
  transform: translateY(120px) scale(0.96);
}

.scene.rising-in {
  transform: translateY(0);
}

.scene-inner {
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ash-light);
  margin-bottom: 18px;
  opacity: 0.85;
}

.scene-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.15;
  color: var(--bone);
  margin-bottom: 20px;
  text-shadow: 0 0 22px rgba(107, 24, 48, 0.4);
}

.scene-text {
  font-size: clamp(0.95rem, 2vw, 1.08rem);
  line-height: 1.7;
  color: var(--bone);
  opacity: 0.88;
  margin-bottom: 28px;
}

.riddle-text { max-width: 460px; margin-left: auto; margin-right: auto; }

/* forms */
.auth-form, .riddle-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 340px;
  margin: 0 auto;
}

input[type="text"] {
  background: rgba(228, 221, 208, 0.05);
  border: 1px solid rgba(145, 134, 163, 0.4);
  border-radius: 4px;
  padding: 14px 16px;
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus {
  border-color: var(--moss-glow);
  background: rgba(228, 221, 208, 0.08);
  box-shadow: 0 0 0 3px rgba(159, 194, 92, 0.12);
}

input[type="text"]::placeholder { color: rgba(228, 221, 208, 0.35); }

button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid rgba(156, 44, 73, 0.7);
  border-radius: 4px;
  padding: 14px 20px;
  cursor: pointer;
  background: var(--blood);
  color: var(--bone);
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

button:hover { transform: translateY(-2px); background: var(--blood-glow); box-shadow: 0 10px 28px rgba(107, 24, 48, 0.5); }
button:focus-visible { outline: 2px solid var(--moss-glow); outline-offset: 3px; }

.auth-hint, .riddle-hint {
  min-height: 22px;
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--ash-light);
  font-style: italic;
}

/* fall transition */
.fall-scene .scene-inner { display: flex; align-items: center; justify-content: center; }
.fall-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.3rem, 4vw, 2rem);
  color: var(--ash-light);
  opacity: 0.75;
  letter-spacing: 0.04em;
}

/* maze */
.maze-inner { display: flex; flex-direction: column; align-items: center; }
#maze-canvas {
  background: var(--void-deep);
  border: 1px solid rgba(107, 24, 48, 0.45);
  border-radius: 6px;
  margin-top: 12px;
  touch-action: none;
  box-shadow: 0 0 32px rgba(0,0,0,0.5) inset;
}
#maze-canvas.win {
  animation: maze-win-pulse 0.5s ease;
}
@keyframes maze-win-pulse {
  0% { filter: brightness(1); transform: scale(1); }
  50% { filter: brightness(1.7) saturate(1.3); transform: scale(1.03); }
  100% { filter: brightness(1); transform: scale(1); }
}
.maze-hint {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--ash-light);
  opacity: 0.7;
}
.maze-steps {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--moss-glow);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* warm message */
.warm-message {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  line-height: 1.6;
  color: var(--ember);
  opacity: 0;
  animation: fade-in-slow 1.6s ease forwards 0.3s;
}

@keyframes fade-in-slow {
  to { opacity: 0.95; }
}

.continue-btn {
  margin-top: 32px;
  background: transparent;
  border: 1px solid var(--ash-light);
  color: var(--bone);
}
.continue-btn:hover { background: rgba(145, 134, 163, 0.12); box-shadow: none; }

/* video */
.video-inner { display: flex; flex-direction: column; align-items: center; }
#greeting-video, #intro-video {
  width: 100%;
  max-width: 480px;
  border-radius: 6px;
  background: black;
  border: 1px solid rgba(107, 24, 48, 0.4);
}

/* MJ transition */
.mj-scene { background: var(--void-deep); }
.mj-silhouette {
  width: 140px;
  height: 220px;
  background: linear-gradient(180deg, rgba(159, 194, 92, 0.14), transparent);
  border-radius: 50% 50% 40% 40%;
  position: relative;
  animation: mj-lean 2.4s ease-in-out infinite alternate;
}
@keyframes mj-lean {
  0% { transform: rotate(0deg) translateX(0); }
  100% { transform: rotate(-6deg) translateX(-8px); }
}

/* poem + finale */
.poem-inner { display: flex; flex-direction: column; align-items: center; gap: 28px; }
.poem-lines {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 2.6vw, 1.4rem);
  line-height: 2.1;
  color: var(--bone);
  max-width: 520px;
}
.poem-lines .line { display: block; }
.poem-lines .line.climax { color: var(--ember); font-weight: 600; text-shadow: 0 0 18px rgba(185, 148, 79, 0.4); }

/* буквы проступают из тумана — каждая своя, с небольшой задержкой друг за другом */
.poem-lines .letter {
  display: inline-block;
  opacity: 0;
  filter: blur(7px);
  transition: opacity 0.55s ease, filter 0.55s ease;
  white-space: pre;
}
.poem-lines .letter.visible { opacity: 0.95; filter: blur(0); }

/* birthday reveal — стих дозвучал, Силуэт вступает, дарим подарок */
.birthday-inner { display: flex; flex-direction: column; align-items: center; gap: 34px; }
.birthday-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(2.1rem, 7vw, 3.8rem);
  line-height: 1.25;
  color: var(--ember);
  text-shadow: 0 0 34px rgba(185, 148, 79, 0.55);
  opacity: 0;
  animation: fade-in-slow 1.8s ease forwards 0.15s;
}

.gift-btn {
  background: var(--ember);
  color: var(--void-deep);
  font-size: 1.05rem;
  padding: 16px 32px;
  border-color: rgba(185, 148, 79, 0.7);
  transition: opacity 1s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.gift-btn.hidden { opacity: 0; pointer-events: none; }
.gift-btn:hover { background: var(--ember); box-shadow: 0 12px 32px rgba(185, 148, 79, 0.45); }

.gift-status {
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--ember);
  opacity: 0.9;
}

.credit {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash-light);
  opacity: 0.45;
}

.video-fallback {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  line-height: 1.6;
  color: var(--ash-light);
  max-width: 460px;
  text-align: center;
}

.is-hidden { display: none !important; }

/* мобильные: сцены могут не влезать по высоте — разрешаем прокрутку внутри */
@media (max-width: 560px), (max-height: 620px) {
  .scene { padding: 22px 18px; align-items: flex-start; overflow-y: auto; }
  .scene-inner { padding: 8px 0 24px; }
  .poem-inner { gap: 20px; }
  .poem-lines { line-height: 1.85; }
  .scene-title { margin-bottom: 16px; }
  .scene-text { margin-bottom: 22px; }
}
