/* 사가스토리 — UI
   지도를 전체화면에 깔고, 그 위에 유리(glass) 패널을 띄우는 구성. */

:root {
  --ink:       #eef1f6;
  --ink-dim:   #9aa3b2;
  --ink-faint: #6b7383;

  --glass:     rgba(20, 23, 30, 0.72);
  --glass-2:   rgba(30, 34, 43, 0.72);
  --glass-br:  rgba(255, 255, 255, 0.09);

  --gold:      #f5b445;
  --gold-soft: rgba(245, 180, 69, 0.16);
  --blue:      #4aa3f0;
  --good:      #5ec26a;
  --bad:       #ef6b6b;
  --purple:    #b57bf5;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;

  --shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #12141a; color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI",
               "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── 지도 ─────────────────────────────────────────────── */
/* 지면(눕는 면)과 오브젝트(정면으로 서는 면)를 따로 둔다 */
#map-ground {
  position: fixed; display: block; z-index: 0;
  transform-style: flat; will-change: transform; backface-visibility: hidden;
}
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; }
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(120% 85% at 50% 45%, transparent 55%, rgba(0,0,0,.45) 100%),
    linear-gradient(180deg, rgba(0,0,0,.42), transparent 22%, transparent 74%, rgba(0,0,0,.5));
}
/* 2.5D 일 때는 멀어지는 위쪽을 안개로 덮어 지평선을 만든다 */
body.tilted #vignette {
  background:
    linear-gradient(180deg, #10131a 0%, rgba(16,19,26,.92) 9%, rgba(16,19,26,.55) 20%, transparent 40%),
    radial-gradient(130% 80% at 50% 62%, transparent 52%, rgba(0,0,0,.5) 100%),
    linear-gradient(180deg, transparent 72%, rgba(0,0,0,.5));
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--glass-br);
  box-shadow: var(--shadow);
}

/* ── 상단 ─────────────────────────────────────────────── */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto;
  grid-template-areas: "profile . tools" "wallet wallet wallet";
  gap: 10px; padding: 12px 12px 0;
  pointer-events: none;
}
#top > * { pointer-events: auto; }

.profile {
  grid-area: profile;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 15px 8px 9px; border-radius: 999px;
}
.avatar {
  position: relative; width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: conic-gradient(var(--gold) var(--p, 0%), rgba(255,255,255,.10) 0);
}
.avatar i {
  position: absolute; inset: 3px; border-radius: 50%;
  background: #1b1f27; display: grid; place-items: center;
  font-size: 19px; font-style: normal;
}
.p-meta { line-height: 1.25; }
.p-title { font-size: 13px; font-weight: 700; letter-spacing: -.2px; }
.p-sub { font-size: 10.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.p-sub b { color: var(--gold); font-weight: 600; }
.p-bars { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; width: 118px; }
.p-bar { position: relative; height: 5px; border-radius: 3px; overflow: hidden; background: rgba(0,0,0,.35); }
.p-bar > i { display: block; height: 100%; border-radius: 3px; }
.p-bar.hp > i { background: linear-gradient(90deg, #b3423f, #e0705f); }
.p-bar.mp > i { background: linear-gradient(90deg, #2f5f8a, #5aa0d0); }

.tools { grid-area: tools; display: flex; gap: 7px; position: relative; }
/* 도구 서랍 — 넓은 화면에서는 **없는 셈** 치고(display:contents) 안의 단추가
   도구줄에 그대로 늘어선다. 좁은 화면에서만 ⋯ 뒤로 접힌다(사가고 UI와 같은 결) */
.tools-drawer { display: contents; }
#btn-more { display: none; font-size: 19px; line-height: 1; padding-bottom: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--ink); font-size: 16px; line-height: 1;
  box-shadow: var(--shadow); transition: transform .12s, background .12s;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--glass-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--gold); border-color: var(--gold); color: #22190a; }
.icon-btn.sm { width: 30px; height: 30px; font-size: 13px; box-shadow: none; }
.icon-btn.txt { font-size: 11px; font-weight: 700; letter-spacing: -.3px; }
/* <a class="icon-btn"> 도 있다(어드민 링크) — button과 달리 안 가운데로 안 몰리고 밑줄이 생긴다 */
a.icon-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }

/* 사냥 화면을 크게 보기 — #top 밖의 독립 단추라 도구줄을 감춰도 남는다(사가고 UI와
   같은 결). 켜면 body 에 .focus 가 붙어 도구줄·독·자동 상태 띠를 지운다 —
   실제 조작(#touchpad·#hud)과 대화창(#talkbox)·쉬는 판(#camp)은 그대로 둔다 */
#btn-focus { position: fixed; top: calc(12px + var(--safe-t)); right: 12px; z-index: 14; }
body.focus #btn-focus { background: var(--gold); border-color: var(--gold); color: #22190a; }
body.focus #top, body.focus #autobar, body.focus #dock { display: none !important; }

.wallet {
  grid-area: wallet; justify-self: start;
  display: flex; gap: 3px; padding: 5px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.coin {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.coin span { font-size: 12.5px; }
.coin.hi { background: var(--gold-soft); color: #ffd794; }

/* ── 좌하단 위젯 ──────────────────────────────────────── */
#widgets {
  position: fixed; left: 12px; bottom: calc(14px + var(--safe-b)); z-index: 10;
  display: flex; flex-direction: column; gap: 8px; width: 236px;
}
.widget { border-radius: var(--r-md); padding: 10px 12px; }
.w-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--ink-dim); letter-spacing: .3px; margin-bottom: 5px;
}
.w-head b { color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: -.2px; }
.w-head .right { margin-left: auto; color: var(--gold); font-weight: 700; font-size: 11px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.10); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--gold); transition: width .3s; }
.bar.blue > i { background: var(--blue); }
.w-foot { margin-top: 5px; font-size: 10.5px; color: var(--ink-faint); }
.w-foot b { color: var(--ink-dim); }

/* ── 근처 대상 ────────────────────────────────────────── */
#near {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(14px);
  bottom: calc(16px + var(--safe-b)); z-index: 11;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
#near.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.near-card {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 9px 9px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
.near-ico {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 21px; background: #1b1f27; border: 2px solid var(--glass-br);
}
.near-meta { line-height: 1.3; }
.near-meta b { font-size: 13.5px; }
.near-meta small { display: block; font-size: 10.5px; color: var(--ink-dim); }

/* ── 액션 독 ──────────────────────────────────────────── */
/* 접지 않고 다 펼친다(사가고 UI와 같은 결) — 아홉 칸이라 사가고(여덟 칸)보다
   세로로 더 길다. **사냥 화면을 가리면 안 된다** — 세로 폭이 짧아 위쪽 도구줄과
   부딪힐 자리가 생기면 넘치는 만큼 안에서 스크롤하고(잘려도 화면 위를 덮지
   않는다), 좁은 화면에서는 가로 한 줄로 눕고 옆으로 스크롤한다(아래 780px 규칙) */
#dock {
  position: fixed; right: 12px; bottom: calc(14px + var(--safe-b)); z-index: 12;
  display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 130px - var(--safe-t) - var(--safe-b));
  overflow-y: auto; scrollbar-width: none;
}
#dock::-webkit-scrollbar { display: none; }
#dock button {
  width: 58px; height: 58px; border-radius: 19px; cursor: pointer;
  display: grid; place-items: center; gap: 1px;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--ink); box-shadow: var(--shadow);
  transition: transform .12s, background .12s, border-color .12s;
}
#dock button span { font-size: 21px; line-height: 1; }
#dock button small { font-size: 9.5px; color: var(--ink-dim); }
#dock button:hover { transform: translateY(-2px); }
#dock button.on { background: var(--gold); border-color: var(--gold); }
#dock button.on span, #dock button.on small { color: #22190a; }
#dock button i.badge {
  position: absolute; margin: -34px 0 0 34px; font-style: normal;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* ── 시트 ─────────────────────────────────────────────── */
