:root {
  color-scheme: dark;
  --gold: #e8c872;
  --gold2: #b8913a;
  --panel: rgba(10, 12, 20, 0.86);
  --panel2: rgba(22, 24, 36, 0.92);
  --line: rgba(232, 200, 114, 0.28);
  --text: #eee6d6;
  --dim: #9b93a6;
  --hp: #e0364a;
  --mp: #3f7cff;
  --xp: #b98cff;
  --good: #7fe07a;
  --bad: #ff5a5a;
  --font: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --title: 'Cinzel', 'Noto Serif KR', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05070c; color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#ui .click, #ui button, #ui input, #ui .panel, #ui .slot, #ui .hud-chat, #ui .mm-btn { pointer-events: auto; }
button { font-family: var(--font); cursor: pointer; }
.hidden { display: none !important; }

/* ─── 로딩 ─────────────────────────────── */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, #1c1830 0%, #06060c 70%); transition: opacity 1s; }
#loading.fade { opacity: 0; pointer-events: none; }
.logo { font-family: var(--title); font-weight: 900; letter-spacing: 0.18em; font-size: clamp(38px, 7vw, 92px); background: linear-gradient(180deg, #fff6d8 0%, #e8c872 45%, #8a5a1a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(232, 180, 80, 0.45)) drop-shadow(0 4px 2px rgba(0,0,0,0.8)); text-align: center; line-height: 1; }
.logo-sub { font-family: var(--title); letter-spacing: 0.6em; color: #cdb88a; font-size: clamp(11px, 1.4vw, 16px); margin-top: 10px; text-align: center; text-shadow: 0 0 10px rgba(0,0,0,0.9); padding-left: 0.6em; }
.load-bar { width: min(460px, 80vw); height: 6px; margin-top: 46px; background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a5a1a, #ffe39a); box-shadow: 0 0 12px #ffcf6a; transition: width 0.3s; }
.load-text { margin-top: 14px; color: var(--dim); font-size: 13px; letter-spacing: 0.05em; }
.load-tip { position: absolute; bottom: 8vh; color: #8a8298; font-size: 13px; max-width: 80vw; text-align: center; }

/* ─── 타이틀 ────────────────────────────── */
#title { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: flex; flex-direction: column; background: linear-gradient(90deg, rgba(4,5,10,0.78) 0%, rgba(4,5,10,0.35) 42%, rgba(4,5,10,0) 60%), linear-gradient(0deg, rgba(4,5,10,0.7) 0%, rgba(4,5,10,0) 30%); animation: fadein 1.2s; }
#title > * { pointer-events: auto; }
#title .t-head { padding: 4vh 0 0 5vw; }
#title .logo { text-align: left; font-size: clamp(34px, 5.2vw, 78px); }
#title .logo-sub { text-align: left; padding-left: 0.2em; }
.t-panel { margin: 2.2vh 0 0 5vw; width: min(480px, 90vw); max-height: calc(100vh - 260px); overflow-y: auto; scrollbar-width: none; }
.t-go { margin-left: 5vw; width: min(480px, 90vw); }
@media (max-height: 760px) { #title .t-stats, #title .logo-sub { display: none; } #title .t-desc { font-size: 12px; } }
.t-panel::-webkit-scrollbar { display: none; }
.t-label { font-size: 12px; letter-spacing: 0.2em; color: var(--gold); margin: 12px 0 6px; text-transform: uppercase; }
.t-name { width: 100%; padding: 11px 14px; font-size: 16px; background: rgba(0,0,0,0.5); border: 1px solid var(--line); color: #fff; border-radius: 6px; outline: none; font-family: var(--font); transition: border 0.2s, box-shadow 0.2s; }
.t-name:focus { border-color: var(--gold); box-shadow: 0 0 18px rgba(232,200,114,0.25); }
.t-classes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cls-card { position: relative; background: linear-gradient(180deg, rgba(30,30,46,0.9), rgba(12,12,20,0.95)); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 9px 6px 8px; text-align: center; cursor: pointer; transition: transform 0.2s, border 0.2s, box-shadow 0.2s; }
.cls-card:hover { transform: translateY(-3px); border-color: var(--line); }
.cls-card.sel { border-color: var(--gold); box-shadow: 0 0 22px rgba(232,200,114,0.35), inset 0 0 20px rgba(232,200,114,0.12); }
.cls-card img { width: 46px; height: 46px; }
.cls-card .n { font-weight: 700; margin-top: 6px; font-size: 15px; }
.cls-card .r { font-size: 11px; color: var(--dim); margin-top: 2px; }
.t-desc { margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: #cfc6b8; background: rgba(0,0,0,0.35); border-left: 2px solid var(--gold); padding: 10px 12px; border-radius: 0 6px 6px 0; }
.t-desc b { color: var(--gold); }
.t-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin-top: 10px; font-size: 12px; color: var(--dim); }
.t-stats span { display: flex; align-items: center; gap: 6px; }
.t-stats i { display: inline-block; height: 5px; background: linear-gradient(90deg, #8a5a1a, var(--gold)); border-radius: 3px; }
.t-mode { display: flex; gap: 8px; }
.t-mode button { flex: 1; padding: 10px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.12); color: var(--dim); border-radius: 6px; font-size: 13px; }
.t-mode button.sel { border-color: var(--gold); color: #fff; background: rgba(232,200,114,0.12); }
.t-mode button:disabled { opacity: 0.35; cursor: not-allowed; }
.t-server { font-size: 12px; color: var(--dim); margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #777; display: inline-block; }
.dot.on { background: #5f5; box-shadow: 0 0 8px #5f5; }
.btn-start { margin-top: 14px; width: 100%; padding: 16px; font-size: 19px; font-weight: 800; letter-spacing: 0.3em; color: #1a1208; border: none; border-radius: 8px; background: linear-gradient(180deg, #fff0c0, #e8c872 40%, #a8742a); box-shadow: 0 0 30px rgba(232,180,80,0.45), inset 0 1px 0 #fff; transition: transform 0.15s, box-shadow 0.2s; padding-left: 0.3em; }
.btn-start:hover { transform: scale(1.02); box-shadow: 0 0 44px rgba(255,200,90,0.7), inset 0 1px 0 #fff; }
.btn-start:disabled { filter: grayscale(0.8); opacity: 0.6; }
.t-err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; text-shadow: 0 1px 3px #000; }
.t-foot { position: absolute; right: 3vw; bottom: 3vh; text-align: right; font-size: 12px; color: #8a8298; line-height: 1.7; text-shadow: 0 1px 3px #000; }
.t-foot kbd, .help kbd { display: inline-block; padding: 1px 6px; border: 1px solid rgba(255,255,255,0.25); border-bottom-width: 2px; border-radius: 4px; font-size: 11px; color: #ddd; font-family: var(--font); background: rgba(0,0,0,0.4); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ─── HUD 공통 ──────────────────────────── */
.frame { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05); }
.bar { position: relative; height: 16px; background: rgba(0,0,0,0.6); border-radius: 3px; overflow: hidden; border: 1px solid rgba(0,0,0,0.6); box-shadow: inset 0 1px 3px rgba(0,0,0,0.8); }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; transition: width 0.25s ease-out; }
.bar > i.lag { background: rgba(255,255,255,0.35); transition: width 0.8s ease-in 0.3s; }
.bar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 3px #000; letter-spacing: 0.02em; }
.bar.hp > i.v { background: linear-gradient(180deg, #ff6a7a, #c01830 60%, #800a1a); }
.bar.mp > i.v { background: linear-gradient(180deg, #7aa8ff, #2a5ae0 60%, #12308a); }
.bar.thp > i.v { background: linear-gradient(180deg, #ff8a5a, #c8301a 60%, #7a1208); }

.hud-player { position: absolute; left: 16px; top: 16px; width: 330px; padding: 10px 12px 10px 86px; }
.hud-player .portrait { position: absolute; left: 10px; top: 10px; width: 66px; height: 66px; border-radius: 50%; border: 2px solid var(--gold); box-shadow: 0 0 14px rgba(232,200,114,0.35); background-size: cover; }
.hud-player .lv { position: absolute; left: 50px; top: 56px; background: linear-gradient(180deg, #3a2a10, #1a1206); border: 1px solid var(--gold); color: var(--gold); font-weight: 800; font-size: 12px; border-radius: 10px; padding: 1px 7px; }
.hud-player .nm { font-weight: 700; font-size: 15px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.hud-player .nm small { color: var(--dim); font-weight: 400; font-size: 11px; }
.hud-player .bar { margin-bottom: 5px; }
.hud-player .bar.mp { height: 12px; }
.buffs { position: absolute; left: 16px; top: 108px; display: flex; gap: 6px; }
.buff { position: relative; width: 34px; height: 34px; border-radius: 5px; border: 1px solid var(--gold); background-size: cover; box-shadow: 0 0 10px rgba(232,200,114,0.35); }
.buff span { position: absolute; bottom: -2px; right: 1px; font-size: 10px; font-weight: 800; text-shadow: 0 0 3px #000, 0 0 2px #000; }

.hud-target { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: 360px; padding: 8px 12px 10px; text-align: center; }
.hud-target .nm { font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.hud-target .nm small { font-weight: 400; color: var(--dim); }
.hud-target .cast { margin-top: 6px; font-size: 12px; color: #ffb080; min-height: 16px; font-weight: 700; letter-spacing: 0.05em; }
.hud-boss { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); width: min(620px, 80vw); text-align: center; padding: 8px 14px 10px; border-color: rgba(255,120,60,0.5); box-shadow: 0 0 30px rgba(255,80,30,0.25); }
.hud-boss .nm { font-family: var(--title); font-weight: 900; font-size: 16px; color: #ffcf9a; letter-spacing: 0.1em; margin-bottom: 6px; text-shadow: 0 0 10px #f60; }
.hud-boss .bar { height: 14px; }

.hud-mm { position: absolute; right: 16px; top: 16px; width: 200px; }
.mm-wrap { position: relative; width: 200px; height: 200px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); box-shadow: 0 0 20px rgba(0,0,0,0.7), 0 0 12px rgba(232,200,114,0.25); background: #111; }
.mm-wrap canvas { width: 100%; height: 100%; display: block; }
.mm-n { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 800; color: var(--gold); text-shadow: 0 0 3px #000; }
.mm-info { text-align: center; margin-top: 6px; font-size: 12px; }
.mm-info .zone { font-weight: 700; font-size: 14px; }
.mm-info .sub { color: var(--dim); font-size: 11px; }
.mm-btns { display: flex; justify-content: center; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.mm-btn { width: 30px; height: 30px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); color: var(--gold); font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 0; }
.mm-btn:hover { background: rgba(232,200,114,0.18); }

.hud-quest { position: absolute; right: 16px; top: 326px; width: 230px; padding: 10px 12px; font-size: 12px; }
.hud-quest .qh { color: var(--gold); font-weight: 800; letter-spacing: 0.1em; font-size: 11px; margin-bottom: 6px; }
.hud-quest .qn { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.hud-quest .qp { color: #cfc6b8; }
.hud-quest .qp.done { color: var(--good); }
.hud-quest .qhint { margin-top: 5px; color: var(--dim); font-size: 11px; }

.hud-chat { position: absolute; left: 16px; bottom: 34px; width: 380px; }
.chat-log { height: 170px; overflow-y: auto; padding: 8px 10px; font-size: 12.5px; line-height: 1.55; background: linear-gradient(0deg, rgba(0,0,0,0.55), rgba(0,0,0,0.15)); border-radius: 6px 6px 0 0; mask-image: linear-gradient(0deg, #000 80%, transparent); -webkit-mask-image: linear-gradient(0deg, #000 80%, transparent); scrollbar-width: none; }
.chat-log::-webkit-scrollbar { display: none; }
.chat-log div { text-shadow: 0 1px 2px #000; word-break: break-all; animation: fadein 0.3s; }
.chat-log .n { color: #9fd0ff; font-weight: 700; cursor: pointer; }
.chat-log .sys { color: #ffd87a; }
.chat-log .boss { color: #ff8a5a; font-weight: 700; }
.chat-log .legend { color: #ffa030; font-weight: 700; text-shadow: 0 0 6px #f80; }
.chat-log .epic { color: #d08aff; font-weight: 700; }
.chat-log .enh { color: #7ad8ff; font-weight: 700; }
.chat-log .fail { color: #aaa; }
.chat-log .join, .chat-log .lvl, .chat-log .elite { color: #b8e8a0; }
.chat-log .quest { color: #ffe39a; }
.chat-log .shop, .chat-log .info { color: #c8c0d8; }
.chat-log .me { color: #ffffff; }
.chat-in { width: 100%; padding: 8px 10px; background: rgba(0,0,0,0.65); border: 1px solid var(--line); border-top: none; color: #fff; outline: none; font-family: var(--font); font-size: 13px; border-radius: 0 0 6px 6px; }
.chat-in:focus { border-color: var(--gold); }

.hud-xp { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: rgba(0,0,0,0.75); border-top: 1px solid rgba(232,200,114,0.25); }
.hud-xp i { display: block; height: 100%; background: linear-gradient(90deg, #6a3ad8, #c89aff); box-shadow: 0 0 10px #a070ff; transition: width 0.5s; }
.hud-xp span { position: absolute; right: 12px; bottom: 10px; font-size: 11px; color: #cdbdf0; text-shadow: 0 1px 2px #000; }

.hud-bar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 10px; }
.skills { display: flex; gap: 6px; padding: 8px; }
.slot { position: relative; width: 58px; height: 58px; border-radius: 8px; border: 1px solid rgba(232,200,114,0.45); background: #111 center/cover no-repeat; box-shadow: inset 0 0 10px rgba(0,0,0,0.8); cursor: pointer; overflow: hidden; transition: transform 0.08s; }
.slot:active, .slot.flash { transform: scale(0.93); }
.slot.big { width: 68px; height: 68px; border-color: var(--gold); box-shadow: 0 0 16px rgba(232,200,114,0.35), inset 0 0 10px rgba(0,0,0,0.8); }
.slot .key { position: absolute; left: 3px; top: 1px; font-size: 11px; font-weight: 800; text-shadow: 0 0 3px #000, 0 0 2px #000; z-index: 3; }
.slot .cd { position: absolute; inset: 0; background: conic-gradient(rgba(0,0,0,0) var(--p, 0%), rgba(0,0,0,0.72) 0); z-index: 1; }
.slot .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; text-shadow: 0 0 4px #000; z-index: 2; }
.slot.nomp { filter: saturate(0.2) brightness(0.6); }
.slot.ready-glow::after { content: ''; position: absolute; inset: 0; border-radius: 8px; box-shadow: inset 0 0 18px rgba(255,230,160,0.9); animation: readyGlow 0.5s ease-out forwards; }
@keyframes readyGlow { from { opacity: 1; } to { opacity: 0; } }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 800; text-shadow: 0 0 3px #000, 0 0 2px #000; z-index: 3; }
.pots { display: flex; gap: 6px; padding: 8px; }
.pots .slot { width: 48px; height: 48px; }
.auto-btn { width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(232,200,114,0.5); background: radial-gradient(circle at 50% 35%, #3a3228, #0e0c0a); color: var(--gold); font-weight: 900; font-size: 14px; letter-spacing: 0.05em; box-shadow: 0 0 14px rgba(0,0,0,0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.auto-btn small { font-size: 10px; color: var(--dim); font-weight: 400; margin-top: 2px; }
.auto-btn.on { background: radial-gradient(circle at 50% 35%, #ffe7a0, #c8902a 60%, #6a4410); color: #1a1004; border-color: #fff4c8; box-shadow: 0 0 26px rgba(255,200,80,0.8); animation: autoPulse 1.6s infinite; }
.auto-btn.on small { color: #3a2808; }
@keyframes autoPulse { 50% { box-shadow: 0 0 40px rgba(255,210,100,1); } }
.menu-btns { display: flex; flex-direction: column; gap: 5px; padding: 6px; }
.menu-btns button { width: 44px; height: 30px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--text); font-size: 11px; padding: 0; }
.menu-btns button:hover { background: rgba(232,200,114,0.15); }

/* ─── 알림 ─────────────────────────────── */
#toasts { position: absolute; left: 50%; top: 150px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toast { padding: 6px 16px; background: rgba(0,0,0,0.6); border-radius: 16px; font-size: 13px; font-weight: 600; text-shadow: 0 1px 2px #000; animation: toast 3s forwards; white-space: nowrap; }
.toast.err { color: #ff8a8a; }
.toast.loot { border: 1px solid; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#announce { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); text-align: center; pointer-events: none; }
.ann { font-size: 18px; font-weight: 800; padding: 8px 30px; background: linear-gradient(90deg, transparent, rgba(0,0,0,0.75) 20%, rgba(0,0,0,0.75) 80%, transparent); animation: toast 5s forwards; white-space: nowrap; letter-spacing: 0.03em; }
.ann.legend { color: #ffb040; text-shadow: 0 0 14px #f80; }
.ann.boss { color: #ff7a4a; text-shadow: 0 0 14px #f40; font-size: 20px; }
.ann.enh { color: #8ae0ff; text-shadow: 0 0 12px #0af; }
.ann.epic { color: #d89aff; text-shadow: 0 0 12px #a0f; }
#zone-title { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; }
#zone-title.show { animation: zoneIn 4.5s forwards; }
#zone-title .z1 { font-family: var(--title); font-size: clamp(30px, 4.5vw, 54px); font-weight: 900; letter-spacing: 0.15em; text-shadow: 0 0 20px rgba(0,0,0,0.9), 0 2px 2px #000; }
#zone-title .z2 { font-size: 15px; color: #d8cfc0; letter-spacing: 0.3em; margin-top: 6px; text-shadow: 0 1px 3px #000; }
#zone-title .zline { height: 2px; width: 60%; margin: 10px auto 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
@keyframes zoneIn { 0% { opacity: 0; letter-spacing: 0.5em; } 15% { opacity: 1; letter-spacing: 0.15em; } 75% { opacity: 1; } 100% { opacity: 0; } }
#bigtext { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); pointer-events: none; text-align: center; opacity: 0; }
#bigtext.show { animation: big 2.6s forwards; }
#bigtext .b1 { font-family: var(--title); font-size: clamp(40px, 7vw, 86px); font-weight: 900; background: linear-gradient(180deg, #fff 0%, #ffe39a 40%, #d8902a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 20px rgba(255,200,80,0.8)); letter-spacing: 0.08em; }
#bigtext .b2 { font-size: 18px; color: #fff3d0; text-shadow: 0 0 8px #000; margin-top: 4px; }
#bigtext.red .b1 { background: linear-gradient(180deg, #fff 0%, #ff9a8a 40%, #c01818 100%); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 20px rgba(255,60,40,0.8)); }
#bigtext.blue .b1 { background: linear-gradient(180deg, #fff 0%, #a8e0ff 40%, #2a78d8 100%); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 20px rgba(80,180,255,0.9)); }
@keyframes big { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

/* ─── 이름표 & 데미지 ──────────────────── */
#np-layer, #dmg-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.np { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; will-change: transform; }
.np-name { font-size: 12px; font-weight: 700; text-shadow: 0 0 3px #000, 0 1px 2px #000, 0 0 1px #000; }
.np-title { font-size: 10px; color: #ffd87a; text-shadow: 0 0 3px #000; }
.np-title:empty { display: none; }
.np-hp { width: 64px; height: 5px; margin: 3px auto 0; background: rgba(0,0,0,0.7); border: 1px solid rgba(0,0,0,0.8); border-radius: 2px; overflow: hidden; }
.np-hp i { display: block; height: 100%; background: linear-gradient(180deg, #ff7a7a, #c01a1a); transition: width 0.2s; }
.np-p .np-name { color: #9fd0ff; }
.np-p .np-hp i { background: linear-gradient(180deg, #8aff8a, #2aa02a); }
.np-npc .np-name { color: #ffd87a; font-size: 13px; }
.np-elite .np-name { font-size: 13px; }
.np-elite .np-hp { width: 90px; height: 6px; }
.np-boss .np-name { font-size: 15px; color: #ff9a6a !important; text-shadow: 0 0 8px #f40, 0 0 3px #000; }
.np-boss .np-hp { width: 140px; height: 7px; }
.np.target .np-name::before { content: '▼ '; color: #ff5a5a; }
.np.dead { opacity: 0.4; }
.qmark { width: 22px; height: 30px; margin: 0 auto 2px; font-size: 26px; line-height: 30px; font-weight: 900; color: #ffd23a; text-shadow: 0 0 10px #fa0, 0 2px 2px #000; animation: bob 1.4s ease-in-out infinite; }
.qmark.q-avail::after { content: '!'; }
.qmark.q-ready::after { content: '?'; }
.qmark.q-wait::after { content: '?'; color: #999; text-shadow: none; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.dmg { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 0 4px #000, 0 2px 2px #000, 0 0 1px #000; pointer-events: none; will-change: transform, opacity; white-space: nowrap; font-family: var(--title), var(--font); }
.dmg.mine { color: #ffe9a8; }
.dmg.crit { color: #ffb020; font-size: 32px; text-shadow: 0 0 10px #f60, 0 2px 2px #000; }
.dmg.crit::after { content: '!'; }
.dmg.hurt { color: #ff4a4a; font-size: 20px; }
.dmg.heal { color: #7aff7a; }
.dmg.xp { color: #c8a0ff; font-size: 15px; }
.dmg.gold { color: #ffd84a; font-size: 15px; }
.dmg.other { color: #d0d0d0; font-size: 16px; opacity: 0.85; }

/* ─── 패널 ─────────────────────────────── */
.panel { position: absolute; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06); animation: panelIn 0.18s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; } }
.panel .ph { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(232,200,114,0.1), transparent); border-radius: 10px 10px 0 0; cursor: default; }
.panel .ph h3 { margin: 0; font-family: var(--title); font-size: 15px; letter-spacing: 0.12em; color: var(--gold); }
.panel .x { background: none; border: none; color: var(--dim); font-size: 20px; line-height: 1; padding: 0 4px; }
.panel .x:hover { color: #fff; }
.panel .pb { padding: 14px 16px 16px; }
#inv-panel { right: 250px; top: 50%; transform: translateY(-50%); width: 640px; max-width: 96vw; }
#inv-panel .pb { display: grid; grid-template-columns: 250px 1fr; gap: 16px; }
.equip { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; justify-content: center; }
.equip .eq { width: 64px; height: 64px; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.15); background: rgba(0,0,0,0.4) center/cover no-repeat; position: relative; cursor: pointer; }
.equip .eq .lbl { position: absolute; bottom: -1px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--dim); text-shadow: 0 0 3px #000; }
.equip .eq.has { border-style: solid; }
.equip .eq .enh, .inv-grid .enh { position: absolute; top: 1px; right: 3px; font-size: 11px; font-weight: 900; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.stats { margin-top: 12px; font-size: 12.5px; background: rgba(0,0,0,0.3); border-radius: 6px; padding: 10px 12px; line-height: 1.8; }
.stats div { display: flex; justify-content: space-between; }
.stats b { color: #fff; }
.stats .cp { font-size: 14px; color: var(--gold); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.inv-grid .it { position: relative; aspect-ratio: 1; border-radius: 6px; border: 1px solid rgba(255,255,255,0.08); background: rgba(0,0,0,0.35) center/cover no-repeat; cursor: pointer; transition: transform 0.08s; }
.inv-grid .it:hover { transform: scale(1.06); border-color: var(--gold); z-index: 2; }
.inv-grid .it .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 800; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.inv-grid .it.sel { outline: 2px solid var(--gold); }
.inv-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; }
.gold { color: #ffd84a; font-weight: 800; }
.gold::before { content: '● '; color: #ffcf2a; text-shadow: 0 0 6px #fa0; }
.btn { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(232,200,114,0.18), rgba(232,200,114,0.05)); color: var(--text); font-size: 13px; font-weight: 600; }
.btn:hover { background: linear-gradient(180deg, rgba(232,200,114,0.32), rgba(232,200,114,0.1)); }
.btn.primary { background: linear-gradient(180deg, #ffe7a0, #c8902a); color: #1a1004; border-color: #fff0c0; font-weight: 800; }
.btn.danger { background: linear-gradient(180deg, #c83a3a, #7a1414); color: #fff; border-color: #ff8a8a; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

#tooltip { position: fixed; z-index: 30; max-width: 280px; padding: 10px 12px; background: rgba(8,8,14,0.96); border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; line-height: 1.6; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.7); }
#tooltip .tn { font-weight: 800; font-size: 14px; }
#tooltip .tr { font-size: 11px; color: var(--dim); }
#tooltip .ts { color: #b8f0a8; }
#tooltip .tc { color: var(--dim); font-size: 11px; margin-top: 4px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 4px; }
#tooltip .up { color: var(--good); } #tooltip .down { color: var(--bad); }

.dialog { left: 50%; bottom: 150px; transform: translateX(-50%); width: min(560px, 94vw); }
.dialog .pb { font-size: 14px; line-height: 1.7; }
.dialog .npc-say { color: #efe6d4; background: rgba(0,0,0,0.3); padding: 12px 14px; border-radius: 6px; border-left: 3px solid var(--gold); }
.dialog .qbox { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(232,200,114,0.05); }
.dialog .qbox .qt { color: var(--gold); font-weight: 800; margin-bottom: 4px; }
.dialog .rw { font-size: 12px; color: var(--dim); margin-top: 6px; }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

#shop-panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, 94vw); }
.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 6px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.06); }
.shop-row .ic { width: 44px; height: 44px; border-radius: 6px; background: center/cover; flex: none; }
.shop-row .inf { flex: 1; font-size: 12px; color: var(--dim); }
.shop-row .inf b { display: block; color: var(--text); font-size: 13.5px; }
.shop-row .acts { display: flex; gap: 4px; }
.shop-hint { font-size: 12px; color: var(--dim); margin-top: 10px; }

#enh-panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, 94vw); }
.enh-main { display: flex; gap: 16px; align-items: center; }
.enh-slot { width: 96px; height: 96px; border-radius: 10px; border: 2px solid var(--gold); background: rgba(0,0,0,0.5) center/cover no-repeat; flex: none; position: relative; box-shadow: 0 0 20px rgba(232,200,114,0.3); }
.enh-slot.spin { animation: enhSpin 1.2s ease-in-out; }
@keyframes enhSpin { 0% { transform: scale(1); } 30% { transform: scale(0.9) rotate(-4deg); box-shadow: 0 0 40px #fff; } 60% { transform: scale(1.1) rotate(4deg); box-shadow: 0 0 60px #ffe39a; } 100% { transform: scale(1); } }
.enh-info { flex: 1; font-size: 13px; line-height: 1.8; }
.enh-info .big { font-size: 22px; font-weight: 900; color: var(--gold); }
.enh-warn { margin-top: 10px; padding: 8px 10px; background: rgba(200,40,40,0.18); border: 1px solid rgba(255,90,90,0.4); border-radius: 6px; color: #ffb0b0; font-size: 12px; }
.enh-pick { margin-top: 12px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; max-height: 160px; overflow-y: auto; }
.enh-pick .it { aspect-ratio: 1; border-radius: 5px; background: center/cover; border: 1px solid rgba(255,255,255,0.1); cursor: pointer; position: relative; }
.enh-pick .it.sel { outline: 2px solid var(--gold); }

#map-panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, 96vw); }
#map-panel canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 6px; max-height: 76vh; object-fit: contain; }
#ask { left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(400px, 92vw); z-index: 40; }
#ask .ask-t { font-size: 14px; line-height: 1.7; }
#ask .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
#settings-panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, 94vw); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px; }
.set-row .opts { display: flex; gap: 4px; }
.set-row .opts button { padding: 5px 10px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.12); background: rgba(0,0,0,0.3); color: var(--dim); font-size: 12px; }
.set-row .opts button.sel { border-color: var(--gold); color: #fff; background: rgba(232,200,114,0.15); }
.set-row input[type=range] { width: 150px; accent-color: var(--gold); }
#help-panel { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 13px; }
.help div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }

#death { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(60,0,0,0.35), rgba(0,0,0,0.75)); pointer-events: auto; animation: fadein 1.2s; }
#death h2 { font-family: var(--title); font-size: clamp(36px, 6vw, 70px); margin: 0; color: #c82020; letter-spacing: 0.2em; text-shadow: 0 0 30px #f00, 0 3px 3px #000; }
#death p { color: #d8c8c8; margin: 10px 0 26px; }

#joystick { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.2); transform: translate(-50%, -50%); pointer-events: none; }
#joystick i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(232,200,114,0.5); }
.fps { position: absolute; right: 230px; top: 16px; font-size: 11px; color: #8a8; text-shadow: 0 1px 2px #000; font-family: monospace; }
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.38) 100%); }
.lowhp { position: fixed; inset: 0; pointer-events: none; z-index: 1; box-shadow: inset 0 0 140px rgba(200,0,0,0.6); animation: lowhp 1s infinite; }
@keyframes lowhp { 50% { box-shadow: inset 0 0 80px rgba(200,0,0,0.35); } }

@media (max-width: 900px) {
  .hud-player { width: 250px; left: 8px; top: 8px; transform-origin: top left; }
  .hud-mm { transform: scale(0.72); transform-origin: top right; right: 8px; top: 8px; }
  .hud-quest { top: 200px; right: 8px; width: 190px; transform: scale(0.9); transform-origin: top right; }
  .hud-chat { width: 260px; left: 8px; bottom: 150px; }
  .chat-log { height: 90px; }
  .hud-bar { bottom: 12px; transform: translateX(-50%) scale(0.8); transform-origin: bottom center; }
  .hud-target { width: 240px; top: 76px; }
  .fps { display: none; }
  #inv-panel .pb { grid-template-columns: 1fr; }
  #inv-panel { right: 50%; transform: translate(50%, -50%); max-height: 92vh; overflow-y: auto; }
  .t-panel { margin-top: 2vh; }
}

/* ─── 모바일 (터치 / 좁은 화면): 오른쪽 스킬 패드, 왼쪽 조이스틱 공간 확보 ─── */
@media (max-width: 760px), (pointer: coarse) and (max-height: 540px) {
  .hud-player { width: min(250px, 58vw); padding: 7px 9px 7px 64px; }
  .hud-player .portrait { width: 48px; height: 48px; left: 8px; top: 8px; }
  .hud-player .lv { left: 36px; top: 42px; }
  .hud-player .nm { font-size: 13px; margin-bottom: 4px; }
  .hud-player .bar { height: 13px; }
  .hud-player .bar.mp { height: 10px; }
  .buffs { top: 84px; left: 8px; }
  .hud-mm { transform: scale(0.62); }
  .mm-btns .mm-btn { width: 40px; height: 40px; font-size: 17px; }
  .mm-btns .mm-btn[data-a="sound"], .mm-btns .mm-btn[data-a="help"] { display: none; }
  .hud-quest { top: 208px; right: 8px; width: 180px; transform: scale(0.85); }
  .hud-target { width: min(300px, 70vw); top: auto; bottom: calc(100vh - 150px); }
  .hud-boss { width: 92vw; top: 8px; }
  /* 채팅: 왼쪽 위 작은 로그 (조이스틱 영역을 가리지 않음) */
  .hud-chat { left: 8px; top: 118px; bottom: auto; width: min(260px, 55vw); pointer-events: none; }
  .hud-chat .chat-log { height: 62px; font-size: 11px; padding: 4px 6px; background: linear-gradient(0deg, rgba(0,0,0,0.35), rgba(0,0,0,0)); pointer-events: none; }
  .hud-chat .chat-in { display: none; }
  /* 스킬 패드 */
  .hud-bar { left: auto; right: max(8px, env(safe-area-inset-right, 0px)); bottom: 14px; transform: none; flex-direction: column; align-items: flex-end; gap: 6px; }
  .menu-btns { display: none; }
  .auto-btn { order: 0; width: 58px; height: 58px; font-size: 12px; }
  .pots { order: 1; padding: 5px; gap: 5px; }
  .pots .slot { width: 44px; height: 44px; }
  .skills { order: 2; display: grid; grid-template-columns: repeat(3, 56px); gap: 7px; padding: 7px; }
  .slot, .slot.big { width: 56px; height: 56px; }
  .slot .key { display: none; }
  .hud-xp span { display: none; }
  #toasts { top: 42vh; }
  #zone-title .z1 { font-size: 26px; }
  #bigtext .b1 { font-size: 34px; }
  .dialog { bottom: auto; top: 50%; transform: translate(-50%, -50%); }
}
/* 가로로 눕힌 휴대폰: 스킬 패드를 한 줄로, 퀘스트 창은 숨김 (📜 버튼으로 확인) */
@media (pointer: coarse) and (max-height: 540px) and (orientation: landscape) {
  .hud-bar { flex-direction: row; align-items: flex-end; }
  .hud-mm { transform: scale(0.5); }
  .hud-quest { display: none; }
  .hud-target { top: 8px; bottom: auto; width: min(300px, 36vw); }
  .hud-chat { top: 96px; width: min(300px, 36vw); }
}

/* ─── PWA / 가로 모드 ─────────────────────────────────────── */
.t-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.t-extra:empty { display: none; }
.t-chip { padding: 8px 14px; border-radius: 18px; border: 1px solid var(--line); background: rgba(0,0,0,0.55); color: var(--gold); font-size: 13px; font-weight: 700; }
.t-chip:hover { background: rgba(232,200,114,0.16); }
.t-hint { font-size: 12px; color: #cfc6b8; text-shadow: 0 1px 3px #000; }
.t-hint b { color: var(--gold); }

#rotate { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: rgba(4,5,10,0.92); pointer-events: auto; }
.rot-phone { width: 46px; height: 80px; border: 3px solid var(--gold); border-radius: 9px; position: relative; animation: rotPhone 2.2s ease-in-out infinite; box-shadow: 0 0 20px rgba(232,200,114,0.35); }
.rot-phone::after { content: ''; position: absolute; left: 50%; bottom: 5px; width: 10px; height: 3px; margin-left: -5px; border-radius: 2px; background: var(--gold); }
@keyframes rotPhone { 0%, 20% { transform: rotate(0deg); } 55%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
.rot-t { font-size: 18px; font-weight: 800; color: #fff3d6; }
.rot-s { font-size: 13px; color: var(--dim); }
.rot-b { display: flex; gap: 8px; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .rot-phone { animation: none; transform: rotate(-90deg); } }

#joy-hint { position: absolute; left: calc(max(12px, env(safe-area-inset-left, 0px)) + 18px); bottom: 26px; width: 118px; height: 118px; border-radius: 50%; border: 2px dashed rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; pointer-events: none; }
#joy-hint span { font-size: 12px; color: rgba(255,255,255,0.45); font-weight: 700; letter-spacing: 0.2em; }

/* 패널이 낮은 화면(가로 휴대폰)을 넘지 않도록 */
.panel { max-height: calc(100% - 16px); overflow-y: auto; }

/* 노치/둥근 모서리 안전 영역 (가로 모드) */
.hud-player { left: max(16px, env(safe-area-inset-left, 0px)); }
.hud-mm, .hud-quest { right: max(16px, env(safe-area-inset-right, 0px)); }

/* 가로로 눕힌 휴대폰의 타이틀 화면: 한 화면에 들어오도록 압축 */
@media (max-height: 500px) and (orientation: landscape) {
  #title .t-head { padding: 2.5vh 0 0 max(4vw, env(safe-area-inset-left, 0px)); }
  #title .logo { font-size: 30px; }
  #title .logo-sub, #title .t-foot, #title .t-stats { display: none; }
  #title .t-panel { margin: 1vh 0 0 max(4vw, env(safe-area-inset-left, 0px)); width: min(440px, 50vw); max-height: calc(100vh - 150px); }
  #title .t-label { margin: 6px 0 4px; font-size: 11px; }
  #title .t-name { padding: 7px 12px; font-size: 15px; }
  #title .cls-card { padding: 5px 4px; }
  #title .cls-card img { width: 30px; height: 30px; }
  #title .cls-card .r { display: none; }
  #title .cls-card .n { font-size: 13px; margin-top: 2px; }
  #title .t-desc { display: none; }
  #title .t-go { margin-left: max(4vw, env(safe-area-inset-left, 0px)); width: min(440px, 50vw); }
  #title .btn-start { margin-top: 8px; padding: 10px; font-size: 16px; }
  #title .t-err { min-height: 0; margin-top: 4px; }
}

@media (max-width: 760px), (pointer: coarse) and (max-height: 540px) {
  .hud-player, .buffs, .hud-chat { left: max(8px, env(safe-area-inset-left, 0px)); }
  .hud-mm, .hud-quest { right: max(8px, env(safe-area-inset-right, 0px)); }
}

/* 직접 렌더링(모바일 저사양) 모드의 피격 효과 */
.hitflash { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255,40,20,0) 42%, rgba(255,40,20,0.55) 100%); }
#gfx-lost { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 60; padding: 12px 20px; border-radius: 8px; background: rgba(8,8,14,0.92); border: 1px solid var(--line); color: var(--text); font-size: 14px; pointer-events: none; }
#gfx-lost[hidden] { display: none; }

/* 인앱 브라우저(카카오톡 등) 안내 */
.inapp { margin-top: 26px; width: min(420px, 86vw); padding: 16px 18px; border-radius: 10px; background: rgba(8,8,14,0.9); border: 1px solid var(--line); text-align: center; }
.inapp p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; color: var(--text); word-break: keep-all; }
.inapp p b { color: var(--gold); }
.inapp .ia-go { width: 100%; padding: 13px; font-size: 16px; font-weight: 800; color: #1a1208; border: none; border-radius: 8px; background: linear-gradient(180deg, #fff0c0, #e8c872 40%, #a8742a); }
.inapp .ia-stay { margin-top: 8px; width: 100%; padding: 10px; font-size: 13px; color: var(--dim); background: transparent; border: 1px solid rgba(255,255,255,0.14); border-radius: 8px; }
.inapp .ia-done { font-size: 12.5px; color: var(--good); margin: 10px 0 0; }
