/* ═══ Interactive Gift Surprise — Apple × Blizzard ═══ */

:root {
  --void: #060404;
  --gold: #e8c060;
  --gold-light: #fff0c8;
  --crimson: #8b1820;
  --warm: #ff9050;
  --font-display: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-body: 'Cinzel', Georgia, serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--void);
  color: #f2ebe3;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ─── FX overlays ─── */

.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.fx-vignette {
  background: radial-gradient(ellipse 72% 62% at 50% 48%, transparent 32%, rgba(0,0,0,0.5) 100%);
}

.fx-warmth {
  z-index: 1;
  background:
    radial-gradient(ellipse 50% 40% at 50% 62%, rgba(255, 140, 60, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(80, 20, 10, 0.25) 0%, transparent 50%);
}

.fx-grain {
  z-index: 4;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.fx-flash {
  z-index: 60;
  background: #fff;
  opacity: 0;
}

/* ─── Stage ─── */

.stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.stage .finale,
.stage .finale * {
  pointer-events: auto;
}

/* ─── CSS fallback box (если WebGL недоступен) ─── */

.box-fallback {
  position: fixed;
  left: 50%;
  top: 58%;
  width: min(220px, 42vw);
  height: min(180px, 34vw);
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}

.box-fallback.is-visible {
  opacity: 1;
}

.box-fallback__body {
  position: absolute;
  inset: 18% 8% 0;
  background: linear-gradient(145deg, #1a1210 0%, #0a0606 50%, #120a0a 100%);
  border: 1px solid rgba(212, 168, 56, 0.35);
  box-shadow:
    0 0 40px rgba(255, 120, 40, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  animation: boxSway 4s ease-in-out infinite;
}

.box-fallback__lid {
  position: absolute;
  top: 0;
  left: 6%;
  right: 6%;
  height: 22%;
  background: linear-gradient(180deg, #221816 0%, #0c0808 100%);
  border: 1px solid rgba(212, 168, 56, 0.3);
  border-radius: 4px 4px 0 0;
  transform-origin: bottom center;
  animation: lidGlow 2.5s ease-in-out infinite;
}

.box-fallback__ribbon-v,
.box-fallback__ribbon-h {
  position: absolute;
  background: linear-gradient(90deg, #a07820, #f0d070, #a07820);
  z-index: 2;
}

.box-fallback__ribbon-v {
  left: 50%;
  top: 18%;
  bottom: 0;
  width: 14px;
  transform: translateX(-50%);
}

.box-fallback__ribbon-h {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 14px;
  transform: translateY(-50%);
}

.box-fallback__bow {
  position: absolute;
  top: 8%;
  left: 50%;
  width: 48px;
  height: 28px;
  transform: translateX(-50%);
  border: 5px solid #d4a838;
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 0 16px rgba(255, 180, 60, 0.4);
}

.box-fallback__glow {
  position: absolute;
  inset: -30%;
  background: radial-gradient(ellipse, rgba(255, 140, 50, 0.25) 0%, transparent 65%);
  animation: breathe 3s ease-in-out infinite;
}

@keyframes boxSway {
  0%, 100% { transform: rotate(-0.6deg); }
  50% { transform: rotate(0.6deg); }
}

@keyframes lidGlow {
  0%, 100% { box-shadow: 0 -4px 20px rgba(255, 140, 50, 0.15); }
  50% { box-shadow: 0 -8px 32px rgba(255, 160, 60, 0.35); }
}

/* ─── НАЖМИ ─── */

.press {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  z-index: 25;
  padding: 0.25rem 0.5rem;
  touch-action: manipulation;
}

.press__label {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.75rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--gold-light);
  text-shadow:
    0 0 24px rgba(255, 200, 100, 0.55),
    0 0 60px rgba(255, 140, 50, 0.25),
    0 2px 8px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s var(--ease-out), text-shadow 0.35s;
  display: block;
  padding-left: 0.28em;
}

.press__glow {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(255, 180, 80, 0.18) 0%, transparent 62%);
  animation: breathe 3s ease-in-out infinite;
  pointer-events: none;
}

.press__trail {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.press.is-ready .press__label {
  animation: readyGlow 1.2s ease-in-out infinite;
}

.press.is-ready:hover .press__label,
.press.is-ready:focus-visible .press__label {
  transform: scale(1.12);
  text-shadow:
    0 0 40px rgba(255, 220, 140, 1),
    0 0 90px rgba(255, 160, 60, 0.65),
    0 0 140px rgba(255, 100, 40, 0.35);
}

.press.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.press-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 19;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.75rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--gold);
  opacity: 0.45;
  transform: translate(-50%, -50%);
  filter: blur(2px);
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.06); }
}

@keyframes readyGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

/* ─── Finale ─── */

#finale[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.finale {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  pointer-events: auto;
  z-index: 30;
}

