/* ═══ sealed-card · 종이 카드풍 + 둥근 파스텔 ═══ */

@font-face {
  font-family: 'Pretendard';
  src: url('./fonts/PretendardVariable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper:   #FAF7F0;
  --paper-2: #F3EEE3;
  --ink:     #2B2721;
  --ink-2:   #6B6358;
  --line:    #D8CFBE;
  --blush:   #E8A0A8;
  --blush-2: #F2B8BE;
  --sky:     #A8C4DE;
  --leaf:    #A9C0A0;
  --wax:     #C9695E;
  --stroke:  #4A3F35;

  --hand: 'Gaegu', 'Pretendard', system-ui, sans-serif;
  --body: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --pad: 22px;
  --radius: 18px;
}

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

html, body {
  margin: 0;
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}

/* 종이 질감 — 아주 미세한 점 두 겹 */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(74,63,53,.09) 1px, transparent 0),
    radial-gradient(circle at 1px 1px, rgba(74,63,53,.05) 1px, transparent 0);
  background-size: 13px 13px, 29px 29px;
  background-position: 0 0, 7px 11px;
}

/* ── 모바일 온리 프레임 ── */
.phone {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  padding: max(env(safe-area-inset-top), 12px) var(--pad) max(env(safe-area-inset-bottom), 28px);
}
@media (min-width: 460px) {
  .phone {
    min-height: auto;
    margin: 28px auto;
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(74,63,53,.16), 0 0 0 1px var(--line);
    overflow: hidden;
  }
}

[hidden] { display: none !important; }

/* ══════════ 1단계 · 봉인 ══════════ */
#seal {
  min-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
@media (min-width: 460px) { #seal { min-height: 560px; } }

.seal-hint-top {
  font-family: var(--hand);
  font-size: 19px;
  color: var(--ink-2);
  margin: 0 0 18px;
  letter-spacing: .02em;
}

.envelope-wrap { position: relative; width: 268px; height: 200px; }

.peek {
  position: absolute;
  object-fit: contain;
  width: 86px; height: 86px;
  left: 50%; top: -28px;
  transform: translateX(-50%);
  z-index: 1;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  50%      { transform: translateX(-50%) translateY(-7px) rotate(2deg); }
}

.envelope { position: absolute; inset: 24px 0 0; z-index: 2; }

.env-body {
  position: absolute; inset: 0;
  background: linear-gradient(170deg, #FFFCF5, #F0E8D8);
  border: 2.6px solid var(--stroke);
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(74,63,53,.15);
}
.env-fold {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: 10px;
}
.env-fold::before, .env-fold::after {
  content: '';
  position: absolute;
  width: 62%; height: 150%;
  border-top: 2.2px solid rgba(74,63,53,.32);
  top: 12%;
}
.env-fold::before { left: -6%;  transform: rotate(34deg); transform-origin: top left; }
.env-fold::after  { right: -6%; transform: rotate(-34deg); transform-origin: top right; }

.env-flap {
  position: absolute;
  left: -1px; right: -1px; top: -1px;
  height: 92px;
  background: linear-gradient(160deg, #F7EFDF, #EADFC8);
  border: 2.6px solid var(--stroke);
  border-radius: 12px 12px 4px 4px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform .7s cubic-bezier(.34, 1.3, .5, 1);
  z-index: 3;
}

.wax {
  position: absolute;
  left: 50%; top: 66px;
  width: 74px; height: 74px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(158,74,65,.36));
  animation: pulse 2.2s ease-in-out infinite;
}
.wax svg { width: 100%; height: 100%; display: block; }
@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.07); }
}

.seal-cta {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--wax);
  margin: 28px 0 0;
}

/* ── 개봉 ── */
#seal.opening .wax    { animation: waxOff .55s ease-in forwards; }
#seal.opening .peek   { animation: peekJoy .5s ease-out forwards; }
#seal.opening .env-flap { transform: rotateX(-172deg); }
#seal.opening .seal-cta, #seal.opening .seal-hint-top { opacity: 0; transition: opacity .3s; }
#seal.opening .envelope-wrap { animation: envOut .75s .35s ease-in forwards; }

@keyframes waxOff {
  to { transform: translateX(-50%) translateY(118px) rotate(58deg) scale(.82); opacity: 0; }
}
@keyframes peekJoy {
  to { transform: translateX(-50%) translateY(-22px) scale(1.14) rotate(0deg); }
}
@keyframes envOut {
  to { transform: translateY(-26px) scale(.9); opacity: 0; }
}

