:root {
  --carpet: #5c0f1c;
  --carpet-deep: #23050a;
  --carpet-mid: #3f0912;
  --gold: #d8b45a;
  --gold-hi: #f6e6ae;
  --gold-lo: #9a772b;
  --cream: #f7eed6;
  --cream-dim: rgba(247, 238, 214, 0.68);
  --cream-faint: rgba(247, 238, 214, 0.42);
  --paper: #fbf5e4;
  --ink: #2a1a10;
  --red-ink: #8e1b25;
  --line: rgba(216, 180, 90, 0.34);
  --panel: rgba(18, 3, 7, 0.5);
  --ok: #9fd3a4;
  --serif: "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --gold-grad: linear-gradient(180deg, #fbefc0 0%, #e2c06a 42%, #c39837 70%, #e9cf7f 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--cream);
  background-color: var(--carpet-deep);
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 214, 140, 0.16) 0%, transparent 60%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.07) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, var(--carpet) 0%, var(--carpet-mid) 45%, var(--carpet-deep) 100%);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.spot {
  position: fixed; inset: 0 0 auto 0; height: 340px; pointer-events: none;
  background: radial-gradient(50% 100% at 50% 0%, rgba(255, 236, 190, 0.12), transparent 70%);
}
.wrap { position: relative; max-width: 460px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--gold-hi); }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 800; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

/* ── 상단 바 ── */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 40px; margin-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--gold-hi); font-family: var(--serif); font-weight: 800; font-size: 17px; letter-spacing: 0.02em; }
.brand svg { width: 22px; height: 22px; }
.back { background: none; border: 0; color: var(--cream-dim); font-size: 15px; padding: 8px 0; cursor: pointer; }

/* ── 공통 요소 ── */
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.22em; color: var(--gold); text-transform: uppercase; font-weight: 600; }
.kicker::before, .kicker::after { content: ""; width: 18px; height: 1px; background: var(--gold); opacity: 0.7; }
.gold-text {
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.muted { color: var(--cream-dim); }
.faint { color: var(--cream-faint); font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hr { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); margin: 22px 0; border: 0; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 56px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer;
  font-size: 17px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-gold {
  color: #2b1405; background: var(--gold-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(120, 80, 10, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.btn-line { color: var(--cream); background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.btn-ghost { color: var(--cream-dim); background: none; min-height: 44px; font-weight: 500; font-size: 15px; }
.btn-sm { min-height: 44px; font-size: 15px; border-radius: 12px; }
.btn .ic { width: 18px; height: 18px; flex: none; }
.premium-tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--gold-grad); color: #3a1e05; letter-spacing: 0.02em; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; backdrop-filter: blur(2px); }
.panel-title { font-family: var(--serif); font-size: 18px; font-weight: 800; margin-bottom: 4px; }

/* ── 첫 화면 ── */
.hero { text-align: center; padding: 26px 0 8px; }
.hero-trophy { width: 108px; height: 108px; margin: 0 auto 14px; display: block; filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45)); }
.hero h1 { font-size: 34px; line-height: 1.28; margin: 14px 0 14px; }
.hero .lead { font-size: 16px; color: var(--cream-dim); }
.hero .lead b { color: var(--cream); font-weight: 600; }
.hero .cta { margin-top: 28px; }
.badges { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.badge { font-size: 12.5px; color: var(--cream-dim); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; }

.steps { counter-reset: s; margin-top: 34px; display: grid; gap: 10px; }
.step { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(216, 180, 90, 0.18); }
.step::before { counter-increment: s; content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-weight: 800; color: #3a1e05; background: var(--gold-grad); font-size: 15px; }
.step b { display: block; font-size: 15.5px; }
.step span { font-size: 13.5px; color: var(--cream-dim); }

.sample { margin: 30px auto 0; width: 78%; max-width: 300px; aspect-ratio: 9 / 16; border-radius: 10px; position: relative; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); transform: rotate(-2deg); }
.sample img { width: 100%; height: 100%; display: block; }
.chips-cloud { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 22px; }
.chips-cloud span { font-size: 13px; padding: 6px 11px; border-radius: 99px; background: rgba(216, 180, 90, 0.1); color: var(--gold-hi); border: 1px solid rgba(216, 180, 90, 0.25); }

.footer { margin-top: 44px; text-align: center; font-size: 12.5px; color: var(--cream-faint); }
.footer a { color: var(--cream-dim); text-decoration: none; margin: 0 7px; }

/* ── 폼 ── */
.page-title { font-size: 26px; line-height: 1.3; margin: 8px 0 6px; }
.page-sub { color: var(--cream-dim); font-size: 14.5px; margin-bottom: 22px; }
.field { margin-bottom: 22px; }
.label { display: flex; align-items: baseline; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--gold-hi); margin-bottom: 8px; }
.label small { font-weight: 400; color: var(--cream-faint); font-size: 12.5px; }
.input {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 12px; font-size: 16px; font-family: var(--sans);
  color: var(--cream); background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); outline: none;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216, 180, 90, 0.18); }
