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

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

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

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

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

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

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

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

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

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

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

.profile {
  grid-area: profile;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 15px 8px 9px; border-radius: 999px;
}
.avatar {
  position: relative; width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: conic-gradient(var(--gold) var(--p, 0%), rgba(255,255,255,.10) 0);
}
.avatar i {
  position: absolute; inset: 3px; border-radius: 50%;
  background: #1b1f27; display: grid; place-items: center;
  font-size: 19px; font-style: normal;
}
.p-meta { line-height: 1.25; }
.p-title { font-size: 13px; font-weight: 700; letter-spacing: -.2px; }
.p-sub { font-size: 10.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.p-sub b { color: var(--gold); font-weight: 600; }

/* 2026-09-01 — 아이콘 다섯 개를 한 줄로 늘어놓으니 좁은 폰 폭에서 profile 과
   합친 너비가 뷰포트를 넘어 오른쪽(어드민·리셋)이 화면 밖으로 밀려났다.
   3D 토글만 붙박이로 두고 나머지 넷은 "더보기" 뒤로 접는다 — #dock-more 와 같은 결. */
.tools { grid-area: tools; display: flex; gap: 7px; position: relative; }
#top-more {
  position: absolute; right: 0; top: calc(100% + 8px);
  display: grid; grid-template-columns: repeat(2, 40px); gap: 7px;
  opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity .16s, transform .16s;
}
#top-more.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.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: 12px; bottom: calc(14px + var(--safe-b)); z-index: 10;
  display: flex; flex-direction: column; gap: 8px; width: 236px;
}
.widget { border-radius: var(--r-md); padding: 10px 12px; }
.w-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--ink-dim); letter-spacing: .3px; margin-bottom: 5px;
}
.w-head b { color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: -.2px; }
.w-head .right { margin-left: auto; color: var(--gold); font-weight: 700; font-size: 11px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.10); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--gold); transition: width .3s; }
.bar.blue > i { background: var(--blue); }
.w-foot { margin-top: 5px; font-size: 10.5px; color: var(--ink-faint); }
.w-foot b { color: var(--ink-dim); }

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

/* ── 액션 독 ──────────────────────────────────────────── */
#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; }

/* 성 안 3D 디오라마 — #sheet-body 의 형제라 innerHTML 교체에도 안 죽는다.
   성(city) 탭이 열렸을 때만 보인다(그 밖엔 항상 display:none) */
#city3d { display: none; width: 100%; height: 168px; flex: 0 0 auto; }
#sheet.show[data-tab="city"] #city3d { display: block; }

/* 전장 3D 디오라마 — #encounter 는 매번 innerHTML 을 통째로 갈아 끼우므로
   (도움말·시나리오 선택도 같은 자리를 쓴다) 이 캔버스는 `showBattle()` 이
   부를 때마다 새로 태어난다(`battle3d.js` 가 렌더러를 매번 다시 묻는다) */
#battle3d { display: block; width: 100%; height: 170px; border-radius: 14px; margin-bottom: 12px; background: #0e1116; }

/* ── 시트 내부 공통 ───────────────────────────────────── */
.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); }
/* ⚙️ 설정 시트(2026-09-10) — 다른 네 판(사가블로·사가의숲·사가스토리·사가고)과 같은 이름 */
.key-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-top: 6px;
  background: rgba(255,255,255,.045); 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;
}
.muted { color: var(--ink-dim); }
.warn { color: var(--bad); }
small.muted { display: block; margin-top: 7px; font-size: 10.5px; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* ── 사가국지: 폰에서 손이 닿게 ─────────────────────────
     상단이 프로필·살림 두 줄로 접히므로 지도를 그만큼 내린다.
     안 내리면 지도의 북쪽 성들이 상단 유리판 밑으로 들어가 못 눌린다 */
  #realm { top: 148px; bottom: calc(80px + var(--safe-b)); }
  .p-sub { white-space: nowrap; }              /* "수입 388/월" 의 '월' 이 떨어져 나갔다 */
  .rlab { font-size: 3.2px; }                  /* 성 이름을 손에 든 채 읽을 크기로 */
  .rlegend { font-size: 10px; gap: 3px 8px; padding-top: 3px; }

  /* 손가락 목표 — 44px 이 손끝의 크기다 */
  .btn.tiny { padding: 9px 12px; font-size: 12px; border-radius: 11px; }
  .ordbtn { min-height: 64px; }
  .offrow { padding: 9px 8px; }
  .fpick { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); max-height: 52vh; }
  .numask input[type="range"] { height: 40px; }
}

