:root {
  --ink: #2a1720;
  --white: #fff;
  --soft-white: rgba(255, 255, 255, 0.9);
  --pink: #ff76a8;
  --pink-deep: #ff3f8f;
  --rose: #ffedf4;
  --blue: #eef7ff;
  --green: #effbf5;
  --yellow: #fff9de;
  --purple: #f6eeff;
  --shadow: 0 18px 44px rgba(89, 29, 48, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #fbd5df;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 234, 240, 0.1), rgba(255, 127, 166, 0.22)),
    url("https://web-img.zf2026.cn/static/images/demo/6250-1.webp") center / cover no-repeat;
  transform: scale(1.03);
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.28), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 117, 155, 0.2));
}

#heartCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.scene {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
}

.popup-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gift-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(88vw, 380px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 20px 60px rgba(185, 37, 91, 0.32), 4px 4px 0 rgba(255, 87, 139, 0.18);
  transform: translate(-50%, -50%);
  animation: modalIn 580ms cubic-bezier(0.2, 0.86, 0.26, 1.2) both;
}

.modal-title {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #ffb6cc, #ff6fa5 48%, #ff3d8d);
  border-bottom: 1px solid rgba(255, 100, 150, 0.3);
}

.title-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #ff4a90;
  background: rgba(255, 255, 255, 0.92);
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  padding: 26px 22px 24px;
  text-align: center;
}

.modal-body p {
  margin: 0;
  color: #5b3744;
  font-size: 19px;
  line-height: 1.7;
  font-weight: 700;
}

.open-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 22px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #ff79aa, #ff2e85);
  box-shadow: 0 10px 24px rgba(255, 58, 133, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.open-btn:active {
  transform: translateY(1px);
}

.gift-modal.hide {
  animation: modalOut 260ms ease forwards;
}

.message-popup {
  position: absolute;
  width: 95px;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  overflow: hidden;
  color: #2c1b24;
  background: var(--white);
  box-shadow: 0 6px 18px rgba(255, 72, 133, 0.32);
  opacity: 0;
  transform: translate(var(--from-x), var(--from-y)) scale(0.4) rotate(var(--rot));
  backface-visibility: hidden;
  contain: layout paint style;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  animation: flyIn 4200ms cubic-bezier(0.1, 0.54, 0.18, 1) forwards, softFloat 6.2s ease-in-out infinite;
  animation-delay: var(--delay), calc(var(--delay) + 4200ms);
}

.popup-layer.bursting .message-popup {
  animation: burstToScreen 3200ms cubic-bezier(0.16, 0.9, 0.18, 1) forwards;
  animation-delay: var(--burst-delay);
  box-shadow: 0 18px 42px rgba(255, 72, 133, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.popup-layer.burst-ready .message-popup {
  will-change: transform, opacity;
}

.popup-layer.bursting .popup-text {
  font-weight: 950;
}

.popup-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 16px;
  padding: 0 5px;
  color: rgba(70, 31, 44, 0.74);
  font-size: 8px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid rgba(255, 161, 191, 0.35);
}

.popup-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff6fa5;
  box-shadow: 9px 0 0 #ffd36e, 18px 0 0 #74dfbf;
}

.popup-text {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px 5px;
  font-size: 11px;
  line-height: 1.28;
  font-weight: 900;
  text-align: center;
  word-break: break-word;
}

.theme-pink {
  background: #fff0f6;
}

.theme-blue {
  background: var(--blue);
  box-shadow: 0 6px 18px rgba(92, 154, 255, 0.28);
}

.theme-green {
  background: var(--green);
  box-shadow: 0 6px 18px rgba(61, 185, 133, 0.24);
}

.theme-yellow {
  background: var(--yellow);
  box-shadow: 0 6px 18px rgba(239, 175, 48, 0.24);
}

.theme-purple {
  background: var(--purple);
  box-shadow: 0 6px 18px rgba(145, 91, 210, 0.24);
}

.circle-btn,
.small-round {
  position: fixed;
  z-index: 3;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  background: rgba(46, 22, 34, 0.38);
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(70, 22, 38, 0.18);
  backdrop-filter: blur(10px);
}

.music-btn {
  top: max(22px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.music-disc {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid currentColor;
  animation: spin 3.8s linear infinite;
}

.music-disc::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.muted .music-disc {
  animation-play-state: paused;
  opacity: 0.55;
}

.float-actions {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  gap: 12px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 260ms ease, transform 260ms ease;
}

.is-open .float-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body:has(.popup-layer.bursting) .float-actions {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

body:has(.popup-layer.bursting) .music-btn {
  opacity: 0;
  pointer-events: none;
}

.small-round {
  position: static;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 5;
  padding: 9px 15px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  background: rgba(45, 20, 32, 0.72);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(14px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes modalIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.86);
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes modalOut {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

@keyframes flyIn {
  0% {
    opacity: 0;
    transform: translate(var(--from-x), var(--from-y)) scale(0.4) rotate(var(--rot));
  }
  70% {
    opacity: 1;
    transform: translate(0, 0) scale(calc(var(--scale) * 1.08)) rotate(var(--rot));
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(var(--scale)) rotate(var(--rot));
  }
}

@keyframes softFloat {
  0%,
  100% {
    margin-top: 0;
  }
  50% {
    margin-top: -8px;
  }
}

@keyframes burstToScreen {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(var(--scale)) rotate(var(--rot));
    filter: blur(0);
  }
  16% {
    transform: translate3d(calc(var(--burst-x) * -0.04), calc(var(--burst-y) * -0.04), 0) scale(calc(var(--scale) * 0.92)) rotate(var(--rot));
  }
  66% {
    opacity: 1;
    transform: translate3d(calc(var(--burst-x) * 0.92), calc(var(--burst-y) * 0.92), 0) scale(calc(var(--burst-scale) * 1.04)) rotate(var(--burst-rot));
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translate3d(var(--burst-x), var(--burst-y), 0) scale(var(--burst-scale)) rotate(var(--burst-rot));
    filter: blur(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 430px) {
  .message-popup {
    width: 65px;
    min-height: 38px;
    border-radius: 7px;
  }

  .popup-head {
    height: 13px;
    padding: 0 4px;
    font-size: 7px;
  }

  .popup-dot {
    width: 5px;
    height: 5px;
    box-shadow: 7px 0 0 #ffd36e, 14px 0 0 #74dfbf;
  }

  .popup-text {
    min-height: 25px;
    padding: 3px 4px 4px;
    font-size: 9px;
    line-height: 1.16;
  }

  .popup-layer.bursting .popup-text {
    font-size: 10px;
    line-height: 1.18;
  }

  .modal-title {
    min-height: 54px;
    font-size: 21px;
  }

  .modal-body {
    padding: 24px 18px 20px;
  }

  .modal-body p {
    font-size: 18px;
  }
}

@media (min-width: 760px) {
  .message-popup {
    width: 130px;
    min-height: 54px;
  }

  .popup-text {
    font-size: 14px;
  }

  .popup-layer.bursting .popup-text {
    font-size: 15px;
  }
}

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