/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pink:         #ff6eb4;
  --light-pink:   #ffd6ec;
  --purple:       #c084fc;
  --yellow:       #fde68a;
  --mint:         #6ee7b7;
  --orange:       #fb923c;
  --light-orange: #fed7aa;
  --bg:           #fdf4f9;
  --text:         #4a2040;
  --sakura:       #fce7f3;
  --sakura-dark:  #f9a8d4;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.hidden { display: none !important; }

button { touch-action: manipulation; }
.pin-btn, .music-btn, .open-btn {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== PIN Screen ===== */
.pin-screen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: linear-gradient(135deg, var(--pink), var(--orange), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior: none;
}

.pin-box {
  background: white;
  border-radius: 24px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 8px 32px rgba(192, 132, 252, 0.3);
  width: min(340px, 90vw);
}

.pin-cat { width: 80px; height: 80px; margin: 0 auto 0.5rem; display: block; }

.pin-box h2 {
  font-family: 'Pacifico', cursive;
  color: var(--purple);
  margin-bottom: 1.5rem;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--purple);
  background: transparent;
  transition: background 0.2s;
}

.pin-dot.filled { background: var(--purple); }

.pin-error {
  color: #e11d48;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  min-height: 1.2em;
}

.pin-hint {
  color: var(--purple);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  min-height: 1.2em;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.pin-btn {
  background: var(--light-pink);
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  font-size: 1.4rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  justify-self: center;
}

.pin-btn:active { transform: scale(0.92); background: var(--pink); color: white; }
.pin-clear { font-size: 1.2rem; background: #fde8f0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}
.pin-box.shake { animation: shake 0.4s ease; }

/* ===== Music Toggle Button ===== */
.music-btn {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 3000;
  background: white;
  border: 2px solid var(--orange);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(251, 146, 60, 0.3);
  transition: transform 0.2s;
}
.music-btn:hover { transform: scale(1.1); }

/* ===== Cover Screen ===== */
.cover {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: linear-gradient(
    160deg,
    #fde3c0 0%,
    #f9a8d4 38%,
    #fb923c 72%,
    #c2410c 100%
  );
  background-size: 100% 200%;
  background-position: 0% 0%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
  animation: coverDrift 8s ease-in-out infinite alternate;
  overscroll-behavior: none;
}

@keyframes coverDrift {
  from { background-position: 0% 0%; }
  to   { background-position: 0% 60%; }
}

/* Sakura petals */
.cover .petal {
  position: absolute;
  width: 18px;
  height: 18px;
  background: rgba(255, 220, 230, 0.72);
  border-radius: 60% 0 60% 0;
  pointer-events: none;
  animation: petalFall linear infinite;
}
.cover .petal:nth-child(1) { left: 8%;  width: 14px; height: 14px; animation-duration: 7s;   animation-delay: 0s;   opacity: 0.85; }
.cover .petal:nth-child(2) { left: 22%; width: 20px; height: 20px; animation-duration: 9s;   animation-delay: 1.2s; opacity: 0.7;  }
.cover .petal:nth-child(3) { left: 38%; width: 12px; height: 12px; animation-duration: 6s;   animation-delay: 0.5s; opacity: 0.9;  }
.cover .petal:nth-child(4) { left: 55%; width: 16px; height: 16px; animation-duration: 8s;   animation-delay: 2s;   opacity: 0.75; }
.cover .petal:nth-child(5) { left: 68%; width: 22px; height: 22px; animation-duration: 10s;  animation-delay: 0.8s; opacity: 0.65; }
.cover .petal:nth-child(6) { left: 80%; width: 13px; height: 13px; animation-duration: 7.5s; animation-delay: 3s;   opacity: 0.8;  }
.cover .petal:nth-child(7) { left: 14%; width: 18px; height: 18px; animation-duration: 11s;  animation-delay: 1.8s; opacity: 0.6;  }
.cover .petal:nth-child(8) { left: 92%; width: 15px; height: 15px; animation-duration: 8.5s; animation-delay: 4s;   opacity: 0.78; }

@keyframes petalFall {
  0%   { top: -30px; transform: rotate(0deg) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 0.6; }
  100% { top: 110%; transform: rotate(320deg) translateX(60px); opacity: 0; }
}

.cover-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  padding: 2rem;
}

.gift-icon {
  width: 130px;
  height: 130px;
  display: block;
  margin: 0 auto 1rem;
  animation: catBounceGlow 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(251, 146, 60, 0.6))
          drop-shadow(0 0 28px rgba(251, 146, 60, 0.25));
}

