/* 사가고 — 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 일 때는 멀어지는 위쪽을 안개로 덮어 지평선을 만든다.
   **엷게 줄였다**(2026-08-29) — 밤 시각(조명 자체가 어두워진다)과 겹치면
   원래 짙기(맨 위 .92)가 그 위에 또 쌓여 배우·집이 거의 안 보일 만큼
   어두웠다(사용자가 실기기로 발견). 지평선을 가리는 목만 남기고 반쯤 걷었다. */
body.tilted #vignette {
  background:
    linear-gradient(180deg, #10131a 0%, rgba(16,19,26,.5) 9%, rgba(16,19,26,.28) 20%, transparent 40%),
    radial-gradient(130% 80% at 50% 62%, transparent 52%, rgba(0,0,0,.28) 100%),
    linear-gradient(180deg, transparent 72%, rgba(0,0,0,.28));
}

/* **이 규칙은 위의 `body.tilted` 뒤에 와야 한다.** 특정성이 같아서 나중 것이 이긴다 —
   앞에 두었더니 3D 인데도 가짜 지평선이 하늘을 덮어 화면이 새까맸다.
   3D 는 진짜 하늘과 안개(fog)를 가지고 있으니 이 덮개가 필요 없다. */
body.r3d #vignette,
body.r3d.tilted #vignette {
  background: radial-gradient(120% 88% at 50% 46%, transparent 66%, rgba(0,0,0,.28) 100%);
}

.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-goal {
  margin-top: 2px; font-size: 11px; font-weight: 600; cursor: pointer;
  color: #ffd76a; font-variant-numeric: tabular-nums;
}
.p-goal b { color: #fff; }
.p-goal.ready { color: #7ee787; }

/* margin-right: #top 밖의 #btn-mapfocus(⛶)가 이 줄과 똑같은 top-right 자리(우측
   12px)에 고정돼 있다 — 자리를 안 비워 두면 도구줄 맨 끝 단추(⋯ 또는 어드민 쪽
   단추들)가 그 밑에 완전히 가려 눌리지 않는다(2026-09-11, 실기에서 발견) */
.tools { grid-area: tools; display: flex; gap: 7px; position: relative; margin-right: 50px; }
/* 도구 서랍 — 넓은 화면에서는 **없는 셈** 치고(display:contents) 안의 단추가
   도구줄에 그대로 늘어선다. 좁은 화면에서만 ⋯ 뒤로 접힌다(아래 600px 규칙) */
.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 밖의 독립 단추라 도구줄을 감춰도 남는다(2026-09-09).
   켜면 body 에 .mapfocus 가 붙어 도구줄·독·근처 패널·자동 순행 배너를 지운다 —
   조우·시트·미니맵처럼 상황에 따라 뜨는 것은 그대로 둔다(감추면 오히려 못 본다) */
#btn-mapfocus { position: fixed; top: calc(12px + var(--safe-t)); right: 12px; z-index: 14; }
body.mapfocus #btn-mapfocus { background: var(--gold); border-color: var(--gold); color: #22190a; }
body.mapfocus #top, body.mapfocus #autobar, body.mapfocus #near, body.mapfocus #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); }

/* ── 미니맵 (minimap.js) ──────────────────── */
/* 좌하단이다 — 독(dock)은 오른쪽, 근처 대상(#near)은 가운데라 서로 안 걸린다 */
#minimap {
  position: fixed; left: 12px; bottom: calc(14px + var(--safe-b)); z-index: 10;
  padding: 5px; border-radius: 50%; line-height: 0; cursor: pointer;
  transition: width .16s, height .16s, padding .16s;
}
#minimap canvas { display: block; border-radius: 50%; }
#minimap .mm-range {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -8px; padding: 1px 7px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--glass-br);
  font-size: 9.5px; font-weight: 700; color: var(--ink-dim);
  line-height: 1.5; letter-spacing: -.2px; pointer-events: none;
}
/* 접으면 단추 하나만 남는다 — 그리기도 멈춘다(draw 가 바로 돌아선다) */
#minimap.folded { padding: 0; width: 40px; height: 40px; border-radius: 50%; }
#minimap.folded canvas { display: none; }
#minimap.folded .mm-range {
  position: static; transform: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; font-size: 17px; background: none; border: 0;
}
/* ── 가상 조이스틱·PC 방향버튼 — 2026-09-09 ────────────────────
 * "움직이는 게 너무 힘들다"(사가블로 등과 같은 재신고) — 이 판은 실제
 * GPS 로 걷는 게 원작 컨셉이라 오버월드 이동에는 안 맞지만, PC 프로토타입
 * 용 "키보드(모의 이동)" 모드(world.js mode==='keyboard')에는 그대로
 * 맞는다 — world.js 에 이미 있던 setStick(dx,dy) 채널(그때까지 아무 화면도
 * 안 부르고 있었다)에 연결한다. 미니맵(좌하단, 넓은 화면에서만)보다 위에
 * 띄워 겹치지 않게 한다. */
#gjoy, #gpad {
  display: none;
  position: fixed; z-index: 20;
  left: 14px; bottom: calc(150px + var(--safe-b));
  width: 118px; height: 118px;
}
#gjoy.show, #gpad.show { display: block; }
#gjoy {
  border-radius: 50%; touch-action: none;
  background: rgba(20, 22, 28, .32); border: 1px solid var(--glass-br);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, .35), 0 3px 10px rgba(0, 0, 0, .25);
}
#gjoy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px;
  margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #cfe8ff, var(--gold) 75%, #7a5a1a);
  border: 1px solid var(--glass-br);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
#gpad button {
  position: absolute; width: 38px; height: 38px; border-radius: 8px;
  background: rgba(20, 22, 28, .5); border: 1px solid var(--glass-br);
  color: var(--ink); font-size: 16px; line-height: 1; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#gpad button:active { background: rgba(126, 200, 232, .35); }
