/* 색은 모두 변수로. 테마색은 --accent 하나만 바꾸면 된다.
   게임 화면은 늘 어두운 무협 분위기, 패널은 한지·먹 느낌. */
:root {
  --accent: #8b1e1e;
  --gold: #e8c467;
  --bg: #0e0f12;
  --surface: rgba(20, 18, 16, 0.92);
  --surface2: rgba(255, 255, 255, 0.06);
  --text: #f3ead8;
  --muted: #b6aa93;
  --line: rgba(232, 196, 103, 0.28);
  --danger: #ff7a6a;
  --radius: 14px;
  --tap: 48px;           /* 손가락 크기: 단추 최소 높이 */
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0c0e; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#world { position: fixed; inset: 0; display: block; touch-action: none; }
#app { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; }
.screen > * { pointer-events: auto; }
[hidden] { display: none !important; }

/* ---------- 단추 ---------- */
.btn {
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn:focus-visible, .sbtn:focus-visible, .abtn:focus-visible, .mbtn:focus-visible, .hbtn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(180deg, #b52a22, #7a1610); border-color: #e8c467; color: #fff4dc;
  box-shadow: 0 4px 18px rgba(180, 30, 20, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { font-size: 1.2rem; padding: 14px 36px; min-width: 220px; letter-spacing: 0.1em; }
.btn.ghost { background: rgba(0, 0, 0, 0.35); }
.btn.danger { color: var(--danger); border-color: rgba(255, 122, 106, 0.4); }
.btn.sm { min-height: 40px; padding: 6px 14px; font-size: 0.9rem; }
.icon-btn { width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: var(--surface2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.link { color: var(--gold); display: inline-block; padding: 12px 0; }

/* ---------- 처음 화면 ---------- */
.title-screen { display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(0,0,0,0.15), rgba(0,0,0,0.65)); }
.title-box { text-align: center; max-width: 440px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.title-sub { margin: 0; letter-spacing: 0.4em; color: var(--gold); font-size: 0.85rem; text-shadow: 0 2px 8px #000; }
.title-logo {
  margin: 0; font-family: "Batang", "Nanum Myeongjo", "Noto Serif KR", serif; font-weight: 900;
  font-size: clamp(3rem, 14vw, 5.4rem); line-height: 1.05; letter-spacing: 0.08em;
  background: linear-gradient(180deg, #fff6d8 0%, #f0c95a 45%, #a8681c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #3a0a06) drop-shadow(0 10px 24px rgba(0, 0, 0, 0.9));
  animation: logoIn 1.2s ease-out both;
}
@keyframes logoIn { from { opacity: 0; transform: translateY(14px) scale(0.96); letter-spacing: 0.3em; } }
.title-desc { margin: 0 0 8px; color: #efe3c8; text-shadow: 0 2px 6px #000; }
.title-hero { margin: 0; color: var(--gold); font-weight: 700; text-shadow: 0 2px 6px #000; }
.title-box [hidden] { display: none !important; }
.roster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; max-width: 420px; }
.rc { min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 6px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 8, 6, 0.75); color: var(--text); font: inherit; cursor: pointer; }
.rc b { font-size: 0.82rem; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rc small { font-size: 0.68rem; color: var(--muted); }
.rc.on { border-color: var(--gold); background: linear-gradient(180deg, rgba(232, 196, 103, 0.28), rgba(40, 28, 10, 0.85)); box-shadow: 0 0 12px rgba(232, 196, 103, 0.35); }
.rc.on small { color: #ffe8b0; }
.rc.empty { border-style: dashed; opacity: 0.85; }
.rc.empty b { color: var(--muted); font-weight: 700; }
.vault-btn { min-height: 36px; }
.sfx-box { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.sfx-box .row { margin: 0; min-height: 40px; }
.sfx-box p { margin: 0; }
.sfx-box input[type=checkbox] { width: 22px; height: 22px; accent-color: #6dd8ff; }
.sfx-box input[type=range] { flex: 1; max-width: 190px; min-height: 36px; accent-color: #6dd8ff; }
.autodis-box { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.autodis-box .row { margin: 0; }
.autodis-box input[type=checkbox] { width: 22px; height: 22px; accent-color: #ffb84a; }
.autodis-box p { margin: 0; }
.ad-chips button { opacity: 0.55; }
.ad-chips button.on { opacity: 1; }
.ad-chips button.on::before { content: "🔨 "; }
.bag-multi { margin-left: auto; min-height: 36px; }
.bag-multi.on { border-color: #6dff8a; color: #c8ffd4; box-shadow: 0 0 10px rgba(109, 255, 138, 0.35); }
.bag-cell.picked { outline: 3px solid #6dff8a; outline-offset: -3px; }
.bag-cell.picked::after { content: "✔"; position: absolute; left: 4px; bottom: 2px; font-size: 0.8rem; font-weight: 900; color: #6dff8a; text-shadow: 0 1px 2px #000; }
.bag-cell.dim { opacity: 0.35; }
.bulk-panel { display: flex; flex-direction: column; gap: 8px; }
.bulk-panel .row2 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bulk-panel select { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.4); color: var(--text); font: inherit; padding: 0 8px; }
.bulk-sum { margin: 0; font-size: 0.85rem; color: #ffe8b0; }
.btn.warn { border-color: #ff8a7a; color: #ffd0c8; background: linear-gradient(180deg, rgba(194, 58, 46, 0.6), rgba(106, 18, 12, 0.6)); }
.bag-top { gap: 8px; }
.trade-open { position: absolute; left: 8px; bottom: calc(156px + env(safe-area-inset-bottom)); width: 48px; height: 40px; border-radius: 20px; border: 1px solid rgba(255, 216, 74, 0.6); background: rgba(0,0,0,0.55); color: #fff; font-size: 1.2rem; z-index: 4; box-shadow: 0 0 10px rgba(255, 216, 74, 0.3); }
.trade-open[hidden] { display: none; }
.tr-box { width: min(760px, 100%); }
.tr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .tr-cols { grid-template-columns: 1fr; } }
.tr-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.3); }
.tr-col.ok { border-color: #6dff8a; box-shadow: 0 0 10px rgba(109, 255, 138, 0.3); }
.tr-col h3 { margin: 0; font-size: 0.9rem; color: var(--gold); display: flex; justify-content: space-between; gap: 6px; }
.tr-col h3 small { color: #6dff8a; font-size: 0.75rem; }
.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 0.82rem; }
.tr-row .ti { font-size: 1.1rem; flex: none; }
.tr-row .tn { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-row input { width: 58px; margin-left: auto; min-height: 34px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,0.4); color: var(--text); font: inherit; padding: 0 6px; }
.tr-row .btn { min-height: 34px; padding: 0 10px; }
.tr-row .tn + .btn { margin-left: auto; }
.tr-empty { color: var(--muted); font-size: 0.8rem; padding: 6px; }
.tr-status { margin: 0; font-size: 0.85rem; color: #ffe8b0; }
.tr-lock { font-size: 0.72rem; color: #ff9a8a; }
.gift-box { text-align: center; border-color: #ff6b5a; box-shadow: 0 0 30px rgba(255, 80, 60, 0.35), 0 12px 40px rgba(0,0,0,0.8); }
.gift-box h2 { color: #ffd84a; }
.gift-ic { font-size: 3rem; line-height: 1; animation: giftBob 1.2s ease-in-out infinite alternate; }
@keyframes giftBob { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-6px) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .gift-ic { animation: none; } }
.gift-desc { margin: 0; font-size: 0.9rem; }
.gift-box .btn.big { font-size: 1rem; letter-spacing: 0; white-space: nowrap; padding: 8px 14px; }
.bag-cell .st-g { position: absolute; left: 4px; top: 2px; font-style: normal; font-size: 0.58rem; font-weight: 900; color: var(--gc); text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.bag-cell .sk-t { color: #9ad8ff; }
.bag-cell .sk-t.p { color: #9dffb0; }
.bag-cell.stone { box-shadow: inset 0 0 10px color-mix(in srgb, var(--gc) 35%, transparent); }
.bag-cell.box { box-shadow: inset 0 0 14px rgba(255, 59, 59, 0.45), 0 0 10px rgba(255, 59, 59, 0.35); }
.pick-h { margin: 0; color: var(--gold); font-weight: 700; font-size: 0.9rem; text-shadow: 0 2px 6px #000; }
.btn.wait { filter: saturate(0.35) brightness(0.8); }
.class-pick.nudge { animation: nudge 0.5s ease; }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .class-pick.nudge { animation: none; } }
.class-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; max-width: 440px; }
.cls-card { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 4px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.5); color: var(--text); font: inherit; cursor: pointer; }
.cls-card .cls-ic { font-size: 1.3rem; line-height: 1.2; }
.cls-card .cls-name { font-size: 0.88rem; }
.cls-card .cls-desc { font-size: 0.64rem; color: var(--muted); line-height: 1.25; }
.cls-card.sel { border-color: var(--gold); background: rgba(217, 168, 58, 0.22); box-shadow: 0 0 0 2px rgba(217, 168, 58, 0.35); }
.cls-card:focus-visible { outline: 2px solid var(--gold); }
.beta-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px dashed rgba(255, 120, 100, 0.6); background: rgba(120, 20, 20, 0.25); }
.beta-box[hidden] { display: none; }
.invite-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid rgba(122, 200, 255, 0.5); background: rgba(20, 60, 110, 0.25); }
.invite-url { margin: 0; word-break: break-all; }
.invite-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.invite-acts .btn { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 4px; text-decoration: none; font-size: 0.88rem; padding: 6px; }
@media (max-width: 420px) { .invite-acts { grid-template-columns: 1fr; } }
.upd-pop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 12px; background: rgba(0, 0, 0, 0.75); pointer-events: auto; }
.upd-pop[hidden] { display: none; }
.inst-box { align-items: center; text-align: center; }
.btn.title-install { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 5; min-height: 48px; padding: 8px 18px; border: 1px solid #7ac8ff; background: rgba(20, 60, 110, 0.75); color: #e6f6ff; font-weight: 800; box-shadow: 0 0 12px rgba(122, 200, 255, 0.35); }
.btn.title-install[hidden] { display: none; }
#inst-yes.pulse { animation: instPulse 1s ease-in-out infinite alternate; }
.app-badge { font: inherit; cursor: pointer; min-height: 36px; position: fixed; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); z-index: 5; padding: 6px 12px; border-radius: 99px; background: rgba(30, 90, 50, 0.8); border: 1px solid #7dff9a; color: #dfffe6; font-size: 0.8rem; font-weight: 700; }
.app-badge[hidden] { display: none; }
/* 브라우저 메뉴 위치를 짚는 화살표 (크롬 ⋮ 오른쪽 위 / 삼성 인터넷 ≡ 오른쪽 아래) */
.inst-arrow { position: fixed; z-index: 120; right: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.inst-arrow[hidden] { display: none; }
.inst-arrow.top { top: 4px; }
.inst-arrow.bottom { bottom: 6px; flex-direction: column-reverse; }
.inst-arrow .ia-ar { font-size: 3rem; line-height: 1; color: #ffd84a; text-shadow: 0 0 12px #000, 0 0 4px #000; animation: iaBob 0.8s ease-in-out infinite alternate; margin-right: 4px; }
.inst-arrow .ia-txt { max-width: 260px; padding: 8px 12px; border-radius: 12px; background: #ffd84a; color: #2a1a00; font-weight: 800; font-size: 0.95rem; box-shadow: 0 6px 20px rgba(0,0,0,0.6); text-align: right; }
@keyframes iaBob { from { transform: translateY(0); } to { transform: translateY(-10px); } }
.inst-arrow.bottom .ia-ar { animation-name: iaBob2; }
@keyframes iaBob2 { from { transform: translateY(0); } to { transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .inst-arrow .ia-ar { animation: none; } }
@keyframes instPulse { from { box-shadow: 0 0 0 0 rgba(122,200,255,0.0); } to { box-shadow: 0 0 0 6px rgba(122,200,255,0.45); } }
@media (prefers-reduced-motion: reduce) { #inst-yes.pulse { animation: none; } }
.inst-ic { width: 88px; height: 88px; border-radius: 22px; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.6)); }
.inst-box h2 { font-size: 1.2rem; }
.inst-desc { margin: 0; font-size: 0.9rem; color: var(--muted); }
.inst-steps { margin: 0; text-align: left; padding-left: 1.3em; font-size: 0.92rem; line-height: 1.6; }
.inst-steps[hidden] { display: none; }
.inst-steps b { color: var(--gold); }
.inst-acts { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.inst-acts .btn[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 520px) { .inst-ic { width: 56px; height: 56px; } .inst-acts { flex-direction: row; } .inst-acts .btn { flex: 1; } }
.upd-box { width: min(460px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--surface, #24130f); border: 1px solid var(--gold); box-shadow: 0 12px 40px rgba(0,0,0,0.8); color: var(--text); }
.upd-box h2 { margin: 0; font-size: 1.15rem; color: var(--gold); }
.upd-box h2 small { color: var(--muted); font-size: 0.8rem; }
.upd-list { margin: 0; padding-left: 1.2em; font-size: 0.88rem; line-height: 1.5; }
.upd-warn { margin: 0; font-size: 0.84rem; color: #ffc8b8; }
@media (orientation: landscape) and (max-height: 520px) { .upd-box { padding: 10px 14px; gap: 6px; } .upd-list { font-size: 0.8rem; line-height: 1.35; } }
.beta-h { margin: 0; font-size: 0.95rem; }
.beta-tag { background: #b3261e; color: #fff; font-size: 0.7rem; padding: 1px 7px; border-radius: 99px; }
.beta-box textarea { width: 100%; min-height: 84px; border-radius: 10px; border: 1px solid var(--line); background: #1d1813; color: var(--text); font: inherit; padding: 8px 10px; resize: vertical; }
.beta-box textarea:focus { outline: 2px solid var(--gold); }
.new-confirm { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; padding: 12px; border-radius: 12px; background: rgba(120, 20, 20, 0.45); border: 1px solid rgba(255, 120, 100, 0.55); }
.new-warn { margin: 0; color: #ffe2dc; font-size: 0.9rem; line-height: 1.45; text-shadow: 0 1px 3px #000; }
.new-acts { display: flex; gap: 8px; }
.hero-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hero-acts .btn { min-height: 44px; }
.del-box { border-color: rgba(255, 120, 100, 0.7); }
.del-box h2 { color: #ffb0a0; }
.del-who { margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--gold); text-align: center; padding: 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); }
.btn.danger.big { background: linear-gradient(180deg, #c23a2e, #6a120c); color: #fff; border-color: #ff8a7a; }
.new-acts .btn { flex: 1; min-height: 48px; }
.title-hint { margin: 10px 0 0; font-size: 0.78rem; color: #cfc3a8; text-shadow: 0 1px 4px #000; }
.title-links { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.name-row { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 280px; color: var(--muted); font-size: 0.9rem; }
.name-row input {
  min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.55);
  color: var(--text); font: inherit; font-size: 1.1rem; text-align: center; padding: 0 12px; user-select: text;
}
.name-row input:focus { outline: 2px solid var(--gold); }

/* ---------- 게임 화면 HUD ---------- */
.game-screen { pointer-events: none; }
.hud-top { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.hero-card { display: flex; gap: 8px; align-items: center; background: linear-gradient(90deg, rgba(10, 8, 6, 0.85), rgba(10, 8, 6, 0.4)); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px 6px 6px; min-width: 0; max-width: 62vw; }
.lv-badge { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(circle at 35% 30%, #c43a2e, #5a0e0a); border: 2px solid var(--gold); line-height: 1; }
.lv-badge small { font-size: 0.6rem; color: #ffd9a8; }
.lv-badge b { font-size: 1.15rem; }
.hero-bars { flex: 1; min-width: 120px; width: 220px; max-width: 46vw; }
.hero-line { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; margin-bottom: 4px; white-space: nowrap; }
.hero-line b { overflow: hidden; text-overflow: ellipsis; }
.gold { color: var(--gold); font-weight: 700; }
.hpbar { position: relative; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.7); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.15); }
.hpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #ff6b5a, #b3170c); transition: width 0.15s; }
.xpbar { position: relative; height: 11px; margin-top: 3px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.12); }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #8fd6ff, #2a7fd4); box-shadow: 0 0 6px rgba(74, 168, 255, 0.6); transition: width 0.3s; }
.xpbar span { position: relative; display: block; text-align: center; font-size: 0.58rem; font-weight: 700; line-height: 10px; text-shadow: 0 1px 2px #000; }
.hpbar span { position: relative; display: block; text-align: center; font-size: 0.7rem; font-weight: 700; line-height: 15px; text-shadow: 0 1px 2px #000; }
.mm-wrap { text-align: center; }
.mm-btn { pointer-events: auto; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; display: block; }
.mm-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.bigmap { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0, 0, 0, 0.62); padding: 10px; }
.bigmap[hidden] { display: none; }
.bm-box { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 16px; background: rgba(28, 18, 12, 0.96); border: 1px solid var(--gold); box-shadow: 0 10px 40px rgba(0,0,0,0.7); max-height: 100%; }
.bm-head { display: flex; align-items: center; gap: 10px; width: 100%; }
.bm-head h2 { margin: 0; font-size: 1.05rem; color: var(--gold); }
.bm-zone { flex: 1; font-size: 0.82rem; color: var(--muted); }
#bm { width: min(86vw, calc(100vh - 150px)); height: min(86vw, calc(100vh - 150px)); max-width: 620px; max-height: 620px; border-radius: 12px; border: 2px solid var(--line); touch-action: none; cursor: crosshair; background: #000; }
.bm-legend { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; font-size: 0.74rem; color: var(--muted); }
.bm-legend > span { display: inline-flex; align-items: center; gap: 4px; }
.bm-legend i { width: 9px; height: 9px; display: inline-block; border: 1px solid #000; }
.bm-hint { margin: 0; font-size: 0.74rem; color: var(--muted); }
@media (orientation: landscape) and (max-height: 520px) {
  .bm-box { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
  .bm-head { width: auto; flex-direction: column; align-items: flex-start; order: 2; max-width: 180px; }
  #bm { width: calc(100vh - 44px); height: calc(100vh - 44px); }
  .bm-legend { order: 3; flex-direction: column; align-items: flex-start; max-width: 120px; }
  .bm-hint { display: none; }
}
#mm { width: 112px; height: 112px; border-radius: 50%; border: 2px solid var(--gold); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6); background: #000; display: block; }
.zone-name { margin: 4px 0 0; font-size: 0.78rem; font-weight: 700; color: #fff1cf; text-shadow: 0 1px 3px #000; }
.top-btns { position: absolute; top: calc(148px + env(safe-area-inset-top)); right: 8px; display: flex; flex-direction: column; gap: 8px; }
.hbtn { position: relative; width: 56px; height: 56px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 8, 6, 0.8); color: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; }
.hbtn small { font-size: 0.6rem; font-weight: 800; color: #f3e2b8; letter-spacing: -0.02em; }
#btn-char { border-color: var(--gold); box-shadow: 0 0 10px rgba(232, 196, 103, 0.35); }
button.hero-card { pointer-events: auto; cursor: pointer; font: inherit; color: inherit; text-align: left; }
button.hero-card:active { transform: scale(0.98); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: #e2402a; color: #fff; font-size: 0.7rem; font-weight: 800; line-height: 20px; padding: 0 5px; }

.boss-bar { position: absolute; top: calc(78px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(420px, 56vw); text-align: center; }
.boss-bar p { margin: 0 0 3px; font-weight: 800; color: #ffb09a; text-shadow: 0 2px 4px #000; font-size: 0.9rem; }
.bbar { height: 12px; border-radius: 6px; background: rgba(0, 0, 0, 0.75); border: 1px solid #ff7a5a; overflow: hidden; }
.bbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff2a1a, #ff8a3a); transition: width 0.15s; }

.chat { position: absolute; left: 8px; bottom: calc(150px + env(safe-area-inset-bottom)); width: min(380px, 60vw); display: flex; flex-direction: column; gap: 2px; pointer-events: auto; cursor: pointer; z-index: 4; }
.chat:not(.open) p:nth-last-child(n+8) { display: none; }
.chat:not(.open) .chat-head { display: none; }
.chat.open { width: min(480px, 82vw); max-height: 62vh; overflow-y: auto; padding: 6px; border-radius: 12px; background: rgba(8, 6, 4, 0.86); border: 1px solid var(--gold); box-shadow: 0 8px 30px rgba(0,0,0,0.7); z-index: 7; overscroll-behavior: contain; touch-action: pan-y; }
.chat.open p { display: block !important; animation: none; background: rgba(255,255,255,0.04); }
.chat .chat-head { position: sticky; top: -6px; margin: -6px -6px 4px; padding: 6px 10px; background: rgba(30, 22, 12, 0.98); border-bottom: 1px solid var(--line); font-size: 0.78rem; font-weight: 800; color: var(--gold); display: flex; justify-content: space-between; }
.chat p { margin: 0; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.42); font-size: 0.76rem; line-height: 1.35; color: #e9e2d2; text-shadow: 0 1px 2px #000; animation: chatIn 0.3s ease-out; }
@keyframes chatIn { from { opacity: 0; transform: translateX(-8px); } }
.chat .c-sys { color: #ffe08a; }
.chat .c-player { color: #ffffff; }
.chat .c-me { color: #9dffb0; }
.chat-open { position: absolute; left: 8px; bottom: calc(112px + env(safe-area-inset-bottom)); min-width: 48px; height: 36px; border-radius: 18px; border: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.5); color: #fff; font: inherit; font-size: 1rem; display: flex; align-items: center; gap: 4px; padding: 0 10px; z-index: 4; }
.chat-open[hidden], .chat-bar[hidden] { display: none; }
.chat-open b { font-size: 0.72rem; color: #9dffb0; }
.chat-bar { position: absolute; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); max-width: 560px; display: flex; gap: 6px; padding: 6px; border-radius: 12px; background: rgba(10, 6, 4, 0.88); border: 1px solid var(--line); z-index: 20; }
.chat-bar input { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #1d1813; color: var(--text); font: inherit; padding: 0 10px; }
.chat-bar input:focus { outline: 2px solid var(--gold); }
.chat .c-npc { color: #bfe3ff; }
.chat .c-world { color: #ffb36b; font-weight: 700; }
.chat .c-g0 { color: #b9bec4; } .chat .c-g1 { color: #f2f2f2; } .chat .c-g2 { color: #5fd36a; } .chat .c-g3 { color: #4aa8ff; }
.chat .c-g4 { color: #c48bff; } .chat .c-g5 { color: #ff9a2e; } .chat .c-g6 { color: #ff5b5b; } .chat .c-g7 { color: #ffd84a; } .chat .c-g8 { color: #7ef9ff; }

.banner {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%); white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
  font-family: "Batang", "Nanum Myeongjo", serif; font-weight: 900; font-size: clamp(1.3rem, 5vw, 2.3rem);
  color: var(--bc, #ffe58a); text-shadow: 0 0 18px var(--bc, #ffe58a), 0 3px 0 #000, 0 6px 16px #000; pointer-events: none;
}
.banner.show { animation: bannerIn 2.6s ease-out both; }
@keyframes bannerIn { 0% { opacity: 0; transform: translateX(-50%) scale(1.6); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-20px); } }

/* 오른쪽 아래 조작 */
.controls { position: absolute; right: calc(12px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 236px; height: 236px; }
.abtn {
  position: absolute; right: 0; bottom: 0; width: 92px; height: 92px; border-radius: 50%; cursor: pointer; font-size: 2.1rem;
  border: 3px solid var(--gold); color: #fff;
  background: radial-gradient(circle at 35% 30%, #d6463a, #6a0f0a 70%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.abtn:active { transform: scale(0.94); }
.sbtn {
  --gc: #888; --cd: 0deg;
  position: absolute; width: 60px; height: 60px; border-radius: 50%; cursor: pointer; overflow: hidden;
  border: 2.5px solid var(--gc); color: #fff; font-weight: 800; font-size: 0.82rem;
  background: radial-gradient(circle at 35% 30%, rgba(80, 70, 60, 0.95), rgba(14, 12, 10, 0.95));
  box-shadow: 0 0 12px color-mix(in srgb, var(--gc) 50%, transparent), 0 4px 12px rgba(0, 0, 0, 0.6);
}
.sbtn::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(0, 0, 0, 0.7) var(--cd), transparent 0); pointer-events: none; }
.sbtn .ic { position: relative; z-index: 0; color: var(--gc); text-shadow: 0 1px 3px #000; letter-spacing: -0.02em; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; width: 100%; }
.sbtn .ic .sy { font-size: 1.25rem; line-height: 1.1; filter: drop-shadow(0 1px 2px #000); }
.sbtn .ic .nm { font-size: 0.56rem; font-weight: 800; max-width: 54px; overflow: hidden; white-space: nowrap; text-overflow: clip; margin-bottom: 6px; }
.sbtn .cdt { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; font-size: 1.15rem; text-shadow: 0 1px 3px #000; }
.sbtn kbd { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font: 700 0.55rem system-ui; opacity: 0.6; z-index: 2; }
.sbtn.empty { opacity: 0.6; border-style: dashed; }
.sbtn.empty .ic { font-size: 1.4rem; color: #aaa; }
.sbtn:active { transform: scale(0.92); }
#skill-0 { right: 104px; bottom: 6px; }
#skill-1 { right: 96px; bottom: 76px; }
#skill-2 { right: 52px; bottom: 136px; }
#skill-3 { right: -6px; bottom: 156px; }
#skill-4 { right: 168px; bottom: 4px; }
.mbtn { position: absolute; width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: rgba(10, 8, 6, 0.8); color: #fff; cursor: pointer; font-weight: 800; }
.mbtn.pot { left: -66px; bottom: 0; font-size: 1.3rem; }
.mbtn.pot b { position: absolute; right: 3px; bottom: 1px; font-size: 0.72rem; }
.mbtn.pot .pot-cd { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 1.15rem; font-weight: 900; color: #fff; text-shadow: 0 1px 3px #000; pointer-events: none; }
.mbtn.pot.cd { filter: brightness(0.55); }
.mbtn.pot.cd .pot-cd { filter: brightness(1.8); }
.pot-swap { position: absolute; left: -76px; bottom: 34px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--gold); background: rgba(20, 14, 8, 0.95); color: #ffe9a0; font-size: 0.8rem; font-weight: 900; line-height: 1; padding: 0; z-index: 2; cursor: pointer; }
.pot-swap:active { transform: scale(0.9); }
.mbtn.auto { left: -66px; bottom: 62px; font-size: 0.85rem; }
.mbtn.apot { left: -132px; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0; line-height: 1.05; }
.mbtn.apot .apot-ic { font-size: 0.95rem; }
.mbtn.apot small { font-size: 0.55rem; color: var(--muted); }
.mbtn.apot b { font-size: 0.72rem; color: #ffb3c4; }
.mbtn.apot.on { border-color: #ff8fab; box-shadow: 0 0 12px rgba(255, 120, 160, 0.45); background: linear-gradient(180deg, rgba(110, 20, 50, 0.9), rgba(40, 8, 20, 0.9)); }
.mbtn.apot.on small { color: #ffd6e0; }
.mbtn.pas { left: -132px; bottom: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0; line-height: 1.05; border-color: #9ffbff; box-shadow: 0 0 10px rgba(120, 230, 255, 0.3); }
.mbtn.pas .pas-ic { font-size: 1.1rem; }
.mbtn.pas small { font-size: 0.55rem; color: #bff6ff; }
.mbtn.pas:active { transform: scale(0.92); }
.apot-pop { position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: calc(250px + env(safe-area-inset-bottom)); width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid #ff8fab; border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); z-index: 5; }
.apot-pop h3 { margin: 0; color: #ffb3c4; }
.apot-body { display: flex; flex-direction: column; gap: 8px; }
.apot-row { display: flex; align-items: center; gap: 10px; }
.apot-toggle { min-width: 72px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.45); color: var(--muted); font: inherit; font-weight: 800; cursor: pointer; }
.apot-toggle.on { background: linear-gradient(180deg, #c23a5e, #6a1028); color: #fff; border-color: #ff8fab; }
.apot-info { font-size: 0.82rem; }
.apot-slider { display: flex; align-items: center; gap: 6px; }
.apot-slider input { flex: 1; accent-color: #ff6b8a; min-height: 32px; }
.apot-slider b { min-width: 42px; text-align: right; color: #ffb3c4; }
.apot-quick { display: flex; gap: 6px; }
.mbtn.auto.on { background: linear-gradient(180deg, #2f8a5a, #145234); border-color: #8dffb8; box-shadow: 0 0 14px rgba(80, 255, 160, 0.5); animation: autoPulse 1.6s infinite; }
@keyframes autoPulse { 50% { box-shadow: 0 0 22px rgba(80, 255, 160, 0.8); } }


.joy { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.18)); border: 2px solid rgba(255, 255, 255, 0.35); pointer-events: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #c9b98f); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); transform: translate(-50%, -50%); }

.dead { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(40, 0, 0, 0.6); text-align: center; padding: 16px; }
.dead h2 { margin: 0; font-family: "Batang", serif; font-size: 2.4rem; color: #ff6a5a; text-shadow: 0 3px 0 #000; }
.shop { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius); padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7); display: flex; flex-direction: column; gap: 8px; }
.shop h3 { margin: 0; color: var(--gold); }
.slot-pop-box { width: min(460px, 100%); }
.sp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-body { display: flex; flex-direction: column; gap: 8px; }
.sp-sec { margin: 4px 0 0; font-size: 0.8rem; font-weight: 800; color: var(--muted); }
.sp-cur { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--gold); background: rgba(232, 196, 103, 0.08); }
.sp-cur.empty { border-style: dashed; border-color: var(--line); background: none; }
.sp-cur b, .sp-item b { display: block; font-size: 0.92rem; }
.sp-cur small, .sp-item small { color: var(--muted); font-size: 0.74rem; }
.sp-list { display: flex; flex-direction: column; gap: 6px; }
.sp-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.sp-item:active { transform: scale(0.98); }
.sp-item.far { opacity: 0.55; }
.sp-item .sp-tag { font-size: 0.72rem; font-weight: 700; color: #9ffbff; white-space: nowrap; }
.portal-box { width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; z-index: 12; }
.dg-box { border-color: #c08bff; box-shadow: 0 0 24px rgba(160, 90, 255, 0.4), 0 10px 40px rgba(0,0,0,0.7); }
.dg-box h3 { color: #e0b8ff; }
.portal-item.dg-exit { border-color: #c08bff; }
.portal-list { display: flex; flex-direction: column; gap: 6px; }
.portal-item { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.portal-item .pi-ic { font-size: 1.4rem; text-align: center; }
.portal-item b { display: block; font-size: 0.92rem; }
.portal-item small { color: var(--muted); font-size: 0.74rem; }
.portal-item .pi-wb { display: block; color: #ff8af0; font-weight: 700; }
.portal-item .pi-wb.soon { color: #ffd84a; font-weight: 600; }
.portal-item .pi-st { font-size: 0.74rem; font-weight: 700; color: #9dffb0; }
.portal-item.here { border-color: var(--gold); background: rgba(217,168,58,0.16); cursor: default; }
.portal-item.locked { opacity: 0.5; cursor: not-allowed; }
.portal-item.locked .pi-st { color: #ff9a8a; }
@media (orientation: landscape) and (max-height: 520px) { .portal-item { min-height: 44px; padding: 4px 10px; } }
.shop p { margin: 0; }
.shop-row { display: flex; gap: 8px; }
#shop { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; }
.mat-have { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 5px; }
.mat-chip { display: flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 9px; background: rgba(0,0,0,0.35); border: 1px solid var(--line); font-size: 0.76rem; }
.mat-chip b { margin-left: auto; color: #fff; }
.mat-chip.zero { opacity: 0.45; }
.grade-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 4px; }
.grade-chips button { min-height: 36px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer; }
.grade-chips button.on { border-color: var(--gold); box-shadow: 0 0 8px rgba(232,196,103,0.4); background: rgba(232,196,103,0.15); }
.smith-list { display: flex; flex-direction: column; gap: 8px; }
.smith-card { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,0.3); }
.smith-card .sm-ic { font-size: 1.8rem; text-align: center; }
.smith-card small { display: block; margin-top: 1px; }
.smith-card .sm-need { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; margin-top: 3px; }
.smith-card .sm-need .lack { color: #ff8a7a; }
.smith-card .sm-need .ok { color: #9dffb0; }
.smith-card .btn { min-height: 44px; }
.shop-list { display: flex; flex-direction: column; gap: 6px; }
.shop-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.3); }
.shop-item .si-ic { font-size: 1.4rem; text-align: center; }
.shop-item b { display: block; font-size: 0.9rem; }
.shop-item small { display: block; color: var(--muted); font-size: 0.72rem; line-height: 1.3; }
.shop-item .si-pr { color: var(--gold); font-weight: 800; font-size: 0.78rem; }
.shop-item .si-btns { display: flex; gap: 4px; }
.shop-item .btn { min-height: 38px; padding: 0 10px; font-size: 0.8rem; }
.buffs { position: absolute; left: calc(8px + env(safe-area-inset-left)); top: calc(138px + env(safe-area-inset-top)); z-index: 3; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255, 216, 74, 0.5); color: #ffe9a0; font-size: 0.72rem; font-weight: 800; pointer-events: none; }
.buffs[hidden] { display: none; }
.notice-bar { position: absolute; left: 50%; top: calc(6px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 6; max-width: min(560px, calc(100vw - 260px)); padding: 7px 14px; border-radius: 12px; background: linear-gradient(180deg, rgba(120, 70, 10, 0.95), rgba(60, 30, 4, 0.95)); border: 1px solid #ffd84a; color: #fff6d0; font-size: 0.85rem; font-weight: 800; text-align: center; box-shadow: 0 4px 18px rgba(0,0,0,0.6), 0 0 14px rgba(255, 216, 74, 0.35); cursor: pointer; animation: noticeIn 0.4s ease-out; }
.notice-bar[hidden] { display: none; }
@keyframes noticeIn { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .notice-bar { animation: none; } }
@media (max-width: 600px) { .notice-bar { max-width: calc(100vw - 24px); top: calc(150px + env(safe-area-inset-top)); } }
.notice-box { border-color: #ffd84a; }
.notice-text { margin: 0; font-size: 1rem; line-height: 1.6; white-space: pre-wrap; }
.shop-row .btn { flex: 1; padding: 8px; }

/* ---------- 패널(도감·설정) ---------- */
.panel-screen { background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 12px; backdrop-filter: blur(3px); }
.panel {
  width: min(720px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; touch-action: pan-y;
  background: linear-gradient(180deg, rgba(34, 28, 22, 0.97), rgba(18, 15, 12, 0.97)); border: 1px solid var(--gold); border-radius: 18px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -16px; background: rgba(28, 23, 18, 0.98); margin: -16px -16px 0; padding: 12px 16px; border-bottom: 1px solid var(--line); z-index: 2; }
.panel-head h2 { margin: 0; font-family: "Batang", serif; color: var(--gold); }
.panel p { margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); }
.row select { min-height: 44px; border-radius: 10px; background: #1d1813; color: var(--text); border: 1px solid var(--line); padding: 0 10px; font: inherit; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.stat { background: var(--surface2); border-radius: 10px; padding: 6px; text-align: center; }
.stat small { display: block; color: var(--muted); font-size: 0.7rem; }
.stat b { font-size: 1rem; }
.slots-row { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.book-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); color: var(--text); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px; }
.slot kbd { font: 700 0.6rem system-ui; opacity: 0.6; }
.book-slots.pas { grid-template-columns: repeat(3, 1fr); }
.slot.pslot { border-style: dashed; border-color: rgba(126, 249, 255, 0.45); }
.slot.empty { opacity: 0.75; }
.slot .slot-x { font-size: 0.62rem; font-weight: 600; opacity: 0.6; }
.slot.pick { border-color: #ffd84a; box-shadow: 0 0 0 2px rgba(255, 216, 74, 0.35); animation: slotPick 1s ease-in-out infinite alternate; }
@keyframes slotPick { from { background: rgba(0, 0, 0, 0.35); } to { background: rgba(255, 216, 74, 0.16); } }
@media (prefers-reduced-motion: reduce) { .slot.pick { animation: none; } }
.pick-msg { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 216, 74, 0.12); border: 1px solid rgba(255, 216, 74, 0.4); font-size: 0.85rem; }
.pick-msg[hidden] { display: none; }
.skill-card.passive { border-style: dashed; }
.sc-up { font-size: 0.72rem; font-weight: 800; margin-left: 4px; }
.sc-star { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; margin: 2px 0 4px; }
.sc-star i { display: block; height: 100%; }
.btn.promote { background: linear-gradient(90deg, #b8860b, #ffd84a, #b8860b); color: #2a1a00; font-weight: 800; }
.rates summary { cursor: pointer; min-height: 40px; line-height: 40px; color: var(--gold); font-weight: 700; }
.rate-table { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.rate { display: grid; grid-template-columns: 64px 1fr 56px 64px; gap: 8px; align-items: center; font-size: 0.82rem; }
.rhead { color: var(--muted); font-size: 0.72rem; }
.rname { font-weight: 800; }
.rbar { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.rbar i { display: block; height: 100%; border-radius: 4px; }
.rval, .rmob { text-align: right; font-variant-numeric: tabular-nums; }
.grade-sec { display: flex; flex-direction: column; gap: 6px; }
.book-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 0; }
.btab { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 5px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); color: var(--muted); font: inherit; font-size: 0.85rem; font-weight: 800; cursor: pointer; padding: 4px 6px; }
.btab .bt-ic { font-size: 1.15rem; }
.btab b { font-size: 0.72rem; min-width: 22px; padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.btab.on { color: #fff; border-color: var(--gold); background: linear-gradient(180deg, rgba(232, 196, 103, 0.25), rgba(232, 196, 103, 0.08)); box-shadow: 0 0 10px rgba(232, 196, 103, 0.25); }
.btab.on b { background: var(--gold); color: #2a1a08; }
.book-empty { text-align: center; padding: 18px 8px; }
.grade-h { margin: 6px 0 0; display: flex; align-items: baseline; gap: 8px; font-family: "Batang", serif; font-size: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.grade-h small { font-family: system-ui, sans-serif; font-size: 0.75rem; }
.skill-card { --gc: #888; border: 1px solid color-mix(in srgb, var(--gc) 55%, transparent); border-left: 4px solid var(--gc); border-radius: 12px; padding: 10px 12px; background: linear-gradient(90deg, color-mix(in srgb, var(--gc) 12%, transparent), transparent 70%); display: flex; flex-direction: column; gap: 4px; }
.skill-card.unknown { opacity: 0.55; filter: grayscale(0.6); }
.sc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sc-name { font-size: 1.05rem; }
.sc-nmw { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; }
.sc-plus { font-size: 0.95rem; font-weight: 900; color: #ffe27a; text-shadow: 0 0 6px rgba(255, 210, 80, 0.55), 0 1px 2px #000; }
.sc-lv { font-size: 0.8rem; color: var(--gold); font-weight: 700; }
.sc-desc { font-size: 0.86rem; color: #e6dcc6; }
.sc-meta { font-size: 0.76rem; color: var(--muted); }
.sc-acts { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; background: rgba(232, 196, 103, 0.15); color: var(--gold); font-weight: 700; }

/* 가방 */
.bag-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bag-gold { color: var(--gold); font-weight: 700; }
.bag-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.bag-cell { --gc: #e86b8a; position: relative; aspect-ratio: 1; min-height: var(--tap); border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(0, 0, 0, 0.4); box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6); padding: 2px; }
.bag-cell.empty { opacity: 0.55; }
button.bag-cell { color: var(--text); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid color-mix(in srgb, var(--gc) 70%, transparent); background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--gc) 28%, transparent), rgba(0, 0, 0, 0.5) 75%); }
button.bag-cell.sel { outline: 2px solid var(--gold); outline-offset: 1px; box-shadow: 0 0 12px color-mix(in srgb, var(--gc) 70%, transparent); }
button.bag-cell.divine { animation: divineGlow 2s linear infinite; }
@keyframes divineGlow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
.bag-cell .bi { font-size: 1.5rem; line-height: 1.1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); }
.bag-cell .bg-g { font-size: 0.56rem; font-weight: 800; line-height: 1; text-shadow: 0 1px 2px #000; }
.bag-cell .bn { font-size: 0.62rem; font-weight: 700; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: color-mix(in srgb, var(--gc) 55%, #fff); }
.bag-cell .bc { position: absolute; right: 4px; top: 2px; font-size: 0.7rem; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.bag-act { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 8px 16px; display: flex; align-items: center; gap: 10px; background: rgba(20, 15, 10, 0.97); border-top: 1px solid var(--gold); box-shadow: 0 -6px 16px rgba(0,0,0,0.5); z-index: 3; }
.bag-act[hidden] { display: none; }
.bag-act .ba-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; font-size: 0.88rem; }
.bag-act .ba-name small { display: block; font-weight: 600; font-size: 0.7rem; color: var(--muted); }
.bag-act .btn { min-height: 46px; padding: 0 18px; white-space: nowrap; }
.bag-detail { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 120px; }
.bd-name { margin: 0; font-size: 1.05rem; }

.bag-cell .bup, .eq-slot .bup { position: absolute; right: 4px; top: 2px; font-size: 0.7rem; color: #6dff8a; text-shadow: 0 1px 2px #000; }
.eq-stats { margin: 0; font-size: 0.86rem; color: #9dffb0; font-weight: 700; }
.opt-h { margin: 4px 0 0 !important; font-size: 0.78rem; color: var(--muted); }
.opt-list { --gc: #888; margin: 0; padding: 6px 10px; list-style: none; border-left: 3px solid var(--gc); border-radius: 6px; background: color-mix(in srgb, var(--gc) 10%, transparent); display: flex; flex-direction: column; gap: 2px; }
.opt-list li { font-size: 0.86rem; font-weight: 700; color: #ffe9a8; }
.opt-list li::before { content: "◇ "; color: var(--gc); }
.opt-inline { font-size: 0.72rem; color: #ffe9a8; }
.bag-cell .enh, .eq-slot .enh, .forge-icon .enh { position: absolute; left: 4px; top: 2px; font-size: 0.72rem; font-weight: 900; color: #ffe066; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.forge-btn { border-color: #e8c467; }
.forge-panel { width: min(520px, 100%); }
.forge-body { display: flex; flex-direction: column; gap: 8px; }
.forge-stage { --gc: #888; position: relative; height: 150px; border-radius: 14px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--gc) 35%, transparent), rgba(0, 0, 0, 0.6) 70%), #120e0a; border: 1px solid color-mix(in srgb, var(--gc) 60%, transparent); }
.forge-icon { position: relative; width: 92px; height: 92px; border-radius: 18px; display: grid; place-items: center; border: 2px solid var(--gc); background: rgba(0, 0, 0, 0.45); box-shadow: 0 0 24px color-mix(in srgb, var(--gc) 60%, transparent); }
.forge-icon .bi { font-size: 3rem; }
.forge-icon .enh { font-size: 1rem; }
.forge-result { position: absolute; bottom: 8px; left: 0; right: 0; margin: 0 !important; text-align: center; font-family: "Batang", serif; font-weight: 900; font-size: 1.25rem; text-shadow: 0 2px 0 #000, 0 0 12px currentColor; }
.forge-stage.r-ok .forge-result { color: #8dffb8; }
.forge-stage.r-fail .forge-result { color: #d6d6d6; }
.forge-stage.r-down .forge-result { color: #ff7a6a; }
.forge-stage.r-ok .forge-icon { animation: forgeOk 0.9s ease-out; }
.forge-stage.r-down .forge-icon, .forge-stage.r-fail .forge-icon { animation: forgeFail 0.5s ease-out; }
.forge-stage.hammer .forge-icon { animation: forgeHit 0.2s ease-in-out 3; }
@keyframes forgeHit { 50% { transform: scale(0.9) rotate(-6deg); filter: brightness(1.8); } }
@keyframes forgeOk { 0% { transform: scale(1.4); filter: brightness(2.5); box-shadow: 0 0 80px #fff; } 100% { transform: scale(1); } }
@keyframes forgeFail { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.forge-cmp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: var(--surface2); }
.forge-cmp .arrow { color: var(--gold); }
.forge-cmp .up { color: #6dff8a; font-weight: 700; }
.forge-rate i { background: linear-gradient(90deg, #b8860b, #ffe066); }
.forge-cost { display: flex; gap: 16px; font-weight: 800; font-size: 0.95rem; }
.forge-cost .lack { color: #ff7a6a; }
.forge-max { margin: 0; color: var(--gold); font-weight: 800; }
.forge-go:disabled { opacity: 0.5; cursor: not-allowed; }
/* 캐릭터 창: 실루엣 인형 + 부위별 장비 칸 */
.doll { flex: none; position: relative; width: 300px; height: 340px; margin: 0 auto; border-radius: 16px; background: radial-gradient(ellipse at 50% 55%, #3a2c1c 0%, #16110c 62%, transparent 75%); }
.doll-lines { position: absolute; inset: 0; width: 300px; height: 340px; pointer-events: none; }
.doll-cv { position: absolute; left: 60px; top: 0; width: 180px; height: 340px; pointer-events: none; }
.doll .eq-slot.doll-slot { position: absolute; width: 60px; min-height: 0; height: 72px; padding: 3px 2px; }
.doll .doll-slot .bi { font-size: 1.35rem; }
.doll .doll-slot .es-slot { font-size: 0.6rem; font-weight: 800; color: var(--gold); }
.doll .doll-slot .es-name { font-size: 0.58rem; white-space: normal; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-align: center; }
.es-name .es-g { font-weight: 900; text-shadow: 0 1px 2px #000; }
.doll .doll-slot.empty .bi { opacity: 0.45; filter: grayscale(1); }
.hico { width: 24px; height: 24px; fill: #f0d48a; color: #f0d48a; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); }
#btn-char .hico { fill: #ffe2a0; color: #ffe2a0; }
/* 캐릭터 창 가방(끌어서 장착) */
.doll-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
.doll-bag-btn { min-height: 40px; }
.char-sheet { display: flex; flex-direction: column; gap: 6px; background: linear-gradient(180deg, rgba(34, 28, 22, 0.98), rgba(18, 15, 12, 0.98)); border: 1px solid var(--gold); border-radius: 16px; padding: 10px 12px; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7); overflow-y: auto; touch-action: pan-y; }
.char-sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head b { color: var(--gold); }
.chips { display: flex; gap: 4px; flex: 1; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.chip.on { background: rgba(232, 196, 103, 0.2); color: var(--gold); border-color: var(--gold); }
.sheet-hint { margin: 0 !important; }
.char-bag { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.char-bag .bag-cell { touch-action: none; }
.cbag-empty { grid-column: 1 / -1; }
.doll .doll-slot { touch-action: none; }
.set-tag { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); padding: 0 5px; border-radius: 6px; font-style: normal; font-size: 0.5rem; font-weight: 900; color: #1a1208; line-height: 1.4; box-shadow: 0 1px 3px rgba(0,0,0,0.6); white-space: nowrap; z-index: 2; pointer-events: none; }
.set-bar { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 2px; box-shadow: 0 0 6px currentColor; }
.drag-ghost { --gc: #888; position: fixed; z-index: 50; width: 58px; height: 58px; margin: -29px 0 0 -29px; display: grid; place-items: center; font-size: 1.8rem; border-radius: 14px; border: 2px solid var(--gc); background: rgba(0, 0, 0, 0.75); box-shadow: 0 0 22px var(--gc); pointer-events: none; transform: scale(1.08); }
.drop-ok { outline: 2px dashed #8dffb8 !important; outline-offset: 2px; }
.drop-hover { outline: 3px solid #8dffb8 !important; box-shadow: 0 0 22px rgba(141, 255, 184, 0.7) !important; }
.char-sets { display: flex; flex-direction: column; gap: 6px; }
.set-box { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: rgba(0, 0, 0, 0.25); }
.set-h { margin: 0 0 2px !important; font-weight: 800; font-size: 0.9rem; }
.set-list { --sc: #888; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 1px; }
.set-list li { font-size: 0.78rem; color: var(--muted); opacity: 0.6; }
.set-list li::before { content: "○ "; }
.set-list li.on { color: #fff3d0; opacity: 1; font-weight: 700; }
.set-list li.on::before { content: "● "; color: var(--sc); }
/* 넓은 화면: 캐릭터 창 옆에 가방 */
@media (min-width: 1000px) {
  [data-screen="char"].bag-open { display: flex; justify-content: center; align-items: center; gap: 12px; }
  [data-screen="char"].bag-open .panel { width: min(640px, 56vw); }
  .char-sheet { width: 360px; max-height: calc(100vh - 24px); }
}
/* 좁은 화면: 가방은 아래에서 올라오는 판 */
@media (max-width: 999px) {
  .char-sheet { position: fixed; left: 8px; right: 8px; bottom: 8px; max-height: 44vh; z-index: 6; }
  [data-screen="char"].bag-open { place-items: start center; }
  [data-screen="char"].bag-open .panel { max-height: calc(56vh - 20px); }
}
.stat-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: 0.82rem; }
.ss-row { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; border-bottom: 1px dashed rgba(232, 196, 103, 0.12); }
.ss-row span { flex: 1; }
.ss-row.main b { font-size: 1rem; color: #fff6dc; }
.cs-extra { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.8rem; }

/* 퀘스트 알림판(게임 화면 왼쪽 위) */
.quest-track { position: absolute; top: calc(76px + env(safe-area-inset-top)); left: 8px; width: min(310px, 46vw); display: flex; flex-direction: column; gap: 4px; }
.qrow { display: flex; align-items: center; gap: 6px; min-height: 44px; width: 100%; padding: 4px 8px; border-radius: 10px; border: 1px solid var(--line); background: linear-gradient(90deg, rgba(10, 8, 6, 0.82), rgba(10, 8, 6, 0.45)); color: var(--text); font: inherit; font-size: 0.78rem; text-align: left; cursor: pointer; }
.qtag { flex: none; font-size: 0.66rem; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: #8b1e1e; color: #ffe6b0; }
.qrow.bounty .qtag { background: #2a4f7a; color: #d6ecff; }
.qtext { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; text-shadow: 0 1px 2px #000; }
.qrow.locked .qtext { color: var(--muted); }
.qclaim { flex: none; font-size: 0.7rem; font-weight: 800; color: #10220f; background: #8dffb8; padding: 3px 7px; border-radius: 999px; }
.qrow.done { border-color: #8dffb8; box-shadow: 0 0 12px rgba(141, 255, 184, 0.45); animation: autoPulse 1.6s infinite; }

/* 캐릭터 창 */
.char-top { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; }
.char-cv { width: 160px; height: 200px; border-radius: 14px; border: 1px solid var(--line); background: radial-gradient(ellipse at 50% 70%, #3a2c1c, #120e0a 75%); }
.char-stats { display: flex; flex-direction: column; gap: 4px; }
.char-name { margin: 0; font-family: "Batang", serif; color: var(--gold); font-size: 1.3rem; }
.cs-row { display: flex; align-items: baseline; gap: 8px; font-size: 0.9rem; }
.cs-row span { min-width: 64px; }
.cs-bonus { color: #6dff8a; font-weight: 800; }
.char-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.eq-slot { --gc: #555; position: relative; min-height: 84px; border-radius: 12px; border: 1.5px solid var(--gc); background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--gc) 26%, transparent), rgba(0, 0, 0, 0.5) 75%); color: var(--text); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; }
.eq-slot.empty { border-style: dashed; opacity: 0.75; }
.eq-slot.sel { outline: 2px solid var(--gold); outline-offset: 1px; }
.eq-slot .bi { font-size: 1.5rem; line-height: 1.1; }
.es-slot { font-size: 0.62rem; color: var(--muted); }
.es-name { font-size: 0.68rem; font-weight: 700; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: color-mix(in srgb, var(--gc) 50%, #fff); }
.q-sub { margin: 8px 0 2px !important; font-weight: 700; color: var(--gold); font-size: 0.85rem; }
.cand { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; background: var(--surface2); }
.cand-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cand-info .bd-name { font-size: 0.92rem; }
.cand .up { color: #6dff8a; font-weight: 700; font-size: 0.75rem; }
.cand .down { color: #ff8a7a; font-size: 0.75rem; }

/* 퀘스트 창 */
.q-h { margin: 4px 0 0; font-family: "Batang", serif; color: var(--gold); font-size: 1.05rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.quest-list { display: flex; flex-direction: column; gap: 6px; }
.qcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: rgba(0, 0, 0, 0.25); }
.qcard.cur { border-color: var(--gold); background: linear-gradient(90deg, rgba(232, 196, 103, 0.12), transparent 70%); }
.qcard.done { opacity: 0.55; padding: 6px 12px; }
.qcard.later { opacity: 0.7; }
.qcard.locked { border-color: #7a6a4a; }
.qc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.warn { margin: 0; color: #ffb36b; }
.qbar { position: relative; height: 18px; border-radius: 9px; background: rgba(0, 0, 0, 0.6); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.12); }
.qbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2f8a5a, #8dffb8); }
.qbar span { position: relative; display: block; text-align: center; font-size: 0.72rem; font-weight: 800; line-height: 17px; text-shadow: 0 1px 2px #000; }

.toast {
  position: fixed; left: 50%; bottom: calc(180px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(10, 8, 6, 0.9); color: #fff3d6; border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; max-width: calc(100vw - 32px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); z-index: 10; font-weight: 600; font-size: 0.9rem; text-align: center; pointer-events: none;
}

/* 폰 세로 */
@media (max-width: 560px) {
  .hero-bars { width: 150px; }
  .lv-badge { width: 40px; height: 40px; }
  #mm { width: 92px; height: 92px; }
  .top-btns { top: calc(126px + env(safe-area-inset-top)); }
  .controls { transform: scale(0.86); transform-origin: right bottom; }
  .chat { top: calc(200px + env(safe-area-inset-top)); bottom: auto; width: 62vw; }
  .chat:not(.open) p:nth-last-child(n+5) { display: none; }
  .chat p { font-size: 0.68rem; padding: 1px 6px; background: rgba(0,0,0,0.32); }
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .boss-bar { top: calc(64px + env(safe-area-inset-top)); width: 50vw; left: 8px; transform: none; text-align: left; display: none; }
  body[data-view="game"] .boss-bar:not([hidden]) { display: block; top: calc(160px + env(safe-area-inset-top)); width: 58vw; }
  .rate { grid-template-columns: 52px 1fr 48px 56px; }
  .bag-grid { grid-template-columns: repeat(5, 1fr); }
  .quest-track { top: calc(70px + env(safe-area-inset-top)); width: 60vw; }
  .qrow { min-height: 40px; font-size: 0.72rem; }
  .char-top { grid-template-columns: 1fr; justify-items: center; }
  .doll { transform-origin: top center; }
  .char-stats { width: 100%; }
  .hbtn { width: 52px; height: 52px; }
  .char-cv { width: 120px; height: 150px; }
  .eq-slot { min-height: 76px; }
}
@media (max-height: 520px) {
  .controls { transform: scale(0.78); transform-origin: right bottom; }
  .chat { bottom: 60px; }
  .top-btns { flex-direction: row; top: 8px; right: 140px; }
}
/* ---------- 폰 가로 화면 (높이가 낮은 가로) ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .chat-open { bottom: calc(96px + env(safe-area-inset-bottom)); height: 32px; }
  .title-screen { overflow-y: auto; padding: 8px; }
  .title-box { gap: 6px; }
  .title-logo { font-size: clamp(2.2rem, 13vh, 3.6rem); }
  .title-desc { margin: 0; font-size: 0.85rem; }
  .title-hint { display: none; }
  .name-row { flex-direction: row; align-items: center; max-width: 360px; }
  .name-row input { min-height: 44px; flex: 1; }
  .btn.big { min-height: 48px; padding: 8px 28px; }

  .hud-top { top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); right: calc(6px + env(safe-area-inset-right)); }
  .hero-card { padding: 4px 10px 4px 4px; }
  .lv-badge { width: 38px; height: 38px; }
  .lv-badge b { font-size: 1rem; }
  .hero-bars { width: 170px; min-width: 0; }
  .hero-line { font-size: 0.78rem; margin-bottom: 2px; }
  .hpbar { height: 14px; }
  .hpbar span { line-height: 13px; font-size: 0.64rem; }
  .xpbar { height: 10px; margin-top: 2px; }
  .xpbar span { line-height: 9px; font-size: 0.54rem; }
  #mm { width: 84px; height: 84px; }
  .zone-name { font-size: 0.66rem; margin-top: 2px; }
  .top-btns { flex-direction: row; top: calc(6px + env(safe-area-inset-top)); right: calc(100px + env(safe-area-inset-right)); gap: 6px; }
  .hbtn { width: 46px; height: 46px; gap: 1px; }
  .hbtn .hico { width: 20px; height: 20px; }
  .hbtn small { font-size: 0.55rem; }
  .badge { top: -5px; right: -5px; min-width: 17px; height: 17px; line-height: 17px; font-size: 0.6rem; }
  .quest-track { top: calc(60px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); width: min(250px, 32vw); gap: 3px; }
  .qrow { min-height: 34px; font-size: 0.68rem; padding: 2px 6px; }
  .qtag { font-size: 0.58rem; padding: 1px 4px; }
  .qclaim { font-size: 0.6rem; padding: 2px 5px; }
  .boss-bar, body[data-view="game"] .boss-bar:not([hidden]) { display: block; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 30vw; text-align: center; }
  .boss-bar p { font-size: 0.72rem; }
  .bbar { height: 9px; }
  .chat { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: calc(6px + env(safe-area-inset-left)); width: min(330px, 36vw); }
  .chat p { font-size: 0.64rem; padding: 1px 6px; background: rgba(0, 0, 0, 0.32); }
  .chat:not(.open) p:nth-last-child(n+4) { display: none; }
  .banner { top: 22%; font-size: clamp(1.1rem, 6vh, 1.8rem); }
  .controls { transform: scale(0.7); transform-origin: right bottom; right: calc(10px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
  .apot-pop { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(230px + env(safe-area-inset-right)); max-height: calc(100vh - 80px); overflow-y: auto; padding: 10px; gap: 6px; }
  .toast { bottom: calc(12px + env(safe-area-inset-bottom)); font-size: 0.8rem; padding: 6px 14px; }
  .shop { max-height: calc(100vh - 16px); overflow-y: auto; }
  .dead h2 { font-size: 1.8rem; }

  /* 패널: 화면 높이에 맞추고 넓게 */
  .panel-screen { padding: 8px calc(8px + env(safe-area-inset-right)) 8px calc(8px + env(safe-area-inset-left)); }
  .panel { max-height: calc(100vh - 16px); padding: 12px; gap: 8px; }
  .panel-head { top: -12px; margin: -12px -12px 0; padding: 8px 12px; }
  .panel-head h2 { font-size: 1.15rem; }
  .bag-grid { grid-template-columns: repeat(8, 1fr); }
  .bag-cell { min-height: 0; }
  .stat-row { grid-template-columns: repeat(5, 1fr); }
  /* 캐릭터 창: 왼쪽 인형, 오른쪽 능력치·세트·장비 자세히 */
  .char-panel { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-content: start; width: min(860px, 100%); }
  .char-panel > .panel-head { grid-column: 1 / -1; }
  .char-panel > .doll-wrap { grid-column: 1; grid-row: 2 / span 4; position: sticky; top: 46px; align-self: start; }
  .char-panel > #char-sets, .char-panel > #char-stats, .char-panel > #char-detail { grid-column: 2; }
  .doll { zoom: 0.8; }
  .doll-bag-btn { min-height: 36px; }
  .char-sheet { position: static; width: min(330px, 40vw); max-height: calc(100vh - 16px); box-shadow: none; }
  [data-screen="char"].bag-open { display: flex; justify-content: center; align-items: stretch; gap: 8px; place-items: unset; }
  [data-screen="char"].bag-open .panel { width: auto; flex: 1; max-width: 560px; max-height: calc(100vh - 16px); }
  [data-screen="char"].bag-open .char-panel { grid-template-columns: auto minmax(0, 1fr); }
  .char-bag { grid-template-columns: repeat(4, 1fr); }
  [data-screen="char"].bag-open .stat-sheet { grid-template-columns: 1fr; }
  .ss-row span { white-space: nowrap; }
  .forge-stage { height: 110px; }
}
/* 가로로 돌려 달라는 안내 */
.rotate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(8, 6, 4, 0.94); text-align: center; }
.rotate[hidden] { display: none; }
.rotate-box { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 320px; }
.rotate-box h2 { margin: 0; font-family: "Batang", serif; color: var(--gold); }
.rotate-box p { margin: 0; color: var(--muted); }
.rotate-ic { font-size: 3.4rem; animation: rotPhone 2s ease-in-out infinite; }
@keyframes rotPhone { 0%, 25% { transform: rotate(0deg); } 50%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) {
  .rotate-ic { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .title-logo, .banner.show, .chat p, .mbtn.auto.on, button.bag-cell.divine, .qrow.done, .forge-icon { animation: none !important; }
}
/* 가로 화면(큰 폰·태블릿 포함): 캐릭터·가방·비급·설정 단추를 위쪽 한 줄(미니맵 왼쪽)에 */
@media (orientation: landscape) and (min-height: 521px) {
  .top-btns { flex-direction: row; top: calc(8px + env(safe-area-inset-top)); right: calc(136px + env(safe-area-inset-right)); gap: 8px; }
}