#scrim {
  position: fixed; inset: 0; z-index: 20; background: rgba(6,8,12,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#scrim.show { opacity: 1; pointer-events: auto; }

#sheet {
  position: fixed; z-index: 21; display: flex; flex-direction: column;
  top: 12px; right: 12px; bottom: 12px; width: 392px;
  border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 20px)); opacity: 0;
  transition: transform .26s cubic-bezier(.22,1,.36,1), opacity .2s;
}
#sheet.show { transform: none; opacity: 1; }
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--glass-br); flex: 0 0 auto;
}
.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; letter-spacing: -.2px; }
.grip { display: none; }
#sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 14px; overscroll-behavior: contain; }
#sheet-body::-webkit-scrollbar { width: 8px; }
#sheet-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* ── 시트 내부 공통 ───────────────────────────────────── */
.sec { margin-bottom: 18px; }
.sec:last-child { margin-bottom: 4px; }
.sec h4 {
  margin: 0 0 9px; font-size: 10.5px; font-weight: 700;
  color: var(--ink-faint); letter-spacing: .6px; text-transform: uppercase;
}
.card { background: rgba(255,255,255,.045); border: 1px solid var(--glass-br); border-radius: var(--r-md); padding: 12px; }
.hint { font-size: 11.5px; color: var(--ink-dim); background: rgba(255,255,255,.04);
        border-radius: var(--r-sm); padding: 10px 12px; line-height: 1.6; }
.hint b { color: var(--gold); }
/* 도움말 시트의 "규칙" 목록(ui.js) — 2026-09-09, 죽은 CSS 정리 중 실수로
   같이 지웠다가 되살렸다(구 "던전 시트·경고" 절 소속이었지만 실제로는
   이 판 자체가 쓴다) */
.rulelist { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--ink-dim); line-height: 1.7; }
.rulelist b { color: var(--ink); }
/* 가방·저자 — 카드 안에서 단추를 한 줄로 흘린다 */
.btn-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; }
.card.on { border-color: rgba(232,193,90,.5); background: rgba(232,193,90,.07); }
.card + .card { margin-top: 7px; }
.muted { color: var(--ink-dim); }
.warn { color: var(--bad); }
small.muted { display: block; margin-top: 7px; font-size: 10.5px; }

.row { display: flex; align-items: center; gap: 8px; }
.row .sp { margin-left: auto; }

/* 건물 목록 */
.blist { display: flex; flex-direction: column; gap: 5px; }
.brow {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 4px 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.045); border: 1px solid transparent;
}
.brow.built { border-color: rgba(245,180,69,.22); background: rgba(245,180,69,.07); }
.brow.off { opacity: .42; }
.brow .bi { font-size: 18px; grid-row: span 2; }
.brow .bn { font-size: 12.5px; font-weight: 600; }
.brow .bl { font-size: 11px; font-weight: 700; color: var(--gold); }
.brow .be { grid-column: 2 / -1; font-size: 10.5px; color: var(--ink-dim); }

