/* =========================================================
   Birthday Date Mission - Styles (mobile-first)
   ========================================================= */
:root {
  --pink-50: #fff5f8;
  --pink-100: #ffe4ec;
  --pink-200: #ffc8d9;
  --pink-300: #ffa3bf;
  --pink-500: #ff4f8b;
  --pink-600: #e63d78;
  --lavender: #e9dcff;
  --peach: #ffe3d3;
  --text: #5c4b51;
  --text-soft: #8d7680;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(255, 79, 139, 0.18);
  --radius: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Gowun Dodum", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--pink-100) 0%, var(--peach) 50%, var(--lavender) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  min-height: 100dvh;
}

button { font-family: inherit; }

/* ---------- 떠다니는 하트 ---------- */
.floating-hearts { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.floating-hearts span {
  position: absolute;
  bottom: -40px;
  opacity: 0.55;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: 0.6; }
  100% { transform: translateY(-110vh) rotate(40deg); opacity: 0; }
}

/* ---------- 진행 바 ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 6px; background: rgba(255, 255, 255, 0.6); z-index: 20;
}
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--pink-300), var(--pink-500));
  border-radius: 0 6px 6px 0;
  transition: width 0.6s ease;
}

/* ---------- 이전 / 다음 버튼 ---------- */
.page-nav {
  position: fixed; top: 14px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  pointer-events: none;
}
.nav-btn {
  pointer-events: auto;
  border: 2px solid var(--pink-200);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--pink-500);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(255, 79, 139, 0.15);
  transition: opacity .2s, transform .1s;
  touch-action: manipulation;
}
.nav-btn:active { transform: scale(0.94); }
.nav-btn:disabled { opacity: 0; pointer-events: none; }
.nav-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- 레이아웃 ---------- */
.app { position: relative; z-index: 1; min-height: 100dvh; }

.screen {
  display: none;
  min-height: 100dvh;
  padding: 68px 16px 32px; /* 상단 이동 버튼 공간 확보 */
  align-items: center;
  justify-content: center;
  position: relative;
}
.screen.active { display: flex; animation: screenIn 0.6s ease both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.card-box {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 32px 22px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 2;
}
.center { text-align: center; }

/* ---------- 타이포 ---------- */
.eyebrow {
  font-family: "Gaegu", cursive;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--pink-500);
  letter-spacing: 1px;
}
.title {
  font-family: "Gaegu", cursive;
  font-size: 2.4rem;
  line-height: 1.25;
  margin: 8px 0 16px;
}
.name { color: var(--pink-500); }
.subtitle {
  font-family: "Gaegu", cursive;
  font-size: 1.9rem;
  line-height: 1.25;
  margin: 6px 0 12px;
}
.step {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--white);
  background: var(--pink-300);
  padding: 4px 12px;
  border-radius: 999px;
}
.desc { font-size: 1rem; line-height: 1.7; color: var(--text-soft); margin: 14px 0 24px; }
.desc.small { font-size: 0.92rem; margin: 4px 0 16px; }
.status { min-height: 1.5em; margin: 12px 0; font-weight: 700; color: var(--pink-500); }

/* ---------- 버튼 ---------- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(135deg, var(--pink-300), var(--pink-500));
  padding: 15px 30px;
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--pink-600), 0 10px 20px rgba(255, 79, 139, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s;
  touch-action: manipulation;
  user-select: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-600), 0 4px 10px rgba(255, 79, 139, 0.3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost {
  background: var(--white);
  color: var(--pink-500);
  box-shadow: 0 4px 0 var(--pink-200);
  border: 2px solid var(--pink-200);
}
.btn.small-btn { font-size: 0.9rem; padding: 10px 18px; margin-top: 18px; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hidden { display: none !important; }
.pop-in { animation: popIn 0.5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 1. 랜딩 ---------- */
.cake { font-size: 4.5rem; animation: bounce 2s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ---------- 2. 카드 게임 ---------- */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px auto 0;
  max-width: 330px;
}
.mem-card {
  aspect-ratio: 3 / 4;
  perspective: 800px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}