#gpad button[data-dir="up"] { left: 50%; top: 2px; transform: translateX(-50%); }
#gpad button[data-dir="down"] { left: 50%; bottom: 2px; transform: translateX(-50%); }
#gpad button[data-dir="left"] { left: 2px; top: 50%; transform: translateY(-50%); }
#gpad button[data-dir="right"] { right: 2px; top: 50%; transform: translateY(-50%); }

/* ── 키 세팅(⌨️, 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;
}

/* 좁은 화면에서는 좌하단이 통째로 남의 자리다 — 독(#dock)이 가로 한 줄로 눕고
   그 위에 근처 대상 카드(#near)가 두 장까지 쌓인다. 그래서 **위로 옮긴다**:
   지갑 줄 아래, 자동 순행 띠(#autobar, top 106px)보다 더 아래. */
@media (max-width: 780px) {
  /* `--below-header` 는 지갑 줄과(켜져 있으면) 자동 순행 띠까지 실제로 잰
     아래 끝이다(ui.js syncHeaderStack) — 152px 는 값이 아직 없을 때뿐이다 */
  #minimap { top: calc(var(--below-header, 152px) + 8px); bottom: auto; left: 10px; }
}

/* ── 근처 대상 ────────────────────────────────────────── */
#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 { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.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); }

/* ── 액션 독 ──────────────────────────────────────────── */
#dock {
  position: fixed; right: 12px; bottom: calc(14px + var(--safe-b)); z-index: 12;
  display: flex; flex-direction: column; gap: 8px;
}
#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; }

/* ── 오버월드 전체 지도 (M키) — PLAN 25-1절 ──────────────── */
#overworld-map {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
}
#overworld-map.show { display: flex; }
#overworld-map .ow-scrim {
  position: absolute; inset: 0; background: rgba(6,8,12,.6);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#overworld-map .ow-panel {
  position: relative; width: min(92vw, 640px); height: min(80vh, 640px);
  border-radius: var(--r-lg); display: flex; flex-direction: column; padding: 14px;
}
#overworld-map .ow-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#overworld-map .ow-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
#overworld-map .ow-head small { flex: 1; }
#overworld-map .ow-close { margin-left: auto; }
#overworld-map canvas { flex: 1 1 auto; width: 100%; height: 100%; border-radius: var(--r-md); }

/* ── 시트 내부 공통 ───────────────────────────────────── */
.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); }
.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; } }

/* ── 도적전(사가블로식 실시간) HUD ─────────────────────────
 * `#encounter`와 달리 **화면을 안 막는다** — 지도를 계속 드래그·탭으로
 * 움직일 수 있어야 사거리 안으로 걸어 들어갈 수 있다. 그래서 컨테이너는
 * pointer-events:none 이고, 실제 버튼만 auto 로 되돌린다. */
#rogue-hud { position: fixed; inset: 0; z-index: 35; display: none; pointer-events: none; }
#rogue-hud.show { display: block; }
#rogue-hud .ra-hud {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(92vw, 380px); padding: 10px 14px; border-radius: var(--r-lg);
  background: rgba(20,22,28,.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-br); pointer-events: none;
}
#rogue-hud .ra-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
#rogue-hud .ra-row small { width: 44px; flex: none; opacity: .8; }
#rogue-hud .ra-row .bar { flex: 1; }
#rogue-hud .ra-foe small { color: #e08a8a; }
#rogue-hud .ra-tell {
  text-align: center; margin: 6px 0; padding: 4px 0; border-radius: 8px;
  background: rgba(224,90,90,.18); color: #ff9d9d; font-weight: 700;
  visibility: hidden; opacity: 0; transition: opacity .12s;
}
#rogue-hud .ra-tell.show { visibility: visible; opacity: 1; animation: fade .12s ease-out; }
#rogue-hud .ra-tell.stagger { background: rgba(255,224,102,.22); color: #ffe066; }
#rogue-hud .ra-combo { text-align: center; min-height: 16px; font-weight: 700; color: #ffb454; }
#rogue-hud .ra-pad { display: flex; gap: 8px; margin-top: 8px; }
#rogue-hud .ra-pad .btn { flex: 1; pointer-events: auto; }


/* 교전에 실제 3D 상대가 섰을 때(`duel.js` `open()` 이 `duel3d` 를 붙인다) —
   무대가 카드 뒤에 있으니 어둡게+흐리게 덮으면 아무 뜻이 없다. 아래로
   붙여 HUD 처럼 만들고, 배경은 거의 그대로 비친다(2026-08-30) */
#encounter.duel3d {
  align-items: flex-end;
  background: rgba(6,8,12,.16);
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px);
}
#encounter.duel3d .duel {
  background: rgba(20,22,28,.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  margin-bottom: 4px;
}
/* 초상 둘은 이제 실제 배우가 대신한다 — 카드 안에 남겨 두면 같은 싸움이
   둘로 겹쳐 보인다. 피해 숫자·강타 예고(`#d-pops`·`#d-tell`)는 정보라 남긴다 */
#encounter.duel3d .d-unit, #encounter.duel3d .d-name { display: none; }
#encounter.duel3d .duel-arena { height: 46px; background: none; margin: 0 0 2px; }

/* 등용·포획도 3D 무대(encounter3d.js)가 있으면 같은 문제 — 화면 전체를
   짙게 가리면 뒤에 세운 상대가 안 보인다(2026-09-06, "등용 하려는 인물이
   안 보임" 지적). duel3d 와 같은 처방: 배경을 거의 비치게 하고 카드를
   아래로 붙여 얼굴 자리를 비운다. */
#encounter.enc3d {
  align-items: flex-end;
  background: rgba(6,8,12,.16);
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px);
}
#encounter.enc3d .enc-card { margin-bottom: 4px; }

.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, 짧은 뷰포트로 재현 — 인물 초상이 top:-38px로 화면 위에 있었다).
     세로 스크롤을 열어 준다 */
  max-height: calc(100vh - 36px); overflow-y: auto;
}
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* 걷다가 사건을 만난 순간 — 테두리가 한 번 크게 번졌다 잦아든다(축1, 2026-09-06).
   역참·성채 같은 여느 창과 달리 "찾아낸 것"이라는 티를 눈으로도 낸다 */
