/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #c5306e; /* 主色 */
  --color-secondary: #ff7e5f; /* 次要色 */
  --color-accent: #4a6fa5; /* 强调色 */
  --color-success: #5a8d7b; /* 成功色 */
  --color-background: #fef3e7; /* 背景色 */
  --color-text-primary: #5a3e36; /* 文字主色 */
}

body {
  min-height: 100vh;
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background-color: var(--color-background);
  background-image:
    radial-gradient(
      circle at 20% 30%,
      rgba(255, 182, 193, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 70%,
      rgba(255, 222, 173, 0.1) 0%,
      transparent 50%
    );
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--color-text-primary);
  line-height: 1.6;
  position: relative;
}

.music-btn {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  cursor: pointer;
  z-index: 20;
}

/* 修复问题1：优化后的焦点遮罩 */
.focus-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(254, 243, 231, 0.98) 0%,
    /* 与页面背景色一致 */ rgba(254, 243, 231, 0.95) 100%
  );
  z-index: 9999;
  opacity: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 1.2s ease-out;
}

.focus-text {
  font-size: 2.8rem;
  font-weight: bold;
  color: var(--color-primary);
  text-align: center;
  animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

/* 修复问题2：半黑透明遮罩 */
.dark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0); /* 初始完全透明 */
  z-index: 3;
  pointer-events: none;
  transition: background 1.5s ease-in-out;
}

.dark-overlay.active {
  background: rgba(0, 0, 0, 0.7); /* 半黑透明 */
}

/* 主容器 */
.container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

/* 标题 */
.title {
  text-align: center;
  margin-bottom: 76px;
  z-index: 3;
}

.title h1 {
  font-size: 2.5rem;
  background: linear-gradient(90deg, #c5306e, #ff7e5f, #4a6fa5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}

.title p {
  color: #666;
  font-size: 1.1rem;
}

/* 信封容器 */
.envelope-container {
  position: relative;
  width: 320px;
  height: 240px;
  perspective: 1000px;
  margin: 0 auto 40px;
  cursor: pointer;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
  transition: transform 0.3s ease;
}

.envelope-container:hover {
  transform: translateY(-5px);
}

/* 信封样式 */
.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    145deg,
    var(--color-primary),
    var(--color-secondary)
  );
  border-radius: 12px;
  box-shadow:
    inset 2px 2px 5px rgba(255, 255, 255, 0.4),
    inset -2px -2px 5px rgba(190, 60, 100, 0.4),
    0 15px 35px rgba(197, 48, 110, 0.3),
    0 5px 15px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: heartbeat 3s ease-in-out infinite;
}

@keyframes heartbeat {
  0%,
  100% {
    box-shadow:
      inset 2px 2px 5px rgba(255, 255, 255, 0.4),
      inset -2px -2px 5px rgba(190, 60, 100, 0.4),
      0 15px 35px rgba(197, 48, 110, 0.3),
      0 0 0 0 rgba(197, 48, 110, 0.4);
  }
  50% {
    box-shadow:
      inset 2px 2px 5px rgba(255, 255, 255, 0.4),
      inset -2px -2px 5px rgba(190, 60, 100, 0.4),
      0 15px 35px rgba(197, 48, 110, 0.3),
      0 0 0 15px rgba(197, 48, 110, 0);
  }
}

.envelope::before {
  content: "";
  position: absolute;
  top: -100px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-bottom: 100px solid #a5274a;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.envelope-flap {
  position: absolute;
  top: -100px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-bottom: 100px solid #8a1c3d;
  transform-origin: bottom;
  transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
}

/* 卡片样式 */
.card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  min-height: 200px;
  background: rgba(255, 249, 240, 0.95);
  border-radius: 16px;
  padding: 30px 25px;
  transform: translate(-50%, -50%) scale(0.8) rotate(-8deg);
  opacity: 0;
  transition: all 10s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.2),
    0 10px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  z-index: 5;
}

.card.open {
  transform: translate(-50%, -180%) scale(1) rotate(0deg);
  opacity: 1;
}

.card h2 {
  text-align: center;
  color: var(--color-primary);
  font-size: 1.8rem;
  margin-bottom: 20px;
}

.card-content {
  font-size: 1.1rem;
  color: var(--color-text-primary);
  line-height: 1.8;
  text-align: center;
}

/* 修复问题3：优化心里话容器和间距 */
.blessings-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.blessings-container.show {
  opacity: 1;
}

/* 优化后的心里话气泡 - 统一间距 */
.blessing-bubble {
  position: absolute;
  padding: 12px 20px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 80vw;
  z-index: 6;
}

.blessing-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.blessing-bubble.fade-out {
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
}

/* 阶段颜色 */
.blessing-bubble.act1 {
  background: linear-gradient(
    135deg,
    rgba(255, 240, 245, 0.95),
    rgba(255, 228, 225, 0.95)
  );
  color: #c5306e;
  border-left: 4px solid #ff6b9d;
}

.blessing-bubble.act2 {
  background: linear-gradient(
    135deg,
    rgba(240, 248, 255, 0.95),
    rgba(230, 240, 250, 0.95)
  );
  color: #4a6fa5;
  border-left: 4px solid #5d9cec;
}

.blessing-bubble.act3 {
  background: linear-gradient(
    135deg,
    rgba(245, 255, 250, 0.95),
    rgba(240, 255, 250, 0.95)
  );
  color: #5a8d7b;
  border-left: 4px solid #8fbc8f;
}

.blessing-emoji {
  font-size: 1.2rem;
  animation: float 2s ease-in-out infinite;
}

.blessing-text {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(3deg);
  }
}

/* 画布 */
#petals-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#fireworks-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* 操作指引 */
.instructions {
  text-align: center;
  margin-top: 30px;
  color: #666;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 24px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: gentlePulse 3s ease-in-out infinite;
  max-width: 300px;
  z-index: 4;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .title h1 {
    font-size: 2rem;
  }

  .envelope-container {
    width: 280px;
    height: 210px;
  }

  .envelope::before,
  .envelope-flap {
    border-left-width: 140px;
    border-right-width: 140px;
    border-bottom-width: 90px;
    top: -90px;
  }

  .card {
    width: 280px;
    padding: 25px 20px;
  }

  .card h2 {
    font-size: 1.6rem;
  }

  .blessing-bubble {
    font-size: 1rem;
    padding: 10px 16px;
    max-width: 85vw;
  }
}

@media (max-width: 480px) {
  .title h1 {
    font-size: 1.8rem;
  }

  .envelope-container {
    width: 250px;
    height: 190px;
  }

  .envelope::before,
  .envelope-flap {
    border-left-width: 125px;
    border-right-width: 125px;
    border-bottom-width: 80px;
    top: -80px;
  }

  .card {
    width: 260px;
  }

  .blessing-bubble {
    font-size: 0.95rem;
    padding: 8px 14px;
    max-width: 90vw;
  }
}
