:root {
  --cream: #fbf5f0;
  --paper: #fdf9f6;
  --ink: #3d2e33;
  --ink-soft: #5b4a50;
  --rose: #c4507c;
  --rose-deep: #a8436b;
  --rose-soft: #e89ab4;
  --line: #eeb0c3;
  --script: 'Alex Brush', 'Segoe Script', cursive;
  --serif: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
  --vh: 100vh;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
img:not([src]) { visibility: hidden; }
button { font: inherit; color: inherit; }

/* ---------- Сцена и сцена-контейнер ---------- */

.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
}

.bg-wrap { position: absolute; inset: 0; }
.bg {
  position: absolute;
  inset: -40px;
  background-color: var(--cream);
  background-size: cover;
  background-position: center;
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--W, 1000px);
  height: var(--H, 1800px);
  transform: translate(-50%, -50%) scale(var(--s, 1));
}

.el { position: absolute; }
[data-depth] { will-change: transform; }

/* ---------- Уголки ---------- */

.corner { position: absolute; width: var(--cw); pointer-events: none; }
.corner .idle { animation: sway-corner 9s ease-in-out infinite alternate; }
.c-tr { top: -1.5%; right: -2%; }
.c-tl { top: -1.5%; left: -2%; }
.c-br { bottom: -1.5%; right: -2%; }
.c-bl { bottom: -1.5%; left: -2%; }
.c-tr .idle { transform-origin: 100% 0; }
.c-tl .idle { transform-origin: 0 0; }
.c-br .idle { transform-origin: 100% 100%; }
.c-bl .idle { transform-origin: 0 100%; }
.c-tl img { transform: scaleX(-1); }
.c-br img { transform: scaleY(-1); }
.c-bl img { transform: scale(-1, -1); }
.c-tr .in { --from: translate(40%, -40%); }
.c-tl .in { --from: translate(-40%, -40%); }
.c-br .in { --from: translate(40%, 40%); }
.c-bl .in { --from: translate(-40%, 40%); }
.corner .in { animation-name: corner-in; animation-duration: 1.1s; }

.is-landscape .corner { --cw: min(34vmin, 440px); }
.is-portrait .corner { --cw: min(46vmin, 360px); }
.is-portrait .c-tr { --cw: min(34vmin, 260px); }
.is-portrait .c-tl { display: none; }

/* ---------- Рамка ---------- */

.frame { inset: 0; pointer-events: none; }
.frame svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.is-portrait .frame-l, .is-landscape .frame-p { display: none; }
.f-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s cubic-bezier(.45, .1, .25, 1) .1s both paused; }
.f-fill { opacity: 0; animation: fade-in 1.2s ease .1s both paused; }

/* ---------- Раскладка: телефон (1000 × 1800) ---------- */

.is-portrait .balloons { left: -28px; top: 30px; width: 307px; }
.is-portrait .bow { left: 320px; top: 14px; width: 360px; }
.is-portrait .copy { left: 40px; top: 372px; width: 920px; }
.is-portrait .medallion { left: -91px; top: 927px; width: 599px; }
.is-portrait .bunnies { left: 300px; top: 1103px; width: 720px; }

.is-portrait .intro { font-size: 44px; }
.is-portrait .names { font-size: 172px; }
.is-portrait .ribbon { width: 470px; margin-top: -34px; }
.is-portrait .age { font-size: 58px; }
.is-portrait .invite { font-size: 46px; margin-top: 6px; }
.is-portrait .body { font-size: 37px; margin-top: 16px; }
.is-portrait .wait { display: none; }

.is-portrait .sh1 { left: 242px; top: 298px; width: 40px; }
.is-portrait .sh2 { left: 728px; top: 292px; width: 40px; }
.is-portrait .sh3 { left: 150px; top: 715px; width: 34px; }
.is-portrait .sh4 { left: 816px; top: 715px; width: 34px; }
.is-portrait .sh5 { left: 540px; top: 1052px; width: 34px; }
.is-portrait .sh6 { left: 130px; top: 1590px; width: 40px; }

