@font-face { font-family: "Ownglyph PDH"; src: url("ownglyph-pdh.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
:root {
  --pink: #f6a6c1;
  --pink-deep: #ec6f9a;
  --pink-soft: #fde8ef;
  --mint: #8fcfb0;
  --ink: #5a3a48;
  --card: #fffafc;
  --shadow: 0 10px 30px rgba(236, 111, 154, 0.22);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { font-size: 118%; } /* Gaegu·Single Day는 작아 보여서 살짝 키움 */
body {
  font-family: "Ownglyph PDH", "Gaegu", system-ui, sans-serif; /* 본문: 온글잎 박다현체 (한글·영어) */
  color: var(--ink);
  background: linear-gradient(180deg, #fde8ef 0%, #fbd5e2 100%);
  min-height: 100vh;
  overflow-x: hidden;
  word-break: keep-all;          /* 한글은 단어 단위로 줄바꿈 */
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { text-wrap: balance; } /* 두 줄이 될 때 길이를 비슷하게 */
h1, h2, .btn, .eyebrow { font-family: "Jua", "Gaegu", sans-serif; }

.page { max-width: 560px; margin: 0 auto; padding: calc(72px + env(safe-area-inset-top, 0px)) 16px 56px; text-align: center; position: relative; z-index: 1; }
.eyebrow { margin: 0; color: var(--pink-deep); letter-spacing: .08em; }
.head h1 { margin: 6px 0 4px; font-size: clamp(26px, 7vw, 38px); font-weight: 400; }
.sub { margin: 0; opacity: .75; white-space: pre-line; }

/* 트리 */
.stage { position: relative; margin: 18px auto 8px; border-radius: 28px; overflow: hidden; box-shadow: var(--shadow); line-height: 0; }
.tree-img { width: 100%; height: auto; display: block; aspect-ratio: 1168 / 1425; background: var(--pink-soft); }
.ornaments { position: absolute; inset: 0; }
.env {
  position: absolute; width: 9.6%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  filter: drop-shadow(0 2px 2px rgba(120, 60, 80, .25));
  animation: pop .5s ease-out both;
}
.env svg { width: 100%; height: 100%; display: block; }
.env.new { animation: pop .6s ease-out both, twinkle 1.1s ease-in-out .6s 4; z-index: 2; }
@keyframes pop { from { transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(0); opacity: 0; } to { transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(1); opacity: 1; } }
@keyframes twinkle { 0%, 100% { filter: drop-shadow(0 0 0 #fff) brightness(1); } 50% { filter: drop-shadow(0 0 10px #fff6b0) brightness(1.25); } }
.sparkle { position: absolute; width: 6px; height: 6px; background: #fff7b8; border-radius: 50%; box-shadow: 0 0 10px 4px rgba(255, 240, 150, .9); animation: spark .9s ease-out forwards; pointer-events: none; }
@keyframes spark { from { transform: translate(0,0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }

.count { margin: 10px 0 18px; font-size: 1.05rem; }
.count strong { color: var(--pink-deep); font-size: 1.3em; }

/* 버튼 */
.actions { display: grid; gap: 12px; justify-items: center; margin-top: 18px; }
.btn { border: 0; border-radius: 999px; padding: 13px 26px; font-size: 1.05rem; cursor: pointer; text-decoration: none; display: inline-block; transition: transform .15s, box-shadow .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--pink-deep); color: #fff; box-shadow: var(--shadow); }
.btn.ghost { background: #fff; color: var(--pink-deep); border: 2px solid var(--pink); }
.btn.wide { width: 100%; margin-top: 10px; }
.music { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(90, 58, 72, .45); display: grid; place-items: center; padding: 14px; z-index: 10; overflow-y: auto; }
.modal[hidden] { display: none; }
.sheet { background: var(--card); border-radius: 24px; padding: 24px 20px 20px; width: 100%; max-width: 440px; position: relative; box-shadow: var(--shadow); text-align: left; animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 14px; font-weight: 400; font-size: 1.4rem; }
.close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 28px; color: var(--ink); cursor: pointer; opacity: .6; }
label, fieldset { display: block; margin: 0 0 14px; font-size: .95rem; border: 0; padding: 0; }
legend { padding: 0; margin-bottom: 6px; }
input, textarea { width: 100%; font: inherit; color: inherit; border: 2px solid var(--pink-soft); border-radius: 14px; padding: 11px 13px; margin-top: 6px; background: #fff; }
input:focus, textarea:focus { outline: none; border-color: var(--pink); }
.hint { display: block; text-align: right; font-size: .8rem; opacity: .6; margin-top: 4px; }
.error { color: #c23b5e; margin: 0 0 8px; font-size: .9rem; }

/* 편지지 */
.papers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.papers button { border: 2px solid transparent; border-radius: 14px; padding: 8px 2px 6px; font: inherit; font-size: .82rem; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.papers button .pi { width: 40px; height: 40px; display: block; }
.papers button .pi svg { width: 100%; height: 100%; display: block; }
.papers button.sel { border-color: var(--pink-deep); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(236,111,154,.25); }
.paper { border-radius: 16px; padding: 4px; margin-top: 6px; }
.paper textarea { border: 0; background: transparent; margin: 0; resize: vertical; line-height: 1.8; min-height: 150px; }
.snow, .papers .snow { background: linear-gradient(#f4f9ff, #dcecfa); }
.gift, .papers .gift { background: linear-gradient(#fff3f3, #ffd9de); }
.ribbon, .papers .ribbon { background: linear-gradient(#fff0f5, #fcd3e1); }
.sock, .papers .sock { background: linear-gradient(#fff6ec, #fbd9c6); }

/* 완료 */
.done { text-align: center; }
.done .big { font-size: 54px; }
.done-sub { margin: 0 0 14px; opacity: .8; }
.bubble { background: var(--pink-soft); border-radius: 18px; padding: 14px 16px; margin-bottom: 8px; position: relative; overflow: hidden; min-height: 84px; }
.bubble canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; border-radius: 18px; transition: opacity .6s ease; }
.bubble canvas.gone { opacity: 0; pointer-events: none; }
.skip { border: 0; background: none; color: var(--ink); opacity: .55; font: inherit; font-size: .82rem; text-decoration: underline; cursor: pointer; margin-bottom: 10px; }
.skip[hidden] { display: none; }
.bubble .who { font-size: .78rem; color: var(--pink-deep); }
.bubble p { margin: 4px 0 0; font-size: 1.05rem; }
.bubble .msg-img { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; margin: 0 auto; }

/* 눈 */
.snow-layer { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flake { position: absolute; top: -10px; color: #fff; opacity: .85; animation: fall linear infinite; text-shadow: 0 0 4px rgba(255,255,255,.8); }
@keyframes fall { to { transform: translateY(105vh) translateX(var(--sway, 20px)); } }
@media (prefers-reduced-motion: reduce) { .flake, .env, .env.new { animation: none; } }

/* ---------- 관리자 ---------- */
.admin { max-width: 760px; text-align: left; }
.admin h1 { text-align: center; }
.login { max-width: 340px; margin: 40px auto; background: var(--card); padding: 24px; border-radius: 22px; box-shadow: var(--shadow); }
.stats { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.chip { background: #fff; border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow); }
.chip b { color: var(--pink-deep); font-size: 1.2em; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .btn { padding: 8px 16px; font-size: .9rem; }
.card { background: var(--card); border-radius: 18px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 4px 14px rgba(236,111,154,.15); }
.card.rep { border: 2px solid #e8708f; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; opacity: .8; flex-wrap: wrap; }
.body { white-space: pre-wrap; word-break: break-word; margin: 8px 0; line-height: 1.7; }
.row-actions { display: flex; gap: 8px; }
.row-actions .btn { padding: 6px 14px; font-size: .85rem; }
.btn.danger { background: #e8708f; color: #fff; }
.empty { text-align: center; opacity: .7; padding: 30px 0; }

/* ---------- 음원 카드 ---------- */
.music-sec { margin-top: 28px; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mcard { min-width: 0; box-sizing: border-box; background: #fff9fb; border: 2px solid #f3d9e3; border-radius: 24px; padding: 26px 12px 22px; min-height: 190px; justify-content: center; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mcard .emoji { font-size: 40px; line-height: 1.1; }
.mcard h3 { margin: 4px 0 6px; white-space: nowrap; font-family: "Playfair Display", Georgia, serif; font-size: .9rem; letter-spacing: .03em; text-transform: uppercase; color: #8a5568; }
.mcard p { margin: 0; font-size: .85rem; line-height: 1.55; color: #b08a98; white-space: pre-line; flex: 1; }
.mcard .pill { margin-top: 4px; background: #f7dfe8; color: #8a5568; border-radius: 999px; padding: 9px 16px; font-size: .85rem; text-decoration: none; white-space: nowrap; transition: transform .15s; }
.mcard .pill:active { transform: scale(.96); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.pills a { background: #f7dfe8; color: #8a5568; border-radius: 999px; padding: 8px 14px; font-size: .85rem; text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- 줄바꿈/반응형 ---------- */
#doneTitle, .bubble p, .done-sub { white-space: pre-line; }
.done h2 { font-size: clamp(1.15rem, 5.2vw, 1.4rem); line-height: 1.4; }
.bubble p { font-size: clamp(.95rem, 4.2vw, 1.05rem); line-height: 1.6; }
.sub { line-height: 1.6; font-size: clamp(.88rem, 3.8vw, 1rem); }
@media (max-width: 360px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .btn { padding: 12px 20px; font-size: 1rem; }
  .mcard h3 { font-size: .8rem; }
  .mcard .pill { padding: 8px 12px; font-size: .8rem; }
}
@media (min-width: 768px) {
  .page { padding-top: 96px; max-width: 600px; }
  .head h1 { font-size: 42px; }
}

/* 트리 페이지 넘기기 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0 2px; font-family: "Jua", sans-serif; }
.pager button { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--pink); background: #fff; color: var(--pink-deep); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0 3px; }
.pager button:disabled { opacity: .35; cursor: default; }
.pager span { min-width: 64px; }

/* 관리자: 여러 개 선택 */
.selbar { background: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 14px rgba(236,111,154,.15); margin-bottom: 12px; justify-content: space-between; position: sticky; top: 8px; z-index: 5; }
.chk, .who { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
.chk input, .pick { width: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--pink-deep); cursor: pointer; flex: none; }
.selbar #selCount { font-size: .9rem; opacity: .75; flex: 1; text-align: center; }
.selbar .btn:disabled { opacity: .4; cursor: default; }
.card.picked { outline: 2px solid var(--pink); }

/* ---------- 인트로 (총 3초): 선물상자가 열리며 빛이 퍼지고 → 원래 화면이 나타나요 ---------- */
body.intro-open { overflow: hidden; }
.intro { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(180deg, #fde8ef 0%, #fbd5e2 100%); animation: introOut .7s ease-in 2.3s forwards; }
@keyframes introOut { to { opacity: 0; visibility: hidden; } }

.gift-stage { position: relative; width: min(64vw, 270px); aspect-ratio: 1; }
.ibox, .glow { position: absolute; left: 0; width: 100%; }
.ibox { bottom: 0; height: 100%; z-index: 3; overflow: visible; animation: ibIn .5s cubic-bezier(.3, 1.5, .5, 1) both, shake .45s ease-in-out .5s, ibOut .5s ease-in 1.9s forwards; transform-origin: 50% 90%; }
@keyframes ibIn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg); } 40% { transform: rotate(5deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(3deg); } }
@keyframes ibOut { to { transform: translateY(30px) scale(.92); opacity: 0; } }

.lid { transform-box: fill-box; transform-origin: 20% 100%; animation: lidOpen .55s cubic-bezier(.2, .8, .3, 1) 1s forwards; }
@keyframes lidOpen { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-52px, -120px) rotate(-38deg); opacity: 0; } }

.glow { z-index: 1; bottom: 14%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 248, 205, 1) 0%, rgba(255, 244, 190, 0) 68%); opacity: 0; transform: scale(.3); animation: glow 1.3s ease-out 1s forwards; }
@keyframes glow { 0% { opacity: 0; transform: scale(.3); } 35% { opacity: 1; } 100% { opacity: .9; transform: scale(4); } }

.sp { position: absolute; z-index: 4; left: 50%; top: 40%; width: 9px; height: 9px; border-radius: 50%; background: #fff7b8; box-shadow: 0 0 12px 5px rgba(255, 240, 150, .9); opacity: 0; animation: burst .9s ease-out 1.05s forwards; }
.s1 { --dx: -95px; --dy: -80px; } .s2 { --dx: 100px; --dy: -70px; } .s3 { --dx: -120px; --dy: 10px; }
.s4 { --dx: 125px; --dy: 20px; } .s5 { --dx: -50px; --dy: -125px; } .s6 { --dx: 60px; --dy: -130px; }
@keyframes burst { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); } }

@media (prefers-reduced-motion: reduce) {
  .intro { animation-duration: .3s; animation-delay: .6s; }
  .ibox, .lid, .glow, .sp { display: none; }
}

/* 배경음악 on/off */
.music-toggle { position: fixed; top: 12px; right: 12px; z-index: 20; width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--pink); background: #fff; font-size: 1.15rem; cursor: pointer; box-shadow: var(--shadow); padding: 0; }
.music-toggle.off { opacity: .6; }

/* 언어 선택 */
.lang-toggle { position: fixed; top: 12px; left: 12px; z-index: 20; display: flex; background: #fff; border: 2px solid var(--pink); border-radius: 999px; overflow: hidden; box-shadow: var(--shadow); }
.lang-toggle button { border: 0; background: none; padding: 7px 12px; font: inherit; font-family: "Jua", sans-serif; font-size: .8rem; color: var(--pink-deep); cursor: pointer; }
.lang-toggle button.on { background: var(--pink); color: #fff; }