.prod { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prod > div {
  background: rgba(255,255,255,.045); border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.prod b { color: var(--gold); }

.rlist { display: flex; flex-direction: column; gap: 5px; }
.rrow {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px;
  background: rgba(255,255,255,.045); padding: 9px 11px; border-radius: var(--r-sm);
}
.rrow b { flex: 1; font-weight: 600; }
.rrow small { color: var(--ink-dim); font-size: 10.5px; }
.tag { font-size: 10px; font-weight: 700; color: var(--gold);
       background: var(--gold-soft); border-radius: 6px; padding: 3px 7px; }

/* 스프라이트 초상 */
.pt { width: 100%; height: 100%; object-fit: contain; display: block; }
.dcell .de { height: 40px; }
.dcell .de .pt { height: 100%; }
.locked-mark { font-size: 22px; line-height: 40px; }
.brow .bi { width: 26px; height: 26px; }
.enc-big { height: 96px; display: grid; place-items: center; }
.enc-big .pt { height: 96px; width: 96px; }
.enc-icon { overflow: hidden; }
.pc-emoji, .near-ico { overflow: hidden; }

/* 전투 화면 */
.battle-host { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--glass-br); background: #14161d; }
.battle-canvas { width: 100%; height: 200px; display: block; }

/* 부대 */
.stat-row { display: flex; justify-content: space-between; font-size: 12.5px; margin: 7px 0; }
.stat-row b { color: var(--gold); font-variant-numeric: tabular-nums; }
.bstate { font-size: 11.5px; color: var(--ink-dim); margin: 9px 0; line-height: 1.6; }

.plist { display: flex; flex-direction: column; gap: 7px; }
.pcard { background: rgba(255,255,255,.045); border: 1px solid var(--glass-br); border-radius: var(--r-md); padding: 10px; }
.pc-top { display: flex; align-items: center; gap: 10px; }
.pc-emoji {
  width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 21px; border: 2px solid var(--glass-br); border-radius: 13px; background: #1b1f27;
}
.pc-top > div { flex: 1; line-height: 1.35; min-width: 0; }
.pc-top b { font-size: 13px; }
.pc-top small { display: block; font-size: 10.5px; }
.pc-pet { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 11px; }
.pc-pet select {
  flex: 1; background: rgba(0,0,0,.34); color: var(--ink);
  border: 1px solid var(--glass-br); border-radius: 9px; padding: 6px 8px; font-size: 11.5px;
  font-family: inherit;
}
.benchlist { display: flex; flex-wrap: wrap; gap: 5px; }

/* 도감 */
.dexbar { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.dexbar .bar { flex: 1; }
.dexbar small { font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.dexgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.dcell {
  position: relative; background: rgba(255,255,255,.045); border: 1.5px solid transparent;
  border-radius: 13px; padding: 9px 3px 7px; text-align: center;
}
.dcell.locked { opacity: .3; }
.dcell .de { font-size: 22px; display: block; line-height: 1.1; }
.dcell small {
  display: block; font-size: 9.5px; margin-top: 4px; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dcell .cnt {
  position: absolute; right: 4px; top: 4px; font-style: normal; font-size: 9px; font-weight: 700;
  background: var(--gold); color: #22190a; border-radius: 7px; padding: 1px 5px;
}

/* 기록 */
.loglist { display: flex; flex-direction: column; gap: 4px; }
.lrow {
  font-size: 11.5px; padding: 8px 10px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.045); line-height: 1.5;
  border-left: 2.5px solid transparent;
}
.lrow span { color: var(--ink-faint); margin-right: 7px; font-variant-numeric: tabular-nums; }
.lrow.good { border-left-color: var(--good); }
.lrow.bad { border-left-color: var(--bad); }
.lrow.build { border-left-color: var(--gold); }
.lrow.level { border-left-color: var(--blue); }
.lrow.feat { border-left-color: var(--purple); }

/* ── 버튼 ─────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--glass-br); background: rgba(255,255,255,.06); color: var(--ink);
  border-radius: 12px; padding: 10px 14px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  transition: filter .12s, transform .1s;
}
.btn:hover:not(:disabled) { filter: brightness(1.3); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, #f7bd55, #e09a2a);
  border-color: #f7bd55; color: #22190a; font-weight: 700;
}
.btn.ghost { background: transparent; }
.btn.tiny { padding: 6px 10px; font-size: 11px; border-radius: 9px; }
.btn.wide { width: 100%; margin-top: 8px; }

/* ── 조우 모달 ────────────────────────────────────────── */
#encounter {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(6,8,12,.66);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
#encounter.show { display: flex; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.enc-card {
  width: 100%; max-width: 420px; border-radius: var(--r-lg); padding: 20px;
  background: rgba(24,27,34,.94); border: 1px solid var(--glass-br);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  animation: pop .22s cubic-bezier(.22,1,.36,1);
  /* 도움말·등용 카드처럼 내용이 길면 #encounter가 안 막고 그대로 넘쳐
     확인/닫기 버튼이 화면 밖으로 밀려 눌리지 않았다(다섯 판 공통 결함,
     2026-08-31 사가고·사가블로에서 발견). 세로 스크롤을 열어 준다 */
  max-height: calc(100vh - 36px); overflow-y: auto;
}
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.enc-head { display: flex; gap: 13px; align-items: center; margin-bottom: 15px; }
.enc-icon {
  width: 62px; height: 62px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 31px; border: 3px solid var(--glass-br); border-radius: 20px; background: #1b1f27;
}
.enc-name { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.enc-name .rar { font-size: 12px; margin-left: 5px; letter-spacing: 0; }
.enc-sub { font-size: 11.5px; color: var(--ink-dim); margin-top: 3px; }
.enc-stats { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }

.enc-bar {
  position: relative; height: 22px; background: rgba(0,0,0,.4);
  border-radius: 11px; overflow: hidden; margin: 12px 0;
}
.enc-bar-fill { height: 100%; background: linear-gradient(90deg, #e09a2a, #ffd691); transition: width .4s cubic-bezier(.22,1,.36,1); }
.enc-bar-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; }

.enc-cost { font-size: 11.5px; color: var(--ink-dim); margin: 9px 0; }
.enc-hist { font-size: 11.5px; line-height: 1.8; margin: 11px 0; min-height: 22px; }
.enc-hist .good { color: var(--good); }
.enc-hist .meh { color: var(--ink-dim); }
.enc-hint { font-size: 11.5px; color: var(--ink-dim); margin: 9px 0; }
.enc-hint b { color: var(--ink); }

.enc-actions { display: flex; flex-direction: column; gap: 7px; margin: 11px 0; }
.btn.appeal { text-align: left; padding: 11px 14px; border-radius: 13px; }
.btn.appeal b { display: block; font-size: 13px; }
.btn.appeal small { display: block; font-size: 10.5px; color: var(--ink-dim); margin-top: 2px; font-weight: 400; }

.enc-card.result { text-align: center; }
.enc-big { font-size: 60px; line-height: 1.1; margin-bottom: 6px; }
.enc-card.result h3 { margin: 6px 0; font-size: 20px; font-weight: 700; }
.enc-card.result.good h3 { color: var(--gold); }
.enc-card.result.bad h3 { color: var(--ink-dim); }
.quote { font-size: 12.5px; color: var(--ink-dim); font-style: italic; margin: 10px 0; line-height: 1.7; }
.enc-reward { font-size: 12.5px; color: var(--good); margin: 12px 0; line-height: 1.8; }

.catch-track {
  position: relative; height: 38px; background: rgba(0,0,0,.4);
  border: 1px solid var(--glass-br); border-radius: 13px; margin: 16px 0; overflow: hidden;
}
.catch-zone { position: absolute; top: 0; bottom: 0; background: rgba(94,194,106,.3);
              border-left: 2px solid var(--good); border-right: 2px solid var(--good); }
.catch-needle { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 10px #fff; }

.helplist { font-size: 12.5px; line-height: 2.1; margin: 12px 0; }
.helplist b { color: var(--gold); display: inline-block; min-width: 46px; }

/* ── 토스트 ───────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%) translateY(-14px);
  z-index: 50; padding: 11px 20px; border-radius: 999px;
  background: rgba(24,27,34,.94); border: 1px solid rgba(245,180,69,.45);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 넓은 화면에서 시트가 열리면 독과 근처 카드를 왼쪽으로 비켜준다 */
@media (min-width: 781px) {
  #dock { transition: right .26s cubic-bezier(.22,1,.36,1); }
  body.sheet-open #dock { right: 416px; }
  body.sheet-open #near.show { transform: translateX(calc(-50% - 202px)); }
}

/* ── 좁은 화면: 시트를 하단 시트로 ────────────────────── */
@media (max-width: 780px) {
  #sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 76%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(calc(100% + 20px));
    padding-bottom: var(--safe-b);
  }
  .grip {
    display: block; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22);
  }
  .sheet-head { padding-top: 18px; }
  #widgets { width: calc(100% - 96px); max-width: 236px; }
  #dock { flex-direction: row; }
  #dock button { width: 52px; height: 52px; border-radius: 17px; }
  #near { bottom: calc(84px + var(--safe-b)); }
  .wallet { flex-wrap: wrap; }
}

/* 독을 접지 않고 다 펼치면(사가고 UI와 같은 결) 아홉 칸이 된다 — 좁은 화면에서는
   가로로 다 못 앉으니 옆으로 스크롤한다(사가고에서 먼저 밟은 자리).
   **가운데 조작 띠(#hud, 사냥 중 스킬 줄)를 덮으면 안 된다** — #hud 는
   `min(560px, 100vw-96px)` 로 가운데 앉으므로, 독의 너비를 그 양옆 남는
   자리(= (100vw - hud폭)/2)로 못 박아 아무리 가로로 늘어도 hud 쪽으로
   넘어가지 않고 그 안에서만 옆으로 스크롤한다 */
@media (max-width: 780px) {
  #dock { left: 12px; justify-content: flex-end; overflow-x: auto; }
}
/* 561~780px 만 — #hud 가 아직 가운데 앉아 있는 폭이다(560px 이하에서는 아래
   560px 규칙이 hud 를 오른쪽으로 옮겨 독 위에 쌓아서, 이 계산이 필요 없다.
   그 폭까지 이 값을 그대로 물리면 hud 공식과 안 맞아 독이 과하게 좁아진다) */
@media (min-width: 561px) and (max-width: 780px) {
  #dock { max-width: calc((100vw - min(560px, 100vw - 96px)) / 2 - 24px); }
}

/* 세로 폭이 짧으면(가로로 눕힌 폰·창을 낮게 줄인 PC) 폭은 780px 을 넘어도
   독(세로 아홉 칸, 약 590px)이 위쪽 도구줄까지 덮을 수 있다 — 그때도 위
   780px 규칙과 같은 결로 눕혀서 사냥 화면을 가리지 않게 한다 */
@media (min-width: 781px) and (max-height: 640px) {
  #dock {
    flex-direction: row; left: 12px; justify-content: flex-end;
    max-height: none; overflow-y: visible; overflow-x: auto;
    max-width: calc((100vw - min(560px, 100vw - 96px)) / 2 - 24px);
  }
  #dock button { width: 46px; height: 46px; border-radius: 15px; }
}

/* ── 폰 폭: 상단 도구를 ⋯ 뒤로 접는다 (사가고 UI와 같은 결) ───────── */
@media (max-width: 600px) {
  #btn-more { display: inline-block; }
  .tools-drawer {
    display: none;
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 14;
    flex-wrap: wrap; justify-content: flex-end; gap: 7px;
    width: max-content; max-width: calc(100vw - 24px);
    padding: 9px; border-radius: var(--r-md);
    background: var(--glass); border: 1px solid var(--glass-br);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
  }
  .tools-drawer.show { display: flex; }
}

/* ══ 인물 성장 · 영지 경영 (v0.7) ═══════════════════════════════ */

/* 눌러서 상세로 가는 카드들 — 버튼이지만 카드처럼 보이게 */
.dcell, .pc-emoji, .benchbtn, .govchip {
  font: inherit; color: inherit; -webkit-appearance: none; appearance: none;
}
.dcell, .benchbtn, .govchip { cursor: pointer; }
button.pc-emoji { cursor: pointer; padding: 0; }
.dcell:active, .benchbtn:active, .govchip:active { transform: scale(.97); }

.bar.sm { height: 5px; }
.bar.tiny { height: 3px; margin-top: 5px; }

/* 부대 카드 */
.pc-top > .pc-meta { flex: 1; line-height: 1.35; min-width: 0; }
.pc-top > .pc-btns { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; }
.pc-meta b { font-size: 13px; }
.pc-meta small { display: block; font-size: 10.5px; }

/* 대기 인물 */
.benchlist { gap: 6px; }
.benchbtn {
  display: flex; align-items: center; gap: 7px; padding: 5px 9px 5px 5px;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br); border-radius: 12px;
}
.benchbtn .pt { width: 26px; height: 26px; }
.benchbtn b { font-size: 12px; font-weight: 600; }
.benchbtn small { font-size: 10px; color: var(--ink-dim); }

/* 교역 */
.tradelist { display: flex; flex-direction: column; gap: 5px; }
.trow {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.045); padding: 9px 11px; border-radius: var(--r-sm);
}
.trow.off { opacity: .45; }
.trow .te { font-size: 19px; width: 22px; text-align: center; }
.trow .tn { flex: 1; min-width: 0; line-height: 1.35; }
.trow .tn b { font-size: 12.5px; display: block; }
.trow .tn small { font-size: 10.5px; color: var(--ink-dim); }

/* 영지 카드 */
.rcard {
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  border-radius: var(--r-md); padding: 11px 12px; margin-bottom: 7px;
}
.rcard.cap { border-color: rgba(245,180,69,.30); background: rgba(245,180,69,.06); }
.rc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-top b { font-size: 13px; }
.rc-spec { font-size: 11.5px; font-weight: 700; margin-left: auto; }
.rc-dev { display: flex; align-items: center; gap: 8px; margin: 9px 0 7px; font-size: 11.5px; }
.rc-dev .bar { flex: 1; }
.rc-dev b { color: var(--gold); }
.rc-dev small { color: var(--ink-faint); font-size: 10.5px; white-space: nowrap; }
.rc-eff { font-size: 11px; color: var(--ink-dim); line-height: 1.6; }
.rc-gov {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11.5px;
}
.rc-gl { color: var(--ink-faint); }
.rc-gov select {
  flex: 1; min-width: 120px; background: rgba(0,0,0,.34); color: var(--ink);
  border: 1px solid var(--glass-br); border-radius: 9px; padding: 6px 8px;
  font-size: 11.5px; font-family: inherit;
}
.govchip {
  display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 4px;
  background: rgba(255,255,255,.06); border: 1px solid var(--glass-br); border-radius: 11px;
}
.govchip .pt { width: 24px; height: 24px; }
.govchip b { font-size: 12px; }
.govchip small { font-size: 10px; color: var(--ink-dim); }

/* ── 인물 · 펫 상세 ─────────────────────────────────────────── */
#detail {
  position: fixed; inset: 0; z-index: 45; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(6,8,12,.70);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}
