/* ===== 全局重置与基础 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pink: #ff6b8a;
  --pink-light: #ffb3c1;
  --pink-pale: #fff0f5;
  --cream: #fff9f0;
  --text-dark: #4a3040;
  --text-mid: #7a5060;
  --text-light: #b08090;
  --white: #ffffff;
  --shadow: 0 8px 32px rgba(255, 107, 138, 0.15);
  --shadow-hover: 0 16px 48px rgba(255, 107, 138, 0.25);
  --radius: 16px;
  --transition: 0.4s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
  background: linear-gradient(135deg, var(--pink-pale) 0%, var(--cream) 100%);
  min-height: 100vh;
  color: var(--text-dark);
  line-height: 1.8;
  overflow-x: hidden;
}

/* ===== 通用 section ===== */
.section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.section.hidden {
  display: none;
  opacity: 0;
}

.section.fade-in {
  animation: fadeIn 0.8s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 密码页 ===== */
.password-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.password-hint {
  font-size: 18px;
  color: var(--text-mid);
  letter-spacing: 0.05em;
}

.password-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.password-input {
  padding: 12px 20px;
  border: 2px solid var(--pink-light);
  border-radius: 50px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-dark);
  background: var(--white);
  outline: none;
  width: 180px;
  text-align: center;
  letter-spacing: 0.15em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.password-input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 107, 138, 0.15);
}

.btn-password {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--pink) 0%, #ff8fa3 100%);
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 107, 138, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.btn-password:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 107, 138, 0.45);
}

.password-error {
  font-size: 14px;
  color: var(--pink);
  animation: fadeIn 0.3s ease forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

.password-input.shake {
  animation: shake 0.45s ease;
  border-color: var(--pink);
}

/* ===== 信封页 ===== */
.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.envelope-hint {
  font-size: 18px;
  color: var(--text-mid);
  letter-spacing: 0.05em;
}

.envelope-click-hint {
  font-size: 14px;
  color: var(--pink-light);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(-4px); }
}

/* 信封主体 */
.envelope {
  cursor: pointer;
  width: min(82vw, 340px);
  position: relative;
  filter: drop-shadow(0 8px 24px rgba(255, 107, 138, 0.2));
  transition: transform 0.3s ease, filter 0.3s ease;
  outline: none;
}

.envelope:hover,
.envelope:focus {
  transform: translateY(-6px) scale(1.02);
  filter: drop-shadow(0 16px 40px rgba(255, 107, 138, 0.35));
}

.envelope-body {
  position: relative;
  width: 100%;
  padding-top: 66%; /* 3:2 比例 */
  background: var(--white);
  border-radius: 4px 4px 8px 8px;
  border: 2px solid var(--pink-light);
  overflow: visible;
}

/* 信封盖（三角形） */
.envelope-flap {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  height: 55%;
  background: linear-gradient(160deg, #ffe0ea 0%, #ffc8d8 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 4px 4px 0 0;
  transform-origin: top center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  border: 2px solid var(--pink-light);
}

/* 信封盖打开 */
.envelope.open .envelope-flap {
  transform: rotateX(180deg);
}

/* 信封内容占位（爱心） */
.envelope-content-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.heart-icon {
  font-size: 48px;
  color: var(--pink);
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.12); }
}

/* 信封底部折痕线 */
.envelope-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(0deg, #fff5f8 0%, transparent 100%);
  border-radius: 0 0 6px 6px;
  z-index: 0;
}

/* 信封淡出 */
.envelope-wrapper.fade-out {
  animation: fadeOut 0.6s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.95); }
}

/* ===== 打字机页 ===== */
.typewriter-wrapper {
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding: 20px;
}

.typewriter-text {
  font-size: 20px;
  line-height: 2;
  color: var(--text-dark);
  text-align: center;
  min-height: 2em;
  position: relative;
}