.enc-card.pingnew { animation: pop .22s cubic-bezier(.22,1,.36,1), pingring 1.1s ease-out; }
@keyframes pingring {
  0%   { box-shadow: 0 0 0 0 rgba(245,180,69,.55), 0 24px 70px rgba(0,0,0,.6); }
  60%  { box-shadow: 0 0 0 14px rgba(245,180,69,0), 0 24px 70px rgba(0,0,0,.6); }
  100% { box-shadow: 0 0 0 0 rgba(245,180,69,0), 0 24px 70px rgba(0,0,0,.6); }
}

.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); }

/* 포획 성공/실패 — 결과 창이 뜨는 순간 한 번 더 갈린다(축2: 손맛) */
.catchpop { animation: catchpop .45s cubic-bezier(.2,1.4,.4,1); }
.catchpop .enc-big { animation: catchglow 1.1s ease-out .1s; }
@keyframes catchpop {
  0%   { transform: scale(.82); opacity: 0; }
  60%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes catchglow {
  0%   { filter: brightness(1) drop-shadow(0 0 0 rgba(255,215,100,0)); }
  30%  { filter: brightness(1.6) drop-shadow(0 0 18px rgba(255,215,100,.85)); }
  100% { filter: brightness(1) drop-shadow(0 0 0 rgba(255,215,100,0)); }
}
.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; }

/* 사건의 선택지 (event.js) — 고르는 것이 둘·셋이라 사이를 띄운다.
   `.btn.wide` 를 그대로 쓰되 세로로 쌓기만 한다 */
.enc-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* 발견 격자 (codex.js) — 갈래마다 한 칸. 다 채운 갈래는 금빛으로 */
.cx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 10px 0 8px; }
.cx-cell {
  display: grid; place-items: center; gap: 1px; padding: 9px 4px;
  background: rgba(255,255,255,.04); border: 1px solid var(--glass-br); border-radius: 12px;
}
.cx-cell b { font-size: 19px; line-height: 1.1; }
.cx-cell span { font-size: 11px; color: var(--ink-dim); }
.cx-cell small { font-size: 11.5px; font-weight: 700; color: var(--ink-faint); }
.cx-cell.full { border-color: rgba(245,180,69,.5); }
.cx-cell.full small { color: var(--gold); }

.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); }
/* 갈래별 색(축1, 2026-09-06 "알림이 약하다") — 늘 같은 금테였던 것을 갈래로 나눈다.
   find(발견·나침반) 는 더 오래·더 밝게, bad 는 가라앉은 색, good 은 초록기 */
#toast.t-find { border-color: rgba(245,180,69,.85); box-shadow: var(--shadow), 0 0 18px rgba(245,180,69,.35); animation: toastpop .3s cubic-bezier(.22,1,.36,1); }
#toast.t-good { border-color: rgba(120,200,120,.6); }
#toast.t-bad { border-color: rgba(160,160,170,.4); color: var(--ink-dim); }
@keyframes toastpop { 0% { transform: translateX(-50%) translateY(-14px) scale(.9); } 60% { transform: translateX(-50%) translateY(3px) scale(1.03); } 100% { transform: translateX(-50%) translateY(0) scale(1); } }

/* ── 레벨 업 ───────────────────────────────────────────── */
#levelup {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%);
  z-index: 51; pointer-events: none; opacity: 0;
}
#levelup.show { opacity: 1; }
.lv-banner {
  text-align: center; padding: 10px 26px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(30,26,14,.92), rgba(20,17,10,.92));
  border: 1px solid rgba(245,180,69,.6); box-shadow: 0 0 30px rgba(245,180,69,.35);
}
.lv-banner b {
  display: block; font-size: 13px; letter-spacing: 3px; color: #ffd76a;
}
.lv-banner span { display: block; font-size: 26px; font-weight: 800; color: #fff; margin-top: 2px; }
#levelup.show .lv-banner { animation: lvpop 1.8s cubic-bezier(.2,1.4,.4,1); }
@keyframes lvpop {
  0%   { transform: scale(.6); opacity: 0; }
  15%  { transform: scale(1.08); opacity: 1; }
  25%  { transform: scale(1); }
  75%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.04); opacity: 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; }
}

/* ── 폰 폭: 상단 도구를 ⋯ 뒤로 접는다 ─────────────────────
 * 도구가 아홉이라(👤 는 account.js 가 끼운다) 390px 에서 416px 을 달라 한다.
 * 그리드의 tools 칸이 `auto` 라 줄지 않고 그대로 화면 밖으로 밀려 나가 —
 * 뒤쪽 서넛은 보이지도, 눌리지도 않았다. 실제 폰에서 밟은 자리다.
 */
@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; }
  /* 독이 일곱이 되는 때(던전이 열린 뒤)가 있다. `right` 만 잡혀 있으면 폭이
     내용을 따라 늘어 왼쪽으로 화면을 넘어간다 — 양쪽을 붙들어 그 안에서 굴린다 */
  #dock { left: 12px; justify-content: flex-end; }
  /* 근처 카드가 `left:50%` 라 **화면 절반**만 쓸 수 있었다. 폰에서는 그 절반이
     195px 이라 '가까이 가기' 가 석 줄로 쪼개졌다. 양쪽을 잡고 가운데로 모은다 */
  #near { left: 12px; right: 12px; transform: translateY(14px); }
  #near.show { transform: translateY(0); }
  .near-card { width: 100%; max-width: 348px; }
}

/* 근처 카드 — 이름은 줄여도 되지만 단추는 줄이면 안 된다 */
.near-card .btn { white-space: nowrap; flex: 0 0 auto; }
.near-card .near-meta { flex: 1 1 auto; min-width: 0; }
.near-card .near-meta b, .near-card .near-meta small {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}

/* ══ 인물 성장 · 영지 경영 (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; }
}

/* ══ 로그라이크 던전 · 장비 · 방치형 (v0.8) ═════════════════════ */