#detail.show { display: flex; animation: fade .18s ease-out; }

.dt-card {
  position: relative; width: 100%; max-width: 440px; margin: auto;
  border-radius: var(--r-lg); padding: 18px;
  background: rgba(24,27,34,.96); border: 1px solid var(--glass-br);
  box-shadow: 0 24px 70px rgba(0,0,0,.62);
  animation: pop .22s cubic-bezier(.22,1,.36,1);
}
.dt-x { position: absolute; top: 11px; right: 11px; z-index: 2; }

.dt-top { display: flex; gap: 14px; align-items: flex-start; }
.dt-portrait {
  width: 132px; height: 152px; flex: 0 0 auto;
  border-radius: 14px; display: block; object-fit: cover;
}
.dt-head { flex: 1; min-width: 0; padding-right: 26px; }
.dt-name { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.dt-name b { font-size: 20px; letter-spacing: -.4px; }
.dt-name .hanja { font-size: 12.5px; color: var(--ink-faint); letter-spacing: 1px; }
.dt-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.dt-tags .tag { background: rgba(255,255,255,.08); color: var(--ink-dim); }
.dt-tags .tag.fac { color: #fff; }
.dt-lv { font-size: 12.5px; margin: 8px 0 6px; }
.dt-lv b { color: var(--gold); font-size: 15px; }
.rankmark { font-size: 11px; color: var(--purple); font-weight: 700; }
.dt-where { font-size: 11px; color: var(--ink-dim); margin-top: 7px; }

.dt-stats { margin: 15px 0 4px; display: flex; flex-direction: column; gap: 7px; }
.st { display: flex; align-items: center; gap: 9px; font-size: 11.5px; }
.st-l { width: 30px; color: var(--ink-dim); flex: 0 0 auto; }
.stbar {
  position: relative; flex: 1; height: 9px; border-radius: 5px;
  background: rgba(255,255,255,.09); overflow: hidden;
}
.stbar > i {
  position: absolute; left: 0; top: 0; height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #e09a2a, #ffd691);
}
/* 성장분과 기본치의 경계 — 어디까지가 타고난 힘인지 보인다 */
.stbar > u {
  position: absolute; left: 0; top: 0; height: 100%;
  border-right: 2px solid rgba(255,255,255,.55);
}
.st-v { width: 62px; text-align: right; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.st-v em { font-style: normal; color: var(--good); font-size: 10px; margin-left: 3px; }

.dt-line {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; padding: 9px 11px; margin-top: 10px;
  background: rgba(255,255,255,.045); border-radius: var(--r-sm);
}
.dt-line b { color: var(--gold); font-variant-numeric: tabular-nums; }

.dt-pet { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 11.5px; flex-wrap: wrap; }
.dt-pet select {
  flex: 1; min-width: 140px; background: rgba(0,0,0,.34); color: var(--ink);
  border: 1px solid var(--glass-br); border-radius: 9px; padding: 6px 8px;
  font-size: 11.5px; font-family: inherit;
}
.dt-pet small { width: 100%; }

.dt-bio { font-size: 12px; line-height: 1.8; margin: 13px 0 0; color: #d7dce6; }
.dt-acts { display: flex; flex-direction: column; gap: 6px; margin-top: 13px; }
.dt-acts .btn.wide { margin-top: 0; }
.dt-tip { display: block; margin-top: 9px; font-size: 10.5px; line-height: 1.7; }
.dt-tip b { color: var(--ink); }

@media (max-width: 780px) {
  .dt-card { padding: 15px; }
  .dt-top { gap: 11px; }
  .dt-portrait { width: 104px; height: 122px; }
  .dt-name b { font-size: 17px; }
  .st-v { width: 56px; }
}

/* ── 오버월드 전체 지도 (2026-09-02, M키식 토글) ───────────────
   #detail 과 같은 뼈대(꽉 찬 배경 + 가운데 카드) — 다른 점은 카드 안에
   가로로 늘어선 마을·사냥터 사슬(.ow-chain)뿐이다. */
#owmap {
  position: fixed; inset: 0; z-index: 46; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(6,8,12,.74);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}
#owmap.show { display: flex; animation: fade .18s ease-out; }

.ow-card {
  position: relative; width: 100%; max-width: 620px; margin: auto;
  border-radius: var(--r-lg); padding: 20px 18px;
  background: rgba(24,27,34,.96); border: 1px solid var(--glass-br);
  box-shadow: 0 24px 70px rgba(0,0,0,.62);
  animation: pop .22s cubic-bezier(.22,1,.36,1);
}
.ow-card h3 { margin: 0 0 12px; font-size: 16px; }
.ow-x { position: absolute; top: 11px; right: 11px; z-index: 2; }

.ow-chain {
  display: flex; align-items: stretch; gap: 0; overflow-x: auto;
  padding: 4px 2px 10px; -webkit-overflow-scrolling: touch;
}
.ow-node {
  flex: 0 0 auto; width: 92px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 10px 6px; border-radius: 12px;
  background: rgba(255,255,255,.045); border: 1px solid transparent;
  text-align: center;
}
.ow-node i { font-size: 20px; }
.ow-node b { font-size: 11.5px; line-height: 1.3; }
.ow-node small { font-size: 9.5px; color: var(--ink-dim); }
.ow-node.locked { opacity: .45; }
.ow-node.open.town b { color: #a8d8e0; }
.ow-node.open.field b { color: #ffcf7a; }
.ow-node.cur {
  background: rgba(232,193,90,.16); border-color: var(--gold, #e8c15a);
  box-shadow: 0 0 0 1px rgba(232,193,90,.35) inset;
}
.ow-node.cur b { color: var(--gold, #e8c15a); }
.ow-link {
  flex: 0 0 20px; align-self: center; height: 2px; margin: 0 -1px;
  background: rgba(255,255,255,.12);
}
.ow-link.open { background: rgba(232,193,90,.4); }

@media (max-width: 780px) {
  .ow-card { padding: 16px 12px; }
  .ow-node { width: 78px; padding: 8px 4px; }
}

/* ══ 오프라인 / 온라인 · 사관 (v0.9) ═══════════════════════════ */

.modeswitch { display: flex; gap: 6px; margin-bottom: 9px; }
.modeswitch .btn { flex: 1; }

.netrow {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 9px; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 11.5px; background: rgba(255,255,255,.05);
}
.netrow.ok { border: 1px solid rgba(94,194,106,.30); }
.netrow.bad { border: 1px solid rgba(239,107,107,.30); }
.netrow .btn { margin-left: auto; }

.hint.goodbox { border: 1px solid rgba(94,194,106,.35); background: rgba(94,194,106,.09); color: #bfe8c6; }
.hint.goodbox b { color: #eaffee; }

.acts { display: flex; flex-direction: column; gap: 6px; }
.acts .btn.wide { margin-top: 0; text-align: left; }

.talkbox {
  margin-top: 9px; padding: 10px; border-radius: var(--r-md);
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  display: flex; flex-direction: column; gap: 7px;
}
.talkbox .row { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.talkbox select, .talkbox input {
  flex: 1; background: rgba(0,0,0,.34); color: var(--ink);
  border: 1px solid var(--glass-br); border-radius: 9px; padding: 7px 9px;
  font-size: 12px; font-family: inherit; min-width: 0;
}
.talkbox .btn.wide { margin-top: 0; }

.ailog { display: flex; flex-direction: column; gap: 6px; }
.airow {
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  border-left: 3px solid var(--purple);
  border-radius: var(--r-sm); padding: 9px 11px;
}
.ai-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.ai-top b { font-size: 12px; }
.ai-top small { font-size: 10px; color: var(--ink-faint); margin-left: auto; }
.ai-text { font-size: 11.5px; line-height: 1.75; color: #d7dce6; white-space: normal; }

.on-dot { color: var(--purple); }

@media (max-width: 780px) {
  .modeswitch { flex-direction: column; }
}

/* ── 3D 모드 — 지평선 안개를 더 깊게 (포켓몬GO식 카메라) ──
 * 2026-09-09 — 이 아래 있던 "고딕 던전 · 오브 HUD · 서당" 셋(v1.0)은 죽은
 * CSS였다(PLAN 28절 "UI 리뉴얼" 감사 중 찾음) — saga-dungeon 템플릿에서
 * 복사해 온 뒤 이 판(메이플風 옆으로 걷기)에 맞춰 JS 쪽만 걷어내고(`ui.js`
 * 머리말 "던전 전용을 걷어낸 자리에" 참고) CSS는 안 지웠던 것. 어느 kind
 * 도 `#dg-*`·`.qcard`류 클래스를 실제로 안 쓴다(문답은 사가국지만 갖는다 —
 * 루트 CLAUDE.md). 지웠다 — 이 안개 효과만 실제로 쓰인다. */
body.tilted3 #vignette {
  background:
    linear-gradient(180deg, #0d1017 0%, rgba(13,16,23,.95) 12%, rgba(13,16,23,.6) 26%, transparent 46%),
    radial-gradient(140% 85% at 50% 70%, transparent 50%, rgba(0,0,0,.55) 100%),
    linear-gradient(180deg, transparent 76%, rgba(0,0,0,.55));
}

/* ── 자동 순행 (auto.js) ─────────────────────────────────── */
#autobar {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(106px + var(--safe-t)); z-index: 13;
  display: none; max-width: min(560px, calc(100vw - 24px));
}
#autobar.show { display: block; }
.auto-card {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; border-radius: 14px;
  background: var(--glass); border: 1px solid rgba(201,162,74,.45);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow); font-size: 12px; white-space: nowrap;
}
.auto-card b { color: var(--gold); font-size: 12px; }
.auto-card span {
  color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis;
  max-width: 46vw;
}
.autoflags { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 4px; }


/* ── 쉬는 화면(캠프) — 동행이 없을 때 뜨는 배경 ───────────────
 * 원래 던전 게임의 "본영(本營)" 화면 CSS를 그대로 물려받은 자리였다(id
 * 이름도 그 흔적, 2026-09-09 정리). z-index 는 #stage3d(1) 보다도 뒤(0)다 — 앞에 두면 3D 가 그려질 때(#stage 가
   ctx.clearRect 로 투명해지는 자리) 이 배경이 3D 세계를 덮어 버린다.
   지금은 동행이 하나도 없을 때만(자가진단 밖에서는 극히 드묾) 쓰인다.
   **음수를 쓰지 않는다** — 실기기(하이브리드 GPU 노트북)에서 음수 z-index +
   전체화면 fixed 캔버스 조합이 크롬 컴포지터에 안 올라가(SharedImage mailbox
   에러) 캔버스가 화면에 아예 합성되지 않는 버그를 실제로 밟았다. 순서만
   지키면서 0 이상으로 다 밀어 올렸다(camp-bg 0 < stage3d 1 < stage 2) */
#camp-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(120% 80% at 50% 8%, rgba(201,162,74,.10), transparent 60%),
    radial-gradient(90% 70% at 50% 100%, rgba(0,0,0,.6), transparent 70%),
    linear-gradient(180deg, #171a21 0%, #101319 55%, #0b0d12 100%);
}
#camp-bg::after {                     /* 성문 실루엣 — 선 몇 개로 분위기만 */
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent 18%, rgba(255,255,255,.03) 18.4%, transparent 19%),
    linear-gradient(90deg, transparent 81%, rgba(255,255,255,.03) 81.4%, transparent 82%),
    linear-gradient(0deg, rgba(255,255,255,.04) 0 1px, transparent 1px) ;
  background-position: 0 0, 0 0, 0 62%;
  background-repeat: no-repeat;
}
#camp {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 8; width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 210px); overflow: auto;
  display: none;
}
#camp.show { display: block; }
.camp-card {
  padding: 16px 16px 14px; border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.camp-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.camp-head b { font-size: 15px; color: var(--gold); }
.camp-head span { font-size: 11.5px; }
.camp-card .btn.wide { margin-top: 8px; }
.camp-auto { margin-top: 12px; border-top: 1px solid var(--glass-br); padding-top: 4px; }
.camp-auto .sec { margin: 0; }
.camp-auto h4 { margin-top: 6px; }

/* ── 사냥터 게임 ──────────────────────────────────────────── */
#stage { position: fixed; inset: 0; z-index: 2; display: block; touch-action: none; }
/* 3D 바탕 — #stage(2D, 조작·오버레이) 바로 뒤에 깔린다. WebGL 이 없으면 그냥 비어 있고
   #stage 가 옛 2D 그림을 그대로 채운다(side-view.js 의 use3d 판정) */
/* width/height 100% 을 빼먹으면(다른 네 판은 다 갖고 있다) inset:0 을 무시하고
   캔버스 고유 크기(렌더 해상도, 뷰포트보다 큼) 그대로 떠서 왼쪽 위 한 귀퉁이만
   보이고 나머지는 새까맣게 보인다 — side-view3d.js 의 setSize 세 번째 인자를
   고친 것과 같은 문제를 CSS 쪽에서도 막아 둔다(다섯 판 공통 안전장치) */
#stage3d { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; pointer-events: none; }

#hud {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-b)); z-index: 12;
  display: none; width: min(560px, calc(100vw - 96px));
}
#hud.show { display: block; }
.hud-card {
  padding: 9px 11px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
/* 줄·문 안내 — 그 앞에 섰을 때만 뜬다 */
.hud-hint {
  display: none; margin: -2px 0 7px; text-align: center;
  font-size: 12px; font-weight: 600; letter-spacing: .2px;
  color: #dff0ff; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.hud-hint.show { display: block; }

/* 마을 사람 대화(PLAN 16절) — #hud 바로 위, 같은 폭·같은 유리 재질 */
#talkbox {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + var(--safe-b)); z-index: 13;
  display: none; width: min(480px, calc(100vw - 48px));
}
#talkbox.show { display: block; }
.talk-card {
  padding: 12px 14px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.talk-card b { display: block; font-size: 13px; margin-bottom: 5px; color: #f0e2c8; }
.talk-card p { margin: 0 0 9px; font-size: 13px; line-height: 1.55; color: var(--ink); }
.talk-card .btn { width: 100%; }
/* 체력·기력 띠는 없다 — 상단 프로필 카드(.p-bars)가 상시 보여 준다.
   여기서 또 그리면 조작 띠가 세로로 길어져 캐릭터 발밑을 가린다 */
.hud-skills { display: flex; gap: 6px; align-items: center; }
.hud-sk {
  position: relative; width: 46px; height: 46px; border-radius: 14px; overflow: hidden;
  background: rgba(255,255,255,.06); border: 1px solid var(--glass-br);
  color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.hud-sk.ready { border-color: rgba(201,162,74,.7); background: rgba(201,162,74,.16); }
.hud-sk b { font-size: 20px; line-height: 1; }
.hud-sk small {
  position: absolute; right: 4px; top: 2px; font-size: 9px; color: var(--ink-dim);
}
.hud-sk u {                       /* 쿨다운 — 위에서 덮는다 */
  position: absolute; left: 0; top: 0; right: 0; display: block;
  background: rgba(0,0,0,.55); height: 0;
}
.hud-sk.potion { border-color: rgba(208,89,107,.55); }
.hud-sk.potion small { color: #f0b7bf; }
.hud-out { margin-left: auto; }

/* ── 손가락 조작판 (2026-09-01) ─────────────────────────────
 * 화면을 숨은 넷으로 나눠 짚던 예전 방식은 손가락뿐인 기기에서 이 단추가
 * 대신 맡는다(side-view.js 의 onDown 이 core.touchOnly() 일 때 존을 안 켜
 * 겹쳐 두 번 눌리지 않는다). #hud·#dock 위로, 화면 좌우 가장자리에 띄운다 —
 * 가운데(체력·기력·스킬 띠)를 가리지 않으려는 자리다.
 * 2026-09-09 — "피시에서는 마우스 클릭 버튼으로"(사용자 요청). 원래는
 * 손가락뿐인 기기에서만(hover:none · pointer:coarse) 보이게 미디어쿼리로
 * 막아 뒀는데, 그 담을 뗀다 — PC 마우스로도 그대로 눌러 걸을 수 있다
 * (숨은 존 탭 이동은 그대로 살아 있어 둘 다 쓸 수 있다, 사가블로 #dg-pad와
 * 같은 결). */
#touchpad { position: fixed; inset: 0; z-index: 11; pointer-events: none; display: none; }
.pad-side { position: absolute; display: none; gap: 10px; pointer-events: auto; }
.pad-l { left: 14px; bottom: calc(150px + var(--safe-b)); }
.pad-r { right: 14px; bottom: calc(150px + var(--safe-b)); flex-direction: column; }
.pad-btn {
  width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-br);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--ink); font-size: 19px; line-height: 1;
  box-shadow: var(--shadow); transition: transform .1s, background .1s;
  touch-action: none;
}
.pad-btn:active { transform: scale(.9); background: var(--glass-2); }
#touchpad.show { display: block; }
#touchpad.show .pad-side { display: flex; }

/* ── 키 세팅(⌨️, 2026-09-09) ──────────────────────────── */
.key-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-top: 6px;
  background: rgba(255,255,255,.04); border-radius: var(--r-sm);
}
.key-row b { flex: 0 0 48px; }
.key-cur { flex: 1; font-weight: 700; color: var(--gold); letter-spacing: .5px; }
.key-row button {
  padding: 6px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--glass-br); background: rgba(255,255,255,.06);
  color: var(--ink); font-size: 11.5px; cursor: pointer;
}

/* ══ 폰 화면 (2026-08-26) ═════════════════════════════════════════
 * 이 아래는 **좁은 폭에서만** 걸린다. 780px 미디어쿼리가 이미 시트·독을
 * 하단으로 내려 주지만 상단과 조작 띠는 손대지 않아, 폰(390px)에서 무너졌다 —
 * 프로필 이름이 한 글자씩 줄바꿈되고, 도구 여섯 중 둘이 화면 밖으로 나가고,
 * **조작 띠 여덟 칸이 독에 덮여** 아예 누를 수 없었다.
 * (사가의숲에서 같은 자리를 먼저 밟았다 — 그 커밋과 같은 결로 짰다)
 */
@media (max-width: 560px) {
  /* ── 상단 ─────────────────────────────────────────────────── */
  #top { gap: 6px; padding: calc(6px + var(--safe-t)) 8px 0; }

  /* 프로필 — 지도·자동만 붙박이라 도구가 먹는 폭이 줄었지만, "그래도 위쪽을
     가린다"(사용자)는 지적에 카드 자체를 낮춘다. 두 줄이던 상태 줄을 한 줄로
     자르고, 아바타·글자·막대를 다 한 단계씩 내려 세로 높이를 확 줄인다. */
  .profile { min-width: 0; max-width: calc(100vw - 130px); padding: 4px 9px 4px 5px; gap: 6px; }
  .avatar { width: 28px; height: 28px; }
  .avatar i { font-size: 12px; }
  .p-meta { min-width: 0; }
  .p-title { font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .p-sub { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .p-bars { width: 100%; max-width: 100px; margin-top: 2px; gap: 1px; }
  .p-bar { height: 3.5px; }

  /* 도구 — 지도·자동·더보기 셋뿐이라 한 줄로 끝난다(예전엔 아홉이라 두세 줄이었다) */
  .tools { gap: 5px; }
  .icon-btn { width: 34px; height: 34px; font-size: 13px; }
  .icon-btn.txt { font-size: 9.5px; }

  .wallet { flex-wrap: wrap; padding: 4px 6px; }
  .coin { padding: 3px 7px; font-size: 11px; }

  /* ── 조작 띠 ───────────────────────────────────────────────
   * 3차 전직으로 칸이 여섯에서 여덟으로 늘었다. 폰에서는 한 줄에 못 들어가므로
   * **접어서 두 줄**로 두고, 독보다 위로 올린다(같은 높이에 두면 독이 덮는다).
   * 체력·기력 띠를 상단 프로필로 뺀 뒤로 카드가 한 켜 낮아졌다 — 그래도 폰에서는
   * 딱 캐릭터 발밑(화면 가운데 아래)이라, 칸을 더 줄이고 배경도 옅게 해 뒤로
   * 비친다. 안 그러면 공격·스킬 단추 판이 전투 화면을 통째로 가려 버린다.
   */
  /* "밑에 창(스킬·공격)을 메뉴(독) 옆으로 내려줘" 요청 — 화면 가운데 아래를
     가로로 덮던 띠를 접어, 독 바로 위에 붙는 좁은 세로 더미로 옮긴다.
     화면 가운데(캐릭터 발밑)는 완전히 비운다. 독은 right:6px·bottom:14px·
     42px 버튼이라 top 이 56px(+safe) — 그 위 8px 틈에 올려 앉힌다 */
  #hud { left: auto; right: 6px; transform: none; width: auto; bottom: calc(64px + var(--safe-b)); }
  /* "스킬 버튼은 투명으로, 모바일 전투 방식처럼" 요청 — 카드 배경을 아예
     없앤다. 칸(.hud-sk) 자체의 옅은 유리 배경만 남아 버튼은 여전히 보이고
     눌린다 — 그 뒤를 감싸던 판만 사라져 전투 화면이 그대로 비친다 */
  .hud-card {
    padding: 4px; border-radius: 12px; box-shadow: none;
    background: transparent; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  /* 나머지 무예는 auto.js(tickSkillsOnly) 가 자동으로 쓰므로 조작 띠엔
     "공격"(쿨 가장 짧은 자리) 한 칸 + 탕약, 둘뿐이다 — 2칸이면 충분하다 */
  .hud-skills { display: grid; grid-template-columns: repeat(2, 28px); gap: 2px; }
  .hud-sk { width: 28px; height: 28px; border-radius: 9px; }
  .hud-sk b { font-size: 12px; }
  .hud-sk small { font-size: 7px; right: 2px; }
  /* '나온다' 는 두 칸을 다 차지하는 맨 아랫줄로 */
  .hud-out { grid-column: 1 / -1; margin-left: 0; padding: 3px 8px; font-size: 10px; text-align: center; }

  /* 독 — 가로로 깔린다(780px 규칙). 사냥터·가방·더보기 셋뿐이라 오른쪽에
     붙여도 화면을 넓게 안 먹는다(예전엔 여섯이라 화면 폭을 다 썼다).
     상단 도구줄(icon-btn 34px)만큼 더 줄인다 — "하단 독도 더 접어 달라"(사용자) */
  #dock { right: 6px; gap: 5px; }
  #dock button { width: 42px; height: 42px; border-radius: 13px; flex: 0 0 auto; }
  #dock button span { font-size: 16px; }
  #dock button small { font-size: 8px; }

  /* 손가락 조작판 — #hud 가 여기서 거의 전체 폭(calc(100vw-16px))으로 커지고
     두 줄(3차 전직은 스킬 여덟 칸)이라 카드가 높다. 체력·기력 띠를 뺀 뒤로
     260px 만큼은 안 필요해 줄였다(실기기에서 카드 높이 보고 다시 잴 것) */
  .pad-l, .pad-r { bottom: calc(210px + var(--safe-b)); gap: 9px; }
  .pad-btn { width: 44px; height: 44px; font-size: 16px; }

  /* 자동 상태 띠 — 상단이 두 줄인 건 그대로지만 프로필 카드를 낮춰서
     그만큼 올라온다(실기기에서 다시 잴 것) */
  #autobar { top: calc(98px + var(--safe-t)); }
}

/* ══ 가로로 눕힌 폰 (2026-09-09, PLAN 17절 "가로 모드") ═══════════════════
 * 위 560px 규칙은 **폭**으로 가른다 — 세로로 든 폰(390px 안팎)만 잡고,
 * 가로로 눕힌 폰(예: 844×390)은 폭이 넉넉해(844px) 안 걸린다. 그러면 이
 * 파일 앞쪽의 "PC·태블릿" 기본값(#top 두 줄, 조작판 bottom 150px, #hud·
 * #dock 58px 단추)을 그대로 받는데, 세로 390px 화면에서 그 셋을 다 합치면
 * 위아래로 화면의 3분의 2 가까이가 UI로 먹혀 PLAN 17절이 가로 모드에 바라는
 * "더 넓은 시야 · 더 많은 게임 화면"과 정면으로 부딪힌다.
 *
 * 그래서 **폭이 아니라 높이**로 가른다(`orientation:landscape`만으로는 세로가
 * 넉넉한 태블릿 가로 모드까지 잡아버린다 — `max-height`를 반드시 같이 건다).
 * 세로 여유가 없으니 위(상단바)·아래(조작판·HUD·독) 세 군데를 동시에 줄여
 * 가운데 게임 화면 몫을 되찾는다. **정확한 여백은 실기기에서 다시 잴 것**
 * — 여기 값은 기존 560px 규칙의 축소 비율을 그대로 옮긴 어림값이다. */
@media (orientation: landscape) and (max-height: 500px) {
  #top { padding: calc(4px + var(--safe-t)) 8px 0; gap: 4px; }
  .avatar { width: 32px; height: 32px; }
  .avatar i { font-size: 14px; }
  .p-bars { margin-top: 2px; }
  #autobar { top: calc(60px + var(--safe-t)); }

  #dock { bottom: calc(6px + var(--safe-b)); gap: 6px; }
  #dock button { width: 46px; height: 46px; border-radius: 15px; }
  #dock button span { font-size: 17px; }
  #dock button small { font-size: 8px; }

  #hud { bottom: calc(6px + var(--safe-b)); }
  .hud-card { padding: 6px 9px; }
  .hud-sk { width: 38px; height: 38px; border-radius: 12px; }
  .hud-sk b { font-size: 16px; }

  /* 조작판(◀▶·▲▼) — 단추를 줄이고 HUD 가 낮아진 만큼 바닥에 더 붙인다 */
  .pad-l, .pad-r { bottom: calc(84px + var(--safe-b)); gap: 8px; }
  .pad-btn { width: 44px; height: 44px; font-size: 16px; }
}

/* 손가락에는 :hover 가 없다 — 뜬 채로 굳는 것을 막는다 */
@media (hover: none) {
  .icon-btn:hover, #dock button:hover, .hud-sk:hover, .btn:hover:not(:disabled) {
    transform: none; filter: none;
  }
  .icon-btn:hover { background: var(--glass); }
}
