:root {
  --pink-50: #fff5f8;
  --pink-100: #fde4ec;
  --pink-200: #f9c9d7;
  --pink-300: #f7a8bf;
  --pink-400: #ff8fab;
  --pink-500: #e8577a;
  --pink-700: #b8395c;
  --ink: #4a2b33;
  --ink-soft: #8a6670;
  --paper: #ffffff;
  --sea: #8cc3e8;
  --font: "Galmuri11", "Galmuri9", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--pink-100);
  background-image:
    linear-gradient(45deg, var(--pink-50) 25%, transparent 25%, transparent 75%, var(--pink-50) 75%),
    linear-gradient(45deg, var(--pink-50) 25%, transparent 25%, transparent 75%, var(--pink-50) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }

#demo-banner, #closed-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--ink); color: #fff; text-align: center;
  font-size: 12px; padding: 4px 8px;
}

/* ---------- 픽셀 상자 / 버튼 ---------- */
.pixel-box {
  position: relative;
  background: var(--paper);
  margin: 4px;
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink),
    -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    0 8px 0 0 rgba(74, 43, 51, 0.18);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; margin: 4px;
  background: var(--paper); color: var(--ink);
  border: 0; cursor: pointer; text-decoration: none;
  box-shadow:
    0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink),
    -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 -4px 0 0 rgba(74, 43, 51, 0.15);
  transition: transform .05s;
  user-select: none;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--pink-400); color: #fff; text-shadow: 1px 1px 0 var(--pink-700); }
.btn.big { width: calc(100% - 8px); min-height: 52px; font-size: 18px; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.scene { min-height: 100dvh; }
.page { max-width: 480px; margin: 0 auto; padding: 16px 16px 40px; }
.scene-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-right: 44px; }
.scene-head h2 { margin: 0; font-size: 20px; }
.scene-head > :last-child:empty { width: 64px; }

