/* 사가블로 — 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);
  /* 세로에서는 늘 0 이라 안 써도 티가 안 났다 — 가로로 돌리면 아이폰 노치가
     좌우 어느 한쪽으로 붙는다(PLAN 23절). 그동안 위·아래만 있어서 가로
     모드에서 조작판이 노치 밑에 깔릴 수 있었다. */
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 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: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  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; }

/* 2026-09-10 — 사가고와 UI를 맞춘다: 넓은 화면에서는 도구가 줄에 그대로
   늘어서고(.tools-drawer 가 display:contents), 폰 폭(600px 이하)에서만
   ⋯ 뒤로 접힌다(아래 @media 참고). 2026-09-08엔 "붙박이 자동순회 + 나머지는
   늘 접기"로 갔었는데, 그건 사가고의 실제 동작과 달랐다 — 사가고는 넓은
   화면에서 도구를 다 펼쳐 보여준다. */
.tools { grid-area: tools; display: flex; gap: 7px; position: relative; }
.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; }

.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: calc(12px + var(--safe-l)); 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); }

/* 세공 — 박힌 것을 칸으로 보여 준다 */
.socks { display: flex; gap: 5px; margin: 6px 0; }
.sockcell {
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br);
  font-size: 13px; font-weight: 700;
}
.sockcell.empty { color: rgba(255,255,255,.25); border-style: dashed; }
.sockcell.rune { color: #f0a53a; font-family: serif; }

/* ── 액션 독 ──────────────────────────────────────────── */
/* 2026-09-01 — 9개를 다 붙박이로 늘어놓으니 "화면에 너무 차지하네"(사용자).
   자주 쓰는 셋(부대·장비·지도)만 붙박이로 두고 나머지 여섯은 "더보기" 뒤에
   접는다. #dock-more 는 #dock(position:fixed 라 포함 블록이 된다) 기준으로
   절대배치해 독 바로 위에 뜨는 팝오버 — 데스크톱 세로열·폰 3열 그리드
   어느 배치에서도 독 자체 크기와 무관하게 붙는다. */
#dock {
  position: fixed; right: calc(12px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); z-index: 12;
  display: flex; flex-direction: column; gap: 8px;
}
#dock-more {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  display: grid; grid-template-columns: repeat(3, 58px); gap: 8px;
  opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: opacity .16s, transform .16s;
}
#dock-more.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#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); }
.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; }

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

/* 건물 목록 */
.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); }

/* ── 월드맵 (PLAN 28절) ───────────────────────────────── */
.wm-list { display: flex; flex-direction: column; gap: 6px; }
.wm-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--r-sm); background: rgba(255,255,255,.045);
  border-left: 2.5px solid var(--gold);
}
.wm-row.locked { opacity: .38; border-left-color: transparent; }
.wm-row.here { border-left-color: var(--good); background: rgba(120,200,120,.08); }
.wm-ic { font-size: 22px; width: 30px; text-align: center; flex: none; }
.wm-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.wm-info small { color: var(--ink-dim); font-size: 11px; }
.wm-here, .wm-done {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  flex: none;
}
.wm-here { background: var(--good); color: #08210c; }
.wm-done { background: rgba(255,255,255,.08); color: var(--ink-dim); }

/* ── 퀘스트 (PLAN 36절) ───────────────────────────────── */
.qst-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--r-sm); background: rgba(255,255,255,.045);
  border-left: 2.5px solid var(--gold); margin-bottom: 6px;
}
.qst-row.locked { opacity: .38; border-left-color: transparent; }
.qst-row.done { border-left-color: var(--good); opacity: .55; }
.qst-ic { font-size: 20px; width: 26px; text-align: center; flex: none; }
.qst-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qst-info small { color: var(--ink-dim); font-size: 11px; }
.qst-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.qst-bar > i { display: block; height: 100%; background: var(--gold); }
.qst-n { font-size: 10.5px; color: var(--ink-dim); flex: none; }