/* ══ 인물 성장 · 영지 경영 (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식 카메라) ── */
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; }
.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; }


/* 수를 묻는 카드 — prompt 를 걷어낸 자리 */
.numask { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.numask > b {
  font-size: 27px; text-align: center; color: var(--gold, #e8c46a);
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.numask input[type="range"] {
  width: 100%; height: 34px; accent-color: #e09a2a; background: transparent;
}

/* 지도에서 손가락이 닿는 목표 — 보이지 않지만 눌린다 */
.rcity .rhit { fill: transparent; }

/* 무장의 경험 막대 — 충성(초록)과 눈으로 갈라야 한다 */
.bar.sm.gold i { background: linear-gradient(90deg, #d9a441, #f7c96b); }

/* 시나리오 고르기 — 카드 셋이 나란히 서기엔 글이 길다. 한 줄에 하나씩 */
.fpick.scen { grid-template-columns: 1fr; }
.fcard.wide-card { text-align: left; align-items: flex-start; gap: 3px; }
.fcard.wide-card b { font-size: 15px; }

/* 물길 — 배로만 건너는 길. 뭍길과 눈에 띄게 달라야 한다 */
.rmap .rlink.water { stroke: #5aa9d8; stroke-opacity: .55; stroke-dasharray: 1.4 1.2; }
.rmap .rlink.water.same { stroke-opacity: .8; }

/* 명령표에서 못 고르는 칸 */
.ordbtn.disabled { opacity: .32; cursor: not-allowed; }

/* 진영(원정) — 보급·증원 버튼을 나란히 */
.camp-acts { display: flex; gap: 6px; margin-top: 8px; }
.camp-acts .btn { flex: 1; }

/* ── 사가국지 ─────────────────────────────────────────────── */
#camp-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(120% 80% at 50% 6%, rgba(201,162,74,.12), transparent 62%),
    linear-gradient(180deg, #1a1d25 0%, #12151b 60%, #0b0d12 100%);
}
#quizbox {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 8; width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 200px); overflow: auto;
}
.qbox {
  padding: 16px; 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);
}
.qb-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.qb-head b { font-size: 15px; }
.qb-head span { font-size: 11.5px; }
.qbox .dexbar { margin-bottom: 10px; }
.qcats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.qcat-btn {
  display: flex; align-items: center; gap: 7px; padding: 10px 11px;
  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);
}
.qcat-btn:hover { background: rgba(255,255,255,.09); }
.qcat-btn span { font-size: 17px; }
.qcat-btn b { font-size: 12.5px; }
.qcat-btn small { margin-left: auto; font-size: 10px; color: var(--ink-dim); }
.qq { font-size: 15px; line-height: 1.65; margin: 6px 0 12px; font-weight: 600; }
.qchoices { display: flex; flex-direction: column; gap: 6px; }
.qchoice {
  display: flex; gap: 8px; align-items: flex-start; padding: 11px 12px;
  border-radius: var(--r-sm); cursor: pointer; text-align: left; font-size: 13px;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-br); color: var(--ink);
}
.qchoice:hover { background: rgba(201,162,74,.14); border-color: rgba(201,162,74,.5); }
.qchoice b { color: var(--gold); flex: 0 0 auto; }
.qresult { font-size: 13.5px; font-weight: 700; margin: 4px 0 8px; }
.qresult.good { color: var(--good); }
.qresult.bad { color: #e06565; }
.qresult b { color: var(--ink); }
.qwhy { font-size: 12.5px; color: var(--ink-dim); line-height: 1.7; margin: 0 0 10px; }
.qreward {
  font-size: 12px; color: var(--gold); margin-bottom: 10px;
  padding: 8px 10px; border-radius: var(--r-sm); background: rgba(201,162,74,.10);
}

/* ══════════════════════════════════════════════════════════════
   삼국지 — 지도와 그 둘레
   원래 이 판에는 지도가 없었다(강역이 목록이었다). 성 서른 곳과
   그 사이의 길이 판 그 자체가 되면서 가운데 자리를 지도가 차지한다.
   ══════════════════════════════════════════════════════════════ */

#realm {
  position: fixed; inset: 76px 12px 84px; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  /* 2026-09-10 — 한 손가락 드래그로 지도를 직접 미는 손짓(ui-rtk.js bindMapDrag())을
     들이면서 manipulation → none 으로 바꿨다. 어차피 이 안은 스크롤 안 되는
     고정 상자라 브라우저 제스처가 가로챌 게 없고, none 이 여전히 iOS 더블탭
     줌(예전에 manipulation 을 고른 이유)까지 막아 준다 — realm3d 캔버스와 같은 값 */
  touch-action: none;
}
body.sheet-open #realm { right: calc(min(420px, 92vw) + 20px); }
@media (max-width: 780px) { body.sheet-open #realm { right: 12px; } }

/* 2026-09-11 — 예전엔 #realm(2D)과 같은 좁은 인셋(위·아래에 상단바·독을
   피하는 여백)을 썼는데, 3D는 카메라를 돌려 보는 화면이라 2D처럼 "성이
   상단 유리판 밑에 가려 못 눌리는" 문제가 없다(위 #realm 780px 미디어쿼리의
   사정과 다르다) — 그래서 진짜 전체화면으로 깔고, 위에 뜬 유리 패널·독은
   그대로 오버레이로 얹는다("위아래에 검은 화면이 남는다"는 신고의 원인이
   바로 이 여백이었다 — body 배경(#12141a)이 그 틈으로 보인 것). */
#realm3d {
  position: fixed; inset: 0; z-index: 6; display: none;
  touch-action: none;
}
body.sheet-open #realm3d { right: calc(min(420px, 92vw) + 20px); }
@media (max-width: 780px) { body.sheet-open #realm3d { right: 0; } }

.rmap { width: 100%; height: 100%; }
.rlink {
  stroke: rgba(190, 205, 230, .13); stroke-width: .35; stroke-linecap: round;
}
.rlink.same { stroke-width: .55; opacity: .5; }
.rcity { cursor: pointer; }
.rcity circle { transition: r .18s ease; }
.rcity .ring { fill: none; stroke: var(--gold, #e8c46a); stroke-width: .45; }
.rcity:hover circle:first-child { r: 4.2; }
.rlab {
  font-size: 2.5px; fill: #dfe6f2; text-anchor: middle;
  paint-order: stroke; stroke: rgba(8, 10, 14, .85); stroke-width: .7px;
  pointer-events: none; font-weight: 600;
}
.rdis { font-size: 3px; pointer-events: none; }
.rjourney { font-size: 3.4px; text-anchor: middle; pointer-events: none; }

.rlegend {
  display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center;
  padding: 6px 8px 0; font-size: 11px; color: var(--ink-dim, #93a0b4);
}
.rlg { display: inline-flex; align-items: center; gap: 4px; }
.rlg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.rlg.me { color: var(--gold, #e8c46a); font-weight: 700; cursor: pointer; }
.rlg b { color: #dfe6f2; }

/* 상단 '다음 달' */
.next-btn { margin-left: 6px; white-space: nowrap; }

/* ── 지도 조이스틱 · 내 땅으로 · 확대·축소(2026-09-10) ──────────
 * 세계가 삼국지 한 판을 넘어 한국·일본·교주 등으로 늘면서, 전체를 한눈에
 * 다 보여주던 지도는 성 하나하나를 점으로 뭉개 "내 땅이 어딘지" 알아보기
 * 어려워졌다. saga-go 의 #gjoy 와 같은 요령으로 지도(2D·3D 다)를 옮기고
 * 당길 수 있게 한다 — 세력을 고르기 전·시트가 지도를 덮었을 때는 숨긴다
 * (js/ui-rtk.js `syncMapControls()`). */
#rjoy, #rmapctl {
  display: none; position: fixed; z-index: 8;
  left: 14px; bottom: calc(96px + var(--safe-b));
}
#rjoy.show, #rmapctl.show { display: block; }
#rjoy {
  width: 108px; height: 108px; 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);
}
#rjoy-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
  margin: -23px 0 0 -23px; 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);
}
#rmapctl {
  left: 130px; display: none; flex-direction: column; gap: 6px;
}
#rmapctl.show { display: flex; }

/* ── 실시간 전투 현황판(2026-09-10) ───────────────────────────
 * `.rstat`(성 시트가 쓰는 그 줄)를 그대로 재사용한다 — 새 막대 스타일을
 * 만들지 않는다. bhud-round 만 작은 표 하나 더한다. */
.bhud { margin: 2px 0 8px; }
.bhud-round {
  font-size: 11px; color: var(--ink-dim, #93a0b4); text-align: right; margin-top: -2px;
}

/* 성 살림 한 줄 — 이름 · 막대 · 값 */
.rstat {
  display: grid; grid-template-columns: 66px 1fr 62px; align-items: center;
  gap: 8px; margin: 3px 0; font-size: 12px;
}
.rstat > span { color: var(--ink-dim, #93a0b4); }
.rstat > b { text-align: right; font-variant-numeric: tabular-nums; }
.rstat .bar.sm.bad i { background: #c9584f; }

/* 명령 아홉 칸 */
.ordgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.ordbtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1);
  color: inherit; font: inherit;
}
.ordbtn:hover { background: rgba(255, 255, 255, .1); }
.ordbtn span { font-size: 18px; }
.ordbtn b { font-size: 12px; }
.ordbtn small { font-size: 10px; color: var(--ink-dim, #93a0b4); }
.ordbtn.poor { opacity: .45; }

/* 사람 한 줄 (명령 고르기 · 등용) */
.offrow {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; margin: 4px 0; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08);
  color: inherit; font: inherit; text-align: left;
}
.offrow:hover { background: rgba(255, 255, 255, .09); }
.offrow .offname { flex: 1; display: flex; flex-direction: column; font-size: 13px; }
.offrow .offname small { font-size: 10.5px; }
.offrow > b { font-variant-numeric: tabular-nums; color: var(--gold, #e8c46a); }
.offcard .dt-top { display: flex; gap: 10px; align-items: flex-start; }
.offcard .dt-stats { display: flex; gap: 10px; font-size: 11.5px; margin-top: 3px; }
.offcard .dt-bio { display: block; margin-top: 6px; line-height: 1.5; }

/* 세력 고르기 */
.fpick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; margin-top: 10px; max-height: 58vh; overflow: auto;
}
.fcard {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 4px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .05); border: 1.5px solid rgba(255, 255, 255, .12);
  color: inherit; font: inherit;
}
.fcard:hover { background: rgba(255, 255, 255, .11); }
.fcard b { font-size: 13px; }
.fcard small { font-size: 10px; }

/* 일기토 예고장(2026-09-10) — "OOO ⚔️ OOO", 초상 곁들여 */
.bduel {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13px; margin-bottom: 6px; flex-wrap: wrap;
}
.bduel img.pt {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid var(--glass-br); flex: 0 0 auto;
}
.bduel span { font-size: 15px; }

/* 전황 */
.warlog {
  max-height: 52vh; overflow: auto; font-size: 12.5px; line-height: 1.7;
  background: rgba(0, 0, 0, .25); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px;
}
.warlog > div + div { border-top: 1px solid rgba(255, 255, 255, .05); }

.fdot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tag.warnt { color: #f0a0a0; border-color: rgba(240, 160, 160, .5); }
.lnk { cursor: pointer; text-decoration: underline dotted; }
