:root {
  --ink: #070b16;
  --navy: #101a33;
  --text: #e4e0d4;
  --dim: #9a9db0;
  --fire: #ffb347;
  --paper: #f3e6c9;
  --glass: rgba(10, 14, 28, 0.72);
  --line: rgba(243, 230, 201, 0.14);        /* 장식 선 */
  --line-ui: rgba(243, 230, 201, 0.42);     /* 입력칸·단추 테두리 (대비 3:1 이상) */
  --focus: #ffd98a;
  /* 감성 글: 마루부리 → 나눔명조 → 각 언어 세리프. UI: Pretendard → Noto Sans. 기본 시스템 글꼴은 맨 뒤 */
  --serif: "MaruBuri", "Nanum Myeongjo", "Noto Serif KR", "Noto Serif TC", "Noto Serif JP", "Noto Serif Thai", "Noto Serif", Georgia, serif;
  --sans: "Pretendard Variable", "Pretendard", "Noto Sans KR", "Noto Sans TC", "Noto Sans JP", "Noto Sans Thai", "Noto Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --gold: rgba(255, 180, 90, 0.55);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.field input:focus-visible, .field textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
input, textarea { font: inherit; color: var(--text); }
[hidden] { display: none !important; }
.dim { color: var(--dim); }

#lake { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#lake.dragging { cursor: grabbing; }
/* 3D 가 준비되기 전 같은 구도의 정지 그림. 0.6초 크로스페이드 */
.poster { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; pointer-events: none; transition: opacity 0.6s ease; }
.poster.gone { opacity: 0; }

/* 위 */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: calc(14px + var(--safe-t)) 18px 0;
  pointer-events: none;
}
.logo {
  pointer-events: auto;
  font-family: var(--serif); font-weight: 700;
  color: var(--paper); text-decoration: none;
  font-size: 19px; letter-spacing: 0.4em; opacity: 0.92;
  white-space: nowrap; text-shadow: 0 1px 12px rgba(0,0,0,0.6);
}
.count { font-size: 12px; color: var(--dim); text-align: right; line-height: 1.45; max-width: 60vw; text-shadow: 0 1px 8px rgba(0,0,0,0.7); font-variant-numeric: tabular-nums; }
.count b { display: block; font-weight: 500; color: #e9dcc3; font-size: 12.5px; letter-spacing: 0.01em; }
.count small { display: block; font-size: 12px; opacity: 0.85; }

/* 첫 문구 · 이벤트 문구 */
.hero, .banner {
  position: fixed; left: 24px; right: 24px; z-index: 2; text-align: center;
  font-family: var(--serif); color: var(--paper); text-shadow: 0 1px 14px rgba(0,0,0,0.7);
  pointer-events: none; transition: opacity 1.2s ease;
}
.hero { top: calc(26% + var(--safe-t)); font-size: 20px; letter-spacing: 0.02em; opacity: 0.92; }
.banner { top: calc(22% + var(--safe-t)); font-size: 16px; opacity: 0.9; }
.fade-out { opacity: 0 !important; }

/* 흐르는 소원 */
.stream {
  position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-b)); z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; transition: opacity 0.9s ease, transform 0.9s ease; opacity: 0; transform: translateY(6px);
}
.stream.show { opacity: 1; transform: none; }
.stream-wish {
  pointer-events: auto; max-width: 82vw;
  font-family: var(--serif); font-size: 20px; color: #fff3dc; line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 2px 18px rgba(0,0,0,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 6px 10px;
}
.stream-pray {
  pointer-events: auto; font-family: var(--sans); font-size: 14px; font-weight: 500; color: #ffd9a3;
  padding: 10px 16px; min-height: 44px; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: rgba(255,180,90,0.5);
  text-shadow: 0 1px 10px rgba(0,0,0,0.9);
}
.stream-pray:active, .cta:active { background: rgba(255,179,71,0.18); }
.stream-pray.done { color: var(--dim); text-decoration: none; }