/* ── 던전 오버레이 ─────────────────────────────────────────── */
#dungeon {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: #0b0d11;
}
#dungeon.show { display: block; }
body.dungeon-open { overflow: hidden; }

.dg-wrap {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 10px 10px calc(10px + var(--safe-b));
  gap: 8px;
}
#dg-hud {
  flex: 0 0 auto; background: var(--glass); border: 1px solid var(--glass-br);
  border-radius: var(--r-md); padding: 9px 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.dg-row1 { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.dg-floor { font-size: 15px; }
.dg-theme { font-size: 11.5px; color: var(--gold); }
.dg-room { font-size: 11.5px; color: var(--ink-dim); }
.dg-room .ok { color: var(--good); }
.dg-leave { margin-left: auto; }
.dg-hpbar {
  position: relative; height: 18px; margin: 8px 0 6px; border-radius: 9px;
  background: rgba(0,0,0,.45); overflow: hidden;
}
.dg-hpbar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #b8412f, #e8705a);
  transition: width .2s;
}
.dg-hpbar > span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.dg-row2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 11.5px; }
.dg-loot b { color: var(--gold); }
.dg-loot small { color: var(--ink-faint); }
.dg-boons { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.dg-boon {
  position: relative; font-size: 15px; line-height: 1;
  background: rgba(255,255,255,.07); border-radius: 8px; padding: 3px 5px;
}
.dg-boon i {
  position: absolute; right: -3px; bottom: -4px; font-style: normal;
  font-size: 9px; font-weight: 700; color: #fff;
  background: var(--purple); border-radius: 6px; padding: 0 3px;
}

.dg-stage { position: relative; flex: 1 1 auto; min-height: 0; }
#dg-canvas {
  width: 100%; height: 100%; display: block; border-radius: var(--r-md);
  background: #14161c; border: 1px solid var(--glass-br); touch-action: none;
}
.dg-tip { flex: 0 0 auto; text-align: center; font-size: 11px; color: var(--ink-faint); }
.dg-tip b { color: var(--ink-dim); }

/* 은사 선택 */
#dg-choice {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; padding: 14px;
  background: rgba(6,8,12,.72); border-radius: var(--r-md);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
