/* 레이아웃: 휴대폰 한 손 세로 화면. 양피지 한 장 위에 상태 → 일러스트 → 본문 → 선택지 → 하단 메뉴 순으로 쌓는다.
   단일 테마(양피지 + 호두나무 바탕)를 의도적으로 고정한다. */
:root {
  --wood: #1e1713;
  --paper: #d8cab0;
  --paper-2: #cbbb9d;
  --paper-3: #e6dbc4;
  --ink: #2a1f19;
  --ink-2: #5b4a3b;
  --rule: #9a8566;
  --blood: #8c2a23;
  --gold: #9a7420;
  --hp: #3e7c4d;
  --foe: #a5392f;
  --mem: #6a4596;
  --trait: #2c6a78;
  --party: #3d6b33;
  --cost: #8a5a1c;
  --good: #2f7040;
  --bad: #9a2e26;
  --f-display: 'Song Myung', 'Gowun Batang', 'Nanum Myeongjo', serif;
  --f-body: 'Gowun Batang', 'Nanum Myeongjo', 'Apple SD Gothic Neo', serif;
  --f-num: 'Silkscreen', 'Gowun Batang', monospace;
  color-scheme: light;
}

.journey-guide { margin:16px 0; padding:12px 14px; border:1px solid var(--rule); border-radius:6px; font-size:14px; line-height:1.8; }
.journey-guide summary { cursor:pointer; color:var(--ink); font-weight:bold; }
.journey-guide p { margin:10px 0 0; color:var(--ink-2); }
.combat-help { margin:8px 10px 12px; font-size:13px; line-height:1.6; color:var(--ink-2); }
.camp-stat-explanation { display:block; margin-top:8px; font-size:12px; line-height:1.7; }
.end-growth-hint { font-size:14px; line-height:1.8; text-align:center; }
#end-actions .end-growth-action { grid-column:1 / -1; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--wood);
  background-image: radial-gradient(ellipse at 50% 0%, #2e231c 0%, var(--wood) 70%);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255, 250, 235, 0.35), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(120, 90, 50, 0.10), transparent 45%),
    repeating-linear-gradient(0deg, rgba(90, 70, 40, 0.025) 0 2px, transparent 2px 4px);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  position: relative;
}
.screen { padding: 14px 16px 24px; }
/* Character camp: supplied 941 × 1672 composition, isolated from expedition UI. */
#class-screen { padding: 0 0 20px; min-height: 100vh; background: #121b24; color: #e8d9b8; }
#class-screen > .screen-title { display: none; }
#class-list { display: block; position: relative; width: 100%; aspect-ratio: 941 / 1672; overflow: hidden; }
.camp-scene { position: absolute; width: 941px; height: 1672px; transform-origin: top left; }
.camp-image { position: absolute; pointer-events: none; image-rendering: auto; }
.camp-character { object-fit: contain; object-position: center bottom; }
.camp-sprite, .camp-portrait { image-rendering: pixelated; }
.camp-portrait { object-fit: fill; }
.camp-text { position: absolute; font-family: var(--f-body); color: #e8d9b8; line-height: 1.3; white-space: pre-wrap; }
.camp-heading, .camp-label { font-family: var(--f-display); }
.camp-label { color: #c8bea7; text-shadow: 2px 3px #101b26; }
.camp-label.is-selected { color: #f0d49c; }
.camp-selection { image-rendering: pixelated; }
.camp-traits { position: absolute; background: linear-gradient(110deg, #182630, #18252e); }
.camp-trait { display: grid; place-items: center; border: 3px solid #a18b68; background: #1c2b34; box-shadow: inset 0 0 0 3px #101b24; color: #e8d9b8; clip-path: polygon(4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px), 0 4px, 4px 4px); }
.camp-hit { position: absolute; z-index: 4; background: transparent; border: 0; border-radius: 0; padding: 0; cursor: pointer; }
.camp-hit:hover { background: #ffcc6610; }
.camp-hit:active { background: #0003; }
.camp-hit:focus-visible { outline: 4px solid #ffc770; outline-offset: -4px; }
.camp-hit:disabled { cursor: not-allowed; background: #17233188; }
.camp-locked-art { filter: grayscale(.85) brightness(.65); }
.camp-unlock-hint, .camp-unlock-progress { color: #f2d59c; line-height: 1.45; }
.camp-unlock-progress { background: #1b2a35; box-sizing: border-box; padding: 8px; }
.camp-picker { position: absolute; z-index: 6; inset: 150px 80px auto; max-height: 750px; overflow: auto; padding: 28px; border: 3px solid #a58d68; background: #172331fa; }
.camp-picker input, .camp-picker button { display: block; width: 100%; margin: 12px 0; padding: 18px; font: 36px var(--f-body); color: #f3e2bd; background: #26323e; border: 1px solid #a58d68; }
#class-screen > .lede { padding: 0 20px; color: #a3a49e; font-size: 13px; }
#class-anchor { margin: 0 16px 18px; color: var(--ink); }
#game-screen { padding-bottom: 86px; }
.pxi { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.num { font-family: var(--f-num); font-size: 0.78em; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.bad-text { color: var(--bad); }
button { font-family: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--blood); outline-offset: 2px; }

/* ---------- 버튼 ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-top: 18px; }
.btn {
  appearance: none; border: 2px solid var(--ink); background: var(--paper-3);
  padding: 12px 16px; font-size: 17px; font-family: var(--f-display);
  box-shadow: 3px 3px 0 var(--ink); cursor: pointer; text-align: center;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--blood); color: #f4e8d2; border-color: #3a1410; box-shadow: 3px 3px 0 #3a1410; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; border-color: var(--rule); color: var(--ink-2); }
.mini {
  appearance: none; border: 1.5px solid var(--ink); background: var(--paper-3); padding: 5px 10px;
  font-size: 13px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink);
}
.mini.ghost { background: transparent; box-shadow: none; border-color: var(--rule); color: var(--ink-2); }
.mini.on { background: var(--ink); color: var(--paper-3); }
.confirm-msg { margin: 0; font-size: 14px; line-height: 1.6; }

/* ---------- 타이틀 ---------- */
.title-art-wrap { margin: 4px -4px 0; background: #120a12; }
.title-art-wrap canvas { width: 100%; height: auto; }
/* 타이틀: 야영지 장면 (title-ui-kit). .ts-scene 안은 시안 기준 좌표 941×1672 px,
   UI.fitTitle()이 화면에 맞춰 통째로 확대·축소한다. */
.screen.title-screen { padding: 0; }
.ts-stage {
  position: relative; overflow: hidden;
  height: 100vh; height: calc(100dvh - var(--safe-top, 0px)); min-height: 480px;
  background: linear-gradient(#17212a, #11171d 55%, #0b0f15);
  color: #e8e0cd; user-select: none; -webkit-user-select: none;
}
.ts-scene {
  position: absolute; left: 0; top: 0; width: 941px; height: 1672px;
  transform-origin: 0 0; opacity: 0; transition: opacity 0.6s ease;
}
.ts-scene.ready { opacity: 1; }
.ts-l { position: absolute; pointer-events: none; -webkit-user-drag: none; }
.ts-bg { left: 0; top: 0; width: 941px; height: 1672px; }
.ts-glow { left: 103px; top: 1025px; width: 550px; height: 550px; mix-blend-mode: screen; opacity: 0.55; }
.ts-props { left: 112px; top: 1080px; width: 440px; height: 340px; }
.ts-hero { left: 529px; top: 1030px; width: 357px; height: 298px; }
/* 모닥불: 22×32칸 픽셀 불꽃을 6배(한 칸 = 배경 픽셀 6px)로 키운다. 장작 앞에서 타오르고, 밑동은 둥글게 다듬는다 */
.ts-fire { left: 307px; top: 1160px; width: 132px; height: 192px; image-rendering: pixelated; image-rendering: crisp-edges; }
.ts-embers { position: absolute; inset: 0; pointer-events: none; }
.ts-embers i { position: absolute; left: 0; top: 0; background: #ff9a54; box-shadow: 0 0 10px 2px rgba(255, 120, 50, 0.6); will-change: transform, opacity; }

.ts-logo { position: absolute; left: 67px; top: 388px; margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 82px; line-height: 1.2; letter-spacing: 0.02em; color: #eee7d2; white-space: nowrap; text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55); }
.ts-sub { position: absolute; left: 71px; top: 512px; margin: 0; font-size: 30px; line-height: 1.4; color: #959991; white-space: nowrap; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.ts-rule { position: absolute; left: 74px; top: 584px; width: 64px; height: 8px; }
.ts-rule img { display: block; width: 64px; height: 8px; }
.ts-loop { position: absolute; left: 156px; top: 570px; margin: 0; font-size: 24px; line-height: 36px; color: #b9705a; white-space: nowrap; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.ts-diamond { position: absolute; left: 68px; top: 682px; width: 28px; height: 28px; transition: top 0.12s ease; filter: drop-shadow(0 0 8px rgba(238, 133, 86, 0.75)); animation: tsPulse 1.6s ease-in-out infinite; }
@keyframes tsPulse { 50% { filter: drop-shadow(0 0 3px rgba(238, 133, 86, 0.4)); } }
.ts-menu { position: absolute; left: 62px; top: 660px; width: 470px; }
.ts-item {
  display: flex; align-items: center; width: 425px; height: 74px; padding: 0 0 0 52px; margin: 0;
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  font-family: var(--f-body); font-size: 38px; line-height: 1; color: #e8e0cd; white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); transition: color 0.12s ease;
}
.ts-item.sel { color: #ed9160; }
.ts-item.press { color: #ffc087; }
.ts-item:disabled { color: #777b77; cursor: default; }
.ts-item:focus, .ts-item:focus-visible { outline: none; }   /* 포커스는 선택 표시(◆ + 색)로 보여 준다 */
.ts-confirm { margin: 0 0 10px; padding-left: 52px; width: 470px; font-size: 27px; line-height: 1.55; color: #cfc6b2; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7); white-space: normal; }
.ts-proto { position: absolute; left: 74px; top: 1612px; margin: 0; font-family: var(--f-num); font-size: 19px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(232, 224, 205, 0.3); }
body.app-paused .ts-scene *, body.app-paused .ts-scene { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .ts-diamond { animation: none; }
  .ts-embers { display: none; }
}

/* ---------- 직업 선택 ---------- */
.screen-title { font-family: var(--f-display); font-weight: 400; font-size: 24px; text-align: center; margin: 8px 0 6px; }
.lede { text-align: center; color: var(--ink-2); font-size: 14px; line-height: 1.7; margin: 0 0 14px; text-wrap: balance; }
.anchor-box { display: flex; gap: 10px; align-items: center; border: 1.5px dashed var(--gold); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; background: rgba(154, 116, 32, 0.08); }
.anchor-box canvas { width: 32px; height: 32px; }
.class-list { display: flex; flex-direction: column; gap: 12px; }
.class-card {
  appearance: none; display: grid; grid-template-columns: 88px 1fr; gap: 12px; text-align: left; cursor: pointer;
  border: 2px solid var(--ink); background: var(--paper-3); padding: 12px; box-shadow: 4px 4px 0 var(--ink);
}
.class-card:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.class-art { width: 88px; height: auto; align-self: center; }
.class-card:has(.class-illust) { grid-template-columns: 104px 1fr; padding-bottom: 0; }
.class-art.class-illust { width: 104px; align-self: end; }
.class-card:has(.class-illust) .class-body { padding-bottom: 12px; }
.class-body { min-width: 0; }
.class-body h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.class-blurb { margin: 2px 0 8px; font-size: 14px; color: var(--ink-2); }
.class-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 8px; }
.class-stats div { display: flex; gap: 4px; align-items: baseline; }
.class-stats dt { font-size: 12px; color: var(--ink-2); }
.class-stats dd { margin: 0; font-family: var(--f-num); font-size: 12px; }
.class-gear { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }

/* ---------- 칩 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: 11.5px; line-height: 1; padding: 4px 6px 3px; border: 1px solid currentColor; border-radius: 2px; white-space: nowrap; }
.chip.trait { color: var(--trait); background: rgba(44, 106, 120, 0.08); }
.chip.mem { color: var(--mem); background: rgba(106, 69, 150, 0.08); }
.chip.mem::before { content: '✦ '; }
.chip.party { color: var(--party); background: rgba(61, 107, 51, 0.08); }
.chip.item { color: var(--gold); background: rgba(154, 116, 32, 0.08); }
.chip.mor { color: var(--blood); }
.chip.cost { color: var(--cost); border-style: dashed; }
.chip.bad { color: var(--bad); background: rgba(154, 46, 38, 0.08); }

/* ---------- HUD ---------- */
.hud { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding-bottom: 8px; }
.hud-portrait { width: 56px; height: 56px; border: 2px solid var(--ink); background: #5a6e7a; box-shadow: inset 0 0 0 2px var(--paper-3); overflow: hidden; }
.hud-portrait canvas { width: 100%; height: 100%; }
.hud-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.hud-name { display: flex; gap: 6px; align-items: center; font-family: var(--f-display); font-size: 17px; }
.mor-chip { font-family: var(--f-body); font-size: 11px; padding: 2px 6px; border: 1px solid var(--ink-2); color: var(--ink-2); }
.mor-chip.good { color: var(--good); border-color: var(--good); }
.mor-chip.bad { color: var(--bad); border-color: var(--bad); }
.hpbar { display: flex; align-items: center; gap: 6px; }
.hp-ic canvas, .res canvas, .stat canvas { width: 16px; height: 16px; }
.hpbar-track { flex: 1; height: 12px; border: 1.5px solid var(--ink); background: #3a2a24; position: relative; min-width: 0; }
.hpbar-track i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#6fb26b 0 35%, var(--hp) 35%); transition: width 0.35s steps(8); }
.hud-res { display: flex; gap: 14px; }
.res, .stat { display: inline-flex; gap: 4px; align-items: center; }
.hud-stats { display: grid; grid-template-columns: auto auto; gap: 3px 10px; border-left: 1.5px dotted var(--rule); padding-left: 10px; }
.hud-inj { grid-column: 1 / -1; }
.hud-inj:empty { display: none; }
.journey { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0 10px; }
.jr-region { font-family: var(--f-display); font-size: 15px; white-space: nowrap; }
.rod { flex: 1; height: 6px; position: relative; background: linear-gradient(var(--gold), #c9a24a 50%, #6a4e14); border: 1px solid #4a3410; min-width: 30px; }
.rod::before, .rod::after { content: ''; position: absolute; top: 50%; width: 8px; height: 8px; background: #c9a24a; border: 1px solid #4a3410; transform: translateY(-50%) rotate(45deg); }
.rod::before { left: -5px; } .rod::after { right: -5px; }

/* ---------- 이벤트 ---------- */
.stage { display: flex; flex-direction: column; }
.ev-title { font-family: var(--f-display); font-weight: 400; font-size: 20px; margin: 4px 0 8px; text-wrap: balance; }
.illus-frame { background: #1a1214; margin: 0 -2px; }
.illus-frame canvas { width: 100%; height: auto; }
/* 스탠딩 일러스트: 장면 위에 서 있는 캐릭터 메인 그림 */
.illus-frame, .title-art-wrap { position: relative; }
.illus-frame canvas.bust, .title-art-wrap canvas.bust {
  position: absolute; bottom: 0; width: auto; height: 100%; pointer-events: none;
  filter: drop-shadow(3px 0 0 rgba(18, 10, 16, 0.45));
  animation: bustInL 0.5s cubic-bezier(.2, .8, .3, 1) both;
}
.illus-frame canvas.bust.left, .title-art-wrap canvas.bust.left { left: 1.5%; }
.illus-frame canvas.bust.right, .title-art-wrap canvas.bust.right { right: 1.5%; animation-name: bustInR; filter: drop-shadow(-3px 0 0 rgba(18, 10, 16, 0.45)); }
@keyframes bustInL { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes bustInR { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.ev-text { margin-top: 14px; line-height: 1.78; font-size: 16px; min-height: 3em; }
.ev-text p { margin: 0 0 0.85em; }
.ev-text p.speech { padding-left: 12px; border-left: 2px solid var(--rule); color: #3a2c22; }
.ev-text p.chosen { font-size: 13.5px; color: var(--ink-2); margin-bottom: 0.6em; }
.ev-text.fade { animation: fadeUp 0.45s ease-out; }
@keyframes fadeUp { from { opacity: 0.35; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.notes { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.note { font-size: 14px; }
.note.good, .note.gold, .note.item, .note.mor-good { color: var(--good); }
.note.bad, .note.lose, .note.mor-bad { color: var(--bad); }
.note.mem { color: var(--mem); font-weight: 700; }
.note.mem::before { content: '✦ '; }
.note.trait { color: var(--trait); font-weight: 700; }
.note.party { color: var(--party); font-weight: 700; }
.note.region { color: var(--ink-2); font-style: italic; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-2); margin: 10px 0 6px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 0; border-top: 1.5px solid var(--rule); }
.divider span { font-family: var(--f-num); font-size: 11px; }

/* ---------- 선택지 ---------- */
.choices { display: flex; flex-direction: column; gap: 2px; }
.choice-head { font-size: 14px; color: var(--ink-2); padding: 4px 2px 8px; line-height: 1.6; }
.choice-head .trig-title { display: block; color: var(--blood); font-family: var(--f-display); font-size: 17px; font-weight: 400; }
.choice-head .trig-text { display: block; }
.choice {
  appearance: none; border: 0; background: transparent; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; padding: 10px 6px; width: 100%;
  border-bottom: 1px dotted rgba(154, 133, 102, 0.6);
}
.choice:hover { background: rgba(255, 248, 230, 0.4); }
.choice:active { background: rgba(140, 42, 35, 0.08); }
.choice .mark { width: 10px; height: 10px; margin: 6px 0 0 5px; transform: rotate(45deg); border: 2px solid var(--ink); background: var(--paper-3); box-shadow: inset 0 0 0 2px var(--paper-3), inset 0 0 0 6px var(--gold); }
.choice.go .mark { box-shadow: inset 0 0 0 2px var(--paper-3), inset 0 0 0 6px var(--blood); }
.choice-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice-t { font-size: 16.5px; font-weight: 700; line-height: 1.45; }
.choice-sub { font-size: 12.5px; color: var(--ink-2); }
.choice.locked { opacity: 0.5; cursor: not-allowed; }
.choice.dim .choice-t { color: var(--ink-2); }
.check { font-size: 12.5px; }
.check-p { color: var(--trait); font-weight: 700; }
.check-b { color: var(--mem); }

/* ---------- 전투 ---------- */
.combat { background: var(--paper-2); border: 2px solid var(--ink); padding: 0 0 6px; margin: 0 -2px; }
.combat.paused .cb-view { outline: 2px solid var(--blood); }
.cb-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 6px; padding: 6px 8px 4px; }
.cb-side { display: flex; flex-direction: column; min-width: 0; }
.cb-side.r { align-items: flex-end; text-align: right; }
.cb-name { font-family: var(--f-display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cb-atk { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-2); }
.cb-atk .sw { width: 10px; height: 10px; background: linear-gradient(135deg, transparent 40%, #4a4a52 40% 60%, transparent 60%); }
.cb-tier { font-family: var(--f-display); color: var(--blood); font-size: 15px; padding-bottom: 2px; }
.cb-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px 6px; }
.cb-bar { position: relative; height: 22px; border: 2px solid var(--ink); background: #2a1e1c; overflow: hidden; }
.cb-bar i { position: absolute; inset: 0 auto 0 0; transition: width 0.18s linear; }
.cb-bar.l i { background: linear-gradient(#5fae6c 0 40%, #2f7a48 40%); }
.cb-bar.r i { background: linear-gradient(#d0584c 0 40%, #9a2e2a 40%); }
.cb-bar.r i { left: auto; right: 0; }
.cb-bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #f6ecd8; text-shadow: 1px 1px 0 #000; font-size: 10px; }
.cb-view { position: relative; margin: 0 8px; border: 2px solid var(--ink); background: #120a12; box-shadow: inset 0 0 0 2px var(--paper-3); }
.cb-view canvas { width: 100%; height: auto; }
.cb-float { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fnum { position: absolute; transform: translate(-50%, 0); font-family: var(--f-num); font-size: 14px; color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; animation: floatUp 0.95s ease-out forwards; white-space: nowrap; }
.fnum.crit { color: #ffd24a; font-size: 19px; }
.fnum.hurt { color: #ff8a7a; }
.fnum.heal { color: #8af08a; }
.fnum.poison { color: #9ae05a; font-family: var(--f-body); font-size: 13px; }
.fnum.holy { color: #fff4b0; }
.fnum.warn { color: #ff4a3a; font-size: 22px; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -26px) scale(1); } }
.cb-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.8); font-family: var(--f-display); font-size: 34px; color: #f6ecd8; text-shadow: 2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s; white-space: nowrap; }
.cb-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cb-banner.good { color: #ffe08a; }
.cb-banner.bad { color: #ff7a6a; }
.cb-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; padding: 6px 8px 0; }
.cb-stat { display: flex; flex-wrap: wrap; gap: 4px; min-height: 22px; }
.cb-stat.r { justify-content: flex-end; }
.cstat { font-size: 11px; padding: 3px 5px; border: 1.5px solid var(--ink); background: var(--paper-3); }
.cstat.party { color: var(--party); }
.cstat.bad { color: var(--bad); }
.cb-speed { appearance: none; border: 2px solid var(--ink); background: var(--paper-3); font-family: var(--f-num); font-size: 13px; padding: 4px 12px; border-radius: 12px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
.cb-log { list-style: none; margin: 6px 8px 0; padding: 0; font-size: 13px; color: var(--ink-2); min-height: 20px; }
.clog { line-height: 1.5; }
.clog.good { color: var(--good); }
.clog.bad { color: var(--bad); }
.clog.warn { color: var(--blood); font-weight: 700; }

/* ---------- 하단 메뉴 ---------- */
.dock {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper-2); border-top: 2px solid var(--ink);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.dock button { appearance: none; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 2px 0; font-size: 11.5px; color: var(--ink-2); }
.dock button canvas { width: 32px; height: 32px; }
body.in-combat .dock { pointer-events: auto; }
body.in-combat .dock button { opacity: 0.55; pointer-events: none; }

/* ---------- 시트 ---------- */
.sheet { position: fixed; inset: 0; background: rgba(20, 12, 10, 0.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none !important; }
.sheet-panel { width: 100%; max-width: 480px; max-height: 86vh; background: var(--paper); border-top: 3px solid var(--ink); display: flex; flex-direction: column; animation: sheetUp 0.22s ease-out; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; border-bottom: 1.5px solid var(--rule); }
.sheet-head h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.sheet-body h3 { font-family: var(--f-display); font-weight: 400; font-size: 17px; margin: 18px 0 8px; border-bottom: 1px dotted var(--rule); padding-bottom: 4px; }
.equip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.equip-slot { border: 1.5px solid var(--ink); background: var(--paper-3); padding: 8px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; min-width: 0; }
.equip-slot canvas { width: 32px; height: 32px; }
.slot-label { font-size: 11px; color: var(--ink-2); }
.slot-name { font-size: 13px; font-weight: 700; word-break: keep-all; }
.slot-stat { font-size: 11px; color: var(--ink-2); }
.slot-empty { width: 32px; height: 32px; border: 1.5px dashed var(--rule); }
.inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.inv-cell { appearance: none; position: relative; border: 1.5px solid var(--ink); background: var(--paper-3); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 4px; min-width: 0; }
.inv-cell.empty { border-style: dashed; border-color: var(--rule); background: transparent; cursor: default; }
.inv-cell canvas { width: 32px; height: 32px; }
.inv-name { font-size: 10.5px; line-height: 1.2; text-align: center; word-break: keep-all; }
.qty { position: absolute; right: 4px; top: 2px; font-family: var(--f-num); font-size: 10px; }
.detail { display: grid; grid-template-columns: 36px 1fr; gap: 8px; margin-top: 10px; padding: 10px; border: 1.5px solid var(--gold); background: rgba(154, 116, 32, 0.07); }
.detail canvas { width: 32px; height: 32px; }
.detail p { margin: 2px 0; font-size: 13px; }
.detail-acts { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.trait-list, .mem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.trait-list li, .mem-list li { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; line-height: 1.55; }
.trait-list b { color: var(--trait); }
.mem-list b { color: var(--mem); }
.mem-list li.unknown { opacity: 0.45; }
.npc-card { display: grid; grid-template-columns: 52px 1fr; gap: 10px; border: 1.5px solid var(--ink); background: var(--paper-3); padding: 10px; margin-bottom: 8px; }
.npc-card .portrait { width: 52px; height: 52px; border: 1.5px solid var(--ink); background: #5a6e7a; }
.npc-card.small-card { grid-template-columns: 40px 1fr; padding: 8px; }
.npc-card.small-card .portrait { width: 40px; height: 40px; }
.npc-card.dead { opacity: 0.5; }
.npc-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.npc-body p { margin: 0; }
.npc-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.rel-row { display: flex; flex-wrap: wrap; gap: 4px; }
.rel-chip { font-size: 12px; border: 1px solid var(--rule); padding: 2px 6px; background: var(--paper); }
.rel-chip i { font-style: normal; color: var(--ink-2); margin-right: 4px; font-size: 11px; }
.mor-scale { margin: 16px 4px 4px; }
.mor-track { height: 10px; border: 1.5px solid var(--ink); background: linear-gradient(90deg, #6a1e1a, #b4a080 50%, #3e7c4d); position: relative; }
.mor-pin { position: absolute; top: -6px; width: 4px; height: 18px; background: var(--ink); transform: translateX(-50%); }
.mor-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-top: 4px; }
.fac-list { list-style: none; margin: 0; padding: 0; }
.fac-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dotted var(--rule); font-size: 14px; }
.fac-tier { font-weight: 700; color: var(--ink-2); }
.fac-tier.good { color: var(--good); }
.fac-tier.bad { color: var(--bad); }
.bestiary { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.bestiary li { border: 1px solid var(--rule); padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-size: 12px; background: var(--paper-3); }
.bestiary li.unknown { color: var(--rule); justify-content: center; min-height: 80px; }
.best-art { width: 40px; height: 40px; }
.seg { display: flex; gap: 6px; }
.about { margin-top: 24px; }

/* ---------- 결말 ---------- */
.end-body { line-height: 1.7; }
.end-desc { text-align: center; margin: 4px 0 14px; text-wrap: balance; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 8px; }
.end-stats div { border: 1.5px solid var(--ink); background: var(--paper-3); padding: 6px 10px; }
.end-stats dt { font-size: 12px; color: var(--ink-2); }
.end-stats dd { margin: 0; font-weight: 700; }
.end-body h3 { font-family: var(--f-display); font-weight: 400; font-size: 17px; margin: 16px 0 8px; }
.kept { display: flex; align-items: center; gap: 8px; border: 1.5px dashed var(--gold); padding: 8px 10px; }
.kept canvas { width: 32px; height: 32px; }

/* ---------- 토스트 ---------- */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(10px); background: var(--ink); color: var(--paper-3); padding: 8px 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .hud { grid-template-columns: 48px 1fr auto; gap: 8px; }
  .hud-portrait { width: 48px; height: 48px; }
  .hud-stats { gap: 2px 6px; padding-left: 6px; }
  .choice-t { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- 원스토어 광고 ---------- */
.chip.ad { color: var(--gold); border-style: dashed; background: rgba(154, 116, 32, 0.06); }
.chip.ad::before { content: '▶ '; font-size: 0.85em; }
html.has-safe-area #app { padding-top: var(--safe-top, 0px); padding-left: var(--safe-left, 0px); padding-right: var(--safe-right, 0px); }
html.has-safe-area .dock { padding-bottom: calc(6px + var(--safe-bottom, 0px)); }
html.has-safe-area .sheet-body { padding-bottom: calc(24px + var(--safe-bottom, 0px)); }
.mock-ad { position: fixed; inset: 0; z-index: 100; background: rgba(10, 8, 6, 0.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mock-ad-box { width: 100%; max-width: 360px; background: var(--paper); padding: 24px 16px; text-align: center; border: 2px solid var(--ink); }
.mock-ad-tag { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; }
.mock-ad-count { margin: 0 0 16px; font-family: var(--f-num); font-size: 32px; }
.mock-ad-acts { display: flex; flex-direction: column; gap: 8px; }

/* ---------- v4 데이터 연결 추가 ---------- */
.chip.fight { color: var(--blood); background: rgba(140, 42, 35, 0.06); }
.chip.fac, .chip.rel { color: var(--ink-2); }
.chip.love { color: #a8366a; background: rgba(168, 54, 106, 0.08); }
.note.love { color: #a8366a; font-weight: 700; }
.ev-text p.dim { color: var(--ink-2); }
.ev-text p.result { color: var(--ink); }
.ev-text p.aside { font-size: 13.5px; color: var(--ink-2); font-style: italic; }
.ev-text p.chosen { margin-top: 0.2em; }
.anchor-box { flex-direction: column; align-items: stretch; }
.vault-head { font-size: 13.5px; }
.vault-row { display: flex; flex-wrap: wrap; gap: 6px; }
.vault-item { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.vault-item canvas { width: 24px; height: 24px; }
.vault-item.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: rgba(154, 116, 32, 0.12); }
.vault-mark { font-style: normal; font-size: 11px; color: var(--gold); }
.data-warn { color: var(--bad) !important; }
.data-list { margin: 0; padding-left: 18px; max-height: 40vh; overflow: auto; }
.data-list li { margin: 2px 0; word-break: break-all; }
.end-desc.epilogue { font-size: 14px; color: var(--ink-2); }
.choice.ghost-choice { opacity: 0.85; }
/* Compact audio controls also fit the 320px mobile sheet. */
.sfx-settings { margin-bottom: 1.2rem; }
.sfx-volume { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .9rem 0; }
.sfx-volume span { flex: 1 0 100%; }
.sfx-volume input { flex: 1; min-width: 80px; max-width: 300px; accent-color: #806345; }
.sfx-volume output { min-width: 3.2em; font-variant-numeric: tabular-nums; }