.finale__wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.25rem, 3.5vh, 2rem);
}

.finale__hint {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3.8vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  color: #1a1210;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.15),
    0 0 24px rgba(0, 0, 0, 0.25);
}

.finale__hint.is-visible {
  visibility: visible;
  animation: hintPulse 2.8s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.88; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.08); }
}

.certificate {
  position: relative;
  width: min(520px, 92vw);
  aspect-ratio: 1.55;
  transform-style: preserve-3d;
  perspective: 900px;
}

.certificate__glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse, rgba(255, 120, 40, 0.35) 0%, transparent 65%);
  animation: certGlow 3s ease-in-out infinite;
}

.certificate__frame {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #1a0c08 0%, #080404 45%, #140808 100%);
  border: 2px solid rgba(232, 192, 96, 0.55);
  box-shadow:
    0 0 50px rgba(255, 100, 40, 0.25),
    inset 0 0 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.certificate__frame::before,
.certificate__frame::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(232, 192, 96, 0.45);
}

.certificate__frame::before { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.certificate__frame::after { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.certificate__ornament {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 38%;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(120, 20, 20, 0.5) 0%, transparent 70%),
    radial-gradient(ellipse at 50% 30%, rgba(255, 80, 40, 0.15) 0%, transparent 60%);
  border: 1px solid rgba(200, 80, 40, 0.2);
  clip-path: polygon(35% 0%, 65% 0%, 78% 35%, 70% 100%, 30% 100%, 22% 35%);
}

.certificate__brand {
  margin-top: 42%;
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.85rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff0c0, #d4a030);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.certificate__type {
  font-size: clamp(0.72rem, 2.4vw, 0.9rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(240, 230, 220, 0.45);
  margin-top: 0.35rem;
}

.certificate__line {
  width: 50%;
  height: 1px;
  margin: 0.6rem 0;
  background: linear-gradient(90deg, transparent, rgba(232, 192, 96, 0.5), transparent);
}

.certificate__edition {
  font-size: clamp(0.75rem, 2.4vw, 0.88rem);
  letter-spacing: 0.18em;
  color: rgba(240, 230, 220, 0.4);
}

.certificate__sheen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.certificate__sheen::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  transform: skewX(-18deg);
  animation: sheen 4.5s ease-in-out infinite;
}

@keyframes certGlow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes sheen {
  0%, 100% { left: -100%; }
  50% { left: 150%; }
}

.finale__copy {
  text-align: center;
  max-width: 420px;
}

.finale__title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  color: var(--gold-light);
  margin-bottom: 0.4rem;
}

.finale__text,
.finale__wish {
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  line-height: 1.55;
  color: rgba(242, 235, 227, 0.75);
}

.finale__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(360px, 88vw);
}

/* ─── Buttons ─── */

.btn {
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 2vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 1rem 1.5rem;
  border: none;
  cursor: pointer;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s;
}

.btn:active { transform: scale(0.98); }

.btn--gold {
  color: #1a0808;
  background: linear-gradient(180deg, #f0d080 0%, #c99028 100%);
  box-shadow: 0 0 30px rgba(255, 160, 60, 0.3);
}

.btn--gold:hover {
  box-shadow: 0 0 45px rgba(255, 180, 80, 0.45);
}

.btn--outline {
  color: rgba(242, 235, 227, 0.85);
  background: rgba(10, 6, 4, 0.7);
  border: 1px solid rgba(232, 192, 96, 0.35);
}

.btn--block { width: 100%; }

/* ─── Loader ─── */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--void);
  transition: opacity 0.8s, visibility 0.8s;
  pointer-events: all;
}

.loader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader__ring {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(232, 192, 96, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Modal ─── */

.modal {
  position: relative;
  border: 1px solid rgba(232, 192, 96, 0.35);
  background: linear-gradient(180deg, #140a08, #060404);
  color: #f2ebe3;
  padding: 2rem;
  max-width: 380px;
}

.modal::backdrop { background: rgba(0, 0, 0, 0.88); }

.modal__close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal__tag {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 0.75rem;
}

.modal__code {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 1.05rem;
  color: var(--gold-light);
  margin-bottom: 1.25rem;
  letter-spacing: 0.06em;
}
