/* 판소리 한마당 — 웹툰 화풍: 한지 바탕, 먹선 칸, 말풍선 */
@font-face { font-family: 'HanmadangSerif'; src: url('../assets/fonts/myeongjo.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'HanmadangSerif'; src: url('../assets/fonts/myeongjo-bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'HanmadangBrush'; src: url('../assets/fonts/brush.woff2') format('woff2'); font-display: swap; }

:root {
  --paper: #f5ecdc;
  --paper-2: #eadcc1;
  --paper-3: #fffaf1;
  --ink: #221c18;
  --ink-2: #54483d;
  --ink-3: #8a7c6c;
  --line: 2px solid var(--ink);
  --seal: #b8352a;
  --coin: #b98318;        /* 벌이(엽전) */
  --coin-bg: #fbf0d4;
  --fame: #2f3f73;        /* 명성(먹빛 남색) */
  --fame-bg: #e6eaf6;
  --fiction: #1f7474;     /* 게임 설정(虛) */
  --fiction-bg: #e2f0ee;
  --interp: #6a4a8c;      /* 해석 */
  --interp-bg: #efe8f6;
  --tale: #8a5a1c;        /* 전해지는 이야기 */
  --tale-bg: #f7ebd6;
  --ok: #2f7a4b;
  --bad: #b8352a;
  --m-bijang: #3d58a8;    /* 비장 */
  --m-aejeol: #8a4c9e;    /* 애절 */
  --m-golgye: #d97a1e;    /* 골계 */
  --m-jangjung: #2b7a5c;  /* 장중 */
  --m-hwapyeong: #c8433a; /* 흥·화평 */
  --shadow: 3px 3px 0 rgba(34, 28, 24, .9);
  --shadow-soft: 0 4px 16px rgba(60, 40, 10, .16);
  --radius: 14px;
  --fs: 1;
  --serif: 'HanmadangSerif', 'Noto Serif KR', 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --sans: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  --brush: 'HanmadangBrush', var(--serif);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper) url('../assets/ui/paper.webp') repeat;
  background-size: 512px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: calc(16px * var(--fs));
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
b { font-weight: 800; }
h2, h3 { line-height: 1.35; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.muted { color: var(--ink-3); }
.small { font-size: .88em; }
.center { text-align: center; }
.sp { height: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ───────── 버튼 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: .5em 1.2em; border-radius: 12px;
  border: var(--line); background: var(--paper-3); color: var(--ink);
  font-weight: 800; letter-spacing: -.01em; box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s, background .2s, opacity .2s;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(34,28,24,.9); }
.btn.primary { background: var(--ink); color: var(--paper-3); }
.btn.accent { background: var(--seal); color: #fff; }
.btn.coin { background: var(--coin); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; }
.btn[disabled] { opacity: .38; pointer-events: none; }
button[hidden] { display: none; }
.btn.small { min-height: 38px; padding: .25em .8em; font-size: .88em; border-radius: 10px; }
.btn.wide { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: var(--line);
  background: var(--paper-3); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; flex: none; box-shadow: 2px 2px 0 rgba(34,28,24,.85);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.off { opacity: .55; }

/* ───────── 윗줄 ───────── */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(245, 236, 220, .94); backdrop-filter: blur(6px); border-bottom: var(--line);
}
.topbar .where { flex: 1; min-width: 0; line-height: 1.2; }
.topbar .where small { display: block; font-size: .72em; color: var(--ink-3); font-weight: 700; }
.topbar .where strong { font-size: .98em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.purse { display: flex; gap: 6px; font-weight: 800; font-size: .86em; }
.purse span { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; border: 1.5px solid currentColor; background: var(--paper-3); }
.purse .p-coin { color: var(--coin); }
.purse .p-fame { color: var(--fame); }
.pans { display: flex; gap: 4px; }
.pans i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--paper-3); }
.pans i.done { background: var(--ink); }
.pans i.now { background: var(--seal); border-color: var(--seal); }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.screen { flex: 1; display: flex; flex-direction: column; }
.hd { font-family: var(--serif); font-weight: 700; font-size: 1.25em; margin: 6px 0 10px; }
.hd small { display: block; font-family: var(--sans); font-size: .62em; color: var(--seal); font-weight: 800; letter-spacing: .08em; }

/* ───────── 타이틀 ───────── */
.title-screen { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 24px 16px 28px; text-align: center; overflow: hidden; }
.title-screen .art { position: absolute; inset: 0; background-size: cover; background-position: center 35%; }
.title-screen .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(245,236,220,.0) 0%, rgba(245,236,220,0) 45%, rgba(245,236,220,.9) 74%, var(--paper) 100%); }
.title-screen .logo { position: relative; margin-bottom: auto; margin-top: 4vh; }
.title-screen h1 { font-family: var(--brush); font-weight: 400; font-size: clamp(64px, 19vw, 118px); line-height: .95; margin: 0; color: var(--ink); text-shadow: 0 0 18px rgba(255,250,240,.95), 0 0 4px rgba(255,250,240,.9); }
.title-screen .sub { display: inline-block; margin-top: .5em; font-weight: 800; font-size: clamp(14px, 3.8vw, 18px); letter-spacing: .12em; color: #fff; background: var(--seal); padding: 3px 12px; border-radius: 6px; border: var(--line); box-shadow: var(--shadow); }
.title-screen .menu { position: relative; display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.title-screen .credit { position: relative; margin-top: 14px; font-size: .78em; color: var(--ink-2); }
.title-screen .music-toggle { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 2; }

/* ───────── 말풍선 ───────── */
.say { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start; margin: 0 0 12px; animation: rise .3s ease-out; }
.say.right { grid-template-columns: 1fr 56px; }
.say.right .say-pt { order: 2; }
.say-pt { width: 56px; height: 56px; border-radius: 50%; border: var(--line); object-fit: cover; background: var(--paper-3); }
.bubble { position: relative; background: #fff; border: var(--line); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); font-size: .96em; }
.bubble::before { content: ''; position: absolute; left: -9px; top: 16px; width: 14px; height: 14px; background: #fff; border-left: var(--line); border-bottom: var(--line); transform: rotate(45deg); }
.say.right .bubble::before { left: auto; right: -9px; transform: rotate(-135deg); }
.bubble .nm { display: block; font-size: .78em; font-weight: 800; color: var(--ink-2); margin-bottom: 2px; }
.tagbadge { display: inline-block; font-size: .72em; font-weight: 800; padding: 0 6px; border-radius: 4px; vertical-align: 1px; margin-left: 6px; }
.tagbadge.fiction { background: var(--fiction); color: #fff; }

/* ───────── 카드(사실·게임 설정·해석·일화) ───────── */
.card { position: relative; background: var(--paper-3); border: var(--line); border-radius: var(--radius); padding: 14px 16px 12px; box-shadow: var(--shadow); margin: 0 0 14px; }
.card .kind { display: inline-block; font-size: .72em; font-weight: 800; letter-spacing: .02em; padding: 1px 8px; border-radius: 6px; background: var(--ink); color: var(--paper-3); }
.card h3 { margin: 6px 0 4px; font-size: 1.04em; }
.card p { margin: 4px 0; }
.card .src { font-size: .78em; color: var(--ink-3); margin-top: 6px; }
.card.fiction { background: var(--fiction-bg); border-color: var(--fiction); box-shadow: 3px 3px 0 var(--fiction); }
.card.fiction .kind { background: var(--fiction); }
.card.interp { background: var(--interp-bg); border-color: var(--interp); box-shadow: 3px 3px 0 var(--interp); }
.card.interp .kind { background: var(--interp); }
.card.tale { background: var(--tale-bg); border-color: var(--tale); box-shadow: 3px 3px 0 var(--tale); }
.card.tale .kind { background: var(--tale); }
.card .real { margin-top: 8px; padding-top: 8px; border-top: 1.5px dashed rgba(34,28,24,.3); font-size: .94em; }

/* 원문 */
.orig { position: relative; background: #fbf5e6; border: 1.5px solid #c9b58f; border-radius: 10px; padding: 12px 14px 10px; margin: 10px 0; font-family: var(--serif); }
.orig .seal-mark { position: absolute; top: -10px; right: 10px; }
.seal-mark { display: inline-block; border: 2px solid var(--seal); color: var(--seal); font-family: var(--serif); font-weight: 700; padding: 0 6px; border-radius: 4px; transform: rotate(-4deg); font-size: .78em; background: #fff8ee; }
.orig .o-text { font-size: 1.02em; line-height: 1.85; white-space: pre-line; word-break: keep-all; }
.orig .o-modern { font-size: .9em; color: var(--ink-2); margin-top: 6px; white-space: pre-line; }
.orig .o-gloss { font-family: var(--sans); font-size: .88em; margin-top: 8px; padding-top: 6px; border-top: 1px dashed #c9b58f; }
.orig .o-src { font-family: var(--sans); font-size: .74em; color: var(--ink-3); margin-top: 4px; }
.orig.compact { padding: 8px 10px; }
.orig.compact .o-text { font-size: .92em; line-height: 1.7; }

/* 성격 태그·격 */
.mood { display: inline-block; font-size: .74em; font-weight: 800; color: #fff; padding: 1px 7px; border-radius: 999px; margin: 1px 2px 1px 0; }
.m-bijang { background: var(--m-bijang); }
.m-aejeol { background: var(--m-aejeol); }
.m-golgye { background: var(--m-golgye); }
.m-jangjung { background: var(--m-jangjung); }
.m-hwapyeong { background: var(--m-hwapyeong); }
.m-x { background: var(--ink-3); }
.gyeok { display: inline-block; font-size: .72em; font-weight: 800; padding: 0 6px; border-radius: 4px; border: 1.5px solid; margin-left: 2px; }
.gyeok.hi { color: var(--fame); }
.gyeok.lo { color: var(--seal); }
.len { display: inline-flex; gap: 2px; vertical-align: middle; }
.len i { width: 9px; height: 9px; border-radius: 2px; background: var(--ink); }

/* ───────── 시트·알림·풍선 ───────── */
.sheet-back { position: fixed; inset: 0; background: rgba(30, 20, 10, .42); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s; }
.sheet { background: var(--paper-3); width: min(640px, 100%); max-height: 88vh; overflow: auto; border: var(--line); border-bottom: none; border-radius: 20px 20px 0 0; padding: 18px 18px max(18px, env(safe-area-inset-bottom)); animation: up .25s ease-out; }
.sheet h3 { margin: 0 0 8px; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.sheet .actions .btn { flex: 1 1 auto; }
.sheet.choice .actions { flex-direction: column; }
.pop { position: fixed; z-index: 70; max-width: min(320px, 90vw); background: var(--ink); color: var(--paper-3); border-radius: 10px; padding: 8px 12px; font-size: .86em; line-height: 1.55; box-shadow: var(--shadow-soft); animation: fadein .15s; }
.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--paper-3); padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: .9em; box-shadow: var(--shadow-soft); animation: fadein .2s; pointer-events: none; max-width: 92vw; text-align: center; }
.coinfx { position: fixed; z-index: 90; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, transparent 2px, var(--coin) 3px); border: 2px solid #7d5a10; pointer-events: none; transition: transform .8s ease-out, opacity .9s; }
.shake { animation: shake .35s; }

/* ───────── 여정 지도·채집 ───────── */
.mapbox { position: relative; border: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 2 / 3; max-height: 62vh; margin: 0 auto 12px; background: var(--paper-2) center / cover no-repeat; }
.mapbox svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.pin b { background: var(--paper-3); border: var(--line); border-radius: 8px; padding: 0 6px; font-size: .74em; white-space: nowrap; box-shadow: 2px 2px 0 rgba(34,28,24,.8); }
.pin i { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper-3); margin-top: 2px; }
.pin.done i { background: var(--ink); }
.pin.here i { background: var(--seal); animation: ping 1.2s infinite; }
.pin.next i { background: var(--coin); }
.pin.stop b { background: #fff; font-weight: 700; }
.pin.stop i { width: 12px; height: 12px; border-width: 2px; }
.pin.stop.taken i { background: var(--fiction); }
.places { display: grid; gap: 10px; }
.place { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; text-align: left; border: var(--line); border-radius: 12px; background: var(--paper-3); padding: 8px; box-shadow: var(--shadow); }
.place img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1.5px solid var(--ink); }
.place .pl-name { font-weight: 800; }
.place .pl-hint { font-size: .84em; color: var(--ink-2); }
.place.sel { background: #fff3c7; }
.place.taken { opacity: .5; box-shadow: none; }
.scene-img { width: 100%; border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); aspect-ratio: 3 / 2; object-fit: cover; margin-bottom: 12px; background: var(--paper-2); }

/* 모티프 카드 */
.motif-card { position: relative; border: var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); padding: 12px 14px; margin: 8px 0 12px; animation: flipin .5s ease-out; }
.motif-card .mc-kind { display: inline-block; font-size: .72em; font-weight: 800; padding: 1px 8px; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--paper); }
.motif-card .mc-name { font-family: var(--serif); font-weight: 700; font-size: 1.12em; margin: 4px 0; }
.motif-card .mc-text { font-size: .92em; margin: 4px 0; }
.motif-card .mc-fits { font-size: .84em; color: var(--ink-2); }
.motif-card .mc-src { font-size: .76em; color: var(--ink-3); margin-top: 4px; }
.motif-card .sure { font-size: .72em; font-weight: 800; padding: 0 5px; border-radius: 4px; background: var(--paper-2); margin-left: 4px; }

/* ───────── 판 준비(짜기) ───────── */
.pan-head { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; margin-bottom: 12px; }
.pan-head img { width: 112px; height: 76px; border-radius: 10px; border: var(--line); object-fit: cover; }
.pan-head .ph-name { font-family: var(--serif); font-weight: 700; font-size: 1.15em; line-height: 1.25; }
.pan-head .ph-meta { font-size: .84em; color: var(--ink-2); }
.groups { display: grid; gap: 8px; margin-bottom: 12px; }
.grp { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; border: var(--line); border-radius: 12px; background: var(--paper-3); padding: 6px 10px 6px 6px; }
.grp img { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; }
.grp .g-name { font-weight: 800; font-size: .94em; }
.grp .g-name small { font-weight: 600; color: var(--ink-3); margin-left: 4px; }
.grp .g-likes { font-size: .82em; display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 2px; }
.grp .g-likes .lk { font-weight: 800; }
.grp .g-likes .up { color: var(--ok); }
.grp .g-likes .dn { color: var(--bad); }
.grp .g-likes .unk { color: var(--ink-3); font-weight: 600; }

.board { border: var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); padding: 10px 12px 12px; margin-bottom: 12px; }
.board .b-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.board .b-top b { font-size: .95em; }
.timebar { display: flex; gap: 3px; flex: 1; }
.timebar i { flex: 1; height: 14px; border-radius: 3px; border: 1.5px solid var(--ink); background: repeating-linear-gradient(90deg, #e9d9b5 0 3px, #dcc79c 3px 5px); }
.timebar i.used { background: var(--ink); }
.timebar i.over { background: var(--bad); border-color: var(--bad); }
.plan-empty { font-size: .9em; color: var(--ink-3); padding: 12px 4px; text-align: center; border: 2px dashed rgba(34,28,24,.25); border-radius: 10px; }
.plan-row { border: 1.5px solid var(--ink); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; background: var(--paper-3); }
.plan-row .pr-top { display: flex; align-items: center; gap: 8px; }
.plan-row .pr-name { font-weight: 800; flex: 1; min-width: 0; }
.plan-row .pr-name small { font-weight: 600; color: var(--ink-3); margin-left: 4px; }
.plan-row .pr-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.slot { min-height: 36px; min-width: 92px; padding: 3px 10px; border: 2px dashed rgba(34,28,24,.4); border-radius: 999px; font-size: .84em; font-weight: 700; background: transparent; color: var(--ink-3); }
.slot.filled { border-style: solid; border-color: var(--ink); color: var(--ink); background: #fff; }
.slot.target { border-color: var(--seal); color: var(--seal); background: #fff1ec; animation: pulse 1s infinite; }
.toggle { display: inline-flex; align-items: center; gap: 4px; font-size: .82em; font-weight: 800; min-height: 34px; padding: 2px 10px; border-radius: 999px; border: 1.5px solid var(--ink); background: #fff; }
.toggle.on { background: var(--seal); color: #fff; border-color: var(--seal); }
.x-btn { width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; font-weight: 800; flex: none; }

.hand-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 14px 0 6px; }
.hand-h b { font-size: 1em; }
.hand { display: flex; gap: 10px; overflow-x: auto; padding: 4px 4px 12px; scroll-snap-type: x proximity; }
.dm-card { flex: 0 0 168px; scroll-snap-align: start; text-align: left; border: var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); padding: 0 0 8px; overflow: hidden; display: flex; flex-direction: column; }
.dm-card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-bottom: var(--line); }
.dm-card .dc-body { padding: 6px 8px 0; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.dm-card .dc-name { font-weight: 800; font-size: .98em; line-height: 1.25; }
.dm-card .dc-meta { font-size: .76em; color: var(--ink-2); }
.dm-card.in { opacity: .45; box-shadow: none; }
.dm-card .dc-new { align-self: flex-start; font-size: .68em; font-weight: 800; background: var(--seal); color: #fff; padding: 0 6px; border-radius: 4px; }
.dm-card .dc-req { align-self: flex-start; font-size: .68em; font-weight: 800; background: var(--coin); color: #fff; padding: 0 6px; border-radius: 4px; }
.mo-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.mo-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 38px; padding: 3px 10px; border: 1.5px solid var(--ink); border-radius: 999px; background: #fff; font-size: .86em; font-weight: 700; text-align: left; }
.mo-chip.sel { background: #fff3c7; border-width: 2.5px; box-shadow: 2px 2px 0 var(--ink); }
.mo-chip.used { opacity: .4; }
.mo-chip .k { font-size: .76em; color: var(--ink-3); font-weight: 800; }
.prep-foot { position: sticky; bottom: 0; z-index: 20; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(245,236,220,0), var(--paper) 35%); }

/* ───────── 소리판 ───────── */
.stage-view { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 900px; margin: 0 auto; min-height: min(58vh, 500px); background: var(--paper-2) center / cover no-repeat; border-bottom: var(--line); overflow: hidden; }
.stage-view .meters { position: relative; margin: 8px; display: grid; gap: 4px; }
.meter { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; background: rgba(255,250,241,.9); border: 1.5px solid var(--ink); border-radius: 10px; padding: 2px 8px; font-size: .76em; font-weight: 800; }
.meter .bar { height: 10px; border-radius: 5px; background: #e5d7bd; overflow: hidden; border: 1px solid rgba(34,28,24,.4); }
.meter .fill { height: 100%; width: 50%; background: linear-gradient(90deg, #d97a1e, #c8433a); transition: width .6s ease-out; }
.meter .fill.cold { background: #7b8aa8; }
.meter .cnt { font-variant-numeric: tabular-nums; }
.stage-view .pops { position: absolute; left: 0; right: 0; top: 30%; bottom: 20%; pointer-events: none; }
.pop-b { position: absolute; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 2px 10px; font-weight: 800; font-size: .88em; white-space: nowrap; box-shadow: 2px 2px 0 rgba(34,28,24,.85); animation: popb 1.8s ease-out forwards; }
.pop-b.good { color: var(--seal); }
.pop-b.bad { color: #5b6b8a; background: #eef1f7; }
.pop-b.jw { font-family: var(--serif); }
.stage-view .now { position: relative; display: flex; align-items: flex-end; gap: 8px; margin: auto 8px 8px; padding-top: 64px; }
.stage-view .now img { width: 76px; height: 76px; border-radius: 50%; border: var(--line); background: var(--paper-3); object-fit: cover; flex: none; }
.stage-view .now .gosu-pt { width: 52px; height: 52px; }
.now-box { flex: 1; min-width: 0; background: rgba(255,255,255,.95); border: var(--line); border-radius: 14px; padding: 6px 10px; box-shadow: var(--shadow); }
.now-box .nb-name { font-weight: 800; font-size: .92em; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.now-box .nb-jd { font-size: .74em; font-weight: 800; color: var(--ink-2); border: 1.5px solid var(--ink-2); border-radius: 6px; padding: 0 5px; }
.now-box .nb-line { font-family: var(--serif); font-size: .92em; line-height: 1.55; margin-top: 2px; min-height: 1.5em; }
.tagbadge.original { color: var(--seal); border: 1px solid var(--seal); background: var(--paper-3); }
.now-box .btn { margin-top: 6px; }
.reaction-history { margin-top: 12px; font-size: .88em; }
.reaction-history summary { cursor: pointer; min-height: 44px; padding: 8px 0; font-weight: 800; }
.reaction-entry { border-top: 1px dashed var(--ink-3); padding: 8px 0; }
.reaction-entry p { margin: 3px 0; }
@media (max-width: 520px) {
  .stage-view .now { flex-wrap: wrap; justify-content: space-between; }
  .stage-view .now img { width: 48px; height: 48px; }
  .stage-view .now .gosu-pt { width: 40px; height: 40px; }
  .stage-view .now .now-box { flex: 1 0 100%; order: 1; }
  .btn.small, .slot, .toggle, .mo-chip, .tab { min-height: 44px; }
  .x-btn { width: 44px; height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .plan-row .pr-top { flex-wrap: wrap; }
}
.stage-below { width: 100%; max-width: 900px; margin: 0 auto; padding: 10px 16px 24px; }
.seglist { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 10px; }
.seglist span { font-size: .74em; font-weight: 800; padding: 1px 7px; border-radius: 6px; border: 1.5px solid var(--ink-3); color: var(--ink-3); }
.seglist span.done { border-color: var(--ink); color: var(--ink); background: #fff; }
.seglist span.cur { border-color: var(--seal); color: #fff; background: var(--seal); }
.seglist span.mis { text-decoration: line-through wavy var(--bad); }
.feed { font-size: .86em; }
.feed p { margin: 3px 0; }
.feed .up { color: var(--ok); font-weight: 800; }
.feed .dn { color: var(--bad); font-weight: 800; }

/* ───────── 셈(장부) ───────── */
.ledger { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 12px; }
.ledger .col { border: var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.ledger .col.pay { background: var(--coin-bg); }
.ledger .col.fame { background: var(--fame-bg); }
.ledger h4 { margin: 0 0 6px; font-size: .92em; }
.ledger .col.pay h4 { color: var(--coin); }
.ledger .col.fame h4 { color: var(--fame); }
.ledger .ln { display: flex; justify-content: space-between; gap: 6px; font-size: .82em; padding: 3px 0; border-bottom: 1px dashed rgba(34,28,24,.2); opacity: 0; transform: translateY(4px); transition: opacity .3s, transform .3s; }
.ledger .ln.show { opacity: 1; transform: none; }
.ledger .ln b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger .ln.minus b { color: var(--bad); }
.ledger .ln.plus b { color: var(--ok); }
.ledger .tot { display: flex; justify-content: space-between; font-weight: 800; margin-top: 6px; font-size: 1.02em; }
.ledger .axis { font-size: .7em; font-weight: 800; color: var(--fame); border: 1px solid var(--fame); border-radius: 4px; padding: 0 3px; margin-right: 3px; }
@media (max-width: 520px) { .ledger { grid-template-columns: 1fr; } }

/* ───────── 결과 ───────── */
.result-hero { text-align: center; border: var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); padding: 16px; margin: 6px 0 14px; }
.result-hero .rh-pt { width: 104px; height: 104px; border-radius: 50%; border: var(--line); margin: 0 auto 6px; object-fit: cover; }
.result-hero .rh-title { font-family: var(--brush); font-size: 2.3em; line-height: 1.1; }
.result-hero .rh-sub { font-size: .9em; color: var(--ink-2); }
.axes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 0; }
.axes div { border: 1.5px solid; border-radius: 10px; padding: 6px; font-weight: 800; }
.axes .a-pay { color: var(--coin); background: var(--coin-bg); }
.axes .a-fame { color: var(--fame); background: var(--fame-bg); }
.axes div span { display: block; font-size: 1.5em; }
.bars { display: grid; gap: 6px; margin: 8px 0; }
.bars .br { display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: center; font-size: .82em; }
.bars .br .bb { display: grid; gap: 2px; }
.bars .br .bb i { height: 9px; border-radius: 3px; }
.bars .br .bb i.p { background: var(--coin); }
.bars .br .bb i.f { background: var(--fame); }
.bars .br .bb i.neg { background: var(--bad); }
.my-ch { border: var(--line); border-radius: var(--radius); background: #fbf5e6; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 14px; }
.my-ch h3 { font-family: var(--serif); margin: 0 0 8px; }
.mc-row { border-left: 4px solid var(--ink); padding: 4px 0 4px 10px; margin-bottom: 8px; }
.mc-row .mr-name { font-weight: 800; }
.mc-row .mr-layers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.mc-row .mr-layers span { font-size: .78em; border: 1.5px solid var(--ink-3); border-radius: 6px; padding: 0 6px; background: #fff; }
.mc-row .mr-layers span.mis { border-color: var(--bad); color: var(--bad); }
.mc-row.deonum { border-left-color: var(--seal); }
.name-input { min-height: 46px; padding: 8px 12px; border-radius: 12px; border: var(--line); font: inherit; width: 100%; background: #fff; }

/* ───────── 편람·겹창 ───────── */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: flex; flex-direction: column; animation: fadein .15s; }
.overlay .body { flex: 1; overflow: auto; }
.tabs { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: var(--line); background: var(--paper-2); }
.tab { flex: none; min-height: 38px; padding: 3px 12px; border-radius: 10px; border: 1.5px solid var(--ink); background: var(--paper-3); font-weight: 800; font-size: .88em; }
.tab.on { background: var(--ink); color: var(--paper-3); }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dex-item { border: 1.5px solid var(--ink); border-radius: 10px; background: #fff; padding: 8px; font-size: .86em; text-align: left; }
.dex-item.locked { background: repeating-linear-gradient(135deg, #efe4cf 0 6px, #e8dac0 6px 12px); color: var(--ink-3); }
.dex-item b { display: block; }
.term { border-bottom: 1px dashed rgba(34,28,24,.25); padding: 8px 0; }
.term b { font-family: var(--serif); font-size: 1.05em; }

/* 넓은 화면 */
@media (min-width: 900px) {
  .prep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .wrap.wide { max-width: 1120px; }
  .hand { flex-wrap: wrap; overflow: visible; }
}

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(40px); } to { transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes flipin { from { transform: rotateY(90deg) scale(.9); } to { transform: none; } }
@keyframes ping { 0%, 100% { box-shadow: 0 0 0 0 rgba(184,53,42,.6); } 50% { box-shadow: 0 0 0 8px rgba(184,53,42,0); } }
@keyframes pulse { 0%, 100% { transform: none; } 50% { transform: scale(1.04); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes popb { 0% { opacity: 0; transform: translateY(10px) scale(.8); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (max-width: 520px) {
  .tab { min-height: 44px; }
  .stage-below > .row > b { flex-basis: 100%; }
}

/* 좁은 휴대폰: 윗줄의 판 진행 점을 숨겨 판 이름이 잘리지 않게(작은 글씨 'n판 · …'이 진행을 알려 준다) */
@media (max-width: 440px) {
  .topbar .pans { display: none; }
  .topbar .where strong { font-size: .92em; }
}