/* 光标 */
.typewriter-text.typing::after {
  content: '|';
  color: var(--pink);
  animation: blink 0.7s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ===== 按钮通用 ===== */
.btn-continue,
.btn-accept {
  display: inline-block;
  padding: 14px 36px;
  background: linear-gradient(135deg, var(--pink) 0%, #ff8fa3 100%);
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 20px rgba(255, 107, 138, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.btn-continue:hover,
.btn-accept:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(255, 107, 138, 0.5);
}

.btn-continue:active,
.btn-accept:active {
  transform: translateY(0);
}

/* ===== 照片墙 ===== */
.section-title {
  font-size: 24px;
  color: var(--text-mid);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-align: center;
}

/* ===== 牌堆 ===== */
#photos-section {
  flex-direction: column;
  gap: 32px;
  min-height: 100vh;
  padding: 60px 20px;
  align-items: center;
  justify-content: center;
}

.deck-scene {
  position: relative;
  width: 300px;
  height: 440px;
  margin: 0 auto;
}

/* 牌堆容器 */
.deck-stack {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 340px;
  cursor: pointer;
  z-index: 1;
}

/* 牌堆中每张卡片 */
.deck-card {
  position: absolute;
  width: 260px;
  height: 340px;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffd6e7 0%, #ffadc6 50%, #ff8fa3 100%);
  box-shadow: 0 4px 20px rgba(255,107,138,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
  top: 0; left: 0;
}

.deck-card-pattern {
  width: 76%;
  height: 76%;
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.deck-card-heart {
  font-size: 36px;
  opacity: 0.85;
  animation: heartbeat 2s ease-in-out infinite;
}

.deck-card-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.06em;
}

/* 牌堆悬停 */
.deck-stack:hover .deck-card:last-child {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 16px 40px rgba(255,107,138,0.35);
}

/* 展开的卡片容器 — 与牌堆完全重叠 */
.deck-expanded {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  z-index: 2;
}

/* 展开卡片 — 照片面 */
.expanded-card {
  width: 300px;
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 16px 48px rgba(255,107,138,0.25);
  overflow: hidden;
  cursor: pointer;
  animation: cardFlyIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardFlyIn {
  0%   { opacity: 0; transform: scale(0.75) rotate(-6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.expanded-card.fly-out {
  animation: cardFlyOut 0.45s cubic-bezier(0.4, 0, 0.8, 0.6) forwards;
}

@keyframes cardFlyOut {
  0%   { opacity: 1; transform: scale(1) translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: scale(0.8) translateY(-30px) rotate(4deg); }
}

.expanded-photo {
  width: 100%;
  height: 320px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
}

.expanded-info {
  padding: 14px 18px 16px;
  background: var(--white);
}

.expanded-title {
  font-size: 15px;
  color: var(--text-dark);
  font-weight: 500;
}

.expanded-date {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 3px;
}

.expanded-tap-hint {
  font-size: 12px;
  color: var(--pink-light);
  margin-top: 6px;
  animation: pulse 2s ease-in-out infinite;
}

/* 展开卡片 — 文字面（翻转） */
.expanded-card.show-text {
  background: linear-gradient(145deg, #fff0f5 0%, #ffe8f0 100%);
  animation: cardFlipIn 0.45s ease forwards;
}

@keyframes cardFlipIn {
  0%   { transform: rotateY(90deg) scale(0.9); opacity: 0.5; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.expanded-text-content {
  padding: 40px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  min-height: 380px;
  justify-content: center;
}

.expanded-text-heart {
  font-size: 36px;
  color: var(--pink);
  animation: heartbeat 2s ease-in-out infinite;
}

.expanded-message {
  font-size: 16px;
  line-height: 2;
  color: var(--text-dark);
}

.expanded-text-hint {
  font-size: 12px;
  color: var(--text-light);
}

/* 计数器 — 固定在牌堆底部下方 */
.deck-counter {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--text-light);
  letter-spacing: 0.05em;
  white-space: nowrap;
  z-index: 3;
}

/* 牌堆空了的提示 */
.deck-empty-hint {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  padding: 20px;
  animation: fadeIn 0.5s ease forwards;
}

/* ===== 结束页 ===== */
#ending-section {
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 80vh;
}

.ending-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  text-align: center;
  max-width: 600px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.ending-text {
  font-size: 18px;
  line-height: 2.2;
  color: var(--text-mid);
  white-space: pre-line;
}

.delivered-text {
  font-size: 20px;
  color: var(--pink);
  font-weight: 500;
  animation: fadeIn 0.8s ease forwards;
}

/* 爱心飘落 */
.hearts-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -40px;
  font-size: 24px;
  color: var(--pink);
  animation: floatUp linear forwards;
  opacity: 0.8;
}

@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0.8; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* ===== 通用 hidden ===== */
.hidden {
  display: none !important;
}

/* ===== 响应式：平板 ===== */
@media (min-width: 768px) {
  .envelope {
    width: min(60vw, 360px);
  }

  .envelope-hint {
    font-size: 20px;
  }

  .typewriter-text {
    font-size: 20px;
  }

  .section-title {
    font-size: 26px;
  }
}

/* ===== 响应式：桌面 ===== */
@media (min-width: 1024px) {
  .envelope {
    width: 360px;
  }

  .envelope-hint {
    font-size: 22px;
  }

  .typewriter-text {
    font-size: 22px;
  }

  .section-title {
    font-size: 28px;
  }

  .ending-text {
    font-size: 20px;
  }
}

/* ===== 响应式：大屏 ===== */
@media (min-width: 1440px) {
}