/* ---------- Раскладка: ПК (1800 × 1000) ---------- */

.is-landscape .balloons { left: 205px; top: 10px; width: 276px; }
.is-landscape .bow { left: 767px; top: 6px; width: 280px; }
.is-landscape .copy { left: 457px; top: 276px; width: 900px; }
.is-landscape .medallion { left: 60px; top: 371px; width: 640px; }
.is-landscape .bunnies { left: 1110px; top: 382px; width: 650px; }

.is-landscape .intro { font-size: 35px; }
.is-landscape .names { font-size: 140px; }
.is-landscape .ribbon { width: 380px; margin-top: -24px; }
.is-landscape .age { font-size: 46px; }
.is-landscape .invite { font-size: 36px; margin-top: 4px; }
.is-landscape .body { font-size: 29px; margin-top: 10px; }
.is-landscape .wait { font-size: 32px; margin-top: 12px; }

.is-landscape .sh1 { left: 640px; top: 214px; width: 44px; }
.is-landscape .sh2 { left: 1140px; top: 210px; width: 40px; }
.is-landscape .sh3 { left: 590px; top: 405px; width: 34px; }
.is-landscape .sh4 { left: 1290px; top: 250px; width: 38px; }
.is-landscape .sh5 { left: 1045px; top: 935px; width: 34px; }
.is-landscape .sh6 { left: 1500px; top: 60px; width: 36px; }
.is-landscape .med-infomode .rows li { font-size: 32px; }
.is-landscape .qr { width: 96px; }

/* ---------- Текст ---------- */

.copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}
.copy p, .copy h1 { margin: 0; }
.intro { color: var(--ink); line-height: 1.15; letter-spacing: .005em; }
.names {
  font-family: var(--script);
  font-weight: 400;
  color: var(--rose);
  line-height: .95;
  white-space: nowrap;
  padding: 0 .2em;
  margin-top: -.02em;
  text-shadow: 0 .01em .03em rgba(196, 80, 124, .12);
}
.names .amp { font-size: .82em; }
.ribbon { position: relative; }
.age {
  position: absolute;
  left: 50%;
  top: 37%;
  transform: translate(-50%, -50%);
  color: var(--rose-deep);
  white-space: nowrap;
  line-height: 1;
}
.invite { color: var(--rose); line-height: 1.12; }
.body { color: var(--ink-soft); line-height: 1.2; }
.wait { font-style: italic; color: var(--rose); line-height: 1.2; }

/* ---------- Медальон ---------- */