@keyframes catBounceGlow {
  0%, 100% {
    transform: translateY(0) rotate(-4deg);
    filter: drop-shadow(0 0 10px rgba(251, 146, 60, 0.55))
            drop-shadow(0 0 24px rgba(251, 146, 60, 0.2));
  }
  50% {
    transform: translateY(-18px) rotate(4deg);
    filter: drop-shadow(0 0 20px rgba(251, 146, 60, 0.85))
            drop-shadow(0 0 40px rgba(251, 146, 60, 0.4));
  }
}

.cover-content h2 {
  font-family: 'Pacifico', cursive;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  margin-bottom: 0.5rem;
  color: #fff;
  text-shadow:
    1px 1px 0   rgba(180, 60, 0, 0.4),
    2px 4px 10px rgba(100, 20, 0, 0.3);
}

.cover-sub {
  color: rgba(255, 245, 235, 0.95);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 1.75rem;
}

.open-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff7ed, #fde8c8);
  color: #c2410c;
  border: 2px solid rgba(251, 146, 60, 0.6);
  padding: 1rem 2.5rem;
  border-radius: 50px;
  font-size: 1.2rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(194, 65, 12, 0.25), inset 0 1px 0 rgba(255,255,255,0.8);
  transition: transform 0.2s, box-shadow 0.2s;
}

.open-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: btnShimmer 2.8s ease-in-out infinite;
}

@keyframes btnShimmer {
  0%  { transform: translateX(-100%); }
  60% { transform: translateX(100%); }
  100%{ transform: translateX(100%); }
}

.open-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 14px 36px rgba(194, 65, 12, 0.35), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ===== Balloons ===== */
.balloons {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.balloon {
  position: absolute;
  bottom: -120px;
  font-size: 2.8rem;
  animation: floatUp linear infinite;
  opacity: 0.85;
}

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

/* ===== Hero ===== */
.hero {
  position: relative;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
  overflow: hidden;
  background-image: radial-gradient(
    ellipse 80% 60% at 50% 40%,
    rgba(253, 244, 249, 0.9) 0%,
    rgba(253, 231, 200, 0.4) 55%,
    rgba(253, 244, 249, 0.0) 100%
  );
  background-size: auto;
  background-repeat: no-repeat;
}

/* Ambient rising sakura petals */
.hero-petal {
  position: absolute;
  border-radius: 60% 0 60% 0;
  background: rgba(249, 168, 212, 0.45);
  pointer-events: none;
  animation: heroFloat linear infinite;
}
.hero-petal:nth-child(1) { left: 5%;  bottom: -20px; width: 10px; height: 10px; animation-duration: 12s;  animation-delay: 0s;   opacity: 0.6; }
.hero-petal:nth-child(2) { left: 20%; bottom: -20px; width: 16px; height: 16px; animation-duration: 15s;  animation-delay: 2s;   opacity: 0.5; }
.hero-petal:nth-child(3) { left: 40%; bottom: -20px; width: 12px; height: 12px; animation-duration: 11s;  animation-delay: 4s;   opacity: 0.7; }
.hero-petal:nth-child(4) { left: 60%; bottom: -20px; width: 18px; height: 18px; animation-duration: 14s;  animation-delay: 1s;   opacity: 0.5; }
.hero-petal:nth-child(5) { left: 78%; bottom: -20px; width: 11px; height: 11px; animation-duration: 13s;  animation-delay: 3.5s; opacity: 0.6; }
.hero-petal:nth-child(6) { left: 90%; bottom: -20px; width: 15px; height: 15px; animation-duration: 10s;  animation-delay: 5s;   opacity: 0.55; }

@keyframes heroFloat {
  0%   { transform: translateY(0)       translateX(0)    rotate(0deg);   opacity: 0; }
  8%   { opacity: 0.8; }
  50%  { transform: translateY(-40vh)   translateX(20px) rotate(180deg); }
  92%  { opacity: 0.4; }
  100% { transform: translateY(-100vh)  translateX(-10px) rotate(360deg); opacity: 0; }
}

.title {
  font-family: 'Pacifico', cursive;
  font-size: clamp(2.5rem, 8vw, 5rem);
  color: var(--orange);
  text-shadow:
    2px 3px 6px rgba(194, 65, 12, 0.35),
    0   0  24px rgba(249, 168, 212, 0.5);
  animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.subtitle {
  position: relative;
  display: inline-block;
  margin-top: 1rem;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 600;
  color: var(--purple);
  padding: 0 2.5rem;
  animation: fadeUp 0.8s 0.3s ease both;
}

.subtitle::before,
.subtitle::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 1.8rem;
  height: 1.5px;
  transform: translateY(-50%);
}
.subtitle::before {
  right: 100%;
  margin-right: -2rem;
  background: linear-gradient(90deg, transparent, var(--sakura-dark));
}
.subtitle::after {
  left: 100%;
  margin-left: -2rem;
  background: linear-gradient(90deg, var(--sakura-dark), transparent);
}

.hero-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem auto 0;
  width: min(320px, 80vw);
}
.hero-divider::before,
.hero-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sakura-dark) 50%, transparent);
  opacity: 0.6;
}
.hero-divider__node {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.75rem;
  display: inline-block;
  animation: petalSpin 12s linear infinite;
}
@keyframes petalSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

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