/* ---------- 초대장 ---------- */
#scene-invite { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.invite { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 24px 16px; }
.card { padding: 24px 18px 20px; text-align: center; background: #fffafc; }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: 3px; color: var(--pink-500); }
#couple-canvas { display: block; margin: 8px auto 4px; cursor: pointer; touch-action: manipulation; }
.names { margin: 8px 0 4px; font-size: 26px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.names .heart { color: var(--pink-500); font-size: 22px; animation: beat 1.2s infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } }
.lead { margin: 0 0 16px; color: var(--ink-soft); }
.info { margin: 0 0 12px; padding: 12px; background: var(--pink-50); text-align: left; }
.info div { display: flex; gap: 12px; padding: 3px 0; }
.info dt { flex: 0 0 auto; color: var(--pink-500); }
.info dd { margin: 0; }
.dday { margin: 4px 0 16px; font-size: 22px; color: var(--pink-500); }

.petals { position: absolute; inset: 0; pointer-events: none; }
.petal {
  position: absolute; top: -20px; width: 8px; height: 8px;
  background: var(--pink-300);
  box-shadow: 8px 0 0 var(--pink-300), 0 8px 0 var(--pink-300), 8px 8px 0 #fff;
  opacity: .8;
  animation: fall linear infinite;
}
@keyframes fall {
  0% { transform: translate(0, -20px) rotate(0); }
  100% { transform: translate(60px, 110vh) rotate(360deg); }
}

/* ---------- 옷장 ---------- */
.wd-preview-box { display: flex; flex-direction: column; align-items: center; padding: 16px; margin-bottom: 16px; background: linear-gradient(#fff 70%, var(--pink-100) 70%); }
#wd-preview { display: block; }
.nameplate { margin: 8px 0 0; padding: 2px 12px; background: var(--ink); color: #fff; font-size: 13px; }
.form { padding: 16px; margin-bottom: 16px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-soft); }
.field input, textarea {
  width: 100%; padding: 10px 12px; border: 0; background: var(--pink-50);
  box-shadow: inset 0 0 0 3px var(--ink); outline: none; font-size: 16px; border-radius: 0;
}
.field input:focus, textarea:focus { box-shadow: inset 0 0 0 3px var(--pink-500); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button, .tabs button {
  padding: 10px 6px; border: 0; cursor: pointer; background: var(--pink-50);
  box-shadow: inset 0 0 0 3px var(--pink-200);
}
.seg button.on, .tabs button.on { background: var(--pink-400); color: #fff; box-shadow: inset 0 0 0 3px var(--ink); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 10px; }
.options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border: 0; cursor: pointer; background: #fff;
  box-shadow: inset 0 0 0 3px var(--pink-200); font-size: 11px;
}
.opt canvas { display: block; }
.opt.on { background: var(--pink-50); box-shadow: inset 0 0 0 3px var(--pink-500); }
.swatch { width: 100%; aspect-ratio: 1; }
.swatch i { display: block; width: 28px; height: 28px; box-shadow: 0 0 0 3px var(--ink); }

/* ---------- 식장 ---------- */
#scene-hall { position: fixed; inset: 0; min-height: 0; background: #f7d6df; }
#hall-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hud-top { position: absolute; top: 8px; left: 8px; right: 200px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.chip { background: var(--ink); color: #fff; padding: 2px 10px; font-size: 12px; }
.hint { background: rgba(255, 255, 255, .85); padding: 2px 8px; font-size: 11px; }
.hud-action { position: absolute; left: 0; right: 0; bottom: 92px; display: flex; justify-content: center; }
.hud-action .btn { animation: pop .25s; min-width: 180px; }
@keyframes pop { from { transform: scale(.7); } to { transform: scale(1); } }
.hud-bar {
  position: absolute; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 480px; margin: 0 auto;
}
.hud-bar button {
  display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .95); box-shadow: inset 0 0 0 3px var(--ink); font-size: 11px;
}
.hud-bar button b { font-size: 20px; line-height: 1.2; font-weight: normal; }
.hud-bar button:active { transform: translateY(2px); }

/* ---------- 항구 ---------- */
#harbor-canvas { display: block; width: 100%; height: 150px; margin-bottom: 12px; box-shadow: 0 0 0 4px var(--ink); }
.harbor-title { margin: 0 0 8px; font-size: 16px; }
.rules { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.count { margin: 0 0 8px; font-size: 14px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.summary { font-size: 13px; color: var(--ink-soft); min-height: 1em; }
.file-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.file-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 6px; background: var(--pink-50); font-size: 12px; }
.file-list .th { width: 44px; height: 44px; object-fit: cover; background: var(--pink-200); display: block; }
.file-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .bar { height: 6px; background: var(--pink-200); margin-top: 4px; }
.file-list .bar i { display: block; height: 100%; width: 0; background: var(--pink-500); transition: width .2s; }
.tag { display: inline-block; padding: 1px 6px; font-size: 11px; background: #fff; box-shadow: inset 0 0 0 2px var(--pink-200); white-space: nowrap; }
.tag.ok { background: #e3f4e1; box-shadow: inset 0 0 0 2px #9ccc7f; }
.tag.warn { background: #fff4d6; box-shadow: inset 0 0 0 2px #f0c35a; }
.tag.no { background: #eee; box-shadow: inset 0 0 0 2px #bbb; color: #777; }

/* ---------- 모달 / 토스트 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(74, 43, 51, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { width: 100%; max-width: 380px; padding: 22px 18px 18px; max-height: 90dvh; overflow: auto; }
.modal-x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 18px; cursor: pointer; padding: 6px; }
.modal-box h3 { margin: 0 0 10px; font-size: 18px; }
.modal-box p { margin: 0 0 12px; }
.modal-center { text-align: center; }
.modal-center canvas { display: block; margin: 0 auto 8px; }
.counter { text-align: right; font-size: 12px; color: var(--ink-soft); margin: 4px 0 8px; }
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 16px; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
.bgm-btn {
  position: fixed; top: 8px; right: 8px; z-index: 30; width: 40px; height: 40px; border: 0; cursor: pointer;
  background: #fff; box-shadow: inset 0 0 0 3px var(--ink); font-size: 18px;
}
.bgm-btn.off { opacity: .5; text-decoration: line-through; }
#demo-banner:not([hidden]) ~ .bgm-btn, #demo-banner:not([hidden]) ~ .gb-fab { top: 30px; }

/* ---------- 방명록 모아보기 ---------- */
.gb-fab {
  position: fixed; top: 8px; right: 56px; z-index: 30; height: 40px; padding: 0 12px; border: 0; cursor: pointer;
  background: #fff; box-shadow: inset 0 0 0 3px var(--ink); font-size: 13px;
}
.gb-fab:active { transform: translateY(2px); }
.seg.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 8px; }
.seg.three button { font-size: 13px; padding: 8px 4px; }
.gb-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 55dvh; overflow: auto; display: grid; gap: 6px; }
.gb-list li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 8px 10px; background: var(--pink-50); cursor: pointer; }
.gb-list li:active { background: var(--pink-100); }
.gb-list li.mine { box-shadow: inset 0 0 0 2px var(--pink-400); }
.gb-list canvas { display: block; width: 36px; }
.gb-list .msg { font-size: 15px; word-break: keep-all; overflow-wrap: anywhere; }
.gb-list .who { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.gb-list .who b { font-weight: normal; padding: 0 4px; margin-right: 4px; color: #fff; background: var(--pink-400); }
.gb-list .who b.groom { background: #7aa6d8; }
.gb-empty { text-align: center; color: var(--ink-soft); padding: 24px 0; }