.mem-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.mem-card.flipped .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 12px rgba(255, 79, 139, 0.2);
}
.mem-front {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.5) 0 8%, transparent 9%),
    repeating-linear-gradient(45deg, var(--pink-300) 0 10px, var(--pink-200) 10px 20px);
  font-size: 1.8rem;
  color: var(--white);
  border: 3px solid var(--white);
}
.mem-back {
  background: var(--white);
  transform: rotateY(180deg);
  font-size: 2.6rem;
  border: 3px solid var(--pink-200);
}
.mem-card.matched .mem-back { background: var(--pink-50); border-color: var(--pink-500); animation: matchPulse 0.5s ease; }
@keyframes matchPulse { 50% { transform: rotateY(180deg) scale(1.1); } }

/* ---------- 3. 화투 힌트 ---------- */
.hint-hwatu .card-box { background: rgba(255, 255, 255, 0.88); }
.hwatu-table {
  position: relative;
  margin: 18px auto;
  padding: 18px 10px;
  border-radius: 22px;
  /* 군용 담요 느낌의 초록 테이블 */
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.04) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.04) 0 2px, transparent 2px 4px),
    #3f7f5a;
  box-shadow: inset 0 0 0 6px #2f6246, inset 0 0 30px rgba(0,0,0,.25);
  color: var(--white);
}
.player { font-size: 2.2rem; display: flex; align-items: center; justify-content: center; gap: 8px; }
.bubble {
  font-family: "Gaegu", cursive;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--white);
  color: var(--text);
  padding: 4px 12px;
  border-radius: 14px;
  animation: wiggle 1.2s ease-in-out infinite;
}
.bubble.pink { background: var(--pink-500); color: var(--white); animation-delay: .6s; }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) scale(1.08); } }
.hwatu-cards { display: flex; justify-content: center; margin: 14px 0; height: 96px; }
.hwatu {
  width: 56px; height: 84px;
  margin: 0 -6px;
  border-radius: 6px;
  background: #fffaf0;
  border: 4px solid #d62828;
  box-shadow: 0 4px 8px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  transform: rotate(var(--r));
  animation: slap 2.4s ease-in-out infinite;
  animation-delay: var(--d);
}
.hwatu span { filter: drop-shadow(0 1px 1px rgba(0,0,0,.2)); }
@keyframes slap {
  0%, 60%, 100% { transform: rotate(var(--r)) translateY(0); }
  20% { transform: rotate(var(--r)) translateY(-22px) scale(1.08); }
  30% { transform: rotate(var(--r)) translateY(2px) scale(0.97); }
}

/* ---------- 4. 그림 그리기 ---------- */
.palette { display: flex; justify-content: center; gap: 10px; margin: 6px 0 12px; }
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--c);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .15s;
}
.swatch.active { transform: scale(1.25); box-shadow: 0 0 0 3px var(--pink-300); }
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 16px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle, var(--pink-100) 1px, transparent 1.5px) 0 0 / 18px 18px,
    var(--white);
  border: 3px dashed var(--pink-300);
}
#drawCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.canvas-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--pink-300);
  pointer-events: none;
  transition: opacity .3s;
}

