/* ============ шрифты ============ */
/* Лежат в репозитории, а не грузятся с Google: открытка должна открываться и без сети. */
@font-face {
  font-family: 'Neucha';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/neucha-cyrillic-400-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Neucha';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/neucha-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Balsamiq Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/balsamiq-sans-cyrillic-400-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Balsamiq Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/balsamiq-sans-cyrillic-700-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/nunito-cyrillic-400-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/nunito-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/nunito-cyrillic-700-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/nunito-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============ токены ============ */
:root {
  --bg: #fff6ec;
  --accent: #ff3d8b;
  --warm: #ffb020;
  --glow: #7b5cff;
  --text: #2a2140;
  --muted: rgba(42, 33, 64, 0.62);
  --line: rgba(42, 33, 64, 0.16);
  --panel: #ffffff;
  --ink-soft: rgba(42, 33, 64, 0.06);
  --script: 'Neucha', 'Segoe Script', cursive;
  --display: 'Balsamiq Sans', 'Nunito', system-ui, sans-serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow: 0 18px 44px rgba(42, 33, 64, 0.14);
}

* { box-sizing: border-box; }

/* Собственные display у кнопок и слайдов перебивают правило браузера для [hidden]. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

/* тёплые пятна света по углам */
body::before {
  content: '';
  position: fixed;
  inset: -25vmax;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(34vmax 34vmax at 16% 20%, color-mix(in srgb, var(--glow) 16%, transparent), transparent 70%),
    radial-gradient(40vmax 40vmax at 86% 78%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 72%),
    radial-gradient(30vmax 30vmax at 72% 10%, color-mix(in srgb, var(--warm) 20%, transparent), transparent 70%);
  filter: blur(26px);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ============ человечки на фоне ============ */
.doodles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.doodle {
  position: absolute;
  width: 150px;
  height: auto;
  aspect-ratio: 254 / 252;
  opacity: 0.5;
  animation: bob 5s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -10px; }
}

/* штрихи фигур */
.d-fill    { fill: #fff; stroke: var(--text); stroke-width: 5; stroke-linejoin: round; }
.d-line    { fill: none; stroke: var(--text); stroke-width: 5; stroke-linecap: round; }
.d-thin    { fill: none; stroke: var(--text); stroke-width: 4; stroke-linecap: round; }
.d-dot     { fill: var(--text); }
.d-star    { fill: var(--warm); stroke: var(--text); stroke-width: 4; stroke-linejoin: round; }
.d-flame   { fill: var(--warm); stroke: var(--text); stroke-width: 3.5; }
.d-balloon { fill: #8fb8f0; stroke: var(--text); stroke-width: 5; }
.d-heart   { fill: #ff4d6d; }
.s1 { fill: #ff6ea9; } .s2 { fill: #ffd23f; } .s3 { fill: #5ad1a5; } .s4 { fill: #7cc0ff; }

/* Раскладка: фигуры стоят по краям, чтобы не лезть в текст. */
.d1 { left: 1%;   bottom: 4%;  width: 168px; animation-delay: -0.4s; rotate: -3deg; }
.d2 { right: 2%;  top: 9%;     width: 152px; animation-delay: -1.6s; rotate: 4deg; }
.d3 { right: 3%;  bottom: 5%;  width: 176px; animation-delay: -2.6s; rotate: 2deg; }
.d4 { left: 4%;   top: 7%;     width: 150px; animation-delay: -3.4s; rotate: -5deg; }
.d5 { left: 19%;  bottom: 1%;  width: 118px; animation-delay: -2s;   rotate: 3deg; opacity: 0.3; }
.d6 { right: 20%; top: 1%;     width: 112px; animation-delay: -1s;   rotate: -3deg; opacity: 0.3; }

@media (max-width: 1100px) {
  .d5, .d6 { display: none; }
  .doodle { width: 130px; opacity: 0.42; }
  .d3 { width: 142px; }
}

@media (max-width: 720px) {
  .d1 { left: -6%;  bottom: 2%; width: 116px; }
  .d2 { right: -6%; top: 5%;    width: 108px; }
  .d3 { display: none; }
  .d4 { left: -7%;  top: 3%;    width: 104px; opacity: 0.28; }
  .doodle { opacity: 0.34; }
}

/* ============ общие элементы ============ */
.screen {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(84px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-left)) calc(48px + env(safe-area-inset-bottom));
  text-align: center;
}


.eyebrow {
  margin: 0;
  font-size: clamp(11px, 3vw, 13px);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
.eyebrow.gold { color: var(--warm); }
.eyebrow.pink { color: var(--accent); }
.eyebrow.dim  { color: var(--muted); letter-spacing: 0.4em; }

.gradient-text {
  background: linear-gradient(100deg, var(--accent), var(--warm) 45%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.script-name {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(52px, 14vw, 116px);
  line-height: 1.32;
  padding: 0 0.08em 0.06em;
  margin: 0;
  text-wrap: balance;
}

.script-line {
  font-family: var(--script);
  font-size: clamp(34px, 9vw, 60px);
  line-height: 1.3;
  padding-bottom: 0.06em;
  margin: 0;
  color: var(--text);
}

.hint {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 30px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(100deg, var(--accent), var(--warm));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 38%, transparent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 46%, transparent); }
.btn:active { transform: translateY(0); }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(42, 33, 64, 0.1);
}
.ghost-btn:hover { background: #fff; transform: translateY(-1px); }

:where(button, a, [tabindex]):focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 3px;
}

.back-btn {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  top: calc(16px + env(safe-area-inset-top));
  z-index: 30;
}

/* ============ 1. подарочная коробка ============ */
/* Настоящая 3D-модель на CSS-трансформациях: коробка из граней плюс объёмная крышка.
   Все размеры в em, а масштаб задаёт font-size сцены — так коробка тянется под экран. */
.gift-stage {
  font-size: clamp(1px, 0.3vw, 1.6px);
  width: 240em;
  height: 214em;
  perspective: 2200em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gift-tilt,
.gift-sway,
.gift-body,
.gift-lid {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
}

.gift-tilt {
  width: 0;
  height: 0;
  transform: rotateX(-20deg);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.gift-sway {
  width: 0;
  height: 0;
  animation: sway 7s ease-in-out infinite alternate, hover 3.6s ease-in-out infinite;
}

@keyframes sway {
  from { rotate: y 9deg; }
  to   { rotate: y 41deg; }
}
@keyframes hover {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -10em; }
}

.gface {
  position: absolute;
  left: 50%;
  top: 50%;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.65) 1.4px, transparent 1.8px),
    linear-gradient(155deg,
      color-mix(in srgb, var(--accent) 92%, #fff),
      var(--accent) 55%,
      color-mix(in srgb, var(--accent) 78%, var(--glow)));
  background-size: 26em 26em, auto;
  backface-visibility: hidden;
}

/* Лента: вертикальная полоса на каждой боковой грани. */
.gift-body .gface::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 17%;
  translate: -50% 0;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warm) 78%, #c06a00),
    var(--warm) 42%, #fff0c2 50%, var(--warm) 58%,
    color-mix(in srgb, var(--warm) 78%, #c06a00));
}

/* корпус: 200 x 130, глубина 160 */
.gf { width: 200em; height: 130em; transform: translate(-50%, -50%) translateZ(80em); }
.gb { width: 200em; height: 130em; transform: translate(-50%, -50%) rotateY(180deg) translateZ(80em); }
.gr { width: 160em; height: 130em; transform: translate(-50%, -50%) rotateY(90deg) translateZ(100em); }
.gl { width: 160em; height: 130em; transform: translate(-50%, -50%) rotateY(-90deg) translateZ(100em); }
.gr, .lr { filter: brightness(0.84) saturate(1.05); }
.gl, .ll { filter: brightness(0.94); }
.gb, .lb { filter: brightness(0.78); }

/* крышка: 214 x 36, глубина 174, поднята над корпусом */
.gift-lid {
  width: 0;
  height: 0;
  transform: translateY(-80em);
  transition: transform 0.75s cubic-bezier(0.5, -0.4, 0.4, 1.4), opacity 0.6s ease;
}

.lt {
  width: 206em;
  height: 166em;
  transform-style: preserve-3d;
  backface-visibility: visible;
  transform: translate(-50%, -50%) rotateX(90deg) translateZ(18em);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.7) 1.4px, transparent 1.8px),
    linear-gradient(150deg,
      color-mix(in srgb, var(--accent) 84%, #fff),
      var(--accent) 60%,
      color-mix(in srgb, var(--accent) 82%, var(--glow)));
}
.lf { width: 206em; height: 36em; transform: translate(-50%, -50%) translateZ(83em); }
.lb { width: 206em; height: 36em; transform: translate(-50%, -50%) rotateY(180deg) translateZ(83em); }
.lr { width: 166em; height: 36em; transform: translate(-50%, -50%) rotateY(90deg) translateZ(103em); }
.ll { width: 166em; height: 36em; transform: translate(-50%, -50%) rotateY(-90deg) translateZ(103em); }

/* лента на крышке идёт крестом */
.gift-lid .lf::before,
.gift-lid .lb::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 17%;
  translate: -50% 0;
  background: var(--warm);
}
.gift-lid .lr::before,
.gift-lid .ll::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 21%;
  translate: -50% 0;
  background: var(--warm);
}
.lt::before,
.lt::after {
  content: '';
  position: absolute;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warm) 78%, #c06a00),
    var(--warm) 42%, #fff0c2 50%, var(--warm) 58%,
    color-mix(in srgb, var(--warm) 78%, #c06a00));
}
.lt::before { left: 50%; top: 0; bottom: 0; width: 17%; translate: -50% 0; }
.lt::after  { top: 50%; left: 0; right: 0; height: 21%; translate: 0 -50%;
              background: linear-gradient(180deg,
                color-mix(in srgb, var(--warm) 78%, #c06a00),
                var(--warm) 42%, #fff0c2 50%, var(--warm) 58%,
                color-mix(in srgb, var(--warm) 78%, #c06a00)); }

/* Бант стоит на крышке: он живёт в системе координат самой крышки, а не её грани. */
.gift-lid .bow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 124em;
  height: auto;
  overflow: visible;
  translate: -50% -50%;
  transform: translateY(-50em);
  filter: drop-shadow(0 4em 8em rgba(42, 33, 64, 0.3));
}
.bow-loop { fill: url(#bowFill); }
.bow-tail { fill: color-mix(in srgb, var(--warm) 72%, #b35c00); }
.bow-knot { fill: url(#bowFill); }

/* мягкая тень под коробкой, лежит на «полу» */
.gift-shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 230em;
  height: 170em;
  transform: translate(-50%, -50%) rotateX(90deg) translateZ(-72em);
  background: radial-gradient(closest-side, rgba(42, 33, 64, 0.24), transparent);
  filter: blur(6em);
}

.gift-stage:hover .gift-tilt { transform: rotateX(-26deg); }

/* открытие: крышка взлетает и уходит, коробка растворяется */
.gift-stage.is-opening .gift-lid {
  transform: translateY(-260em) rotateZ(24deg) rotateX(30deg);
  opacity: 0;
}
.gift-stage.is-opening .gift-sway { animation: none; }
.gift-stage.is-opening {
  transition: opacity 0.5s ease 0.25s, scale 0.6s ease 0.2s;
  opacity: 0;
  scale: 1.25;
}

/* ============ 2. слайды ============ */
.screen-deck { justify-content: flex-start; padding-top: 76px; }

.dots {
  position: fixed;
  left: 50%;
  top: calc(22px + env(safe-area-inset-top));
  translate: -50% 0;
  z-index: 30;
  display: flex;
  gap: 12px;
}
.dots button {
  position: relative;
  width: 13px;
  height: 13px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--ink-soft);
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s;
}
/* Точки маленькие — расширяем область нажатия до пальца, не трогая вид. */
.dots button::after {
  content: '';
  position: absolute;
  inset: -14px -8px;
}
.dots button.is-active {
  background: color-mix(in srgb, var(--accent) 60%, #fff);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.slides {
  width: 100%;
  max-width: 700px;
  margin: auto;
}

.slide { display: none; }
.slide.is-active {
  display: block;
  animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.nav-btn {
  position: fixed;
  top: 50%;
  translate: 0 -50%;
  z-index: 30;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(42, 33, 64, 0.12);
}
.nav-btn[data-dir="prev"] { left: calc(18px + env(safe-area-inset-left)); }
.nav-btn[data-dir="next"] { right: calc(18px + env(safe-area-inset-right)); }
.nav-btn:disabled { opacity: 0.25; cursor: default; }

/* — слайд 1: открытка — */
.card-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 3vw, 26px);
}
.card-name-row .party { font-size: clamp(30px, 8vw, 58px); line-height: 1; }
.card-name-row .party.right { scale: -1 1; }

.card-glow {
  position: absolute;
  left: 50%;
  top: 26%;
  translate: -50% -50%;
  width: min(560px, 88vw);
  aspect-ratio: 2 / 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--warm) 30%, transparent), transparent);
  filter: blur(10px);
  pointer-events: none;
  z-index: -1;
}

.card-date { margin: 18px 0 0; color: var(--muted); font-size: 16px; }
.card-signoff { margin: 18px 0 0; color: var(--muted); font-size: 16px; }
.card-actions { margin-top: 30px; }

/* — слайд 2: письмо с пожеланиями — */
/* ---- торт: цилиндр из панелей, который можно крутить ---- */
.cake3d {
  font-size: clamp(0.85px, 0.2vw, 1.3px);
  width: 300em;
  height: 250em;
  margin: 0 auto;
  perspective: 1000em;
  cursor: grab;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  /* без этого перетаскивание выделяет надпись на торте */
  user-select: none;
  -webkit-user-select: none;
}
.cake3d:active { cursor: grabbing; }

.cake-orbit {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  transform: rotateX(-38deg);
}

.cake-orbit > * {
  position: absolute;
  left: 0;
  top: 0;
}

/* бок торта */
.c-panel {
  width: 22em;
  height: 76em;
  background: linear-gradient(180deg, #8b5a35, #6d4227 55%, #55321d);
}

/* крем стекает сверху по каждой панели */
.c-drip {
  position: absolute;
  left: -0.5em;
  right: -0.5em;
  top: -6em;
  display: block;
  border-radius: 0 0 6em 6em;
  background: linear-gradient(180deg, #fffaf0, #f4e3c8);
}

.c-top {
  width: 192em;
  height: 192em;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #fffdf6, #f6e6cb 62%, #e6d0ae);
  box-shadow: inset 0 0 26em rgba(120, 80, 40, 0.22);
}

/* Тень живёт вне 3D-сцены: горизонтальную «тарелку» браузер путал с боками торта. */
.cake-shadow {
  position: absolute;
  left: 50%;
  top: 74%;
  width: 250em;
  height: 60em;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(42, 33, 64, 0.22), transparent);
  filter: blur(4em);
}

.c-candle {
  width: 6em;
  height: 54em;
  background: linear-gradient(180deg, #ff9dc4, var(--accent));
}

.c-flame {
  width: 16em;
  height: 24em;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 68%, #fffbe0, #ffc23d 55%, rgba(255, 106, 0, 0.1));
  box-shadow: 0 0 22em rgba(255, 176, 32, 0.75);
  animation: flicker 1.5s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { scale: 1 1; opacity: 1; }
  40%      { scale: 0.92 1.08; opacity: 0.9; }
  70%      { scale: 1.06 0.95; opacity: 1; }
}

/* имя, выведенное «кремом» на боку */
/* Имя лежит на кремовой крышке: сама крышка развёрнута лицом вверх,
   поэтому текст на ней читается, а не зеркалится. */
.c-name {
  position: absolute;
  left: 50%;
  top: 62%;
  translate: -50% -50%;
  font-family: var(--script);
  font-weight: 400;
  font-size: 40em;
  line-height: 1;
  white-space: pre;
  color: var(--accent);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cake-hint {
  margin: 6px 0 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.4s ease;
}
.cake-hint.is-hidden { opacity: 0; }

.letter-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 46px);
  margin: 22px 0 0;
  min-height: 1.2em;
}
.caret {
  display: inline-block;
  width: 3px;
  height: 0.9em;
  translate: 0 0.1em;
  background: var(--accent);
  animation: blink 1s steps(2) infinite;
}
.caret.is-done { display: none; }
@keyframes blink { 50% { opacity: 0; } }

.letter-body {
  margin: 26px auto 0;
  max-width: 620px;
  text-align: left;
  padding: clamp(20px, 5vw, 30px);
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.letter-intro { margin: 0 0 20px; font-size: 17px; line-height: 1.65; color: var(--muted); }

.wishes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }

.wishes li {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 14px;
  align-items: start;
  font-size: 17px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.wishes li.is-shown { opacity: 1; transform: none; }

/* Пожелания не считают — вместо номера просто метка. */
.wishes li::before {
  content: '';
  width: 12px;
  height: 12px;
  margin-top: 0.5em;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--warm), var(--accent));
}

.letter-closing {
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  line-height: 1.65;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.letter-closing.is-shown { opacity: 1; }

.letter-sign {
  margin: 14px 0 0;
  text-align: right;
  font-family: var(--script);
  font-size: 30px;
  color: var(--accent);
}

.skip-hint {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* — загадывание желания — */
/* Сцена приглушается, торт со свечой остаётся освещённым — как когда гасят свет. */
.wish-dim {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
  background: rgba(19, 11, 28, 0.88);
}
.wish-dim.is-on { opacity: 1; }

/* тёплый ореол от свечи — гаснет вместе с ней */
.wish-dim::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 22vmax at 50% 24%, rgba(255, 176, 32, 0.24), transparent 72%);
  transition: opacity 1.1s ease;
}
.wish-dim.is-out::before { opacity: 0; }

/* Слайд целиком поднимается над затемнением — торт и отсчёт остаются освещёнными.
   Всё, что к ритуалу не относится, на это время убираем. */
.screen-deck.is-wishing .slide.is-active { position: relative; z-index: 4; }

.screen-deck.is-wishing .cake-hint,
.screen-deck.is-wishing .letter-title,
.screen-deck.is-wishing .letter-body,
.screen-deck.is-wishing .skip-hint { display: none; }

.screen-deck.is-wishing .nav-btn,
.screen-deck.is-wishing .dots { opacity: 0.22; }
body:has(.screen-deck.is-wishing) .back-btn { opacity: 0.22; }
.nav-btn, .dots, .back-btn { transition: opacity 0.6s ease; }

.wish {
  margin-top: 18px;
  text-align: center;
  transition: opacity 0.6s ease;
}
.wish.is-fading { opacity: 0; }

.wish-prompt {
  margin: 0;
  font-family: var(--script);
  font-size: clamp(28px, 6.5vw, 42px);
  line-height: 1.25;
  color: #fff6e2;
  text-shadow: 0 2px 18px rgba(255, 176, 32, 0.55), 0 1px 10px rgba(20, 12, 30, 0.8);
}
.wish-prompt span { color: var(--warm); }

.wish-count {
  margin: 10px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(56px, 14vw, 96px);
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(255, 176, 32, 0.65);
}
.wish-count.is-beat { animation: wish-beat 0.85s ease-out; }

@keyframes wish-beat {
  0%   { transform: scale(1.35); opacity: 0.25; }
  35%  { transform: scale(1);    opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

.wish-hint {
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 246, 226, 0.55);
}

.wish-done {
  margin: 0;
  font-family: var(--script);
  font-size: clamp(32px, 8vw, 54px);
  color: var(--warm);
  text-shadow: 0 2px 26px rgba(255, 176, 32, 0.6);
  animation: wish-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.wish-done[hidden] { display: none; }

@keyframes wish-in {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}

/* свеча гаснет, вверх уходит дымок */
.c-flame.is-out {
  animation: none;
  opacity: 0;
  scale: 0.25;
  box-shadow: none;
  transition: opacity 0.6s ease, scale 0.6s ease;
}

.smoke {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 10px;
  height: 10px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(240, 235, 245, 0.5);
  filter: blur(4px);
  pointer-events: none;
  animation: smoke-up 2.4s ease-out forwards;
}
.smoke:nth-of-type(2) { animation-delay: 0.25s; left: 52%; }
.smoke:nth-of-type(3) { animation-delay: 0.5s;  left: 48%; }

@keyframes smoke-up {
  0%   { opacity: 0;   transform: translateY(0)     scale(0.6); }
  25%  { opacity: 0.75; }
  100% { opacity: 0;   transform: translateY(-90px) scale(2.6); }
}

/* — слайд с фотографиями — */
.photo-frame {
  position: relative;
  margin: 20px auto 0;
  max-width: 460px;
  aspect-ratio: 4 / 5;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
}
.photo-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.photo-frame img.is-active { opacity: 1; }

.photo-dots { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.photo-dots button {
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%;
  background: var(--line); cursor: pointer; transition: background 0.3s, width 0.3s;
}
.photo-dots button.is-active { background: var(--accent); width: 20px; border-radius: 4px; }

/* — финальный слайд — */
/* Финал: те же человечки, только в полный цвет и покрупнее. */
.finale-crew {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(0px, 1vw, 16px);
  margin-bottom: 4px;
}
/* Каждый персонаж — фигура с собственной тенью на «полу»: она остаётся на месте
   и поджимается, когда он в прыжке. */
.crew {
  position: relative;
  display: block;
  line-height: 0;
}

.crew::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 66%;
  height: 14px;
  translate: -50% 0;
  border-radius: 50%;
  background: rgba(42, 33, 64, 0.22);
  filter: blur(5px);
  animation: crew-shadow 1.7s ease-in-out infinite;
}

.finale-crew img {
  width: clamp(104px, 25vw, 186px);
  height: auto;
  transform-origin: 50% 94%;
  filter: drop-shadow(0 6px 10px rgba(42, 33, 64, 0.12));
  animation: crew-dance 1.7s ease-in-out infinite;
}

/* лёгкий разнобой по фазе — получается «волна», а не строевой шаг */
.finale-crew .crew:nth-child(2) img,
.finale-crew .crew:nth-child(2)::after { animation-delay: -0.57s; }
.finale-crew .crew:nth-child(3) img,
.finale-crew .crew:nth-child(3)::after { animation-delay: -1.14s; }

@keyframes crew-dance {
  0%   { transform: translateY(0)     rotate(-6deg) scale(1.03, 0.97); }
  22%  { transform: translateY(-15px) rotate(-2deg) scale(0.98, 1.03); }
  50%  { transform: translateY(0)     rotate(6deg)  scale(1.03, 0.97); }
  72%  { transform: translateY(-15px) rotate(2deg)  scale(0.98, 1.03); }
  100% { transform: translateY(0)     rotate(-6deg) scale(1.03, 0.97); }
}

@keyframes crew-shadow {
  0%, 50%, 100% { transform: scale(1);      opacity: 0.9; }
  22%, 72%      { transform: scale(0.72);   opacity: 0.5; }
}
.finale-title { font-family: var(--display); font-weight: 700; font-size: clamp(30px, 7vw, 48px); margin: 20px 0 0; }
.finale-text { margin: 14px 0 30px; font-size: 17px; line-height: 1.6; color: var(--muted); }

/* ============ музыка ============ */
.music-toggle {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(42, 33, 64, 0.12);
  display: none;
  place-items: center;
}
.music-toggle.is-on { display: grid; }
.music-toggle.is-playing { animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.music-frame { position: fixed; left: -9999px; width: 320px; height: 90px; border: 0; }
.music-frame.is-visible {
  left: auto; right: 18px; bottom: 82px; z-index: 30;
  border-radius: 14px; box-shadow: var(--shadow);
}

/* ============ конструктор ============ */
.builder {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.builder h1 { font-family: var(--display); font-weight: 700; font-size: clamp(34px, 8vw, 52px); margin: 0 0 8px; }
.builder .lead { color: var(--muted); margin: 0 0 32px; line-height: 1.6; }

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.field textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 1px;
}
.field .hint { margin-top: 7px; font-size: 12.5px; color: var(--muted); line-height: 1.5; text-transform: none; letter-spacing: 0; }
.field select option { background: #fff; color: var(--text); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

.result { margin-top: 28px; display: none; }
.result.is-visible { display: block; }

.result-link {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  translate: -50% 0;
  z-index: 60;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  border: 0;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, translate 0.3s;
}
.toast.is-visible { opacity: 1; translate: -50% -8px; }

@media (max-width: 560px) {
  /* На узком экране стрелки по бокам легли бы поверх текста — уводим их вниз слева. */
  .nav-btn {
    width: 48px;
    height: 48px;
    top: auto;
    translate: none;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .nav-btn[data-dir="prev"] { left: calc(16px + env(safe-area-inset-left)); }
  .nav-btn[data-dir="next"] { left: calc(74px + env(safe-area-inset-left)); right: auto; }
  .screen-deck { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

  .back-btn { padding: 9px 15px; font-size: 13px; }
  .screen { gap: 14px; }
  .letter-body { padding: 18px 16px; border-radius: 18px; }
  .letter-intro, .wishes li, .letter-closing { font-size: 16px; }
  .wishes li { grid-template-columns: 10px 1fr; gap: 12px; }
  .wishes li::before { width: 10px; height: 10px; }
  .letter-title { margin-top: 16px; }
  .card-name-row { gap: 4px; }
  .btn { padding: 14px 24px; font-size: 15px; }
  .row-2 { grid-template-columns: 1fr; }
}

/* Низкие экраны в альбомной ориентации: убираем лишний вертикальный воздух. */
@media (max-height: 860px) {
  .screen-gift .script-name { font-size: clamp(44px, 9vw, 84px); }
  .gift-stage { font-size: clamp(0.9px, 0.24vw, 1.32px); }
}

@media (max-height: 520px) and (orientation: landscape) {
  .screen { padding-top: calc(64px + env(safe-area-inset-top)); gap: 10px; }
    .cake3d { font-size: 0.72px; }
  .finale-crew img { width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