.input::placeholder { color: var(--cream-faint); }
textarea.input { height: 140px; padding: 14px 16px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; }
.adder { display: flex; gap: 8px; }
.adder .input { flex: 1; }
.adder .btn { width: auto; min-height: 52px; padding: 0 18px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px; font-size: 14.5px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--cream); cursor: pointer; line-height: 1.2;
}
.chip.on { background: rgba(216, 180, 90, 0.18); border-color: var(--gold); color: var(--gold-hi); }
.chip.on::before { content: "✓"; font-size: 12px; }
.chip.me { border-style: dashed; }
.chip .x { border: 0; background: none; color: var(--cream-faint); font-size: 16px; padding: 0 0 0 2px; cursor: pointer; line-height: 1; }
.chip.premium { border-color: rgba(246, 230, 174, 0.6); color: var(--gold-hi); background: linear-gradient(90deg, rgba(216, 180, 90, 0.18), rgba(216, 180, 90, 0.05)); }
.chip.custom { background: rgba(216, 180, 90, 0.22); border-color: var(--gold-hi); }
.hint { font-size: 13px; color: var(--cream-faint); margin-top: 8px; }
.err { color: #ffb4a8; font-size: 13.5px; margin-top: 8px; }
.sticky-cta { padding: 14px 0 6px; margin-top: 8px; }
.sticky-cta.stick { position: sticky; bottom: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(35, 5, 10, 0), rgba(35, 5, 10, 0.94) 38%); }

