:root {
  --ink: #e8ecf6;
  --ink-dim: rgba(232, 236, 246, 0.62);
  --ink-faint: rgba(232, 236, 246, 0.38);
  --glass: rgba(14, 18, 30, 0.42);
  --line: rgba(232, 236, 246, 0.14);
  --wish: #f6e7b8;
  --bg: #05070d;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
button { font: inherit; color: inherit; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#sky.dragging { cursor: grabbing; }

/* 위쪽 */
.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.place { display: flex; flex-direction: column; gap: 3px; }
.place .name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.place .sub { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.icon-btn {
  pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .cross { display: none; }
.icon-btn.muted .wave { display: none; }
.icon-btn.muted .cross { display: inline; }

#hint {
  position: fixed; top: 74px; left: 0; right: 0; margin: 0;
  text-align: center; font-size: 12px; color: var(--ink-faint);
  transition: opacity 1.2s; pointer-events: none;
}
#hint.gone { opacity: 0; }

/* 소원 */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 16px max(22px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.actions { display: flex; gap: 10px; align-items: center; justify-content: center; }
.pill {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 13px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 14px; font-weight: 600; color: var(--ink-dim); cursor: pointer;
  transition: color .3s, border-color .3s, transform .2s;
}
.pill svg { width: 18px; height: 18px; }
.pill:active { transform: scale(0.96); }
.pill .dots { display: inline-flex; gap: 3px; margin-left: 1px; }
.pill .dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: #ffc982; box-shadow: 0 0 6px rgba(255, 201, 130, 0.8);
  transition: background .6s, box-shadow .6s;
}
.pill .dots i.off { background: rgba(232, 236, 246, 0.18); box-shadow: none; }
.pill.dark { color: var(--ink-faint); }
.pill.dark .dots { display: none; }

#wish {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 26px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink-faint); cursor: default;
  transition: color .35s, border-color .35s, box-shadow .35s, background .35s, transform .2s;
}
#wish svg { width: 18px; height: 18px; }
#wish.on {
  color: #1b1708; background: var(--wish); border-color: var(--wish); cursor: pointer;
  box-shadow: 0 0 0 6px rgba(246, 231, 184, 0.12), 0 0 36px rgba(246, 231, 184, 0.55);
  animation: breathe 1.1s ease-in-out infinite;
}
#wish.done {
  color: var(--wish); border-color: rgba(246, 231, 184, 0.5);
  background: rgba(246, 231, 184, 0.08); animation: none;
}
#wish.on:active { transform: scale(0.96); }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 6px rgba(246, 231, 184, 0.12), 0 0 28px rgba(246, 231, 184, 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(246, 231, 184, 0.08), 0 0 48px rgba(246, 231, 184, 0.7); }
}
.wish-note { margin: 0; font-size: 12px; color: var(--ink-faint); transition: opacity .6s; }
.wish-note.gone { opacity: 0; }

#toast {
  position: fixed; left: 50%; bottom: 120px; transform: translate(-50%, 8px);
  font-size: 14px; color: var(--wish); opacity: 0;
  transition: opacity .6s, transform .6s; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 소원을 빌면 위로 떠오르는 작은 빛 */
.spark {
  position: fixed; width: 4px; height: 4px; border-radius: 50%;
  background: var(--wish); box-shadow: 0 0 8px var(--wish);
  pointer-events: none; animation: rise 2.6s ease-out forwards;
}
@keyframes rise {
  from { opacity: 0.95; transform: translate(0, 0); }
  to { opacity: 0; transform: translate(var(--dx), -220px); }
}

/* 첫 화면 */
#intro {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 120%, rgba(5, 7, 13, 0.2), rgba(5, 7, 13, 0.82) 60%);
  transition: opacity 1.6s ease;
}
#intro.gone { opacity: 0; pointer-events: none; }
.intro-card { max-width: 360px; text-align: center; }
.eyebrow { margin: 0 0 14px; font-size: 12px; letter-spacing: 0.12em; color: var(--ink-faint); }
.intro-card h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.lead { margin: 16px 0 30px; font-size: 16px; line-height: 1.7; color: var(--ink-dim); }
.intro-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.intro-actions button {
  width: 220px; padding: 13px 0; border-radius: 999px; cursor: pointer;
  font-size: 15px; font-weight: 600;
}
.primary { background: var(--ink); color: #0b0e18; border: 0; }
.ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); }
.fine { margin: 22px 0 0; font-size: 12px; color: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  #wish.on { animation: none; }
}