/* ── 버튼 ─────────────────────────────────────────────── */
.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);
  /* 도움말(19항목)·등용 카드처럼 내용이 길면 #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; }
  /* 2026-09-01 — "아래 메뉴가 다 안 나와 · 옆으로 짤려"(사용자). 독이 9개로
     늘었는데 flex-direction:row 한 줄로 두고 overflow-x:auto(스크롤바는 숨김)로
     흘려보내고 있었다 — 화면 오른쪽 끝에 붙어 있으니 뒤쪽 몇 개는 안 보이는데
     스크롤 표시조차 없어 사용자는 "안 나온다"로 겪었다. 3열 그리드로 접어
     스크롤 자체를 없앤다 — 좌하단 #widgets(236px)·가운데 #near 와 안 겹치는
     오른쪽 구석 172px 폭이면 충분하다. */
  #dock { display: grid; grid-template-columns: repeat(3, 52px); gap: 8px; }
  #dock button { width: 52px; height: 52px; border-radius: 17px; }
  #dock-more { grid-template-columns: repeat(3, 52px); }

  /* 상단이 폰 폭을 넘어가던 자리 — 마지막 도구(↺ 처음부터)가 화면 밖이었다.
     까닭은 `auto 1fr auto` 였다. 프로필도 도구줄도 auto 라 **둘 다 제 콘텐츠
     폭을 지키려 하고**, 프로필 글이 길어지면(제후 · Lv.16 · 최고 제24층 ·
     동행 4명) 도구줄이 그만큼 오른쪽으로 밀려난다.
     한 줄에 프로필과 도구 여섯을 같이 넣으려다 프로필이 129px 로 눌려
     이름이 잘렸다(「유사…」). 폰에서는 **세 줄로 편다** — 세로는 남는다.
     아이소메트릭 마름모는 가로세로 1.83:1 이라 폰 세로 화면에서 늘 위아래가
     비기 때문이다. 던전에서는 #dungeon 이 이 상단을 통째로 덮으므로 손해가 없다.
     (390px 실측: 넘침 3개 → 0개) */
  #top {
    grid-template-columns: 1fr;
    grid-template-areas: "profile" "tools" "wallet";
    gap: 7px;
  }
  .profile { min-width: 0; overflow: hidden; }
  .p-title, .p-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tools { gap: 6px; justify-content: flex-end; }
  .icon-btn { width: 36px; height: 36px; font-size: 15px; }

  /* 토스트가 top:84px 라 폰에서는 **지갑 줄 위에 겹쳐** 둘 다 못 읽혔다.
     좁은 화면은 상단이 두 줄(프로필·도구 / 지갑)이므로 그 아래로 내린다.
     자동 순행 띠는 한 칸 더 아래 — 둘이 같이 뜨는 때가 있다. */
  #toast { top: 168px; }
  #autobar { top: calc(212px + var(--safe-t)); }
  #near { bottom: calc(84px + var(--safe-b)); }
  .wallet { flex-wrap: wrap; }
}

/* ── 폰 폭: 상단 도구를 ⋯ 뒤로 접는다 (사가고와 같은 문턱) ────── */
@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; }
}

/* ══ 로그라이크 던전 · 장비 · 방치형 (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;
}
/* 3D 층 (dungeon3d.js) — 2D 캔버스 **뒤에 깔릴 셈**이었다.
   2026-08-30 — 아이폰 사파리 실기기로 "핀치·휠 확대가 안 된다" 를 잡다가,
   실은 안 된 지 오래였다는 걸 알았다: `#dg3d` 가 `position:absolute` 라
   DOM 순서와 무관하게 **정적(static) 배치인 `#dg-canvas` 보다 항상 위에서
   그려진다** — 페인트 순서뿐 아니라 **히트테스트(클릭이 어디로 가는지)도
   그 순서를 따른다.** `document.elementFromPoint()` 로 재보니 던전 화면
   한복판에서 실제로 잡히는 건 `#dg3d` 였다 — `#dg-canvas` 의 포인터
   리스너(걷기·핀치·휠)는 3D 가 켜진 동안 **애초에 이벤트를 못 받고
   있었다.** 그런데도 "3인칭에서 걸어 다니는" 것처럼 보였던 건 자동 순회
   (`auto.js`)가 조작 없이도 인물을 움직였기 때문으로 보인다 — 수동
   탭·드래그·핀치·휠은 전부 죽어 있었다.
   `pointer-events:none` 으로 이 캔버스를 히트테스트에서 아예 빼면(그려지긴
   그대로 그려진다 — 이건 페인트가 아니라 이벤트 라우팅만 바꾼다)
   `#dg-canvas` 가 다시 모든 입력을 받는다. */
