:root {
  /* 양피지 톤 테마 — 색은 여기서만 바꾸면 전체에 적용돼요 */
  --bg: #e6d6b6;          /* 바탕 양피지 */
  --surface: #f6eedb;     /* 카드 종이 */
  --surface-2: #eadbbd;   /* 버튼·입력칸 */
  --border: #b99c6e;      /* 낡은 갈색 테두리 */
  --text: #2b2017;        /* 잉크 */
  --muted: #76644c;
  --accent: #8a571c;      /* 청동빛 */
  --accent-ink: #fff6e0;
  --danger: #9e2b25;
  --s0: #a8552e; --s1: #36598a; --s2: #4c7536; --s3: #8a3f6e;  /* 힘·지능·민첩·사교 */
  --radius: 6px;
  --serif: "Gowun Batang", "Nanum Myeongjo", "Noto Serif KR", "Batang", serif;
  --sans: "Noto Sans KR", "Pretendard", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
  background-color: var(--bg);
  /* 가운데는 밝고 가장자리는 그을린 양피지 + 종이 결 */
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(255, 250, 236, .65) 0%, rgba(255, 250, 236, 0) 55%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(88, 58, 24, .32) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
a { color: var(--accent); }
h1 { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; margin: .1rem 0 .3rem; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px;
  background: linear-gradient(180deg, #3d2915 0%, #2a1a0d 100%);
  border-bottom: 3px double #b48b47;
  box-shadow: 0 2px 10px rgba(40, 24, 8, .35);
}
.topbar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: #ead7ad; text-decoration: none; }
.topbar nav a:hover { color: #f3cf86; }
.topbar .muted, .topbar button.link { color: #b9a47e; }
.brand { font-family: var(--serif); color: #edc77c; font-size: 1.15rem; font-weight: 700; text-decoration: none; letter-spacing: .06em; }
.foot { text-align: center; padding: 24px; font-size: .8rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.15rem; font-weight: 600; margin: 0; }
.eyebrow { color: var(--accent); font-size: .8rem; font-weight: 600; margin: 0 0 .3rem; }
.warn { color: var(--danger); }
.center { text-align: center; }
.inline { display: inline; }

.flash {
  max-width: 1100px; margin: 16px auto 0; padding: 10px 16px;
  background: #f4e3b9; border: 1px solid var(--accent); border-radius: var(--radius); color: var(--text);
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card.tight { padding: 14px 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
fieldset { border: none; padding: 0; margin: 0; }
legend { font-weight: 500; margin-bottom: 8px; }

button, .button {
  font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 16px;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--muted); padding: 0; }
.wide { width: 100%; justify-content: center; padding: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex-direction: row; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-weight: 400; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .8rem; }

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.option { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-weight: 400; }
.option span { width: 100%; }
.option-btn { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.option-btn.recommended { border-color: var(--accent); }

/* 슬롯 */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.slot { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.danger-zone summary { color: var(--muted); cursor: pointer; font-size: .85rem; }
.danger-zone form { margin-top: 8px; }

/* 플레이 화면 */
.play { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 16px; }
.stat { margin-bottom: 10px; }
.stat-head { display: flex; justify-content: space-between; font-size: .9rem; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.fill { height: 100%; }
.fill.c0 { background: var(--s0); } .fill.c1 { background: var(--s1); }
.fill.c2 { background: var(--s2); } .fill.c3 { background: var(--s3); }
.fill.fatigue { background: var(--danger); }

.story { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.log { max-height: 55vh; overflow-y: auto; padding-right: 8px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 18px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.line { margin: 4px 0; padding-left: 12px; }
.line.daily { color: var(--muted); }
.line.event { border-left: 2px solid var(--accent); }
.line.system { color: var(--accent); }

/* 타이핑 연출 */
.line.pending, .divider.pending { display: none; }
.line.typing::after { content: "▍"; color: var(--accent); margin-left: 1px; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.actions { transition: opacity .25s ease; }
.actions.waiting { opacity: 0; pointer-events: none; }
.skip-hint { margin: -8px 0 0; text-align: right; }
.verdict { display: inline-block; font-size: .78rem; font-weight: 700; padding: 0 7px; border-radius: 4px; margin-right: 2px; vertical-align: 1px; }
.verdict.ok { background: rgba(76, 117, 54, .15); color: var(--s2); }
.verdict.fail { background: rgba(158, 43, 37, .13); color: var(--danger); }

.event-text { font-size: 1.05rem; margin: 0 0 12px; }
.choice { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.coop { padding: 10px 14px; border: 1px dashed var(--border); border-radius: 8px; }
.coop.open { border-style: solid; border-color: var(--accent); }
.price { color: var(--accent); font-weight: 600; font-size: .85rem; margin-left: 6px; }

/* 승급 시험 */
.promo { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); }
.promo.ready { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.promo.maxed { display: flex; gap: 10px; align-items: baseline; }
.promo-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.promo-text { margin: 0; }
.promo-odds { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.promo-odds .big { font-size: 1.6rem; color: var(--accent); }
.req-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.req-list li { display: grid; grid-template-columns: 76px 1fr 64px 64px; gap: 10px; align-items: center; font-size: .9rem; }
.req-bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.req-bar span { display: block; height: 100%; background: var(--danger); }
.req-list li.ok .req-bar span { background: var(--s2); }
.req-num { text-align: right; }
.req-mark { font-size: .8rem; text-align: right; }
.req-list li.ok .req-mark { color: var(--s2); }
.req-list li.short .req-mark { color: var(--danger); }

/* 게시판 */
.row.tight { gap: 6px; align-items: center; }
.row.between { justify-content: space-between; align-items: flex-start; }
.small-btn { padding: 5px 10px; font-size: .85rem; }
.board-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 7px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; border: 1px solid transparent; }
.tab.on { color: var(--text); border-color: var(--border); background: var(--surface); font-weight: 600; }
.as-char { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-label { flex-direction: row; }
select { padding: 6px 10px; }
.post-list { list-style: none; padding: 0; margin: 8px 0 0; }
.post-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.post-list li:last-child { border-bottom: none; }
.post-title { color: var(--text); text-decoration: none; font-weight: 500; }
.post-title:hover { color: var(--accent); }
.count { color: var(--accent); font-size: .85rem; }
.post-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.author { display: inline-flex; gap: 6px; align-items: baseline; }
.author-name { font-weight: 600; color: var(--text); text-decoration: none; }
a.author-name:hover { color: var(--accent); }
.author-name.gone { color: var(--muted); }
.author-tag { font-size: .75rem; color: var(--accent); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.post-body { white-space: pre-wrap; margin: 18px 0 6px; line-height: 1.75; }
.right { text-align: right; }
.danger-link { color: var(--danger) !important; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-body { white-space: pre-wrap; margin: 4px 0 0; }
.comment-form { display: flex; gap: 8px; margin-top: 14px; align-items: flex-end; }
.comment-form textarea { flex: 1; }
.empty { padding: 28px 0; text-align: center; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pager a { padding: 4px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.pager a.on { color: var(--accent-ink); background: var(--accent); }
main > .card + .card, main > article + .card { margin-top: 16px; }
.profile-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 16px; }
.eyebrow.gap { margin-top: 18px; }
@media (max-width: 760px) { .profile-grid { grid-template-columns: 1fr; } }

/* 데이터 확인 페이지 */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: 28px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--bg); }
.data-table tr.first td { border-top: 1px solid var(--accent); }
.warn-box { border: 1px solid var(--danger); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; }
.ok-box { border: 1px solid var(--s2); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; }
.table-wrap { overflow-x: auto; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; align-items: end; }
.adult { display: flex; flex-direction: column; gap: 18px; }
.quests { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.quest { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }

@media (max-width: 760px) {
  .play { grid-template-columns: 1fr; }
  .panel { position: static; }
  /* 휴대폰에서도 대화 내용은 자기 상자 안에서만 스크롤 (페이지가 끝없이 길어지지 않게) */
  .log { max-height: 48vh; max-height: 48svh; overscroll-behavior: contain; }
}
.err-detail { white-space: pre-wrap; font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: 10px; border-radius: 8px; }

/* 칭호·특별 능력치 */
.stat-head.special { padding: 6px 10px; margin-bottom: 8px; border-radius: 6px; border: 1px dashed var(--accent); }
.stat-head.special b { color: var(--accent); }
.tag.title-tag { border-color: var(--accent); color: var(--accent); }

/* 마을·메인 스토리·NPC·계정 보너스 */
.job-pill { font-size: .75rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 8px; }
.bonus-note { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; padding: 10px 14px; margin-bottom: 16px; border: 1px dashed var(--accent); border-radius: 8px; }
.story-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.story-card.ready { border-color: var(--s1); box-shadow: inset 3px 0 0 var(--s1); }
.story-card .eyebrow { color: var(--s1); }
.story-next { font-weight: 600; margin: 0; }
.chapter-dots { list-style: none; display: flex; gap: 6px; padding: 0; margin: 10px 0 12px; }
.chapter-dots li { width: 22px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.chapter-dots li.done { background: var(--s1); border-color: var(--s1); }
.chapter-dots li.now { border-color: var(--s1); }
.npc-line { margin: 0 0 6px; }
.npc-name { font-weight: 700; color: var(--s1); }
.account-bonus { margin-top: 20px; }
.bonus-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.bonus-list li { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); }
.bonus-list li.on { color: var(--text); }
.bonus-list li div { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.bonus-mark { width: 20px; text-align: center; }
.bonus-list li.on .bonus-mark { color: var(--s2); }


/* ===== 양피지 테마 마무리 ===== */
.card {
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 3px 10px rgba(70, 44, 14, .14);
  outline: 1px solid rgba(185, 156, 110, .45); outline-offset: -6px;   /* 안쪽 테두리 한 줄 더 */
}
input, textarea, select { background: #fbf6ea; }
button, .button { background: var(--surface-2); }
.primary {
  background: linear-gradient(180deg, #a8742c 0%, #7d4f19 100%);
  color: var(--accent-ink); border-color: #6b4214;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.primary:hover:not(:disabled) { border-color: #4f300c; filter: brightness(1.06); }
.eyebrow { letter-spacing: .03em; }
.big { font-family: var(--serif); }

/* 이야기 글은 명조체로, 줄바꿈 그대로 */
.log .line { font-family: var(--serif); font-size: 1.02rem; line-height: 1.85; white-space: pre-line; }
.log .line.daily { font-size: .95rem; }
.line.choice { color: var(--accent); font-weight: 700; margin-top: 10px; }
.line.choice::before { content: "▸ "; }
.divider { font-family: var(--serif); color: var(--accent); }
.divider::before, .divider::after { border-top-color: rgba(138, 87, 28, .35); }
.choice { font-family: var(--serif); font-size: 1rem; }
.routine { color: var(--s2); margin: 4px 0 0; }
.npc-row b { color: var(--s3); }
.tag { background: #efe2c4; }
.foot { color: var(--muted); font-family: var(--serif); }

/* ===== HP · 글 속도 · 전투 ===== */
.fill.hp { background: linear-gradient(90deg, #5e9a48, #7fbf5e); }
.speed-bar { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin: -6px 0 0; }
.speed-bar .muted { margin-right: 4px; }
.speed-bar button { padding: 2px 10px; font-size: .8rem; }
.speed-bar button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.combat { position: relative; border-radius: var(--radius); overflow: hidden; border: 3px double #6b4a22; background: #16202a; touch-action: manipulation; user-select: none; }
.combat canvas { display: block; width: 100%; height: auto; aspect-ratio: 720 / 420; cursor: pointer; }
.combat-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 20px; background: rgba(18, 14, 9, .78); color: #f3e7cc;
}
.combat-overlay[hidden] { display: none; }
.combat-overlay .muted { color: #c9b896; }
.combat-title { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; margin: 0 0 4px; color: #ffd76a; }
kbd { font-family: var(--sans); font-size: .8em; padding: 1px 6px; border: 1px solid #c9b896; border-bottom-width: 2px; border-radius: 4px; }
.warn-light { color: #ff9c86; }
.choice.locked { opacity: .55; cursor: not-allowed; }
.ok-text { color: #4c7a3a; }
.coop-members { list-style: none; padding: 0; margin: 6px 0 10px; display: grid; gap: 4px; }
.coop-members li { display: flex; justify-content: space-between; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.04); font-size: .92rem; }
.coop-members li.st-won b { color: #4c7a3a; }
.coop-members li.st-lost b, .coop-members li.st-spectating b { color: var(--muted, #8a7a66); }
.coop-members li.st-fighting b { color: var(--accent); }
.room-code { margin: 4px 0 8px; }
.room-code b { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .15em; padding: 2px 8px; border: 1px dashed var(--accent); border-radius: 6px; }
.code-join { display: flex; gap: 6px; margin: 6px 0 10px; }
.code-join input { flex: 1; min-width: 0; letter-spacing: .1em; }
label.private-toggle { display: flex; flex-direction: row; gap: 8px; align-items: center; justify-content: flex-start; text-align: left; grid-column: 1 / -1; margin: 0; }
.private-toggle input { width: auto; margin: 0; flex: none; }
.fill.mana { background: linear-gradient(90deg, #5b7fd6, #9a7fe0); }
