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

:root {
  --pulse: 0;
  --cream: #fff3e0;
  --gold: #ffd27a;
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2a0f1e;
  color: var(--cream);
  font-family: 'Nunito', system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#bg, #scene {
  position: fixed;
  inset: 0;
  display: block;
}
#bg { z-index: 0; }
#scene { z-index: 3; }

#sun-glow {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 68% 66%, rgba(255, 200, 110, 0.55), rgba(255, 150, 70, 0) 46%);
  mix-blend-mode: screen;
  opacity: calc(0.25 + var(--pulse) * 0.75);
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 55%, rgba(20, 5, 12, 0.55) 100%);
}

.glass {
  background: rgba(38, 12, 22, 0.42);
  border: 1px solid rgba(255, 220, 170, 0.22);
  box-shadow: 0 18px 50px rgba(10, 2, 8, 0.45);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

/* ---------- Вступление ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sa-top) + 16px) 18px calc(var(--sa-bottom) + 16px);
  transition: opacity 0.9s ease, visibility 0.9s;
}
.intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.intro-card {
  width: min(92vw, 400px);
  padding: 30px 24px 24px;
  border-radius: 28px;
  text-align: center;
  animation: cardIn 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.intro-emblem {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(255, 170, 70, 0.75));
  animation: emblemFloat 4s ease-in-out infinite;
}
@keyframes emblemFloat {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-8px) rotate(8deg); }
}

.intro-small {
  margin: 12px 0 0;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.intro-title {
  margin: 4px 0 10px;
  font-family: 'Marck Script', cursive;
  font-weight: 400;
  font-size: clamp(46px, 14vw, 64px);
  line-height: 1.05;
  background: linear-gradient(180deg, #fff1c9, #ffb85a 70%, #f08a3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35));
}

.intro-text {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.92;
}

.btn {
  border: none;
  cursor: pointer;
  min-height: 48px;
  padding: 12px 34px;
  border-radius: 999px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #3b1226;
  background: linear-gradient(90deg, #ffd27a, #ff9d4a);
  box-shadow: 0 10px 26px rgba(255, 140, 60, 0.35);
  transition: transform 0.15s ease;
}
.btn:active { transform: scale(0.95); }

.intro-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.45;
  opacity: 0.62;
}

/* ---------- Большое приветствие ---------- */
.greeting {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: 46%;
  width: min(90vw, 460px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) scale(0.94);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(0.22, 1, 0.36, 1), visibility 1.1s;
}
.greeting.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}
.greeting.away {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -78%) scale(0.98);
}

.g-name {
  margin: 0;
  font-family: 'Marck Script', cursive;
  font-size: clamp(64px, 20vw, 104px);
  line-height: 1;
  background: linear-gradient(180deg, #fff6d8, #ffc266 65%, #ff9a45);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, 0.45));
}

.g-text {
  margin: 10px auto 0;
  max-width: 22em;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 600;
  line-height: 1.4;
  text-shadow: 0 2px 16px rgba(20, 5, 12, 0.7);
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  z-index: 7;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--sa-top) + 12px) 14px 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.hud.show { opacity: 1; transform: translateY(0); }

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress {
  display: flex;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(38, 12, 22, 0.45);
  border: 1px solid rgba(255, 220, 170, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.slot {
  font-size: 19px;
  line-height: 1;
  filter: grayscale(1) brightness(0.55);
  opacity: 0.55;
  transition: filter 0.6s ease, opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.slot.lit {
  filter: drop-shadow(0 0 8px rgba(255, 190, 80, 0.9));
  opacity: 1;
  transform: scale(1.18);
}

.controls {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 170, 0.28);
  background: rgba(38, 12, 22, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--cream);
  font-size: 17px;
  cursor: pointer;
}
.round-btn:active { transform: scale(0.92); }

.hint {
  margin: 10px auto 0;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  text-shadow: 0 2px 12px rgba(20, 5, 12, 0.85);
  opacity: 0.9;
}

.track-chip {
  margin: 6px auto 0;
  width: fit-content;
  max-width: 92vw;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  background: rgba(38, 12, 22, 0.5);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.track-chip.show { opacity: 0.9; }

/* ---------- Карточка пожелания ---------- */
.wish {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: calc(var(--sa-bottom) + 26px);
  width: min(92vw, 440px);
  padding: 16px 20px 18px;
  border-radius: 22px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 30px) scale(0.96);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.wish.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.wish-label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.wish-text {
  margin: 0;
  font-family: 'Marck Script', cursive;
  font-size: clamp(22px, 6vw, 28px);
  line-height: 1.25;
}

/* ---------- Финал ---------- */
.finale {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sa-top) + 16px) 18px calc(var(--sa-bottom) + 16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1s ease, visibility 1s;
}
.finale.show { opacity: 1; visibility: visible; pointer-events: none; }
.finale.show .btn { pointer-events: auto; }

.finale-card {
  width: min(92vw, 420px);
  padding: 30px 24px 26px;
  border-radius: 28px;
  text-align: center;
}

.finale-emblem {
  font-size: 50px;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(255, 170, 70, 0.75));
}

.finale-title {
  margin: 10px 0 10px;
  font-family: 'Marck Script', cursive;
  font-weight: 400;
  font-size: clamp(40px, 12vw, 56px);
  line-height: 1.05;
  background: linear-gradient(180deg, #fff1c9, #ffb85a 70%, #f08a3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.finale-text {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.55;
  opacity: 0.94;
}

@media (max-height: 640px) {
  .intro-emblem { font-size: 40px; }
  .intro-card { padding: 20px 20px 18px; }
  .g-name { font-size: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .intro-emblem { animation: none; }
}
