html {
  font-size: 16px;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Arial", "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e, #ffa8a8, #ffb3ba);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  min-height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  position: relative;
}
/* 修复移动端 100vh 抖动：设置 CSS 变量 --vh */
:root {
  --vh: 1vh;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  text-align: center;
  position: relative;
  z-index: 10;
  padding: 20px;
  box-sizing: border-box;
  gap: 10px; /* 让模块之间不再挤在一起 */
  padding-top: 0;
  padding-bottom: 30px;
}

.heart {
  width: 80px;
  height: 72px;
  position: relative;
  margin: 15px auto;
  animation: heartbeat 1.5s ease-in-out infinite;
}

.heart::before,
.heart::after {
  content: "";
  width: 42px;
  height: 64px;
  position: absolute;
  left: 40px;
  top: 0;
  background: #ff4757;
  border-radius: 40px 40px 0 0;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.heart::after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}

@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

.title {
  font-size: 36px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin: 16px 0;
  opacity: 0;
  animation: fadeInUp 2s ease forwards 1s;
}

.message {
  font-size: 14px;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  margin: 12px 0;
  opacity: 0;
  animation: fadeInUp 2s ease forwards 2s;
  max-width: 90%;
  line-height: 1.6;
  padding: 0 10px;
}

.button-container {
  margin-top: 15px;
  opacity: 0;
  animation: fadeInUp 2s ease forwards 3s;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  position: relative;
  z-index: 30;
}

.love-button {
  background: linear-gradient(45deg, #ff4757, #ff3742);
  color: white;
  border: none;
  padding: 12px 30px;
  font-size: 16px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(255, 71, 87, 0.4);
  transition: all 0.3s ease;
  min-width: 120px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.love-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(255, 71, 87, 0.6);
}

.love-button:active {
  transform: translateY(0);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating-hearts {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  animation: float 6s linear infinite;
}

@keyframes float {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) rotate(360deg);
    opacity: 0;
  }
}

.fireworks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.firework {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  animation: explode 1s ease-out forwards;
  will-change: transform, opacity;
  transform: translate(0, 0) scale(1);
}

@keyframes explode {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(1);
    opacity: 0;
  }
}

.hidden {
  display: none;
}

.success-message {
  font-size: 24px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin: 18px 0;
  opacity: 0;
  animation: fadeInUp 1s ease forwards;
  padding: 0 20px;
}
/* 星空画布与月亮 */
canvas#stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(var(--vh, 1vh) * 100);
  z-index: 0;
  pointer-events: none;
}
.moon {
  position: fixed;
  top: 30px;
  right: 30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7e6, #ffdca8 60%, rgba(255, 220, 168, 0.1) 70%, transparent 72%);
  box-shadow:
    0 0 20px rgba(255, 236, 179, 0.6),
    0 0 60px rgba(255, 220, 168, 0.3);
  z-index: 2;
  pointer-events: none;
}

/* 玫瑰花瓣飘落 */
.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.petal {
  position: absolute;
  top: -40px;
  width: 14px;
  height: 10px;
  background: radial-gradient(ellipse at center, #ff6b88 0%, #ff3f6c 60%, #e0194f 100%);
  border-radius: 60% 60% 60% 60% / 80% 80% 40% 40%;
  opacity: 0.9;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15));
  animation: petalFall linear forwards;
  will-change: transform, opacity;
}
@keyframes petalFall {
  0% {
    transform: translate(0, -40px) rotate(0deg);
    opacity: 0.9;
  }
  50% {
    transform: translate(12px, 50vh) rotate(180deg);
    opacity: 0.95;
  }
  100% {
    transform: translate(-8px, 110vh) rotate(360deg);
    opacity: 0.95;
  }
}
/* 纪念日角标 */
.anniversary {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 20;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  /* 优化：避免遮挡按钮，并控制宽度 */
  pointer-events: none;        /* 不拦截点击，让下层按钮可点 */
  max-width: 300px;            /* 限宽，减少水平覆盖 */
  overflow-wrap: anywhere;     /* 日期/长词自动换行 */
}
.anniversary strong {
  font-weight: 700;
}

/* 打字机效果区域（固定两行高度，防止挤压抖动） */
.typewriter {
  color: #fff;
  font-size: 18px;
  max-width: 90%;
  line-height: 1.6;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  display: block;
  height: 57.6px; /* 固定约两行（2 × 1.6 × 18px） */
  overflow: hidden; /* 超出直接裁剪，不出现滚动条 */
  padding-right: 2px;
}

/* 打字机文本本体 */
#typeText {
  display: inline;
  max-width: 100%;
}
.caret {
  display: inline-block;
  width: 1px;
  height: 18px; /* 与单行高度对齐 */
  background: #fff;
  margin-left: 4px;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* 3D 爱心环 */
.stage {
  perspective: 800px;
  width: 100%;
  display: flex;
  justify-content: center;
}
.orbit {
  position: relative;
  width: 220px;
  height: 50px;
  transform-style: preserve-3d;
  animation: spin 12s linear infinite;
}
.orbit span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}
@keyframes spin {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}

/* 左上角返回按钮 */
.back-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 8px 12px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}
.back-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.28);
}
.hidden {
  display: none !important;
}

/* 控制面板 */
.controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ctrl-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 10px 14px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  font-size: 15.2px;
  cursor: pointer;
  transition:
    transform 0.2s,
    background 0.2s;
}
/* 降低渲染压力的小技巧 */
.floating-heart,
.petal {
  will-change: transform, opacity;
}
.title,
.message,
.success-message {
  will-change: transform, opacity;
}

.ctrl-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.28);
}