.med { position: relative; outline: none; border-radius: 50%; }
.med-c {
  position: absolute;
  left: 49.4%;
  top: 50.1%;
  width: 58%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.med-infomode { display: none; }
.med-info.is-landscape .med-btnmode { display: none; }
.med-info.is-landscape .med-infomode { display: flex; }
.med { cursor: pointer; }
.med-info.is-landscape .med { cursor: default; }

.icons { display: flex; gap: 22px; color: var(--rose); }
.icons svg { width: 44px; height: 44px; }
.pill {
  margin-top: 26px;
  padding: 18px 34px 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e98aab, #cc5c85);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(196, 80, 124, .32), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.open .pill { animation: pulse 2.6s ease-in-out 3.2s infinite; }
button.pill { border: 0; font-family: var(--serif); cursor: pointer; }
.pill-space { visibility: hidden; }
.medbtn { pointer-events: none; }
.medbtn .med-box { aspect-ratio: 900 / 922; }
.medbtn .icons, .medbtn .divider { visibility: hidden; }
.medbtn .pill { pointer-events: auto; }
.med-info.is-landscape .medbtn { display: none; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--rose-soft); margin-top: 26px; }
.divider i { display: block; width: 70px; height: 2px; background: currentColor; border-radius: 2px; opacity: .8; }
.divider svg { width: 24px; height: 24px; color: var(--rose); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; text-align: left; }
.rows li { display: flex; align-items: center; gap: 16px; font-size: 34px; line-height: 1.1; color: var(--ink); }
.rows svg { width: 42px; height: 42px; flex: none; color: var(--rose); }
.rows small { display: block; font-size: 22px; color: var(--ink-soft); margin-top: 4px; }
.med-infomode .divider { margin-top: 20px; }
.med-infomode .divider i { width: 60px; }
.qr { display: block; width: 104px; margin-top: 16px; padding: 6px; border-radius: 10px; background: rgba(255, 255, 255, .7); }
.qr img { pointer-events: auto; image-rendering: pixelated; }

/* ---------- Крольчихи ---------- */

.bunnies .idle { transform-origin: 50% 100%; animation: breathe 3.8s ease-in-out infinite; }
.hop { position: relative; cursor: pointer; }
.blink { position: absolute; opacity: 0; }
.blink.on { opacity: 1; }

/* ---------- Idle-анимации ---------- */

.balloons .idle { transform-origin: 51% 59%; animation: sway-balloons 7s ease-in-out infinite alternate; }
.balloons { cursor: pointer; }
.bow .idle { transform-origin: 50% 30%; animation: sway-bow 5.5s ease-in-out infinite alternate; }
.sh .idle { animation: float 5s ease-in-out infinite alternate; }
.sh2 .idle { animation-duration: 6.2s; animation-delay: -2s; }
.sh3 .idle { animation-duration: 4.4s; animation-delay: -1s; }
.sh4 .idle { animation-duration: 5.6s; animation-delay: -3s; }
.sh5 .idle { animation-duration: 4.8s; animation-delay: -.5s; }
.sh6 .idle { animation-duration: 6.6s; animation-delay: -4s; }

/* ---------- Появление слоёв ---------- */

.in {
  animation: fade-up 1s cubic-bezier(.2, .8, .2, 1) var(--delay, 0s) both paused;
}
.open .in, .open .f-line, .open .f-fill { animation-play-state: running; }
.bow > .in { animation-name: drop-in; animation-duration: 1.2s; animation-timing-function: ease-out; }
.balloons > .in { animation-name: rise-in; animation-duration: 1.8s; }
.ribbon.in { animation-name: unfurl; animation-duration: .9s; animation-timing-function: cubic-bezier(.3, 1.35, .5, 1); }
.names.in { animation-name: write-in; animation-duration: 1.6s; animation-timing-function: ease-in-out; }
.medallion > .in { animation-name: pop-in; animation-duration: 1s; animation-timing-function: cubic-bezier(.3, 1.4, .5, 1); }
.bunnies > .in { animation-name: bunny-in; animation-duration: 1.2s; animation-timing-function: ease-out; }
.sh > .in { animation-name: pop-in; animation-duration: .8s; }

.instant .in, .instant .f-line, .instant .f-fill { animation: none; opacity: 1; stroke-dashoffset: 0; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(34px); } to { opacity: 1; transform: none; } }
@keyframes corner-in { from { opacity: 0; transform: var(--from); } to { opacity: 1; transform: none; } }
@keyframes drop-in {
  0% { opacity: 0; transform: translateY(-340px) rotate(-8deg); }
  55% { opacity: 1; transform: translateY(16px) rotate(2deg); }
  78% { transform: translateY(-6px) rotate(-1deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes rise-in { from { opacity: 0; transform: translateY(900px) rotate(6deg); } 30% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes unfurl { from { opacity: 0; transform: scaleX(.05); } 40% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes write-in {
  from { opacity: 0; -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  15% { opacity: 1; }
  to { opacity: 1; -webkit-mask-position: 0 0; mask-position: 0 0; }
}
.names.in {
  -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
  mask-image: linear-gradient(90deg, #000 45%, transparent 55%);
  -webkit-mask-size: 300% 100%;
  mask-size: 300% 100%;
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
}
.instant .names.in { -webkit-mask-image: none; mask-image: none; }
@keyframes pop-in { from { opacity: 0; transform: scale(.55) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes bunny-in {
  0% { opacity: 0; transform: translateY(320px) scale(.92); }
  65% { opacity: 1; transform: translateY(-16px) scale(1.02); }
  100% { opacity: 1; transform: none; }
}
@keyframes sway-balloons { from { transform: rotate(-3deg) translateY(4px); } to { transform: rotate(3deg) translateY(-8px); } }
@keyframes sway-bow { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg) scale(1.012); } }
@keyframes sway-corner { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.008, 1.014); } }
@keyframes float { from { transform: translateY(-7px) rotate(-6deg); } to { transform: translateY(7px) rotate(6deg); } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(196, 80, 124, .32), 0 0 0 0 rgba(233, 138, 171, .45), inset 0 1px 0 rgba(255, 255, 255, .35); }
  50% { box-shadow: 0 6px 18px rgba(196, 80, 124, .32), 0 0 0 18px rgba(233, 138, 171, 0), inset 0 1px 0 rgba(255, 255, 255, .35); }
}
@keyframes wiggle {
  0% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 50% { transform: rotate(5deg); }
  75% { transform: rotate(-2deg); } 100% { transform: rotate(0); }
}

/* ---------- Летающие сердечки ---------- */

.fly-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fly {
  position: absolute;
  left: var(--x);
  bottom: -60px;
  width: var(--size);
  opacity: 0;
  animation: rise var(--dur) linear forwards;
}
.fly img { animation: fly-sway var(--sw) ease-in-out infinite alternate; transform: rotate(var(--rot)); }
@keyframes rise {
  0% { opacity: 0; transform: translateY(0); }
  8% { opacity: var(--op); }
  75% { opacity: var(--op); }
  100% { opacity: 0; transform: translateY(calc(-1 * var(--vh) - 120px)); }
}
@keyframes fly-sway {
  from { transform: translateX(calc(-1 * var(--amp))) rotate(var(--rot)); }
  to { transform: translateX(var(--amp)) rotate(calc(-1 * var(--rot))); }
}
.burst { position: fixed; left: 0; top: 0; width: var(--size); pointer-events: none; z-index: 5; }

/* ---------- Кнопка музыки ---------- */

.music {
  position: fixed;
  z-index: 20;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1.5px solid rgba(232, 154, 180, .8);
  border-radius: 50%;
  background: rgba(253, 249, 246, .86);
  box-shadow: 0 4px 14px rgba(196, 80, 124, .18);
  cursor: pointer;
  opacity: 0;
  transform: scale(.6);
  pointer-events: none;
  transition: opacity .5s ease 2.4s, transform .5s cubic-bezier(.3, 1.4, .5, 1) 2.4s;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
/* На ПК кнопка живёт внутри сцены — справа от рамки, под цветами (JS переносит её туда) */
.is-landscape .music { position: absolute; top: 160px; left: 1544px; width: 88px; height: 88px; border-width: 2px; }
.open .music { opacity: 1; transform: none; pointer-events: auto; }
.music-icon {
  position: absolute;
  inset: 16% 19% 16% 23%;
  background: var(--music-icon) center / contain no-repeat;
  animation: note-bob 2.4s ease-in-out infinite;
}
.music::after {
  content: '';
  position: absolute;
  left: 21%;
  right: 21%;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: var(--rose);
  transform: rotate(-45deg) scaleX(0);
  transition: transform .25s ease;
}
.music[aria-pressed="false"] .music-icon { opacity: .45; animation: none; }
.music[aria-pressed="false"]::after { transform: rotate(-45deg) scaleX(1); }
@keyframes note-bob { 0%, 100% { transform: rotate(-6deg) translateY(1px); } 50% { transform: rotate(6deg) translateY(-2px); } }

/* ---------- Загрузка ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 45%, #fffaf7 0%, var(--cream) 70%);
  transition: opacity .9s ease .25s, visibility 0s linear 1.2s;
}
.loader.ready { cursor: pointer; }
.loader.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.lheart {
  --p: 0;
  position: relative;
  width: min(68vmin, 340px);
  aspect-ratio: 560 / 509;
  padding: 0;
  border: 0;
  background: none;
  cursor: inherit;
}
.lh-base, .lh-fill { position: absolute; inset: 0; background: var(--lheart) center / contain no-repeat; }
.lh-base { opacity: .32; filter: saturate(.35) brightness(1.12); }
.lh-fill {
  -webkit-mask-image: linear-gradient(to top, #000 calc(var(--p) * 1.1% - 10%), transparent calc(var(--p) * 1.1%));
  mask-image: linear-gradient(to top, #000 calc(var(--p) * 1.1% - 10%), transparent calc(var(--p) * 1.1%));
}
.lh-text {
  position: absolute;
  left: 0;
  right: 0;
  top: 41%;
  transform: translateY(-50%) scale(.92);
  font-family: var(--serif);
  font-size: min(6.4vmin, 31px);
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 1px 8px rgba(168, 67, 107, .5), 0 0 2px rgba(168, 67, 107, .35);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .7s ease, transform .7s ease;
}
.ready .lh-text { opacity: 1; transform: translateY(-50%); }
.ready .lheart { animation: beat 1.9s ease-in-out .6s infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.06); } 28% { transform: scale(.99); } 42% { transform: scale(1.04); } 60% { transform: scale(1); } }

/* ---------- Окно с информацией ---------- */

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(92, 52, 68, .28);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s ease;
}
.modal-card {
  position: relative;
  width: min(100%, 360px);
  max-height: calc(var(--vh) - 40px);
  overflow: auto;
  padding: 30px 26px 24px;
  border-radius: 28px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  box-shadow: 0 20px 60px rgba(150, 60, 95, .25);
  text-align: center;
  opacity: 0;
  transform: translateY(24px) scale(.94);
  transition: opacity .3s ease, transform .4s cubic-bezier(.3, 1.3, .5, 1);
}
.modal.show .modal-backdrop { opacity: 1; }
.modal.show .modal-card { opacity: 1; transform: none; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rose);
  cursor: pointer;
}
.modal-close svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.modal h2 { margin: 0 0 18px; font-family: var(--script); font-weight: 400; font-size: 44px; line-height: 1; color: var(--rose); }
.m-rows { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 14px; text-align: left; width: fit-content; }
.m-rows li { display: flex; align-items: center; gap: 14px; }
.m-rows svg { width: 30px; height: 30px; flex: none; color: var(--rose); }
.m-rows b { display: block; font-size: 21px; font-weight: 400; color: var(--ink); line-height: 1.15; }
.m-rows small { display: block; font-size: 15px; color: var(--ink-soft); margin-top: 2px; }
.m-route {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  width: 100%;
  padding: 15px 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e98aab, #cc5c85);
  color: #fff;
  font-size: 18px;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(196, 80, 124, .3);
}
.m-route svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.m-qr { display: none; margin-top: 18px; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.m-qr img { width: 120px; image-rendering: pixelated; }
.fine-pointer .m-qr { display: flex; }
.m-wait { margin: 20px 0 0; font-style: italic; font-size: 19px; line-height: 1.3; color: var(--rose); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--cream); z-index: 50; margin: 0; }

/* ---------- Меньше движения ---------- */

@media (prefers-reduced-motion: reduce) {
  .idle, .music-icon, .open .pill, .ready .lheart { animation: none !important; }
  .in { animation-duration: .6s !important; }
}