#dg-choice.show { display: flex; }
.dg-choice-in { text-align: center; max-width: 640px; width: 100%; }
.dg-choice-in h4 { margin: 0 0 12px; font-size: 15px; color: var(--gold); }
.dg-cards { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.dg-card {
  position: relative; width: 168px; padding: 14px 12px; cursor: pointer;
  background: rgba(28,32,40,.96); border: 1px solid var(--glass-br);
  border-radius: var(--r-md); color: inherit; font: inherit; text-align: center;
  display: flex; flex-direction: column; gap: 5px; align-items: center;
}
.dg-card:hover { border-color: var(--gold); background: rgba(40,44,54,.96); }
.dg-card:active { transform: scale(.98); }
.dg-ce { font-size: 26px; line-height: 1; }
.dg-card b { font-size: 13px; }
.dg-card small { font-size: 11px; color: var(--ink-dim); line-height: 1.5; }
.dg-have { font-style: normal; font-size: 10px; color: var(--purple); font-weight: 700; }

/* ── 전리(戰利) 선택 ───────────────────────────────────────── */
#spoil {
  /* 독(우하단)과 근처 대상 카드(하단 중앙) 사이에 뜨게 — 둘 다 가리면 안 된다 */
  position: fixed; left: 50%; bottom: calc(152px + var(--safe-b)); transform: translateX(-50%);
  z-index: 38; display: none; width: min(88vw, 460px);
}
#spoil.show { display: block; animation: pop .22s cubic-bezier(.22,1,.36,1); }
.sp-in {
  background: var(--glass); border: 1px solid rgba(245,180,69,.30);
  border-radius: var(--r-lg); padding: 12px 13px; text-align: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.sp-in h4 { margin: 0 0 9px; font-size: 12.5px; color: var(--gold); }
.sp-cards { display: flex; gap: 7px; justify-content: center; margin-bottom: 7px; }
.sp-card {
  flex: 1; min-width: 0; padding: 10px 8px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br);
  border-radius: var(--r-sm); color: inherit; font: inherit;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.sp-card:hover { border-color: var(--gold); }
.sp-card:active { transform: scale(.97); }
.sp-e { font-size: 20px; line-height: 1; }
.sp-card b { font-size: 12px; }
.sp-card small { font-size: 10px; color: var(--ink-dim); }
.sp-left { color: var(--gold); }

/* ── 가방 · 장비 ───────────────────────────────────────────── */
.bagtools { display: flex; gap: 6px; margin-bottom: 8px; }
.gearlist { display: flex; flex-direction: column; gap: 6px; }
.grow {
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  border-left: 3px solid var(--ink-faint);
  border-radius: var(--r-sm); padding: 9px 11px;
}
.gr-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.gr-top b { font-size: 12.5px; }
.gr-lv { font-size: 10.5px; color: var(--ink-faint); margin-left: auto; }
.gr-opts { font-size: 11px; color: var(--ink-dim); margin: 5px 0 7px; line-height: 1.6; }
.gr-btns { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.gr-none { font-size: 10.5px; }

.dt-gears { display: flex; flex-direction: column; gap: 6px; margin-top: 11px; }
.dt-gear { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11.5px; }
.dt-gear .dg-slot { width: 30px; color: var(--ink-faint); flex: 0 0 auto; }
.dt-gear select {
  flex: 1; min-width: 150px; 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-gear small { width: 100%; padding-left: 37px; font-size: 10.5px; }

/* ── 업그레이드 · 도장 상점 ────────────────────────────────── */
.uplist { display: flex; flex-direction: column; gap: 5px; }
.uprow {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.045); padding: 8px 10px; border-radius: var(--r-sm);
}
.uprow.done { opacity: .6; }
.uprow .ue { font-size: 17px; width: 22px; text-align: center; flex: 0 0 auto; }
.uprow .un { flex: 1; min-width: 0; line-height: 1.35; }
.uprow .un b { font-size: 12px; display: block; }
.uprow .un small { font-size: 10.5px; color: var(--ink-dim); }
.uprow .ul {
  font-size: 11px; font-weight: 700; color: var(--gold);
  min-width: 22px; text-align: right; flex: 0 0 auto;
}

/* ── 자동화 ────────────────────────────────────────────────── */
.autolist { display: flex; flex-direction: column; gap: 5px; }
.autorow {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.045); padding: 8px 10px; border-radius: var(--r-sm);
}
.autorow.off { opacity: .48; }
.autorow .ae { font-size: 17px; width: 22px; text-align: center; flex: 0 0 auto; }
.autorow .an { flex: 1; min-width: 0; line-height: 1.35; }
.autorow .an b { font-size: 12px; display: block; }
.autorow .an small { font-size: 10.5px; color: var(--ink-dim); }

/* ── 던전 시트 · 경고 ──────────────────────────────────────── */
.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); }
.hint.warnbox { border: 1px solid rgba(239,107,107,.35); background: rgba(239,107,107,.08); color: #f3b6b6; }
.hint.warnbox b { color: #ffd9d9; }

/* 지도의 던전 입구 카드 */
.near-card.den { border-color: rgba(180,120,255,.35); }
.den-ico { display: grid; place-items: center; font-size: 24px; border-color: rgba(180,120,255,.5) !important; }

@media (max-width: 780px) {
  .dg-card { width: 100%; max-width: 320px; padding: 11px; flex-direction: row; text-align: left; }
  .dg-card b { flex: 0 0 auto; }
  .dg-cards { flex-direction: column; align-items: center; }
  #dock { overflow-x: auto; }
  .sp-cards { flex-direction: column; }
  .sp-card { flex-direction: row; justify-content: flex-start; gap: 7px; }
}

/* ══ 오프라인 / 온라인 · 사관 (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); }

/* 좁은 화면 — 독이 7개라 가로 스크롤을 허용한다 */
@media (max-width: 780px) {
  #dock { overflow-x: auto; scrollbar-width: none; }
  #dock::-webkit-scrollbar { display: none; }
  .modeswitch { flex-direction: column; }
}

/* ══ 사가고 v1.0 — 고딕 던전 · 오브 HUD · 서당 · 3D ═══════════════ */

/* ── 3D 모드 — 지평선 안개를 더 깊게 (포켓몬GO식 카메라) ──
   **`.r3d` 가 없을 때만 켠다.** 이 안개는 2D 캔버스가 3D 지평선인 척 눈속임하는
   덮개라 진짜 3D(THREE 가 실제로 돈다)에서는 필요 없다 — 위쪽의 `body.r3d`
   규칙(줄 64)과 우선순위가 같아서, 이 규칙이 파일 뒤에 있으면(원래 그랬다)
   3D 가 켜져도 이 덮개가 이겨 화면이 새까매진다. 안 그래도 `.tilted` 에서
   한 번 밟은 함정이다(줄 61 주석) — `.tilted3` 도 같은 함정이었다. */
body.tilted3:not(.r3d) #vignette {
  background:
    linear-gradient(180deg, #0d1017 0%, rgba(13,16,23,.5) 12%, rgba(13,16,23,.3) 26%, transparent 46%),
    radial-gradient(140% 85% at 50% 70%, transparent 50%, rgba(0,0,0,.3) 100%),
    linear-gradient(180deg, transparent 76%, rgba(0,0,0,.3));
}

/* ── 던전: 고딕 스킨 ───────────────────────────────────── */
#dungeon {
  background:
    radial-gradient(120% 90% at 50% 30%, #12131a 0%, #0a0b10 70%, #06070b 100%);
}
#dg-hud {
  background: linear-gradient(180deg, rgba(30,26,20,.92), rgba(18,16,13,.92));
  border: 1px solid rgba(201,162,74,.34);
  border-bottom-width: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 6px 22px rgba(0,0,0,.5);
}
.dg-floor {
  font-family: "Malgun Gothic", serif;
  color: #e8cf9a; letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(0,0,0,.8);
}
.dg-theme { color: #c9a24a; }
#dg-canvas { background: #0a0b10; border-color: rgba(201,162,74,.22); }
.dg-leave { border-color: rgba(201,162,74,.4); color: #e8cf9a; }

/* ── 던전 하단: HP/기력 오브 + 스킬바 (디아블로식) ───────── */
#dg-bottom {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: center; gap: 14px;
  padding: 2px 6px;
}
.dg-orb {
  position: relative; width: 68px; height: 68px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #23252e, #0c0d12 70%);
  border: 3px solid #5a4a30;
  box-shadow: inset 0 3px 9px rgba(0,0,0,.75), 0 3px 10px rgba(0,0,0,.55),
              0 0 0 1px rgba(201,162,74,.25);
  overflow: hidden; flex: 0 0 auto;
}
.dg-orb .dg-orb-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  transition: height .25s;
}
.dg-orb.hp .dg-orb-fill {
  background: linear-gradient(180deg, #e8705a, #8a1f14 65%, #5c120b);
  box-shadow: inset 0 3px 7px rgba(255,190,170,.4);
}
.dg-orb.mp .dg-orb-fill {
  background: linear-gradient(180deg, #5ab4e8, #14468a 65%, #0b2a5c);
  box-shadow: inset 0 3px 7px rgba(170,220,255,.4);
}
.dg-orb.low { animation: orbPulse 1s infinite; }
@keyframes orbPulse {
  0%, 100% { box-shadow: inset 0 3px 9px rgba(0,0,0,.75), 0 0 6px rgba(232,80,60,.4); }
  50% { box-shadow: inset 0 3px 9px rgba(0,0,0,.75), 0 0 16px rgba(232,80,60,.85); }
}
.dg-orb .dg-orb-v {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.9); z-index: 2;
}
.dg-orb small {
  position: absolute; left: 0; right: 0; bottom: 5px; text-align: center;
  font-size: 8.5px; color: rgba(255,255,255,.55); z-index: 2;
}
.dg-skillbar { display: flex; gap: 7px; align-items: flex-end; }
.dg-skill {
  position: relative; width: 52px; height: 52px; border-radius: 11px;
  background: linear-gradient(180deg, #2a2620, #17150f);
  border: 2px solid #4a3d26; color: var(--ink);
  cursor: pointer; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 8px rgba(0,0,0,.5);
  touch-action: manipulation;
}
.dg-skill .dg-sk-e { font-size: 22px; line-height: 48px; position: relative; z-index: 1; }
.dg-skill.ready { border-color: #c9a24a; box-shadow: 0 0 9px rgba(201,162,74,.35), inset 0 1px 0 rgba(255,255,255,.1); }
.dg-skill.nomana .dg-sk-e { filter: grayscale(1); opacity: .5; }
.dg-skill.on { border-color: #f0a53a; box-shadow: 0 0 13px rgba(240,165,58,.6); }
.dg-skill:active { transform: scale(.94); }
.dg-sk-cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: rgba(6,8,14,.78); font-style: normal;
  display: grid; place-items: center;
  color: #e8cf9a; font-size: 15px; font-weight: 800; z-index: 2;
}
.dg-sk-key {
  position: absolute; top: 2px; left: 5px; font-size: 9px; color: rgba(255,255,255,.5); z-index: 3;
}
.dg-sk-cost {
  position: absolute; bottom: 2px; right: 5px; font-size: 9px; color: #7fb4e8; z-index: 3;
}

/* ── 던전 서고 문답 오버레이 ───────────────────────────── */
#dg-quiz {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; padding: 14px;
  background: rgba(6,8,12,.74); border-radius: var(--r-md);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
#dg-quiz.show { display: flex; }
.dg-quiz-in {
  width: 100%; max-width: 480px; text-align: left;
  background: linear-gradient(180deg, rgba(34,30,23,.98), rgba(20,18,14,.98));
  border: 1px solid rgba(201,162,74,.4); border-radius: var(--r-md);
  padding: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
.dg-quiz-in h4 { margin: 0 0 10px; font-size: 14px; color: #e8cf9a; display: flex; gap: 8px; align-items: center; }
.dg-q-cat { font-size: 11.5px; margin-left: auto; }
.dg-q-q { margin: 0 0 12px; font-size: 14.5px; line-height: 1.65; font-weight: 600; }
.dg-q-choices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.dg-q-choice {
  text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 1px solid rgba(201,162,74,.2);
  color: var(--ink); font: inherit; font-size: 12.5px;
}
.dg-q-choice b { color: #c9a24a; margin-right: 6px; }
.dg-q-choice:hover { border-color: #c9a24a; background: rgba(201,162,74,.12); }
.dg-q-result { font-size: 15px; font-weight: 700; margin: 4px 0 8px; }
.dg-q-result.good { color: var(--good); }
.dg-q-result.bad { color: var(--bad); }
.dg-q-result small { font-size: 11px; color: var(--ink-dim); font-weight: 500; }
.dg-q-why { margin: 0 0 8px; font-size: 12px; line-height: 1.7; color: #d7cfc0; }
.dg-q-reward { font-size: 12px; color: var(--good); margin-bottom: 6px; }

/* ── 서당 시트 ────────────────────────────────────────── */
.qcard {
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  border-radius: var(--r-md); padding: 13px;
}
.qcat { font-size: 11.5px; font-weight: 700; margin-bottom: 7px; }
.qq { margin: 0 0 11px; font-size: 14px; line-height: 1.65; font-weight: 600; }
.qchoices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 9px; }
.qchoice {
  text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br);
  color: var(--ink); font: inherit; font-size: 12.5px;
}
.qchoice b { color: var(--gold); margin-right: 6px; }
.qchoice:hover { border-color: var(--gold); }
.qchoice:active { transform: scale(.99); }
.qresult { font-size: 14.5px; font-weight: 700; margin: 2px 0 7px; }
.qresult.good { color: var(--good); }
.qresult.bad { color: var(--bad); }
.qresult small { font-size: 10.5px; color: var(--ink-dim); font-weight: 500; }
.qwhy { margin: 0 0 7px; font-size: 12px; line-height: 1.7; color: #d7dce6; }
.qreward { font-size: 12px; color: var(--good); margin-bottom: 9px; }
/* 문답 난이도 배지 — 초급/중급/고급 */
.tag.lv1 { background: rgba(94,194,106,.18); color: #8ad893; border-color: rgba(94,194,106,.35); }
.tag.lv2 { background: rgba(240,165,58,.18); color: #f3bd60; border-color: rgba(240,165,58,.35); }
.tag.lv3 { background: rgba(224,101,95,.18); color: #ec8b86; border-color: rgba(224,101,95,.35); }

.qcats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.qcat-btn {
  padding: 11px 12px; border-radius: var(--r-sm); cursor: pointer; text-align: left;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br);
  color: var(--ink); font: inherit;
  display: flex; flex-direction: column; gap: 4px;
}
.qcat-btn:hover { border-color: var(--gold); }
.qcat-btn .qc-e { font-size: 18px; }
.qcat-btn b { font-size: 12.5px; }
.qcat-btn small { font-size: 10px; color: var(--ink-dim); }
.qbook { display: flex; flex-direction: column; gap: 6px; }
.qentry {
  background: rgba(255,255,255,.045); border: 1px solid var(--glass-br);
  border-left: 3px solid rgba(201,162,74,.5);
  border-radius: var(--r-sm); padding: 9px 11px;
}
.qe-top { display: flex; gap: 6px; align-items: baseline; font-size: 12px; }
.qe-top b { font-weight: 600; line-height: 1.5; }
.qe-a { font-size: 12px; color: var(--gold); font-weight: 700; margin: 3px 0 2px; }
.qentry small { font-size: 10.5px; color: var(--ink-dim); line-height: 1.6; display: block; }

@media (max-width: 780px) {
  .dg-orb { width: 58px; height: 58px; }
  .dg-skill { width: 46px; height: 46px; }
  .dg-skill .dg-sk-e { font-size: 19px; line-height: 42px; }
  /* 분야가 6개라 1열이면 문답 시작까지 스크롤이 길어진다 — 좁은 화면도 2열로 둔다 */
  .qcat-btn { padding: 9px 10px; }
}


/* ── 자동 순행 (auto.js) ─────────────────────────────────── */
#autobar {
  position: fixed; left: 50%; transform: translateX(-50%);
  /* `--top-bottom` 은 지갑 줄까지 실제로 잰 높이다(ui.js syncHeaderStack) —
     손잡이 줄이 붙거나 지갑이 접혀 늘어나도 안 겹친다. 값이 아직 없을 때
     (첫 페인트)만 106px 로 대신한다 */
  top: calc(var(--top-bottom, 106px) + 8px); 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; }

/* ── 노획 장비 (던전 시트) ───────────────────────────────── */
.gearrow {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 12px; margin: 5px 0; flex-wrap: wrap;
}
.gearrow > b { min-width: 62px; }
.gearcard { margin: 6px 0; }
.gearname { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.gearname small { font-weight: 400; margin-left: 4px; }

/* ── 교전(交戰) — 원작의 탭 전투 ─────────────────────────
   #encounter 안에 뜬다. 조우 카드(.enc-card)와 같은 자리를 쓰되,
   손가락이 닿는 버튼이 크고 아래에 있어야 하므로 세로로 꽉 채운다. */
.duel {
  width: min(420px, 100%); max-height: 100%;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--glass-br);
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
  animation: pop .18s ease-out;
}
.duel-head { display: flex; align-items: baseline; justify-content: space-between; }
.duel-title { font-size: 14px; font-weight: 700; }
.duel-time { font-size: 12px; color: var(--ink-dim); }
.duel-time b { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* 3D 렌더러의 캔버스 — 지면(map-ground)과 오브젝트(map) 사이에 깔린다.
   클릭은 위의 #map 이 받는다(탭 이동·조우). */
#map3d {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; display: none;
}

/* 어드민에서 손잡이를 잡아 두었을 때 프로필에 붙는 배지 */
.p-tune {
  display: inline-block; margin-bottom: 2px; padding: 1px 6px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; color: #1b1205;
  background: linear-gradient(90deg, #f5b445, #e8c15a);
}

.duel-foe { text-align: center; }

/* ── 교전 무대 — 둘이 마주 선다 ───────────────────────────
   적은 뒤쪽(오른편 위, 조금 작게), 나는 앞쪽(왼편 아래, 조금 크게).
   동작은 전부 CSS 애니메이션이라 판정 층과 무관하게 돈다. */
.duel-arena {
  position: relative; height: 172px; margin: 2px 0 4px;
  border-radius: var(--r-md);
  background:
    radial-gradient(120% 78% at 50% 116%, rgba(255,255,255,.10), transparent 62%),
    linear-gradient(180deg, rgba(10,14,22,.55), rgba(10,14,22,.15));
  overflow: hidden;
}
/* 발밑 — 두 사람이 같은 땅을 딛고 선 것처럼 보이게 하는 띠 */
.duel-arena::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  background: linear-gradient(180deg, transparent, rgba(120,150,110,.13));
  pointer-events: none;
}
.d-unit {
  position: absolute; display: flex; align-items: flex-end; justify-content: center;
}
/* 그림책풍 초상은 종이 바탕째 그려진다(어두운 UI 에서 선화가 묻히지 않게).
   무대에서는 그 종이를 **삽화 액자**로 보이게 테를 둘러 붕 뜨지 않게 한다. */
.d-unit .pt {
  width: 100%; height: 100%; object-fit: contain;
  border-radius: 12px; border: 1px solid rgba(0,0,0,.35);
  box-shadow: 0 6px 16px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06) inset;
}
.d-unit .d-shadow {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  width: 62%; height: 11px; border-radius: 50%;
  background: rgba(0,0,0,.42); filter: blur(3px);
}
.d-unit.foe { right: 16px; top: 12px; width: 84px; height: 84px; }
.d-unit.foe .pt { transform: scaleX(-1); }          /* 마주 보게 뒤집는다 */
.d-unit.me  { left: 16px; bottom: 22px; width: 96px; height: 96px; }
.d-name {
  position: absolute; font-size: 11px; font-weight: 700; color: var(--ink-dim);
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}
.d-name.foe { right: 16px; top: 100px; width: 84px; text-align: center; }
.d-name.me  { left: 16px; bottom: 4px; width: 96px; text-align: center; }

/* 내가 친다 */
@keyframes dLunge {
  0%   { transform: translate(0,0) scale(1); }
  35%  { transform: translate(34px,-10px) scale(1.06); }
  60%  { transform: translate(30px,-6px) scale(1.03); }
  100% { transform: translate(0,0) scale(1); }
}
@keyframes dUlt {
  0%   { transform: translate(0,0) scale(1) rotate(0); }
  18%  { transform: translate(-12px,4px) scale(.94) rotate(-4deg); }   /* 움츠렸다가 */
  48%  { transform: translate(60px,-16px) scale(1.16) rotate(6deg); }  /* 뛰어든다 */
  72%  { transform: translate(46px,-8px) scale(1.08) rotate(2deg); }
  100% { transform: translate(0,0) scale(1) rotate(0); }
}
/* 맞는다 */
@keyframes dHurt {
  0%   { transform: translate(0,0); filter: none; }
  20%  { transform: translate(9px,0); filter: brightness(2.1) saturate(.4); }
  45%  { transform: translate(-7px,0); filter: brightness(1.4); }
  70%  { transform: translate(4px,0); }
  100% { transform: translate(0,0); filter: none; }
}
@keyframes dBlast {
  0%   { transform: translate(0,0) scale(1); filter: brightness(3) saturate(0); }
  25%  { transform: translate(14px,-4px) scale(1.08); filter: brightness(2.2); }
  55%  { transform: translate(-10px,2px) scale(.96); filter: brightness(1.3); }
  100% { transform: translate(0,0) scale(1); filter: none; }
}
/* 피한다 */
@keyframes dEvade {
  0%   { transform: translate(0,0); opacity: 1; }
  30%  { transform: translate(-30px,6px) skewX(10deg); opacity: .45; }
  60%  { transform: translate(-26px,4px) skewX(4deg); opacity: .7; }
  100% { transform: translate(0,0); opacity: 1; }
}
.d-unit.me.lunge  { animation: dLunge .24s ease-out; }
.d-unit.me.ulting { animation: dUlt .46s cubic-bezier(.3,-0.4,.4,1.5); }
.d-unit.me.hurt   { animation: dHurt .3s ease-out; }
.d-unit.me.blast  { animation: dBlast .42s ease-out; }
.d-unit.me.evade  { animation: dEvade .38s ease-out; }
/* 적은 반대 방향으로 달려든다 */
.d-unit.foe.lunge { animation: dLunge .3s ease-out reverse; }
.d-unit.foe.hurt  { animation: dHurt .24s ease-out; }
.d-unit.foe.blast { animation: dBlast .46s ease-out; }
/* 강타 예고 — 적이 힘을 모은다 */
.duel.tell .d-unit.foe {
  animation: dCharge .5s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 10px rgba(239,107,107,.9));
}
@keyframes dCharge {
  from { transform: scale(1); }
  to   { transform: scale(1.12) translateY(-4px); }
}

.duel-face .pt { width: 100%; height: 100%; object-fit: cover; }
.duel-emoji { font-size: 52px; }
.duel-foe-name { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.duel-num { font-size: 11px; color: var(--ink-dim); margin-top: 4px;
  font-variant-numeric: tabular-nums; }

.bar.red > i { background: var(--bad); }
.bar.ki > i { background: linear-gradient(90deg, var(--blue), var(--purple)); }

/* 피해 숫자가 뜨는 자리 — 예고 문구도 여기 겹친다 */
.duel-stage { position: relative; height: 42px; }
/* 피해 숫자는 무대 한복판 위쪽에 뜬다 (두 사람 사이) */
.duel-arena .duel-pops { align-items: flex-start; padding-top: 26px; }
.duel-arena .duel-tell { align-items: flex-start; padding-top: 6px; }
.duel-pops { position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; gap: 8px; pointer-events: none; }
.dpop {
  font-size: 17px; font-weight: 800; color: var(--ink);
  animation: dpop .7s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
.dpop.bad { color: var(--bad); }
.dpop.ok { color: var(--good); }
.dpop.big { color: var(--gold); font-size: 22px; }
@keyframes dpop {
  from { transform: translateY(10px) scale(.9); opacity: 0; }
  30%  { transform: translateY(-2px) scale(1.06); opacity: 1; }
  to   { transform: translateY(-20px) scale(1); opacity: 0; }
}

.duel-tell {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--bad);
  letter-spacing: .3px;
}
.duel.tell .duel-tell { display: flex; animation: tellBlink .45s infinite alternate; }
.duel.tell { border-color: rgba(239,107,107,.75); box-shadow: 0 0 0 2px rgba(239,107,107,.25), var(--shadow); }
@keyframes tellBlink { from { opacity: .45; } to { opacity: 1; } }

.duel-me { display: flex; flex-direction: column; gap: 6px; }
.duel-row { display: flex; align-items: center; gap: 8px; }
.duel-row small { width: 34px; font-size: 10.5px; color: var(--ink-dim); }
.duel-row .bar { flex: 1; }

.duel-pad { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; }
.dbtn {
  border: 1px solid var(--glass-br); background: rgba(255,255,255,.07); color: var(--ink);
  border-radius: 14px; padding: 13px 6px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: filter .1s, transform .07s;
}
.dbtn b { font-size: 15px; font-weight: 800; }
.dbtn small { font-size: 9.5px; color: var(--ink-dim); font-weight: 400; }
.dbtn:active:not(:disabled) { transform: scale(.96); }
.dbtn:disabled { opacity: .34; cursor: not-allowed; }
.dbtn.quick { background: linear-gradient(180deg, #f7bd55, #e09a2a);
  border-color: #f7bd55; color: #22190a; }
.dbtn.quick small { color: rgba(34,25,10,.6); }
.dbtn.ult:not(:disabled) { background: linear-gradient(180deg, #b57bf5, #8b52d6);
  border-color: #b57bf5; color: #fff; }
.dbtn.ult:not(:disabled) small { color: rgba(255,255,255,.7); }
.dbtn.dodge { background: rgba(74,163,240,.16); border-color: rgba(74,163,240,.5); }

/* 맞았을 때 흔들림 · 피했을 때 번쩍 */
.jolt { animation: jolt .3s ease-out; }
@keyframes jolt {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-7px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(2px); }
  100% { transform: translateX(0); }
}
.flash { animation: dflash .3s ease-out; }
@keyframes dflash {
  0%   { filter: brightness(1); }
  35%  { filter: brightness(2.1) saturate(.6); }
  100% { filter: brightness(1); }
}

/* ══ 적도(賊徒) — 원작의 로켓단 (js/rogue.js) ═══════════════════
   점거된 역참과, 물리치고 얻은 **암영(暗影)**. 검게 물든 것은 그림을
   따로 그리지 않고 **필터로 물들인다** — 도감 초상 41종을 두 벌 그리면
   sprite.js 가 두 배로 늘어난다(다섯 판이 나눠 든 파일이다). */

.enc-card.rogue h3 { color: #e0837a; }

/* 암영 — 채도를 죽이고 어둡게, 테두리에 붉은 기 */
.pt.dark, .near-ico.dark img, .near-ico.dark canvas {
  filter: saturate(.25) brightness(.55) contrast(1.15);
}
.pt.dark { box-shadow: 0 0 0 2px rgba(192,70,60,.55), 0 0 18px rgba(192,70,60,.35); }
/* `.near-ico` 는 2px 테두리를 이미 갖고 있다 — 그림자를 덧대면 그 밑에 깔려 안 보인다.
   테두리 빛깔을 바꾸는 편이 확실하다 */
.near-ico.dark { border-color: rgba(192,70,60,.75); background: #241a1c; }
