:root {
  --night: #16213e;
  --night2: #0f1830;
  --ink: #2b2420;
  --muted: #7a6f66;
  --paper: #fffaf0;
  --red: #d94848;
  --red-d: #b83434;
  --gold: #f2c14e;
  --line: #eadfcd;
  --radius: 18px;
  --cream: #fff6dc; --pink: #ffdce4; --mint: #d6f3e4; --sky: #d8e9ff; --lilac: #e8ddff; --lemon: #fff3a8;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Gowun Dodum", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 0%, #22305a 0%, var(--night) 45%, var(--night2) 100%) fixed;
  min-height: 100vh;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
body[data-theme="berry"] { background: radial-gradient(120% 80% at 50% 0%, #6b1f2e 0%, #4a1320 50%, #2c0b13 100%) fixed; }
body[data-theme="pine"] { background: radial-gradient(120% 80% at 50% 0%, #1f5a43 0%, #143d2e 50%, #0b2219 100%) fixed; }
body[data-theme="gold"] { background: radial-gradient(120% 80% at 50% 0%, #6a4a1e 0%, #4a3213 50%, #2a1c0a 100%) fixed; }
h1, h2, .jua { font-family: "Jua", "Gowun Dodum", sans-serif; font-weight: 400; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); }

.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow i {
  position: absolute; top: -10px; width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, .8); animation: fall linear infinite;
}
@keyframes fall { to { transform: translate3d(20px, 105vh, 0); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

.wrap { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 20px 16px 64px; }
.testbar { position: relative; z-index: 2; background: var(--gold); color: #3a2a00; text-align: center; font-size: 13px; padding: 6px; }

.hero { text-align: center; color: #fff; padding: 28px 0 18px; }
.hero .tag { display: inline-block; font-size: 13px; padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.12); }
.hero h1 { font-size: clamp(26px, 8vw, 34px); line-height: 1.25; margin: 14px 0 8px; }
.hero p { margin: 0; opacity: .85; line-height: 1.6; }

.card {
  background: var(--paper); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.card + .card { margin-top: 14px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
.input, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fff; font-size: 16px; outline: none;
}
.input:focus, textarea:focus { border-color: var(--red); }
textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.hint-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.free { font-size: 11.5px; background: #e6f4ea; color: #2c6b3f; border-radius: 999px; padding: 2px 8px; margin-left: 4px; }
.game { margin-top: 16px; border: 2px solid var(--gold); background: #fff8e0; border-radius: 14px; padding: 12px; }
.switch { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--ink); font-size: 15px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--red); flex: none; }
.switch small { color: var(--muted); }
.game .hint-note b { color: var(--ink); }
.rel { display: inline-block; font-size: 12px; background: rgba(255,255,255,.75); border-radius: 999px; padding: 3px 9px; margin-bottom: 8px; align-self: flex-start; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 2px solid transparent; border-radius: 999px; padding: 8px 14px; background: #f3ece0; font-size: 14px;
}
.chip[aria-pressed="true"] { border-color: var(--ink); }
.dot { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px; font-size: 17px;
  background: var(--red); color: #fff; font-family: "Jua", sans-serif; letter-spacing: .3px;
  box-shadow: 0 4px 0 var(--red-d);
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-d); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.btn.light { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #d9cfbf; }
.btn + .btn, .btn + .row, .row + .btn { margin-top: 10px; }
.row { display: flex; gap: 8px; }
.row .btn { margin: 0; flex: 1; font-size: 15px; padding: 12px 8px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin: 10px 0 0; }

.steps { color: #fff; margin: 26px 0 0; display: grid; gap: 10px; }
.steps div { background: rgba(255,255,255,.08); border-radius: 14px; padding: 14px 16px; line-height: 1.5; font-size: 15px; }
.steps b { color: var(--gold); font-family: "Jua", sans-serif; font-weight: 400; margin-right: 6px; }

/* 롤페 */
.ptitle { text-align: center; color: #fff; padding: 18px 0 6px; }
.ptitle h1 { font-size: 28px; margin: 0; line-height: 1.3; }
.ptitle .count { margin-top: 6px; opacity: .85; }
/* 꾸미기 */
.board-wrap { position: relative; margin-top: 26px; }
.garland {
  position: absolute; left: 8px; right: 8px; top: -14px; height: 30px; z-index: 2; display: flex; justify-content: space-between;
  padding: 0 10px; pointer-events: none;
}
.garland::before {
  content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 22px;
  border-bottom: 2px solid #2f6b4a; border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.garland i {
  width: 11px; height: 15px; border-radius: 50% 50% 45% 45%; margin-top: 10px; position: relative;
  background: var(--gold); box-shadow: 0 0 10px 2px rgba(242,193,78,.8); animation: twinkle 1.6s ease-in-out infinite;
}
.garland i:nth-child(3n+1) { background: #ff6b6b; box-shadow: 0 0 10px 2px rgba(255,107,107,.8); animation-delay: .4s; }
.garland i:nth-child(3n+2) { background: #7ee0a8; box-shadow: 0 0 10px 2px rgba(126,224,168,.8); animation-delay: .8s; }
.garland i:nth-child(2n) { margin-top: 15px; }
@keyframes twinkle { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .garland i { animation: none; } }

.stk { position: absolute; top: -12px; right: -6px; font-size: 26px; transform: rotate(12deg); filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.note { position: relative; }
.note::before {
  content: ""; position: absolute; top: -8px; left: 50%; width: 46px; height: 16px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(255,255,255,.55); box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.chip.f-pen, .note.f-pen .body { font-family: "Nanum Pen Script", cursive; }
.chip.f-pen { font-size: 19px; }
.note.f-pen .body { font-size: 21px; line-height: 1.25; }
.chip.f-cute, .note.f-cute .body { font-family: "Gaegu", sans-serif; font-weight: 700; }
.note.f-cute .body { font-size: 16px; }
.env .stk { top: auto; bottom: 6px; right: 6px; font-size: 22px; transform: rotate(-8deg); }
.env.has-stk::after { display: none; }
.stickers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stickers button { border: 2px solid transparent; background: #f3ece0; border-radius: 12px; font-size: 22px; padding: 6px 0; }
.stickers button[aria-pressed="true"] { border-color: var(--ink); background: #fff; }
.preview-note { margin-top: 4px; min-height: 70px; }
.preview-note .body { color: var(--ink); }
.preview-note .body:empty::before { content: "여기에 쓴 쪽지가 이렇게 보여요"; color: var(--muted); }
.note.is-new { outline: 3px solid var(--gold); outline-offset: 2px; }
.new-tag { position: absolute; top: -10px; left: -6px; background: var(--red); color: #fff; font-size: 11px; font-family: "Jua", sans-serif; padding: 2px 7px; border-radius: 999px; z-index: 1; }

.news, .bell {
  margin-top: 12px; border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.news { background: #fff; color: var(--ink); box-shadow: 0 0 0 3px var(--gold); }
.bell { background: rgba(255,255,255,.12); color: #fff; }
.news p, .bell p { margin: 0; line-height: 1.4; font-size: 14.5px; }
.news button, .bell button { border: 0; border-radius: 12px; padding: 10px 12px; white-space: nowrap; font-family: "Jua", sans-serif; }
.news button { background: var(--red); color: #fff; }
.bell button { background: #fff; color: var(--ink); }

.board { background: #f7efe1; border-radius: 22px; padding: 30px 12px 20px; min-height: 260px;
  box-shadow: inset 0 0 0 6px #e9dcc4, 0 14px 34px rgba(0,0,0,.3);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: start;
}
.board.empty { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); line-height: 1.6; }
.env {
  aspect-ratio: 1 / .8; border-radius: 10px; position: relative; box-shadow: 0 3px 8px rgba(0,0,0,.12);
  transform: rotate(var(--r, 0deg));
}
.env::before {
  content: ""; position: absolute; inset: 0 0 45% 0; clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: rgba(0,0,0,.07); border-radius: 10px 10px 0 0;
}
.env::after { content: "♥"; position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); color: var(--red); font-size: 16px; }
.board.notes { grid-template-columns: 1fr 1fr; }
.note {
  border-radius: 12px; padding: 12px 12px 10px; font-size: 14.5px; line-height: 1.55; word-break: break-word;
  box-shadow: 0 3px 10px rgba(0,0,0,.12); transform: rotate(var(--r, 0deg)); display: flex; flex-direction: column;
}
.note .body { white-space: pre-wrap; flex: 1; }
.note .meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.note .x { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.lock {
  margin-top: 8px; width: 100%; border: 1.5px dashed rgba(0,0,0,.25); background: rgba(255,255,255,.55);
  border-radius: 10px; padding: 7px 6px; font-size: 13px;
}
.hint-open { margin-top: 8px; background: rgba(255,255,255,.7); border-radius: 10px; padding: 6px 8px; font-size: 13px; text-align: center; }
.hint-open b { font-family: "Jua", sans-serif; font-weight: 400; font-size: 17px; letter-spacing: 2px; color: var(--red-d); }
.c-cream { background: var(--cream); } .c-pink { background: var(--pink); } .c-mint { background: var(--mint); }
.c-sky { background: var(--sky); } .c-lilac { background: var(--lilac); } .c-lemon { background: var(--lemon); }

.bundle {
  margin-top: 14px; background: var(--gold); color: #3a2a00; border-radius: 16px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.bundle p { margin: 0; line-height: 1.4; font-size: 14.5px; }
.bundle button { border: 0; background: #3a2a00; color: #fff; border-radius: 12px; padding: 10px 14px; white-space: nowrap; font-family: "Jua", sans-serif; }

.sharebox { margin-top: 16px; }
.ownerkey { margin-top: 14px; color: #fff; font-size: 13px; opacity: .85; }
.ownerkey summary { cursor: pointer; }
.ownerkey code { display: block; margin-top: 8px; background: rgba(0,0,0,.25); padding: 10px; border-radius: 10px; word-break: break-all; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: none; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 11;
  background: var(--paper); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; display: none;
}
.sheet.open, .sheet-bg.open { display: block; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; }
.sheet .sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.sheet .close { position: absolute; right: 14px; top: 12px; border: 0; background: none; font-size: 24px; color: var(--muted); }
.policy { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 10px 0; }

.done { text-align: center; }
.done .big { font-size: 46px; margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(20,20,20,.9); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

footer { position: relative; z-index: 1; color: rgba(255,255,255,.6); font-size: 11.5px; line-height: 1.6; text-align: center; padding: 10px 16px 30px; max-width: 560px; margin: 0 auto; }
footer a { color: rgba(255,255,255,.8); }
.doc { background: var(--paper); border-radius: var(--radius); padding: 22px; line-height: 1.7; font-size: 15px; }
.doc h1 { font-size: 24px; margin-top: 0; }
.doc h2 { font-size: 18px; margin: 22px 0 6px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc td, .doc th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