/* ── 초대·진행 ── */
.invite-card { text-align: center; padding: 22px 18px; }
.invite-card h2 { font-size: 23px; line-height: 1.35; margin: 10px 0 6px; }
.linkbox { margin: 16px 0 14px; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px dashed var(--line); font-size: 14px; color: var(--gold-hi); word-break: break-all; text-align: left; user-select: all; }
.progress { margin-top: 4px; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.progress-head b { font-family: var(--serif); font-size: 20px; }
.bar { height: 10px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; border: 1px solid rgba(216, 180, 90, 0.2); }
.bar > i { display: block; height: 100%; background: var(--gold-grad); border-radius: 99px; transition: width 0.4s ease; }
.who { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.who span { font-size: 13px; padding: 5px 10px; border-radius: 99px; border: 1px solid rgba(216, 180, 90, 0.2); color: var(--cream-faint); }
.who span.done { color: var(--ok); border-color: rgba(159, 211, 164, 0.4); }
.who span.done::before { content: "✓ "; }

/* ── 닉네임 고르기·투표 ── */
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.name-btn {
  min-height: 64px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); cursor: pointer;
  background: rgba(0, 0, 0, 0.22); font-size: 17px; font-weight: 600; color: var(--cream); text-align: center; line-height: 1.25; word-break: keep-all;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.name-btn:active { transform: scale(0.98); }
.name-btn.sel { background: var(--gold-grad); color: #2b1405; border-color: transparent; }
.name-btn[disabled] { opacity: 0.4; cursor: default; }
.name-btn small { display: block; font-size: 11.5px; font-weight: 400; margin-top: 2px; color: var(--cream-faint); }
.ballot-head { text-align: center; padding: 10px 0 4px; }
.ballot-count { font-size: 13px; color: var(--gold); letter-spacing: 0.12em; }
.ballot-title { font-size: 27px; line-height: 1.3; margin: 14px 0 8px; word-break: keep-all; }
.ballot-desc { color: var(--cream-dim); font-size: 15px; }
.dots { display: flex; justify-content: center; gap: 5px; margin-top: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(216, 180, 90, 0.25); }
.dots i.on { background: var(--gold); }
.dots i.cur { width: 18px; border-radius: 99px; background: var(--gold-hi); }
.laurel { width: 160px; display: block; margin: 0 auto; opacity: 0.95; }

/* ── 결과 ── */
.stage { text-align: center; padding: 30px 0 10px; min-height: 62vh; display: flex; flex-direction: column; justify-content: center; }
.stage h1 { font-size: 30px; line-height: 1.35; margin: 16px 0 10px; word-break: keep-all; }
.envelope { margin: 22px auto 0; width: 100%; padding: 30px 20px 26px; border-radius: 18px; position: relative; color: var(--ink);
  background: linear-gradient(180deg, #fffaf0, #f1e5c6); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(154, 119, 43, 0.4), inset 0 0 0 7px #fbf3dc, inset 0 0 0 8px rgba(154, 119, 43, 0.5); }
.envelope .cat { font-family: var(--serif); font-size: 25px; font-weight: 800; color: var(--red-ink); word-break: keep-all; line-height: 1.3; }
.envelope .desc { font-size: 14px; color: #6b5640; margin-top: 6px; }
.envelope .winner { margin-top: 20px; min-height: 92px; display: grid; place-items: center; }
.envelope .winner b { font-family: var(--serif); font-size: 38px; font-weight: 800; line-height: 1.2; word-break: keep-all; }
.envelope .winner em { display: block; font-style: normal; font-size: 13.5px; color: #8a6d45; margin-top: 4px; }
.envelope .sealed { font-size: 15px; color: #8a6d45; letter-spacing: 0.08em; }
.fade-in { animation: fadeIn 0.5s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } .bar > i { transition: none; } }

.award-list { display: grid; gap: 8px; margin-top: 16px; }
.award-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(216, 180, 90, 0.2); }
.award-row .t { font-size: 14px; color: var(--cream-dim); word-break: keep-all; }
.award-row .w { font-family: var(--serif); font-weight: 800; font-size: 18px; color: var(--gold-hi); text-align: right; word-break: keep-all; }
.award-row .w small { display: block; font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--cream-faint); }
.award-row.mine { border-color: var(--gold); background: rgba(216, 180, 90, 0.12); }

.card-preview { margin: 14px auto 0; width: 72%; max-width: 300px; display: block; border-radius: 8px; box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5); aspect-ratio: 9 / 16; background: rgba(0, 0, 0, 0.2); object-fit: contain; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.tabs button { font-size: 13.5px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--cream-dim); cursor: pointer; }
.tabs button.on { background: rgba(216, 180, 90, 0.18); color: var(--gold-hi); border-color: var(--gold); }
.support { text-align: center; padding: 16px; border-radius: 16px; border: 1px dashed rgba(216, 180, 90, 0.35); }
.support p { font-size: 13.5px; color: var(--cream-dim); margin: 4px 0 12px; }

/* ── 시트(결제 등) ── */
.sheet-bg { position: fixed; inset: 0; background: rgba(8, 1, 3, 0.66); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 460px; max-height: 92dvh; overflow: auto; background: linear-gradient(180deg, #3a0a12, #1c0408); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up 0.22s ease both; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h3 { font-size: 22px; }
.sheet .price { font-family: var(--serif); font-size: 30px; font-weight: 800; margin: 10px 0 2px; }
.perks { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.perks li { padding-left: 26px; position: relative; font-size: 15px; }
.perks li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; transform: rotate(45deg); background: var(--gold-grad); }
.note { font-size: 13.5px; color: var(--cream-dim); background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 12px 14px; }
.sheet-close { position: absolute; }

/* ── 토스트·오류 ── */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #fbf3dc; color: var(--ink); font-size: 14.5px; font-weight: 600; padding: 12px 18px; border-radius: 99px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); transition: 0.2s; z-index: 60; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.error-box { text-align: center; padding: 40px 10px; }
.error-box h2 { font-size: 22px; margin: 12px 0 8px; }
.loading { text-align: center; padding: 120px 0; color: var(--cream-faint); font-size: 14px; }
.loading::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%; border: 2px solid rgba(216, 180, 90, 0.25); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 문서 페이지 ── */
.doc h1 { font-size: 26px; margin: 10px 0 18px; }
.doc h2 { font-size: 18px; margin: 26px 0 8px; color: var(--gold-hi); }
.doc p, .doc li { font-size: 14.5px; color: var(--cream-dim); }
.doc ul { padding-left: 18px; }
.doc li + li { margin-top: 4px; }
.noscript { padding: 40px 0; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