/* ===== Confetti ===== */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 0%, black 8%, black 82%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 8%, black 82%, transparent 100%);
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 60% 0 60% 0;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(-20px) translateX(0)    rotate(0deg);   opacity: 0; }
  12%  { opacity: 0.85; }
  88%  { opacity: 0.6; }
  100% { transform: translateY(380px) translateX(50px) rotate(450deg); opacity: 0; }
}

/* ===== Countdown ===== */
.countdown-section {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.countdown-label {
  font-family: 'Pacifico', cursive;
  color: var(--purple);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.countdown-display {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.digit-box {
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: white;
  border-radius: 16px;
  padding: 0.75rem 1rem;
  min-width: 70px;
  text-align: center;
}

.digit-box span {
  font-family: 'Pacifico', cursive;
  font-size: 2rem;
  display: block;
}

.digit-box small { font-size: 0.75rem; opacity: 0.9; }

.countdown-sub { margin-top: 1rem; color: var(--text); opacity: 0.7; }

/* ===== Message Section ===== */
.message-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.card {
  background: #fff;
  border-radius: 24px;
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 32px rgba(249, 168, 212, 0.18);
  text-align: center;
  border: 2px solid var(--sakura-dark);
  animation: fadeUp 0.8s 0.5s ease both;
}

.card-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-family: 'Noto Serif JP', 'Pacifico', cursive;
  color: var(--orange);
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
}

.message-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: #6b4060;
  margin-bottom: 1rem;
  min-height: 3em;
}

.message-sign {
  font-family: 'Pacifico', cursive;
  color: var(--purple);
  font-size: 1.3rem;
  margin-top: 1.5rem;
}

/* ===== Gallery ===== */
.gallery-section {
  padding: 2rem 1.5rem 4rem;
  max-width: 960px;
  margin: 0 auto;
}

.section-title {
  font-family: 'Pacifico', cursive;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--orange);
  text-align: center;
  margin-bottom: 2rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.photo-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(251, 146, 60, 0.15);
  border: 2px solid var(--light-orange);
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
}

.photo-card:hover {
  transform: translateY(-6px) rotate(1deg);
  box-shadow: 0 14px 32px rgba(251, 146, 60, 0.25);
}

.photo-placeholder {
  height: 200px;
  background: linear-gradient(135deg, var(--light-orange), #e9d5ff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--orange);
  gap: 0.5rem;
}

.photo-placeholder span {
  font-size: 0.9rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  opacity: 0.7;
}

.photo-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.photo-caption {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7c4d6e;
  text-align: center;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  overscroll-behavior: none;
}

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 12px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

/* ===== Sparkle Cursor ===== */
@keyframes sparkle {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 20px)) scale(0); }
}

.sparkle {
  position: fixed;
  pointer-events: none;
  font-size: 14px;
  animation: sparkle 0.6s ease forwards;
  z-index: 9999;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  color: var(--orange);
  font-weight: 700;
  font-size: 1.1rem;
}

.hearts {
  margin-top: 0.5rem;
  font-size: 1.5rem;
  animation: heartPulse 1.5s ease infinite;
}

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

/* ===== Main container z-index fix ===== */
.main {
  position: relative;
  z-index: 1;
}

/* ===== Mobile UX ===== */
@media (max-width: 480px) {
  .pin-btn  { width: 56px; height: 56px; font-size: 1.2rem; }
  .pin-pad  { gap: 0.5rem; }
  .hero     { padding: 3rem 1rem 2rem; }
  .gallery  { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .digit-box { min-width: 56px; padding: 0.5rem; }
  .digit-box span { font-size: 1.5rem; }
  .hero-divider { width: min(240px, 90vw); }
  .subtitle { padding: 0 2rem; }
  .cover .petal:nth-child(5),
  .cover .petal:nth-child(8) { display: none; }
}