/* ---------- 5. 갤러리 힌트 ---------- */
.hint-gallery {
  background:
    linear-gradient(180deg, transparent 78%, #c9a27e 78%, #b88c66 100%),
    linear-gradient(180deg, #fbf5ef, #f3e7dc);
  overflow: hidden;
}
.gallery-wall { position: absolute; inset: 0; pointer-events: none; }
.gallery-wall .frame { position: absolute; opacity: 0.5; }
.gallery-wall .f1 { top: 6%; left: -20px; transform: rotate(-3deg); }
.gallery-wall .f2 { top: 4%; right: -24px; transform: rotate(4deg); }
.gallery-wall .f3 { bottom: 8%; left: -28px; transform: rotate(2deg); }
.gallery-wall .f4 { bottom: 5%; right: -20px; transform: rotate(-4deg); }

.frame {
  display: inline-block;
  padding: 12px;
  background: linear-gradient(135deg, #e8c77a, #b8893a 40%, #f2d98f 60%, #a67a2e);
  border-radius: 4px;
  box-shadow: 0 10px 22px rgba(80, 50, 20, 0.35), inset 0 0 0 2px rgba(255,255,255,.4);
}
.frame .art {
  width: 90px; height: 110px;
  background: #fffdf8;
  box-shadow: inset 0 0 0 10px #f6efe4, inset 0 0 0 11px #d8c9b3;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
}
.gallery-card { background: rgba(255, 253, 250, 0.9); }
.main-frame { position: relative; display: block; width: fit-content; margin: 16px auto 10px; }
.main-frame .art.big { width: 200px; height: 200px; font-size: 5rem; overflow: hidden; }
.main-frame .art.big img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.spotlight {
  position: absolute; left: 50%; top: -50px;
  width: 260px; height: 120px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at top, rgba(255, 240, 200, .55), transparent 70%);
  pointer-events: none;
}
.plaque {
  display: inline-block;
  background: #fff;
  border: 1px solid #e0d4c4;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text-soft);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  margin-bottom: 8px;
}
.plaque strong { color: var(--text); font-size: 0.95rem; }

/* ---------- 6. 레이싱 게임 ---------- */
.track {
  position: relative;
  height: 110px;
  margin: 10px 0 14px;
  border-radius: 16px;
  background: #6b6b76;
  box-shadow: inset 0 6px 0 #fff, inset 0 -6px 0 #fff, 0 6px 14px rgba(0,0,0,.15);
  overflow: hidden;
}
.lane-line {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 4px; transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, #ffd166 0 20px, transparent 20px 40px);
}
.finish-line {
  position: absolute; right: 18px; top: 0; bottom: 0; width: 24px;
  background:
    conic-gradient(#000 25%, #fff 0 50%, #000 0 75%, #fff 0) 0 0 / 12px 12px;
}
.car {
  position: absolute;
  left: 6px; top: 50%;
  font-size: 2.8rem;
  transform: translateY(-50%) scaleX(-1); /* 오른쪽을 보도록 반전 */
  transition: left 0.15s ease-out;
  line-height: 1;
}
.car.boost { animation: shake 0.15s; }
@keyframes shake { 50% { transform: translateY(-54%) scaleX(-1) rotate(4deg); } }
.race-meter { height: 12px; border-radius: 999px; background: var(--pink-100); overflow: hidden; }
.race-meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink-300), var(--pink-500)); transition: width .15s; }
.big-btn { font-size: 1.4rem; padding: 20px 44px; }

