/* 의천 - 수묵화 스타일 */
:root {
  --paper: #efe6d2;
  --paper-2: #e5d9bf;
  --paper-3: #f7f1e3;
  --ink: #1f1a14;
  --ink-2: #4a4036;
  --ink-3: #7a6d5d;
  --line: #c9b99a;
  --seal: #a8261b;
  --seal-2: #c8442f;
  --jade: #2f6b5a;
  --gold: #9a7428;
  --qi: #2e5d8a;
  --hp: #9b2c22;
  --shadow: 0 8px 30px rgba(31, 26, 20, .25);
  --display: 'Song Myung', 'Batang', serif;
  --body: 'Gowun Batang', 'Batang', 'Noto Serif KR', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, .5), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 90, 50, .12), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
}
button {
  font: inherit; color: inherit; cursor: pointer;
  background: var(--paper-3); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 12px; transition: background .15s, border-color .15s, transform .05s;
}
button:hover:not(:disabled) { background: #fff; border-color: var(--ink-3); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--ink); color: var(--paper-3); border-color: var(--ink); }
button.primary:hover:not(:disabled) { background: #3a3128; }
button.seal { background: var(--seal); color: #fff; border-color: var(--seal); }
button.seal:hover:not(:disabled) { background: var(--seal-2); }
button.ghost { background: transparent; }
input[type=text] {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--paper-3); color: var(--ink); width: 100%;
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.realm-box {
  display: flex; align-items: baseline; gap: 8px; padding: 8px 0 10px; border-top: 1px solid var(--line);
}
.realm-box .rn { font-family: var(--display); font-size: 30px; }
.realm-box .rh { color: var(--ink-3); font-size: 16px; }
.bar-row { margin: 6px 0; }
.bar-row .lbl { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.bar { height: 7px; background: var(--paper-2); border-radius: 4px; overflow: hidden; margin-top: 2px; }
.bar > i { display: block; height: 100%; border-radius: 4px; transition: width .3s; }
.bar.hp > i { background: var(--hp); }
.bar.qi > i { background: var(--qi); }
.bar.ins > i { background: var(--gold); }
.bar.mas > i { background: var(--jade); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 10px 0; padding-top: 10px; border-top: 1px solid var(--line); }
.stat { display: flex; justify-content: space-between; }
.stat span { color: var(--ink-3); }
.res { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.res div { display: flex; justify-content: space-between; }
.res span { color: var(--ink-3); }
.active-arts { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }

/* ── 지도 ── */
.world { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@keyframes pulse { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

/* ── 장소 ── */
.place-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.place-head h2 { font-size: 26px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-2); }
.tag.sect { border-color: var(--seal); color: var(--seal); }
.tag.wild { border-color: var(--jade); color: var(--jade); }
.acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.act { text-align: left; padding: 8px 12px; }
.act b { display: block; font-weight: 700; }
.act small { color: var(--ink-3); font-size: 12px; }
.act.danger { border-color: var(--seal); }
.act.danger b { color: var(--seal); }

/* ── 모달 ── */
#modal:empty { display: none; }
.overlay {
  position: fixed; inset: 0; background: rgba(31, 26, 20, .45); display: grid; place-items: center;
  padding: 16px; z-index: 10; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  background: var(--paper-3); border: 1px solid var(--ink-3); border-radius: 6px; box-shadow: var(--shadow);
  width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 24px;
  background-image: linear-gradient(var(--paper-3), var(--paper-3)), radial-gradient(circle at 0 0, var(--paper-2), transparent);
}
.dialog.wide { width: min(900px, 100%); }
.next-arts { margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.next-arts span { display: inline-block; margin-right: 6px; }
.next-open { color: #3f8a58; }
.next-lock { color: var(--ink-3); }
.dialog.sv-dlg { width: min(640px, 100%); text-align: center; }
.sv-lead, .sv-note { color: var(--ink-2); font-size: 14px; margin: 4px 0 10px; }
.sv-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sv-sec h3 { font-size: 20px; margin-bottom: 4px; }
.sv-sum { font-family: var(--display); font-size: 15px; margin: 4px 0 8px; }
.sv-code { width: 100%; height: 108px; resize: vertical; padding: 8px 10px; font: 12px/1.45 ui-monospace, Consolas, monospace; word-break: break-all;
  background: #f7f1e3; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); }
.row-btns.sv-btns { justify-content: center; margin-top: 8px; }
.dialog h2 { font-size: 26px; margin-bottom: 4px; }
.dialog .body { margin: 12px 0 18px; white-space: normal; }
.dialog .row-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dialog .choices { display: flex; flex-direction: column; gap: 8px; }
.dialog .choices button { text-align: left; padding: 10px 14px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.close-x { border: none; background: none; font-size: 22px; padding: 0 6px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .35);
}
.item .nm { font-weight: 700; }
.item .ds { grid-column: 1; font-size: 13px; color: var(--ink-3); }
.item .btns { grid-row: 1 / span 3; grid-column: 2; display: flex; gap: 6px; }
.item.on { border-color: var(--jade); box-shadow: inset 3px 0 0 var(--jade); }
.group-title { font-family: var(--display); font-size: 18px; margin: 14px 0 6px; }

table.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rank th, table.rank td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.rank th { font-weight: 400; color: var(--ink-3); font-size: 12px; }
table.rank tr.me td { background: rgba(168, 38, 27, .08); font-weight: 700; }
table.rank tr.beat td { color: var(--ink-3); text-decoration: line-through; }
table.rank td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── 전투 ── */
.battle .fighters { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.fighter { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; background: rgba(255, 255, 255, .4); }
.fighter.enemy { border-color: var(--seal); }
.fighter .fn { font-family: var(--display); font-size: 19px; }
.fighter .fr { font-size: 12px; color: var(--ink-3); }
.fighter .st { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.vs { font-family: var(--display); font-size: 28px; color: var(--seal); }
.blog {
  height: 230px; overflow-y: auto; margin: 12px 0; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .3);
}
.blog p { margin: 0 0 6px; }
.blog .p { color: var(--ink); }
.blog .e { color: var(--hp); }
.blog .sys { color: var(--ink-3); text-align: center; font-style: italic; }
.bacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.bacts button { text-align: left; padding: 7px 10px; }
.bacts button small { display: block; font-size: 11px; color: var(--ink-3); }
.bacts .sep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 2px 0; }
.name-row { display: flex; gap: 8px; max-width: 420px; }
.name-row button { white-space: nowrap; }

/* ── 토스트 ── */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper-3); padding: 10px 18px; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 반응형 ── */
@media (max-width: 600px) {
  .battle .fighters { grid-template-columns: 1fr; }
  .vs { text-align: center; font-size: 20px; }
  .dialog { padding: 18px 16px; }
}

/* ── 칭호·관계·인물 ── */
.titles { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 8px; }
.tag.gold { border-color: var(--gold); color: var(--gold); }
.rel { font-size: 11px; padding: 0 6px; border-radius: 8px; margin-left: 4px; color: #fff; background: var(--ink-3); white-space: nowrap; }
.rel-sabu { background: var(--jade); }
.rel-sahyeongje { background: #6f8a8f; }
.rel-friend { background: var(--gold); }
.rel-rival { background: #4f86a8; }
.rel-enemy { background: var(--hp); }
.rel-spouse { background: #d4577a; }
.npc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.favor { position: relative; height: 7px; background: var(--paper-2); border-radius: 4px; margin-top: 2px; }
.favor i { position: absolute; top: 0; height: 100%; background: var(--jade); border-radius: 4px; }
.favor::after { content: ''; position: absolute; left: 50%; top: -2px; width: 1px; height: 11px; background: var(--ink-3); }
button.link { border: none; background: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
ul.chron { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow-y: auto; }
ul.chron li { padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
ul.chron .when { display: inline-block; min-width: 92px; color: var(--ink-3); font-size: 12px; }

/* ── 장비 ── */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 6px; }
.slot-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .35); }
.slot-card button { align-self: flex-start; margin-top: 4px; padding: 2px 10px; font-size: 13px; }
.item.legend { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }

/* ── 실시간 전투 ── */
.overlay.combat-wrap { padding: 0; background: #2a241d; display: block; overflow: hidden; }
.cb-root { width: 100%; height: 100%; }
.cb { display: flex; flex-direction: column; height: 100vh; max-width: 1400px; margin: 0 auto; padding: 10px 14px; gap: 8px; color: var(--paper-3); }
.cb-top { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; }
.cb-name { font-family: var(--display); font-size: 18px; }
.cb-name span { font-family: var(--body); font-size: 12px; opacity: .7; }
.cb-bar { position: relative; height: 14px; background: rgba(239, 230, 210, .2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.cb-bar i { position: absolute; inset: 0 auto 0 0; background: #c0392b; transition: width .1s; }
.cb-bar.qi i { background: #3a76b0; }
.cb-bar span { position: absolute; left: 6px; top: 0; font-size: 11px; line-height: 14px; }
.cb-mid { text-align: center; }
.cb-title { font-family: var(--display); font-size: 24px; letter-spacing: 4px; }
.cb-time { font-size: 12px; opacity: .7; }
.cb-foes { display: flex; flex-direction: column; gap: 4px; }
.cb-foe .cb-name { font-size: 15px; text-align: right; }
.cb-foe.dead { opacity: .35; }
.cb-stage { position: relative; flex: 1; min-height: 0; border-radius: 6px; overflow: hidden; box-shadow: 0 6px 30px rgba(0, 0, 0, .4); }
.cb-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(31, 26, 20, .6); text-align: center; padding: 16px; }
.cb-over[hidden] { display: none; }
.cb-over h2 { font-size: 34px; }
.cb-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cb-btns button { color: var(--ink); }
.cb-btns button.seal, .cb-btns button.primary { color: #fff; }
.cb-help { font-size: 13px; opacity: .85; max-width: 640px; line-height: 1.7; }
.cb-big { font-family: var(--display); font-size: 120px; line-height: 1; color: var(--seal-2); text-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.cb-big.lose { color: #9aa0a6; }
.cb-big.flee { color: #8fb3cc; }
.cb-dock { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.cb-slots, .cb-side { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-slot { position: relative; overflow: hidden; width: 104px; height: 62px; padding: 4px 6px; text-align: left; background: rgba(239, 230, 210, .92); color: var(--ink); border-color: rgba(0, 0, 0, .3); }
.cb-slot b { display: block; font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-slot small { font-size: 11px; color: var(--ink-3); }
.cb-key { position: absolute; right: 4px; top: 2px; font-size: 10px; color: var(--ink-3); }
.cb-slot.item, .cb-slot.tog { width: 78px; }
.cb-slot.gad { width: 96px; }
.cb-cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(31, 26, 20, .55); pointer-events: none; }
.cb-slot.noqi { box-shadow: inset 0 0 0 2px #3a76b0; }
.cb-slot.noqi b { color: #3a76b0; }
@media (max-width: 700px) {
  .cb { padding: 6px; }
  .cb-top { grid-template-columns: 1fr 1fr; }
  .cb-mid { display: none; }
  .cb-slot { width: 74px; height: 54px; }
  .cb-slot.item, .cb-slot.tog { width: 62px; }
  .cb-big { font-size: 80px; }
}
.list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ── 그림: 초상·표지·지도 ── */
canvas.portrait { display: block; width: 56px; height: 56px; border-radius: 6px; border: 2px solid var(--ink); background: #e9dfc8; }
canvas.portrait.sm { width: 38px; height: 38px; border-width: 1.5px; flex: none; }
canvas.portrait.md { width: 84px; height: 84px; flex: none; }
canvas.portrait.big { width: 150px; height: 190px; flex: none; }
.mini-seal { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; display: grid; place-items: center; color: #fff; font-family: var(--display); font-size: 13px; border-radius: 3px; box-shadow: 0 0 0 2px var(--paper-3); }

/* ── 전투: 자동 표시 ── */
.cb-auto { position: absolute; left: 4px; top: 2px; font-style: normal; font-family: var(--display); font-size: 11px; color: #fff; background: #9aa0a6; border-radius: 3px; padding: 0 3px; line-height: 15px; }
.cb-slot.on .cb-auto { background: var(--seal); }
.cb-slot b { margin-top: 12px; }
.cb-slot.empty { opacity: .5; }
.cb-tog { margin-top: 4px; }
.cb-tog button b { font-weight: 700; }
.lb { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; pointer-events: none; line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85), 0 0 6px rgba(0, 0, 0, .6); color: #f4efe2; }
.lb b { display: block; font-family: var(--display); font-weight: 400; font-size: 15px; }
.lb i { display: inline-block; font-style: normal; font-size: 11px; padding: 0 6px; margin-bottom: 1px; border-radius: 8px; background: rgba(31, 26, 20, .7); color: #f2d27a; text-shadow: none; }
.lb small { display: block; font-size: 11px; opacity: .85; }
.lb.me b { color: #ffe08a; }
.lb.npc b { color: #bfe6ef; }
.lb.npc.rel-enemy b, .lb.npc.rel-rival b { color: #ffb0a0; }
.lb.npc.rel-spouse b, .lb.npc.rel-friend b, .lb.npc.rel-sabu b, .lb.npc.rel-sahyeongje b { color: #b6efb0; }
.lb.master b { color: #e8b0ff; font-size: 16px; }
.lb.master.beat b { color: #bcb4c0; }
.lb.keeper b { color: #f4e2a0; font-size: 14px; }
.lb.folk b { color: #e8e2d4; font-size: 13px; }
.lb.foe b { color: #ffd2c8; font-size: 14px; }
.lb.foe.strong b { color: #ff7a66; }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 3px; border: 1px solid rgba(201, 162, 58, .8); background: rgba(201, 162, 58, .18);
  color: #f2d27a; font: 12px/18px var(--body); text-align: center; }

/* HUD: 어두운 반투명 판 */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; color: #f1ebdd; }
#hud > * { pointer-events: auto; }
.hud-quest, .hud-where, .hud-me, .hud-log, .hud-menu { position: absolute; background: rgba(22, 19, 15, .72); border: 1px solid rgba(201, 162, 58, .35);
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); backdrop-filter: blur(3px); }
#hud button { color: #f1ebdd; background: rgba(255, 255, 255, .06); border-color: rgba(201, 162, 58, .45); }
#hud button:hover:not(:disabled) { background: rgba(201, 162, 58, .25); border-color: #c9a23a; }
#hud button.seal { background: var(--seal); border-color: var(--seal); color: #fff; }
.small-btn { padding: 2px 8px !important; font-size: 12px !important; margin-left: 6px; }
.q-head { font-family: var(--display); font-size: 15px; color: #e8c86a; margin-bottom: 4px; letter-spacing: 1px; }
.hud-quest { left: 12px; top: 12px; width: min(360px, calc(100vw - 230px)); padding: 10px 12px; font-size: 13px; }
.q-row { padding: 3px 0; border-top: 1px dashed rgba(201, 162, 58, .2); }
.q-head + .q-row { border-top: 0; }
.q-row b { color: #fff; font-weight: 400; font-family: var(--display); font-size: 14px; }
.q-row.ev { color: #f0a890; }
.q-row.muted { color: #a89f8e; }
.q-row.dest span { color: #e8c86a; margin-left: 4px; }
.hud-where { right: 12px; top: 204px; width: 184px; padding: 6px 10px; font-size: 12px; text-align: center; }
.hud-where b { display: block; font-family: var(--display); font-weight: 400; font-size: 17px; color: #fff; }
.hud-where span { display: block; color: #cfc6b4; }
.hud-where .warn { color: #ff8a70; }
.hud-where .walk { height: 4px; margin-top: 5px; background: rgba(255, 255, 255, .12); border-radius: 2px; overflow: hidden; }
.hud-where .walk i { display: block; height: 100%; width: 0; background: #c9a23a; }
.hud-me { left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 8px 12px; width: min(560px, calc(100vw - 24px)); }
.me-port { position: relative; flex: none; }
.me-port canvas.portrait { width: 64px; height: 64px; border-color: #c9a23a; }
.me-port .mini-seal { box-shadow: 0 0 0 2px #1a1612; }
.me-info { flex: 1; min-width: 0; }
.me-name { font-family: var(--display); font-size: 18px; color: #fff; line-height: 1.2; }
.me-name span { font-size: 13px; color: #e8c86a; margin-left: 4px; }
.me-sub { font-size: 12px; color: #cfc6b4; margin-bottom: 3px; }
.hbar { position: relative; height: 15px; margin-top: 3px; background: rgba(0, 0, 0, .5); border: 1px solid rgba(0, 0, 0, .6); border-radius: 3px; overflow: hidden; }
.hbar i { position: absolute; inset: 0 auto 0 0; }
.hbar.hp i { background: linear-gradient(#d65a46, #9b2c22); }
.hbar.qi i { background: linear-gradient(#5c93c8, #2e5d8a); }
.hbar.ins { height: 5px; }
.hbar.ins i { background: #c9a23a; }
.hbar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 14px; text-shadow: 0 1px 1px #000; }
.me-quick { display: flex; flex-direction: column; gap: 5px; flex: none; }
.me-quick button { font-size: 13px; padding: 4px 10px; text-align: left; }
.hud-menu { right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(3, 56px); gap: 4px; padding: 6px; }
.hud-menu button { position: relative; padding: 4px 0 2px; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hud-menu b { font-family: var(--display); font-weight: 400; font-size: 20px; color: #e8c86a; line-height: 1.1; }
.hud-menu span { font-size: 11px; }
.hud-menu kbd { position: absolute; right: 2px; top: 2px; font-size: 9px; line-height: 12px; min-width: 0; padding: 0 3px; }
.hud-log { left: 12px; bottom: 12px; width: min(340px, calc(50vw - 300px)); max-height: 230px; overflow: hidden; padding: 8px 10px; font-size: 12px; }
.hud-log ul { list-style: none; margin: 0; padding: 0; }
.hud-log li { padding: 2px 0; color: #ddd5c4; }
.hud-log li .when { color: #8f8676; margin-right: 6px; font-size: 11px; }
.hud-log li.good { color: #9fd8a8; }
.hud-log li.bad { color: #ff9a86; }
.hud-log li.story { color: #f2d27a; }
@media (max-width: 1100px) { .hud-log { display: none; } }
@media (max-width: 760px) {
  .hud-quest { width: calc(100vw - 130px); font-size: 12px; }
  .hud-where { top: 122px; width: 104px; font-size: 11px; }
  .hud-me { bottom: 76px; }
  .hud-menu { left: 12px; right: 12px; grid-template-columns: repeat(9, 1fr); }
  .hud-menu span { display: none; }
  .hud-menu button { height: 44px; }
}
.char-sheet { display: flex; gap: 20px; align-items: flex-start; }
.char-sheet > div { flex: 1; min-width: 0; }
@media (max-width: 600px) { .char-sheet { flex-direction: column; align-items: center; } }
.cb.cbov { max-width: none; pointer-events: none; }
.cb.cbov > * { pointer-events: auto; }
.cb.cbov .cb-top { position: relative; z-index: 2; background: rgba(22, 19, 15, .72); border: 1px solid rgba(201, 162, 58, .35); border-radius: 6px; padding: 8px 12px; margin-bottom: auto; }
.cb.cbov .cb-stage { position: fixed; inset: 0; z-index: 1; border-radius: 0; box-shadow: none; }
.cb.cbov .cb-stage canvas { background: transparent; }
.cb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.cb.cbov .cb-dock { position: relative; z-index: 2; background: rgba(22, 19, 15, .72); border: 1px solid rgba(201, 162, 58, .35); border-radius: 6px; padding: 6px; }
.cb.cbov .cb-top { grid-template-columns: minmax(0, 360px) 1fr minmax(0, 420px); }
.cb.cbov .cb-top:not(.boss) .cb-foes { visibility: hidden; }
.cb.cbov .cb-top { grid-template-columns: minmax(0, 360px) 1fr minmax(0, 420px); }
.cb.cbov .cb-top:not(.boss) .cb-foes { visibility: hidden; }

/* ── 캐릭터 생성 ── */
.cr { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 460px; background: radial-gradient(ellipse at 35% 40%, #3a3228 0%, #1a1712 70%); color: #efe7d6; }
.cr-stage { position: relative; overflow: hidden; }
.cr-title { position: absolute; left: 36px; top: 26px; pointer-events: none; }
.cr-title h1 { font-size: 64px; letter-spacing: 12px; line-height: 1; color: #f4ecda; text-shadow: 0 4px 18px rgba(0, 0, 0, .6); }
.cr-title span { display: block; font-family: var(--display); color: #c9433a; letter-spacing: 8px; font-size: 20px; margin-top: 6px; }
.cr-title p { margin: 8px 0 0; color: #a99f8c; font-size: 14px; }
.cr-tip { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); font-size: 12px; color: #8f8676; pointer-events: none; }
.cr-sum { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); text-align: center; font-size: 14px; color: #cfc6b4; pointer-events: none; white-space: nowrap; }
.cr-sum b { font-family: var(--display); font-weight: 400; font-size: 20px; color: #fff; }
.cr-panel { display: flex; flex-direction: column; min-height: 0; background: rgba(18, 16, 13, .88); border-left: 1px solid rgba(201, 162, 58, .35); box-shadow: -8px 0 30px rgba(0, 0, 0, .4); }
.cr-tabs { display: flex; border-bottom: 1px solid rgba(201, 162, 58, .3); }
.cr-tab { flex: 1; padding: 16px 0; border: 0; border-radius: 0; background: transparent; color: #a99f8c; font-family: var(--display); font-size: 19px; letter-spacing: 4px; }
.cr-tab.on { color: #f2d27a; box-shadow: inset 0 -3px 0 #c9a23a; background: rgba(201, 162, 58, .07); }
.cr-tab:hover:not(.on) { background: rgba(255, 255, 255, .04) !important; color: #efe7d6; }
.cr-body { flex: 1; overflow-y: auto; padding: 8px 24px 20px; }
.cr-body h4 { margin: 18px 0 8px; font-family: var(--display); font-weight: 400; font-size: 15px; color: #e8c86a; letter-spacing: 2px; }
.cr .name-row input { background: rgba(255, 255, 255, .06); border-color: rgba(201, 162, 58, .4); color: #fff; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cr button.chip { background: rgba(255, 255, 255, .05); color: #e6dfd0; border: 1px solid rgba(201, 162, 58, .35); padding: 6px 14px; }
.cr button.chip:hover { background: rgba(201, 162, 58, .18); }
.cr button.chip.on { background: #c9a23a; color: #1a1712; border-color: #c9a23a; }
.swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); }
.swatch.on { border-color: #f2d27a; box-shadow: 0 0 0 3px rgba(242, 210, 122, .35); }
.cr-note { font-size: 13px; color: #a99f8c; line-height: 1.7; margin-top: 16px; }
.cr-births { display: grid; gap: 8px; margin-top: 8px; }
.cr button.cr-birth { text-align: left; padding: 10px 14px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(201, 162, 58, .25); color: #e6dfd0; }
.cr button.cr-birth.on { border-color: #c9a23a; background: rgba(201, 162, 58, .14); }
.cr-birth b { display: block; font-family: var(--display); font-weight: 400; font-size: 18px; color: #fff; }
.cr-birth b span { font-size: 13px; color: #c9a23a; margin-left: 6px; }
.cr-birth small { color: #b8ae9c; font-size: 13px; }
.cr-regions { display: grid; gap: 6px; margin-top: 16px; padding: 10px 12px; border-radius: 6px; background: rgba(0, 0, 0, .25); }
.cr-regions b { font-family: var(--display); font-weight: 400; color: #e8c86a; }
.cr-regions small { display: block; color: #a99f8c; font-size: 12px; }
.cr-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-stat { position: relative; padding: 10px 12px 14px; border-radius: 6px; background: rgba(255, 255, 255, .05); overflow: hidden; }
.cr-stat span { color: #cfc6b4; }
.cr-stat b { float: right; font-size: 22px; color: #fff; font-weight: 400; font-family: var(--display); }
.cr-stat i { position: absolute; left: 0; bottom: 0; height: 3px; background: #c9a23a; }
.cr-stat small { display: block; clear: both; color: #8f8676; font-size: 11px; }
.cr-traits { display: grid; gap: 8px; }
.cr-trait { position: relative; padding: 10px 14px; border-radius: 6px; border: 1px solid var(--tc); background: linear-gradient(90deg, rgba(0, 0, 0, .25), transparent), rgba(255, 255, 255, .03); box-shadow: inset 3px 0 0 var(--tc); }
.cr-trait em { position: absolute; right: 12px; top: 10px; font-style: normal; font-size: 11px; color: var(--tc); }
.cr-trait b { display: block; font-family: var(--display); font-weight: 400; font-size: 18px; color: var(--tc); }
.cr-trait small { color: #cfc6b4; }
.cr-trait.t4 { animation: legend 2.4s ease-in-out infinite; }
@keyframes legend { 50% { box-shadow: inset 3px 0 0 var(--tc), 0 0 16px rgba(224, 168, 58, .45); } }
.cr-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid rgba(201, 162, 58, .3); }
.cr-foot button { font-family: var(--display); font-size: 17px; padding: 10px 20px; }
.cr-foot button.ghost { color: #e6dfd0; border-color: rgba(201, 162, 58, .4); }
@media (max-width: 860px) {
  .cr { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .cr-panel { border-left: 0; border-top: 1px solid rgba(201, 162, 58, .35); }
  .cr-title { left: 16px; top: 12px; }
  .cr-title h1 { font-size: 40px; }
  .cr-tip, .cr-sum { display: none; }
  .cr-body { padding: 4px 16px 16px; }
}
.item.book .nm { color: var(--ink); }

.where-btns { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.where-btns button { font-size: 12px; padding: 3px 8px; }

/* 행낭: 아이콘 칸 */
.inv-dlg { width: min(960px, 100%); }
.inv-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.inv-silver { margin-left: auto; }
.inv { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; align-content: start; padding: 10px; background: #2a241d; border-radius: 6px; box-shadow: inset 0 2px 10px rgba(0, 0, 0, .5); }
.inv-cell { position: relative; aspect-ratio: 1; padding: 0; border-radius: 4px; background: linear-gradient(#4a4036, #3a322a); border: 2px solid #5a4e40; }
.inv-cell canvas { display: block; width: 100%; height: 100%; }
.inv-cell.empty { background: rgba(255, 255, 255, .03); border: 2px dashed rgba(255, 255, 255, .08); }
.inv-cell.t2 { border-color: #6fb36a; }
.inv-cell.t3 { border-color: #e0a83a; box-shadow: 0 0 8px rgba(224, 168, 58, .45); }
.inv-cell.on { outline: 3px solid #f2d27a; outline-offset: 1px; }
.inv-cell:hover:not(.empty) { background: linear-gradient(#5a5044, #4a4036) !important; }
.inv-cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.inv-cell .key { position: absolute; left: 2px; top: 1px; font-size: 10px; color: #1a1410; background: #f2d27a; border-radius: 2px; padding: 0 3px; }
.inv-detail { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-3); }
.inv-big { width: 96px; height: 96px; border-radius: 6px; background: linear-gradient(#4a4036, #3a322a); border: 3px solid #5a4e40; margin-bottom: 8px; }
.inv-big.t2 { border-color: #6fb36a; } .inv-big.t3 { border-color: #e0a83a; }
.inv-big canvas { width: 100%; height: 100%; display: block; }
.inv-detail h3 { font-size: 20px; }
.inv-desc { font-size: 14px; color: var(--ink-2); margin: 8px 0 12px; line-height: 1.6; }
.inv-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.warn-t { color: var(--hp); }
.inv-gad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.inv-gslot { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .4); }
.inv-gslot > span { font-weight: 700; color: #fff; background: var(--ink); border-radius: 3px; padding: 0 6px; }
.inv-gslot canvas { width: 32px; height: 32px; }
.inv-gslot b { flex: 1; font-size: 13px; font-weight: 400; }
@media (max-width: 760px) { .inv { grid-template-columns: 1fr; } .inv-grid { grid-template-columns: repeat(5, 1fr); } .inv-gad { grid-template-columns: 1fr; } }

/* 대화창 */
.overlay.talk-wrap { align-items: end; padding-bottom: 28px; background: rgba(20, 16, 12, .45); }
.talk { position: relative; display: grid; grid-template-columns: 220px minmax(0, 1fr); width: min(980px, 100%); background: linear-gradient(#2a241d, #1d1915); color: #efe7d6;
  border: 2px solid #c9a23a; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); overflow: hidden; }
.talk .close-x { position: absolute; right: 8px; top: 6px; color: #efe7d6; background: transparent; border: 0; font-size: 22px; z-index: 1; }
.talk-port { background: radial-gradient(ellipse at 50% 70%, #4a3e30, #241e18); display: flex; align-items: end; justify-content: center; min-height: 260px; }
.talk-pc { width: 220px !important; height: 280px !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; }
.talk-main { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.talk-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.talk-name b { font-family: var(--display); font-weight: 400; font-size: 26px; color: #fff; }
.talk-title { color: #c9bfae; font-size: 13px; }
.talk-bubble { position: relative; padding: 12px 16px; background: #f4ecda; color: #2a211a; border-radius: 6px; font-size: 16px; line-height: 1.6; }
.talk-bubble::before { content: ''; position: absolute; left: -10px; top: 18px; border: 6px solid transparent; border-right: 6px solid #f4ecda; }
.talk-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: #a99f8c; }
.talk-ties { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 12px; }
.talk-ties b { font-weight: 400; color: #e8c86a; margin-right: 4px; }
.tie { padding: 1px 7px; border-radius: 9px; background: rgba(255, 255, 255, .07); color: #ddd5c4; }
.tie em { font-style: normal; font-size: 11px; opacity: .8; }
.tie-mate, .tie-friend { color: #b6efb0; } .tie-warm { color: #d8e8c8; } .tie-cold { color: #f0c0a8; } .tie-foe { color: #ff9a86; }
.talk-favor { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #e8a6b8; }
.talk-favor .favor { flex: 1; }
.talk-favor b { color: #fff; font-weight: 400; min-width: 30px; text-align: right; }
.talk-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.talk-opt { text-align: left; padding: 7px 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(201, 162, 58, .4); color: #efe7d6; }
.talk-opt:hover:not(:disabled) { background: rgba(201, 162, 58, .2) !important; border-color: #c9a23a !important; }
.talk-opt b { display: block; font-weight: 400; color: #fff; }
.talk-opt b::before { content: '▸ '; color: #c9a23a; }
.talk-opt small { color: #a99f8c; font-size: 12px; }
.talk-opt.danger b { color: #ff9a86; }
.talk-opt.sect { border-color: #c9a23a; background: rgba(168, 38, 27, .28); }
@media (max-width: 700px) { .talk { grid-template-columns: 1fr; } .talk-port { min-height: 160px; } .talk-pc { height: 180px !important; width: 160px !important; } }
.here-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.here-card { display: flex; gap: 8px; align-items: center; text-align: left; padding: 6px 8px; }
.here-card small { display: block; color: var(--ink-3); font-size: 12px; }
@media (max-width: 760px) { .hud-where { top: auto; bottom: 170px; width: 180px; } .hud-quest { max-height: 40vh; overflow: hidden; } #minimap { width: 104px; height: 104px; } #prompt { bottom: 236px; } }


/* ── 3D 필드 ── */
#world { position: fixed; inset: 0; display: block; z-index: 0; outline: none; touch-action: none; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.lb { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; pointer-events: none; line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85), 0 0 6px rgba(0, 0, 0, .6); color: #f4efe2; }
.lb b { display: block; font-family: var(--display); font-weight: 400; font-size: 15px; }
.lb i { display: inline-block; font-style: normal; font-size: 11px; padding: 0 6px; margin-bottom: 1px; border-radius: 8px; background: rgba(31, 26, 20, .7); color: #f2d27a; text-shadow: none; }
.lb small { display: block; font-size: 11px; opacity: .85; }
.lb.me b { color: #ffe08a; }
.lb.npc b { color: #bfe6ef; }
.lb.npc.rel-enemy b, .lb.npc.rel-rival b { color: #ffb0a0; }
.lb.npc.rel-spouse b, .lb.npc.rel-friend b, .lb.npc.rel-sabu b, .lb.npc.rel-sahyeongje b { color: #b6efb0; }
.lb.master b { color: #e8b0ff; font-size: 16px; }
.lb.master.beat b { color: #bcb4c0; }
.lb.keeper b { color: #f4e2a0; font-size: 14px; }
.lb.folk b { color: #e8e2d4; font-size: 13px; }
.lb.foe b { color: #ffd2c8; font-size: 14px; }
.lb.foe.strong b { color: #ff7a66; }
.lb .hpb { display: block; width: 64px; height: 6px; margin: 2px auto 0; background: rgba(0, 0, 0, .55); border: 1px solid rgba(0, 0, 0, .7); border-radius: 2px; overflow: hidden; }
.lb .hpb i { display: block; height: 100%; width: 100%; margin: 0; padding: 0; border-radius: 0; background: #d0402e; }
.lb.me .hpb i { background: #e8b84a; }
#minimap { position: fixed; top: 12px; right: 12px; width: 184px; height: 184px; z-index: 3; cursor: pointer; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45)); }
#prompt { position: fixed; left: 50%; bottom: 168px; transform: translateX(-50%); z-index: 3; pointer-events: none; padding: 6px 14px; border-radius: 4px;
  background: rgba(24, 20, 16, .78); color: #f4efe2; font-size: 15px; border: 1px solid rgba(201, 162, 58, .6); white-space: nowrap; }
#prompt span { color: #c9bfae; font-size: 13px; margin-left: 4px; }
#prompt[hidden] { display: none; }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 3px; border: 1px solid rgba(201, 162, 58, .8); background: rgba(201, 162, 58, .18);
  color: #f2d27a; font: 12px/18px var(--body); text-align: center; }
#zoneTitle { position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 2; pointer-events: none; text-align: center; color: #fbf6ea; opacity: 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .7), 0 0 20px rgba(0, 0, 0, .5); }
#zoneTitle.show { animation: zoneIn 3.6s ease-out forwards; }
#zoneTitle .zh { font-family: var(--display); font-size: 56px; letter-spacing: 10px; line-height: 1; }
#zoneTitle .zk { font-family: var(--display); font-size: 24px; letter-spacing: 6px; margin-top: 6px; }
#zoneTitle .zs { font-size: 13px; opacity: .85; margin-top: 2px; }
@keyframes zoneIn { 0% { opacity: 0; transform: translateX(-50%) translateY(10px); } 15% { opacity: 1; transform: translateX(-50%); } 75% { opacity: 1; } 100% { opacity: 0; } }

body.in-battle #hud, body.in-battle #minimap, body.in-battle #prompt, body.in-battle #zoneTitle { display: none; }
.overlay.combat-wrap.c3d { background: transparent; }

/* 생성 화면의 3D 미리보기 */
#cPreview { position: absolute; inset: 0; }
.cr-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.cr-canvas:active { cursor: grabbing; }

/* 천하 지도 (M) */
.dialog.map-dlg { width: min(1320px, 100%); }
.mp { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; }
.mp-map { position: relative; border-radius: 6px; overflow: hidden; border: 2px solid #5a4e40; box-shadow: inset 0 0 30px rgba(0, 0, 0, .35); align-self: start; }
.mp-map canvas { display: block; width: 100%; height: auto; }
.mp-pin { position: absolute; transform: translate(-50%, -50%); padding: 0; border: 0; background: transparent !important; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; z-index: 1; }
.mp-pin i { display: block; width: 10px; height: 10px; border-radius: 50%; background: #8a6a44; border: 2px solid #fff8e6; box-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.mp-pin.city i { width: 14px; height: 14px; border-radius: 2px; background: #6b6458; }
.mp-pin.sect i { width: 14px; height: 14px; transform: rotate(45deg); border-radius: 2px; background: var(--pc, #a8261b); }
.mp-pin b { font-family: var(--display); font-weight: 400; font-size: 13px; color: #fff8e6; background: rgba(26, 20, 14, .72); padding: 0 5px; border-radius: 3px; white-space: nowrap; }
.mp-pin.here b { background: #a8261b; }
.mp-pin.dest b { background: #c9a23a; color: #1a1410; }
.mp-pin.on b { outline: 2px solid #f2d27a; }
.mp-pin.locked { opacity: .55; }
.mp-pin:hover b { background: #c9a23a; color: #1a1410; }
.mp-me { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #e83a2a; border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(232, 58, 42, .3); z-index: 2; pointer-events: none; animation: pulse 1.8s ease-out infinite; }
.mp-side { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-3); font-size: 14px; }
.mp-side h3 { font-size: 22px; }
.mp-side h3 i { font-style: normal; font-size: 14px; color: var(--ink-3); margin-left: 6px; }
.mp-side p { margin: 8px 0; line-height: 1.6; }
.mp-side .acts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.mp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
@media (max-width: 860px) { .mp { grid-template-columns: 1fr; } .mp-pin b { font-size: 11px; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 58, 42, .55); } 100% { box-shadow: 0 0 0 14px rgba(232, 58, 42, 0); } }
.mp-pin.city { flex-direction: column-reverse; }
.mp-pin.here, .mp-pin.on { z-index: 2; }