/* 이은 별자리 수 */
.place .collect {
  font-size: 12px; color: var(--wish); opacity: 0; transition: opacity .6s;
}
.place .collect.show { opacity: 0.85; }

/* 별 이름표 — 고른 별 옆에 붙어 다님 */
#starLabel, #personLabel {
  position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 11px; border-radius: 10px;
  background: rgba(10, 13, 24, 0.62); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: none; white-space: nowrap;
  opacity: 0; transition: opacity .35s;
}
#starLabel.show, #personLabel.show { opacity: 1; }
#starLabel b, #personLabel b { font-size: 14px; font-weight: 600; }
#starLabel span, #personLabel span { font-size: 12px; color: var(--ink-dim); }
#personLabel { align-items: center; border-color: rgba(255, 201, 130, 0.3); }
#starLabel em { font-style: normal; font-size: 11px; color: var(--wish); font-variant-numeric: tabular-nums; }

/* 별자리를 다 이었을 때 이야기 */
#story {
  position: fixed; left: 50%; top: 96px; transform: translate(-50%, -6px);
  width: min(360px, calc(100% - 32px));
  padding: 14px 18px; border-radius: 14px; text-align: center;
  background: rgba(10, 13, 24, 0.6); border: 1px solid rgba(246, 231, 184, 0.28);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity .8s, transform .8s;
}
#story.show { opacity: 1; transform: translate(-50%, 0); }
#story .title { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--wish); }
#story .text { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-dim); word-break: keep-all; }

/* 소원 단추의 상태별 아이콘 */
#wish .ic-pen { display: none; }
#wish.write .ic-star { display: none; }
#wish.write .ic-pen { display: inline; }
#wish.write, #wish.written { color: var(--ink-dim); cursor: pointer; }
#wish.written { color: var(--wish); border-color: rgba(246, 231, 184, 0.35); }

/* 소원 적기 창 */
#wishSheet {
  position: fixed; inset: 0; display: grid; place-items: end center;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
  background: rgba(3, 5, 10, 0.45);
  touch-action: auto;
}
#wishSheet[hidden] { display: none; }
.sheet-card {
  width: min(380px, 100%);
  padding: 20px 18px 16px; border-radius: 18px;
  background: rgba(14, 18, 30, 0.86); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: sheetIn .35s ease-out;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.sheet-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.sheet-sub { margin: 0 0 14px; font-size: 12.5px; line-height: 1.6; color: var(--ink-dim); word-break: keep-all; }
#wishInput {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid rgba(246, 231, 184, 0.3); background: rgba(5, 7, 13, 0.6);
  color: var(--ink); font: inherit; font-size: 16px;
  user-select: text; -webkit-user-select: text; outline: none;
}
#wishInput:focus { border-color: var(--wish); box-shadow: 0 0 0 3px rgba(246, 231, 184, 0.15); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.sheet-actions button { padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; }

/* 하늘로 올라가는 소원 글자 */
.fly-char {
  position: fixed; left: 0; top: 0;
  font-size: 18px; font-weight: 600; color: #fff6dc; white-space: pre;
  text-shadow: 0 0 6px rgba(246, 231, 184, 0.9), 0 0 16px rgba(246, 210, 140, 0.6);
  pointer-events: none; will-change: transform, opacity, filter;
}
.fly-flash {
  position: fixed; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: #fff6dc;
  box-shadow: 0 0 18px 8px rgba(246, 231, 184, 0.75);
  pointer-events: none;
}

/* 함께 보는 사람 수 */
.place .together { font-size: 12px; color: #ffc982; opacity: 0.85; }

/* 위쪽 단추 묶음 · 음악 단추 */
.top { align-items: flex-start; }
.top-actions { display: flex; gap: 8px; }
#music { color: var(--ink-faint); }
#music.on { color: var(--wish); border-color: rgba(246, 231, 184, 0.45); box-shadow: 0 0 14px rgba(246, 231, 184, 0.25); }