/* ══════════ 2단계 · 편지 ══════════ */
#letter { animation: riseIn .75s cubic-bezier(.2,.9,.3,1) both; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(34px); }
  to   { opacity: 1; transform: none; }
}

.card { padding: 16px 0 10px; }

.card-head { text-align: center; padding: 10px 0 24px; }
.to {
  font-family: var(--hand);
  font-size: 19px;
  color: var(--blush);
  margin: 0 0 10px;
}
.title {
  font-family: var(--hand);
  white-space: pre-line;
  font-size: 34px;
  line-height: 1.28;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.01em;
}
.subtitle {
  font-size: 14px;
  white-space: pre-line;
  color: var(--ink-2);
  margin: 12px 0 0;
  line-height: 1.7;
}

/* 얇은 테두리 프레임 */
.frame {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.55);
  padding: 22px 18px;
}

.when { text-align: center; margin-bottom: 26px; }
.when-date {
  font-family: var(--hand);
  font-size: 30px;
  font-weight: 700;
  margin: 0;
}
.rule {
  border: 0;
  border-top: 1.5px solid var(--line);
  width: 54px;
  margin: 12px auto;
}
.when-time { font-size: 16px; color: var(--ink-2); margin: 0; }
.countdown {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--blush);
  margin: 14px 0 0;
}
.countdown:empty { display: none; }

.sec-label {
  font-family: var(--hand);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-2);
  margin: 0 0 16px;
  padding-left: 2px;
}

/* ── 코스 타임라인 ── */
.course { margin-bottom: 30px; }
.course-list { list-style: none; margin: 0; padding: 0 0 0 4px; }
.course-item {
  position: relative;
  padding: 0 0 26px 50px;
}
.course-item:last-child { padding-bottom: 4px; }
.course-item::before {
  content: '';
  position: absolute;
  left: 17px; top: 36px; bottom: 2px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 5px, transparent 5px 10px);
}
.course-item:last-child::before { display: none; }
.course-dot {
  position: absolute;
  object-fit: contain;
  left: 0; top: 0;
  width: 36px; height: 36px;
  object-fit: contain;
}
.course-time {
  font-family: var(--hand);
  font-size: 18px;
  color: var(--blush);
  margin: 0 0 2px;
}
.course-name { font-size: 16px; font-weight: 600; margin: 0; }
.course-desc { font-size: 13.5px; color: var(--ink-2); margin: 5px 0 0; line-height: 1.65; }