#dg3d {
  position: absolute; inset: 0; width: 100%; height: 100%; display: none;
  border-radius: var(--r-md); background: #070809; pointer-events: none;
}
body.dg3d #dg-canvas { background: transparent !important; border-color: transparent !important; }

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

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

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

/* ── 3D 모드 — 지평선 안개를 더 깊게 (포켓몬GO식 카메라) ── */
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));
}

/* ── 던전: 고딕 스킨 ───────────────────────────────────── */
#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: calc(106px + var(--safe-t)); z-index: 13;
  display: none; max-width: min(560px, calc(100vw - 24px));
}
#autobar.show { display: block; }

/* ── GLB 로딩 표시(ui.js, asset3d.stats()) ─────────────────
   화면 맨 위 가장자리에 얇은 띠 하나만 긋는다 — 다른 UI(지갑·미니맵 등)와
   자리를 다툴 일이 없다(2026-09-07, "모바일에서 화면이 까맣게 보인다" 대응). */
#loadbar {
  position: fixed; left: 0; top: 0; right: 0; height: 3px; z-index: 70;
  background: transparent; pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
#loadbar.show { opacity: 1; }
#loadbar > i {
  display: block; height: 100%; width: 0%;
  background: var(--gold, #c9a24a); box-shadow: 0 0 8px rgba(201,162,74,.6);
  transition: width .2s;
}
.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; }


/* ── 본영(本營) — 던전 게임의 첫 화면 ───────────────────── */
#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; }

/* 부대 시트의 인물 줄 */
.partyrow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; cursor: pointer; margin: 6px 0;
}
.pr-ico {
  width: 46px; height: 46px; border-radius: 13px; overflow: hidden;
  border: 2px solid var(--glass-br); display: grid; place-items: center; flex: 0 0 auto;
}
.pr-ico img { width: 100%; height: 100%; object-fit: contain; }
.pr-meta { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.pr-meta b { font-size: 13px; }
.pr-meta small { font-size: 10.5px; }

/* ══ 마을(村) ═══════════════════════════════════════════════════
 * 마을은 던전과 **같은 화면**(#dungeon)을 쓴다. 그림·조작·조명을 두 벌 만들
 * 이유가 없다. 다만 마을은 내려가는 곳이 아니라 **사는 곳**이라 셋이 다르다.
 *
 *   1) 캔버스가 맨 아래로 내려간다
 *      던전에서는 #dungeon 이 z-index 60 으로 전부 덮는다 — 그 화면에서는
 *      상단도 독도 쓸 일이 없으니 그게 맞다. 마을에서는 정반대다. 볼일이
 *      상단(프로필·지갑·도구)과 독(부대·장비·…)에 있으므로 캔버스는 배경이 된다.
 *   2) 조작판(#dg-bottom)을 숨긴다
 *      마을에서는 구슬이 늘 가득이고 무예를 쓸 일이 없다 — 값이 없는 판이다.
 *      게다가 폰에서는 조작판과 독이 같은 자리를 두고 싸운다.
 *   3) 조작 안내(.dg-tip)를 되살린다
 *      diablo.css 가 그 줄을 조작판 안(.d2-keys)으로 옮겨 감췄는데, 마을에는
 *      그 판이 없다. 독 위로 한 줄 올린다.
 */
body.town-open #dungeon { z-index: 3; }
/* 넓은 화면에서 독은 **오른쪽에 세로로** 선다. 마름모는 화면 폭까지 꽉 차니
   그 오른쪽 끝이 독 아래로 들어가 사람이 가렸다. 무대를 그만큼 물린다.
   좁은 화면은 독이 하단으로 눕고, 그 자리는 metrics() 의 PAD_BOT 이 이미 비운다. */
@media (min-width: 781px) {
  body.town-open .dg-stage { right: 84px; }
}
body.town-open #dg-bottom { display: none !important; }
/* 층은 상단 프로필이 이미 말한다("🏯 마을 · 최고 제N층") — 두 번 쓰지 않는다 */
body.town-open #dg-hud { display: none !important; }
body.town-open .dg-tip {
  display: block !important;
  position: absolute; left: 0; right: 0;
  bottom: calc(88px + var(--safe-b));
  padding: 0 14px; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
