* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  background: #d8f5e8;
  transition: background 0.6s ease;
}

canvas {
  display: block;
  position: fixed;
  inset: 0;
}

#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#title {
  margin-top: 22px;
  text-align: center;
  color: #6b5b6e;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
  user-select: none;
}

#title h1 {
  font-size: 28px;
  letter-spacing: 2px;
}

#template-name {
  font-size: 14px;
  opacity: 0.75;
  margin-top: 4px;
}

#hint {
  margin-top: 12px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  color: #d96a7f;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

#templates {
  position: absolute;
  bottom: 32px;
  left: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.chip {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 16px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);
  color: #6b5b6e;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(120, 90, 120, 0.12);
  text-align: left;
}

.chip:hover {
  transform: translateY(-2px) scale(1.03);
  background: rgba(255, 255, 255, 0.85);
}

.chip.active {
  background: #fff;
  box-shadow: 0 6px 20px rgba(255, 130, 160, 0.35);
  border-color: #ffb6c8;
}

#bottom-bar {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  pointer-events: auto;
}

.tool-btn {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 16px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  color: #6b5b6e;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(120, 90, 120, 0.12);
  transition: transform 0.15s ease, background 0.2s ease;
}

.tool-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.9);
}

.tool-btn.active {
  background: linear-gradient(145deg, #ff9eb5, #ff7fa5);
  color: #fff;
  border-color: #fff;
  box-shadow: 0 6px 18px rgba(255, 130, 160, 0.45);
}

#shutter {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: linear-gradient(145deg, #ff9eb5, #ff7fa5);
  box-shadow: 0 8px 24px rgba(255, 127, 165, 0.5),
    inset 0 -4px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 34px;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

#shutter:hover {
  transform: scale(1.06);
}

#shutter:active {
  transform: scale(0.92);
}

/* ===================== 倒计时 ===================== */
#countdown {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#countdown.hidden {
  display: none;
}

#countdown-num {
  font-family: "ZCOOL KuaiLe", sans-serif;
  font-size: 190px;
  color: #fff;
  text-shadow: 0 10px 44px rgba(255, 110, 150, 0.85),
    0 4px 0 rgba(255, 110, 150, 0.6);
}

#countdown-num.tick {
  animation: pop-num 0.9s ease forwards;
}

@keyframes pop-num {
  0% {
    transform: scale(1.7);
    opacity: 0;
  }
  25% {
    transform: scale(1);
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: scale(0.92);
    opacity: 0.35;
  }
}

/* ===================== 胶卷相册 ===================== */
#gallery {
  position: absolute;
  right: 22px;
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 30vw;
  overflow-x: auto;
  padding: 10px 6px;
  pointer-events: auto;
  scrollbar-width: thin;
}

.thumb {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 72px;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 6px 16px rgba(120, 80, 100, 0.28);
  cursor: pointer;
  transition: transform 0.15s ease;
  transform: rotate(-2.5deg);
}

.thumb:nth-child(even) {
  transform: rotate(2.5deg);
}

.thumb:hover {
  transform: rotate(0) scale(1.12);
  z-index: 2;
}

.thumb img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

.thumb button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #ff6f9c;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding: 0;
}

.thumb:hover button {
  opacity: 1;
}

#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.45s ease-out;
}

#flash.on {
  opacity: 1;
  transition: opacity 0.05s ease-in;
}

#photo-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(90, 70, 90, 0.45);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#photo-modal.hidden,
#hint.hidden {
  display: none;
}

#photo-card {
  background: #fff;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

