#page-2 {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
.card {
  width: 100%;
  max-width: 920px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(6px);
  position: relative;
  overflow: hidden;
}
header {
  display: flex;
  gap: 20px;
  align-items: center;
}
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.3)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--accent);
  flex-shrink: 0;
  border: 4px solid rgba(255, 255, 255, 0.6);
}
h1 {
  margin: 0;
  font-size: 28px;
}
p.lead {
  margin: 6px 0 0;
  color: #333;
  opacity: 0.9;
}
.controls {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
button {
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}
.secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid rgba(0, 0, 0, 0.06);
}
.message-area {
  margin-top: 22px;
  font-size: 20px;
  line-height: 1.4;
  color: #222;
  padding: 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.footer {
  margin-top: 18px;
  font-size: 13px;
  color: #555;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.small {
  font-size: 12px;
  color: #666;
}
.share {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.3)
  );
  padding: 8px 10px;
  border-radius: 8px;
}
.palette {
  display: flex;
  gap: 8px;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.6);
}
/* confetti canvas full-screen inside card */
canvas#confetti {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
/* simple responsive */
@media (max-width: 560px) {
  .avatar {
    width: 72px;
    height: 72px;
    font-size: 30px;
  }
  h1 {
    font-size: 22px;
  }
  .message-area {
    font-size: 17px;
  }
}
audio {
  display: none !important;
}

/* 信封图标样式 */
.envelope-icon {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 10;
}

.envelope-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.envelope-icon svg {
  width: 20px;
  height: 20px;
}

/* page3 样式 */
#page-3 {
  min-height: 100%;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  padding: 20px;
}

.letter-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(6px);
}

.letter-header {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
}

.back-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
}

.back-btn:hover {
  background: #ff5252;
}

.letter-header h2 {
  margin: 0;
  font-size: 24px;
  color: #333;
}

.letter-content {
  font-family: 'XiaoZhiTiaoQingChunTi', 'STKaiti', 'KaiTi', cursive, sans-serif;
  font-size: 18px;
  line-height: 1.8;
  color: #2c2c2c;
  background: #fffef8;
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 30px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  white-space: pre-line;
}

.image-gallery h3 {
  margin-bottom: 20px;
  color: #333;
  font-size: 20px;
  text-align: center;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.image-item {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-item:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.image-item:hover img {
  transform: scale(1.1);
}

/* 图片模态框样式 */
.image-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  position: relative;
  margin: auto;
  padding: 20px;
  width: 90%;
  max-width: 900px;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 50%;
  transform: translateY(-50%);
}

.modal-content img {
  pointer-events: auto; /* 图片本身可以点击 */
  cursor: zoom-out; /* 显示缩放光标 */
}

.modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close-modal:hover {
  color: #bbb;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .letter-container {
    padding: 20px;
    margin: 10px;
  }
  
  .letter-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .letter-content {
    padding: 20px;
    font-size: 18px;
  }
  
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .modal-content {
    width: 95%;
    height: 80%;
  }
  
  .close-modal {
    font-size: 30px;
    top: 10px;
    right: 15px;
  }
}

@media (max-width: 480px) {
  .envelope-icon {
    width: 36px;
    height: 36px;
    bottom: 15px;
    right: 15px;
  }
  
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}
#messageBox {
  width: 100%;
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #393939;
  min-height: 40px;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}
#messageText::after {
  content: "|";
  display: inline-block;
  margin-left: 3px;
  animation: blink 0.8s infinite;
}
@keyframes blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