/* ---------- 7. 레이싱 힌트 ---------- */
.hint-racing {
  background:
    conic-gradient(#2b2b2b 25%, #fff 0 50%, #2b2b2b 0 75%, #fff 0) 0 0 / 56px 56px;
}
.hint-racing::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255, 200, 217, .82), rgba(233, 220, 255, .82));
}
.flags { font-size: 2.6rem; display: flex; justify-content: center; gap: 14px; margin: 10px 0; }
.flags span { animation: wave 1s ease-in-out infinite alternate; }
.flags span:nth-child(2) { animation: none; }
.flags span:last-child { animation-delay: .5s; }
@keyframes wave { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.mini-track {
  position: relative;
  height: 60px;
  margin: 14px 0;
  border-radius: 30px;
  background: #555;
  border: 4px solid #fff;
  box-shadow: 0 0 0 4px #ff4f8b;
  overflow: hidden;
}
.mini-track::after {
  content: ""; position: absolute; right: 12px; top: 0; bottom: 0; width: 18px;
  background: conic-gradient(#000 25%, #fff 0 50%, #000 0 75%, #fff 0) 0 0 / 9px 9px;
}
.mini-car {
  position: absolute; top: 50%;
  font-size: 2rem;
  animation: zoom 2.2s ease-in infinite;
}
@keyframes zoom {
  from { left: -50px; transform: translateY(-50%) scaleX(-1); }
  to { left: 110%; transform: translateY(-50%) scaleX(-1); }
}

/* ---------- 8. 퀴즈 ---------- */
.quiz-q { font-size: 1.15rem; font-weight: 700; margin: 14px 0 18px; line-height: 1.6; }
.quiz-options { display: grid; gap: 10px; }
.quiz-opt {
  font-size: 1rem;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid var(--pink-200);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .2s, border-color .2s, transform .1s;
}
.quiz-opt:active { transform: scale(0.98); }
.quiz-opt.wrong { border-color: #ff6b6b; background: #fff0f0; animation: no 0.4s; }
.quiz-opt.correct { border-color: var(--pink-500); background: var(--pink-100); font-weight: 700; }
@keyframes no { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- 9. 보상 ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.gift { font-size: 5rem; margin-bottom: 6px; animation: giftShake 1.2s ease-in-out infinite; display: inline-block; }
.gift.opened { animation: popIn .6s both; }
@keyframes giftShake {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-10deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-6deg); }
}
.reward .subtitle { margin-bottom: 20px; }
.gift-reveal { margin-top: 10px; animation: popIn .6s both; }
.reveal-item {
  background: var(--pink-50);
  border: 2px solid var(--pink-200);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}
.reveal-label { font-size: .85rem; color: var(--text-soft); }
.reveal-value { font-size: 1.2rem; font-weight: 700; color: var(--pink-500); margin-top: 4px; }
.letter {
  text-align: left;
  font-family: "Gaegu", cursive;
  font-size: 1.2rem;
  line-height: 1.7;
  background:
    repeating-linear-gradient(transparent 0 31px, var(--pink-100) 31px 32px),
    #fffdfb;
  padding: 16px 18px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
.letter .sign { text-align: right; margin-top: 8px; color: var(--pink-500); }
.gift-photo { width: 100%; border-radius: 16px; margin-bottom: 10px; }

/* ---------- 비밀번호 잠금 ---------- */
.lock-modal {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(92, 75, 81, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: screenIn .3s ease both;
}
.lock-box {
  position: relative;
  width: 100%; max-width: 340px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.lock-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: none;
  font-size: 1.2rem; color: var(--text-soft);
  cursor: pointer; padding: 4px 8px;
}
.lock-icon { font-size: 2.6rem; }
.lock-title { font-family: "Gaegu", cursive; font-size: 1.6rem; margin: 4px 0 6px; }
.lock-msg { font-size: .9rem; color: var(--text-soft); min-height: 1.4em; }
.lock-msg.error { color: #ff6b6b; font-weight: 700; }
.lock-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 20px; }
.lock-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--pink-300);
  transition: background .15s;
}
.lock-dots span.filled { background: var(--pink-500); border-color: var(--pink-500); }
.lock-dots.shake { animation: no .4s; }
.lock-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lock-pad button {
  height: 56px;
  border: none;
  border-radius: 16px;
  background: var(--pink-50);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .1s, transform .1s;
}
.lock-pad button:active { background: var(--pink-200); transform: scale(.95); }

/* ---------- 태블릿/데스크탑 ---------- */
@media (min-width: 600px) {
  .card-box { padding: 40px 36px; }
  .title { font-size: 2.8rem; }
  .gallery-wall .frame { opacity: 0.85; }
  .gallery-wall .f1 { left: 4%; }
  .gallery-wall .f2 { right: 4%; }
  .gallery-wall .f3 { left: 6%; }
  .gallery-wall .f4 { right: 6%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