@keyframes pop {
  from {
    transform: scale(0.6) rotate(-4deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

#photo-img {
  max-height: 70vh;
  max-width: 80vw;
  border-radius: 14px;
  display: block;
}

#photo-actions {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

#download-btn,
#close-modal {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

#download-btn {
  background: linear-gradient(145deg, #7dedc4, #4fd1a5);
  color: #fff;
}

#close-modal {
  background: linear-gradient(145deg, #ffd166, #ffb84d);
  color: #fff;
}

#download-btn:hover,
#close-modal:hover {
  filter: brightness(1.06);
}

/* ===================== 首页 ===================== */
#home {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #ffd6e7 0%, #ffb6c8 45%, #ffc8dd 100%);
  transition: opacity 0.7s ease, transform 0.7s ease;
  overflow: hidden;
}

#home.away {
  opacity: 0;
  transform: scale(1.08);
  pointer-events: none;
}

#home-card {
  position: relative;
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  border: 3px solid #fff;
  border-radius: 36px;
  padding: 52px 64px;
  box-shadow: 0 24px 60px rgba(214, 92, 134, 0.35);
  animation: card-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes card-in {
  from {
    transform: translateY(40px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

#home-card h1 {
  font-size: 44px;
  color: #d6437a;
  letter-spacing: 3px;
  text-shadow: 0 3px 0 #fff;
}

#home-quote {
  margin-top: 26px;
  font-size: 24px;
  line-height: 1.7;
  color: #8c5a6e;
}

#home-quote-sub {
  margin-top: 14px;
  font-size: 16px;
  line-height: 1.8;
  color: #b07a90;
}

#start-btn {
  margin-top: 32px;
  font-family: inherit;
  font-size: 22px;
  padding: 16px 52px;
  border: 4px solid #fff;
  border-radius: 999px;
  background: linear-gradient(145deg, #ff9eb5, #ff6f9c);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 110, 150, 0.55);
  transition: transform 0.15s ease;
  animation: heartbeat 1.6s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.06); }
  24% { transform: scale(1); }
}

#start-btn:hover {
  transform: scale(1.08);
  animation: none;
}

#start-btn:active {
  transform: scale(0.94);
}

#home-tip {
  margin-top: 18px;
  font-size: 13px;
  color: #c290a4;
}

.float-emoji {
  position: absolute;
  font-size: 42px;
  opacity: 0.85;
  animation: floaty 7s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(214, 92, 134, 0.25));
  user-select: none;
}

.float-emoji:nth-child(1) { top: 12%; left: 12%; animation-delay: 0s; }
.float-emoji:nth-child(2) { top: 70%; left: 8%; font-size: 56px; animation-delay: -1.5s; }
.float-emoji:nth-child(3) { top: 18%; right: 14%; font-size: 50px; animation-delay: -3s; }
.float-emoji:nth-child(4) { top: 62%; right: 10%; animation-delay: -4.5s; }
.float-emoji:nth-child(5) { top: 38%; left: 5%; font-size: 36px; animation-delay: -2s; }
.float-emoji:nth-child(6) { top: 8%; left: 45%; font-size: 38px; animation-delay: -5s; }
.float-emoji:nth-child(7) { bottom: 8%; left: 40%; font-size: 40px; animation-delay: -3.8s; }
.float-emoji:nth-child(8) { top: 42%; right: 4%; font-size: 44px; animation-delay: -6s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-26px) rotate(8deg); }
}

/* ===================== 成片预览面板 ===================== */
#preview-panel {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%) rotate(2.5deg);
  background: #fff;
  border-radius: 18px;
  padding: 12px 12px 14px;
  box-shadow: 0 14px 36px rgba(120, 80, 100, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#preview-panel.show {
  opacity: 1;
  transform: translateY(-50%) rotate(-2.5deg);
}

#preview-panel::before {
  /* 顶部胶带 */
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 86px;
  height: 26px;
  background: rgba(255, 182, 200, 0.75);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#preview-title {
  font-size: 13px;
  color: #c2718a;
  text-align: center;
  margin-bottom: 8px;
}

#preview-canvas {
  display: block;
  position: static;
  width: 200px;
  height: 250px;
  border-radius: 10px;
}

@media (max-width: 860px) {
  #preview-panel {
    display: none;
  }
}