/* ── 장소 · 지도 ── */
.place { margin-bottom: 30px; }
.place-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  background: rgba(255,255,255,.55);
}
.place-name { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.place-addr { font-size: 13px; color: var(--ink-2); margin: 0 0 14px; line-height: 1.6; }
.map-row { display: flex; gap: 10px; }
.map-btn {
  flex: 1;
  min-height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.map-btn:active { background: var(--paper-2); transform: scale(.98); }

/* ── 한마디 ── */
.note { margin-bottom: 32px; }
.note-text {
  font-family: var(--hand);
  font-size: 20px;
  line-height: 1.85;
  margin: 0;
  white-space: pre-line;
}
.note-from {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--ink-2);
  text-align: right;
  margin: 18px 0 0;
}

/* ── 응답 ── */
.rsvp { padding-top: 6px; }
.choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.choice {
  min-height: 54px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color .18s, background .18s;
}
.choice .emo { font-size: 20px; line-height: 1; }
.choice[aria-pressed="true"] {
  border-color: var(--blush);
  border-width: 2.2px;
  background: #FDF3F4;
}
.choice:active { transform: scale(.985); }

.msg-label {
  display: block;
  font-family: var(--hand);
  font-size: 18px;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.msg-box {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.65);
  padding: 14px;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  resize: none;
}
.msg-box:focus { outline: 2px solid var(--blush-2); outline-offset: 1px; }

.send {
  width: 100%;
  min-height: 54px;
  margin-top: 18px;
  border: 0;
  border-radius: 15px;
  background: var(--blush);
  color: #fff;
  font-family: var(--hand);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}
.send:disabled { background: var(--line); color: #fff; cursor: default; }
.send:not(:disabled):active { transform: scale(.985); filter: brightness(.96); }

.rsvp-err {
  font-size: 13.5px;
  color: #B4453C;
  margin: 12px 0 0;
  text-align: center;
  line-height: 1.6;
}

/* ── 완료 ── */
.done { text-align: center; padding: 18px 0 8px; animation: riseIn .55s both; }
.done-mascot { width: 120px; height: 120px; object-fit: contain; }
.done-text {
  font-family: var(--hand);
  font-size: 23px;
  line-height: 1.6;
  margin: 12px 0 0;
  white-space: pre-line;
}
.again {
  margin-top: 22px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-family: var(--body);
  font-size: 13.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 44px;
  padding: 0 10px;
}

.card-foot { text-align: center; padding: 30px 0 6px; }
.dots { color: var(--line); letter-spacing: .3em; font-size: 15px; }

/* ── 모션 최소화 ── */
@media (prefers-reduced-motion: reduce) {
  .peek, .wax { animation: none; }
  #letter, .done { animation: none; }
  .env-flap { transition: none; }
  #seal.opening .wax, #seal.opening .peek, #seal.opening .envelope-wrap { animation-duration: .01s; }
}

/* ══════════ 1.5단계 · 관문 ══════════ */
#gate {
  position: relative;
  min-height: calc(100dvh - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  animation: riseIn .6s both;
}
@media (min-width: 460px) { #gate { min-height: 560px; } }
#gate.shake { animation: shake .35s; }
@keyframes shake {
  0%,100% { transform: none; }
  20% { transform: translate(-4px, 2px) rotate(-.6deg); }
  40% { transform: translate(4px, -2px) rotate(.6deg); }
  60% { transform: translate(-3px, -1px); }
  80% { transform: translate(3px, 1px); }
}
.gate-mascot { width: 108px; height: 108px; object-fit: contain; transform-origin: 50% 90%; }
.gate-mascot.laugh { animation: laugh .55s cubic-bezier(.3,1.6,.4,1); }
@keyframes laugh {
  0%   { transform: none; }
  30%  { transform: translateY(-16px) rotate(-8deg) scale(1.08, .92); }
  60%  { transform: translateY(0) rotate(6deg) scale(.95, 1.06); }
  100% { transform: none; }
}
.gate-title {
  font-family: var(--hand);
  font-size: 32px; font-weight: 700; line-height: 1.3;
  margin: 8px 0 6px; white-space: pre-line;
}
.gate-sub { font-size: 14px; color: var(--ink-2); margin: 0 0 22px; white-space: pre-line; }

.arena {
  position: relative;
  width: 100%;
  height: 300px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.yes, .no {
  border: 0;
  border-radius: 16px;
  font-family: var(--hand);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  -webkit-touch-callout: none;
}
.yes {
  position: absolute;
  left: 50%; top: 34%;
  transform: translate(-50%, -50%) scale(var(--yes-scale, 1));
  transition: transform .25s cubic-bezier(.3,1.5,.5,1);
  padding: 16px 30px;
  font-size: 24px;
  background: var(--blush); color: #fff;
  box-shadow: 0 8px 18px rgba(232,160,168,.4);
  z-index: 1;
  animation: wiggle 2.8s ease-in-out infinite;
}
@keyframes wiggle {
  0%,100% { rotate: 0deg; }
  25% { rotate: -1.5deg; }
  75% { rotate: 1.5deg; }
}
.yes.beg { animation: beg .9s ease-in-out infinite; }
@keyframes beg {
  0%,100% { box-shadow: 0 8px 18px rgba(232,160,168,.4); rotate: 0deg; }
  50% { box-shadow: 0 10px 28px rgba(232,160,168,.75); rotate: -2deg; }
}
.yes:active { transform: translate(-50%, -50%) scale(calc(var(--yes-scale, 1) * .96)); }

.no {
  position: absolute;
  left: 0; top: 0;                 /* 위치는 transform으로만 */
  transform-origin: 50% 100%;
  will-change: transform;
  padding: 12px 22px;
  font-size: 19px;
  background: var(--paper); color: var(--ink-2);
  border: 1.5px solid var(--line);
  box-shadow: 0 4px 10px rgba(74,63,53,.12);
  z-index: 2;
}
.no.free { position: fixed; z-index: 50; }
.no.poof { animation: poof .6s cubic-bezier(.5,-.4,.6,1) forwards; }
@keyframes poof {
  0%   { opacity: 1; filter: none; }
  40%  { opacity: 1; transform: scale(1.35, .7) rotate(6deg); }
  100% { opacity: 0; transform: scale(0, 0) rotate(540deg); filter: blur(4px); }
}
.gate-taunt {
  font-family: var(--hand);
  white-space: pre-line;
  font-size: 18px; color: var(--wax);
  min-height: 1.6em; margin: 16px 0 0;
}
.gate-taunt.pop { animation: pop .4s cubic-bezier(.3,1.6,.4,1); }
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .yes, .gate-mascot.laugh, .gate-taunt.pop, #gate.shake { animation: none; }
}