/* 아래 */
.bottom {
  position: fixed; left: 0; right: 0; z-index: 3;
  bottom: calc(18px + var(--safe-b));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 12px; pointer-events: none;
}
.bottom > * { pointer-events: auto; }
.cta {
  justify-self: center;
  border: 1px solid var(--gold);
  background: rgba(8, 11, 22, 0.55);
  color: #f6ecd6;
  font-family: var(--sans); font-weight: 500; font-size: 16px; letter-spacing: 0.01em;
  padding: 13px 30px; min-height: 50px; border-radius: 24px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 6px 24px rgba(0,0,0,0.35), 0 0 28px rgba(255,179,71,0.12);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.cta.appear { animation: rise 1.2s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.icon-btn, .lang-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: var(--dim); opacity: 0.8; background: rgba(7,11,22,0.35);
}
.icon-btn { grid-column: 1; justify-self: start; }
.cta { grid-column: 2; }
.lang-btn { grid-column: 3; justify-self: end; font-size: 12px; letter-spacing: 0.05em; width: auto; min-width: 44px; padding: 0 14px; height: 44px; border-radius: 999px; white-space: nowrap; }
.icon-btn.on { color: var(--fire); opacity: 1; }
.icon-btn svg { width: 20px; height: 20px; }

/* 아래에서 올라오는 창 */
.sheet-root { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-root::before { content: ""; position: absolute; inset: 0; background: rgba(4,6,14,0.35); opacity: 0; transition: opacity 0.4s; }
.sheet-root.show::before { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 520px;
  background: rgba(10,14,28,0.92); /* 뒤 흐림 없음: 3D 호수와 겹치면 프레임이 떨어진다 */
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 18px 22px calc(22px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.45);
  transform: translateY(100%); transition: transform 0.45s cubic-bezier(.2,.8,.2,1);
  max-height: 86vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sheet-root.show .sheet { transform: none; }
.sheet.card { padding-bottom: calc(18px + var(--safe-b)); }
/* 남의 등 카드: 등이 보이게 작게, 더 투명하게 */
.sheet-root.mini::before { background: rgba(4,6,14,0.08); }
.sheet.mini { max-width: 400px; width: calc(100% - 24px); margin-bottom: calc(14px + var(--safe-b)); border-radius: 20px; border-bottom: 1px solid var(--line); padding: 16px 20px 16px; background: rgba(10,14,28,0.78); }
.sheet.mini h2 { font-size: 17px; }
.sheet.mini .wish { font-size: 18px; margin: 6px 0 8px; }
.sheet.mini .row { margin-top: 12px; }
.sheet.mini .link { margin-top: 8px; }
.you-too { position: fixed; z-index: 4; transform: translate(-50%, 6px); font-family: var(--serif); font-size: 16px; color: var(--paper); text-shadow: 0 1px 12px rgba(0,0,0,0.8); opacity: 0; transition: opacity 0.7s ease, transform 0.7s ease; pointer-events: none; white-space: nowrap; }
.you-too.show { opacity: 1; transform: translate(-50%, -4px); }
.sheet .x { position: absolute; top: 6px; right: 8px; width: 44px; height: 44px; border-radius: 50%; color: var(--dim); font-size: 22px; line-height: 1; display: grid; place-items: center; }
.sheet .x:active { color: var(--paper); }
.sheet .handle { width: 36px; height: 4px; border-radius: 2px; background: rgba(243,230,201,0.22); margin: -6px auto 14px; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 20px; line-height: 1.4; color: #f6ecd6; margin-bottom: 4px; text-wrap: balance; }
.sheet .sub { color: var(--dim); font-size: 14px; margin-bottom: 14px; }
.sheet .wish { font-family: var(--serif); font-size: 19px; line-height: 1.55; color: var(--paper); margin: 8px 0 10px; word-break: keep-all; }
.sheet .meta { color: var(--dim); font-size: 13px; }
.sheet label { display: block; font-size: 12px; color: var(--dim); margin: 14px 0 6px; letter-spacing: 0.04em; }
.field { position: relative; }
.field input, .field textarea {
  width: 100%; background: rgba(243,230,201,0.05); border: 1px solid var(--line-ui); border-radius: 12px;
  padding: 12px 56px 12px 14px; font-size: 17px; outline: none; -webkit-user-select: text; user-select: text;
  font-family: var(--serif);
}
.field textarea { resize: none; min-height: 72px; padding-right: 14px; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: rgba(255,179,71,0.5); }
.field .n { position: absolute; right: 12px; top: 13px; font-size: 12px; color: var(--dim); }
.field .n.over { color: #e07070; }
.hint { font-size: 12px; color: var(--dim); margin-top: 6px; }
.row { display: flex; gap: 10px; margin-top: 18px; }
.row > * { flex: 1; }
.btn {
  min-height: 48px; border-radius: 24px; padding: 12px 16px; font-size: 16px; font-family: var(--sans); font-weight: 500;
  border: 1px solid var(--line-ui); color: var(--text); background: rgba(243,230,201,0.04);
  transition: background 0.2s, transform 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn.nowrap { white-space: nowrap; }
.btn.primary { border-color: var(--gold); color: #f6ecd6; background: rgba(255,179,71,0.08); }
.btn.primary:disabled { opacity: 0.4; }
.btn.ghost { border-color: transparent; color: var(--dim); }
.btn.kakao { background: #fee500; color: #191919; border-color: #fee500; font-weight: 600; }
.btn.hold { position: relative; overflow: hidden; }
.btn.hold .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,179,71,0.22); transition: width 0.1s linear; }
.btn.hold span { position: relative; }
.link { display: inline-block; margin-top: 14px; font-size: 13px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.center { text-align: center; }
.path { display: flex; gap: 6px; margin: 16px 0 6px; }
.path i { flex: 1; height: 5px; border-radius: 3px; background: rgba(243,230,201,0.1); }
.path i.on { background: linear-gradient(90deg, #ffb347, #ffd98a); box-shadow: 0 0 10px rgba(255,179,71,0.5); }
.share-text { font-family: var(--serif); font-size: 16px; line-height: 1.6; color: var(--paper); background: rgba(243,230,201,0.05); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0 4px; }
.moods { display: grid; gap: 8px; margin-top: 10px; }
.moods .btn { text-align: left; font-family: var(--serif); }
.moods .btn.on { border-color: rgba(255,179,71,0.55); background: rgba(255,179,71,0.1); }
.natures { display: flex; gap: 8px; margin-top: 10px; }
.natures .btn { flex: 1; min-height: 44px; padding: 8px 4px; font-size: 14px; }
.natures .btn.on { border-color: rgba(255,179,71,0.55); background: rgba(255,179,71,0.1); color: var(--paper); }
.timer { display: flex; gap: 8px; margin-top: 14px; }
.timer .btn { min-height: 44px; padding: 8px; font-size: 14px; }
.timer .btn.on { border-color: rgba(255,179,71,0.55); color: var(--paper); }
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.langs .btn.on { border-color: rgba(255,179,71,0.55); color: var(--paper); }
.tiny { font-size: 12px; color: var(--dim); margin-top: 14px; text-align: center; }
.tiny a { color: var(--dim); }
.check, .sheet label.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 4px; cursor: pointer; font-size: 14px; line-height: 1.45; letter-spacing: 0; color: var(--text); }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--amber); flex: none; }
.check b { display: block; font-weight: 500; color: #f6ecd6; }
.check small { display: block; color: var(--dim); font-size: 12.5px; }
.offer { border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px 10px; margin: 6px 0 2px; }
.btn .price { display: block; font-size: 12px; color: var(--dim); font-weight: 400; margin-top: 2px; }
.sheet .btn.kakao { color: #191919; }

/* 걱정이 물에 풀리는 */
.dissolve { font-family: var(--serif); font-size: 18px; line-height: 1.7; color: var(--paper); min-height: 72px; word-break: keep-all; }
.dissolve span { display: inline-block; transition: opacity 0.9s ease, transform 0.9s ease, filter 0.9s ease; }
.dissolve span.gone { opacity: 0; transform: translateY(14px); filter: blur(4px); }

/* 의식 중 침묵 */
body.silent .top, body.silent .bottom, body.silent .stream, body.silent .hero, body.silent .banner { opacity: 0; transition: opacity 0.6s; }
.top, .bottom, .stream, .hero, .banner { transition: opacity 0.6s; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 20;
  font-size: 14px; color: var(--paper); background: var(--glass); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}
.offline { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; text-align: center; background: var(--ink); font-family: var(--serif); font-size: 18px; color: var(--paper); gap: 6px; }

@media (min-width: 768px) {
  .top { padding-left: 28px; padding-right: 28px; }
  .logo { font-size: 21px; }
  .count { font-size: 13px; } .count b { font-size: 15px; }
  .hero { font-size: 24px; }
  .stream-wish { font-size: 19px; }
  .sheet { border-radius: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
  .sheet-root { align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- 추모 마당 ---------- */
.seg { display: flex; gap: 6px; margin: 4px 0 12px; padding: 3px; border: 1px solid var(--line); border-radius: 14px; }
.seg-btn { flex: 1; padding: 9px 0; border: 0; border-radius: 11px; background: transparent; color: var(--dim); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .3s, color .3s; }
.seg-btn.on { background: rgba(255,180,90,0.14); color: #f6ecd6; }
.field select { width: 100%; appearance: none; -webkit-appearance: none; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: #f6ecd6; font: inherit; font-size: 16px; }
.field select:focus { outline: none; border-color: rgba(255,179,71,0.5); }
.offer.quiet { border: 0; padding: 10px 0 0; text-align: center; }
.offer.quiet small { display: block; color: var(--dim); font-size: 12.5px; margin-top: 4px; }
.link.strong { color: #f6ecd6; font-size: 14px; margin-top: 4px; }
.photo-preview { width: 120px; height: 120px; margin: 12px auto 4px; border-radius: 50%; background: center / cover no-repeat; box-shadow: 0 0 0 1px var(--line), 0 0 40px rgba(255,180,90,0.25); opacity: 0.9; }

.count .sponsor { display: block; margin-top: 3px; opacity: 0.75; }

/* 사업자 정보 줄 (모든 화면 하단). 호수에서도 접지 않고 작게 펼쳐 둔다. */
.biz-footer { font-family: var(--sans); font-size: 11px; line-height: 1.6; color: var(--dim); text-align: center; padding: 18px 16px calc(14px + var(--safe-b)); }
.biz-footer p { margin: 0; }
.biz-footer .biz-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 12px; margin-top: 4px; }
.biz-footer a { color: var(--dim); text-decoration: underline; text-underline-offset: 2px; padding: 3px 0; }
.biz-footer.compact { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 0 12px calc(4px + var(--safe-b)); font-size: 9.5px; line-height: 1.45; color: rgba(190,194,210,0.78); text-shadow: 0 1px 4px rgba(0,0,0,0.95); }
.biz-footer.compact .biz-links { margin-top: 1px; gap: 0 12px; }
.biz-footer.compact a { color: rgba(214,216,228,0.85); padding: 2px 0; }
body.lake .bottom { bottom: calc(var(--foot-h, 40px) + 8px); }
body.lake .stream { bottom: calc(var(--foot-h, 40px) + 86px); }
body.lake .toast { bottom: calc(var(--foot-h, 40px) + 80px); }
body.silent .biz-footer.compact { opacity: 0; pointer-events: none; transition: opacity 0.4s; }

/* 금빛 선물 초 단추 (보내기 화면·/gift) */
.btn.gold { display: flex; align-items: center; justify-content: center; text-decoration: none; border: 1px solid var(--gold); color: #f6ecd6; background: linear-gradient(180deg, rgba(255,190,100,0.18), rgba(255,170,80,0.06)); }
.offer .offer-line { margin: 8px 0 8px; font-size: 14px; color: var(--text); }
.offer .offer-line small { display: block; color: var(--dim); font-size: 12.5px; margin-top: 2px; }

/* 한도 안내 한 줄 (오류가 아니라 안내) */
.hint.warn { color: var(--paper); }
/* 내 초 목록 (여러 개) */
.pick-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 6px; }
.pick { display: grid; gap: 2px; text-align: left; width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); color: var(--text); font: inherit; cursor: pointer; }
.pick b { font-family: var(--serif); font-weight: 400; font-size: 16px; color: var(--paper); }
.pick span { font-size: 14px; } .pick small { font-size: 12px; color: var(--dim); }

/* 첫 화면 작은 [선물 초] 단추 (로고 아래, 얇은 금색 테두리) */
.top-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.gift-pill { pointer-events: auto; font-size: 12px; color: #f3e6c9; text-decoration: none; border: 1px solid rgba(255,180,90,0.7); border-radius: 999px; padding: 4px 11px; background: rgba(8,11,22,0.45); text-shadow: 0 1px 6px rgba(0,0,0,0.7); }
body.silent .gift-pill { opacity: 0; pointer-events: none; }
/* 보내기: 받는 사람 화면 미리보기 두 장 + 같은 크기 단추 두 개 */
.gift-choice .preview-title { font-size: 13.5px; color: var(--dim); margin: 2px 0 8px; text-align: center; }
.gift-choice .thumbs { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.gift-choice figure { margin: 0; text-align: center; }
.gift-choice figcaption { font-size: 12.5px; color: var(--text); margin-top: 4px; }
.gift-thumb { display: block; border-radius: 14px; border: 1px solid var(--line); }
.row.two > .btn { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.3; font-size: 14.5px; padding-left: 10px; padding-right: 10px; } /* 두 단추는 늘 같은 크기·같은 모양 (금빛을 더 강조하지 않는다) */
.gift-pay .pay-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.gift-pay .pay-head h2 { margin: 0; font-size: 18px; }
.gift-pay .pay-methods { margin: 0 -8px; border-radius: 16px; overflow: hidden; }
.gift-ready { text-align: center; }
