/* 던전파티 — 어두운 판 기본. 게임 그림은 #dp-game(Phaser), 그 위 글·단추는 #dp-ui */
:root {
  --bg: #0d1016; --panel: #161b26; --panel2: #1e2533; --line: #2c3446; --text: #e9edf5; --soft: #9aa5ba; --gold: #ffd84a;
  --hp: #ff5b6b; --mp: #4fa3ff; --ex: #b48cff; --ok: #5fd38a; --accent: #ffb547; --r: 12px;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: Pretendard, 'Noto Sans KR', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
input, select, textarea { user-select: text; -webkit-user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
#dp-game { position: fixed; inset: 0; display: grid; place-items: center; }
#dp-game canvas { display: block; }
#dp-ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#dp-ui > * { pointer-events: auto; }
#dp-ui > #dp-banner, #dp-ui > #dp-toasts, #dp-ui > #dp-flash, #dp-ui > #dp-stage, #dp-ui > #dp-boss { pointer-events: none; }
[hidden] { display: none !important; }
kbd { font: 700 10px/1 ui-monospace, Consolas, monospace; background: #0008; border: 1px solid #fff3; border-radius: 4px; padding: 2px 4px; }

/* 공통 단추 */
.dp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid #ffcf70; background: linear-gradient(#ffc75a, #f29e2e); color: #2a1a00; font-weight: 800; text-decoration: none; white-space: nowrap; }
.dp-btn:hover { filter: brightness(1.08); }
.dp-btn:disabled { opacity: .4; cursor: default; filter: none; }
.dp-btn.dp-soft { background: var(--panel2); border-color: var(--line); color: var(--text); font-weight: 700; }
.dp-btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.dp-btn.on { outline: 2px solid var(--accent); }
.dp-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.dp-row.end { justify-content: flex-end; }
.dp-x { background: none; border: 0; color: var(--soft); font-size: 18px; width: 36px; height: 36px; border-radius: 8px; }
.dp-x:hover { background: #fff1; color: var(--text); }
.dp-eyebrow { margin: 0 0 6px; font-size: 12px; letter-spacing: .14em; color: var(--accent); font-weight: 800; }
.dp-soft-t { color: var(--soft); font-size: 13px; line-height: 1.5; }
.dp-lab { margin: 14px 0 6px; font-size: 13px; font-weight: 800; color: var(--soft); }
.dp-err { color: #ff8a8a; font-size: 13px; min-height: 1em; }

/* 들어오는 문·불러오기 */
#dp-door, #dp-load { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 30%, #1d2638, #07090d 70%); }
#dp-load { transition: opacity .4s; } #dp-load.dp-gone { opacity: 0; pointer-events: none; }
.dp-door-box, .dp-load-box { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: 0 20px 60px #0008; }
.dp-door-box h1 { margin: 0 0 10px; font-size: 22px; } .dp-door-box p { color: var(--soft); line-height: 1.6; margin: 0; }
.dp-load-box b { display: block; margin-bottom: 14px; }

/* 막대 */
.dp-bar { position: relative; height: 12px; background: #0009; border-radius: 6px; overflow: hidden; border: 1px solid #ffffff14; }
.dp-bar i { position: absolute; inset: 0 auto 0 0; width: 0; transition: width .15s; border-radius: inherit; }
.dp-bar em { position: absolute; inset: 0; font: 700 9px/12px ui-monospace, Consolas, monospace; font-style: normal; text-align: center; color: #fffc; text-shadow: 0 1px 2px #000; }
.dp-bar.hp i { background: linear-gradient(#ff8590, var(--hp)); } .dp-bar.mp i { background: linear-gradient(#86c2ff, var(--mp)); }
.dp-bar.ex { height: 5px; } .dp-bar.ex i { background: var(--ex); }
.dp-bar.ld { height: 8px; } .dp-bar.ld i { background: linear-gradient(90deg, #ffb547, #ffd84a); }
.dp-bar.boss { height: 14px; } .dp-bar.boss i { background: linear-gradient(#ff7a4a, #d8323c); }
.dp-bar.q { height: 14px; margin-top: 6px; } .dp-bar.q i { background: var(--ok); } .dp-bar.q em { line-height: 14px; }

/* HUD */
#dp-hud { position: fixed; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); width: 250px; }
.dp-me { display: flex; gap: 8px; align-items: center; background: #0b0e15d0; border: 1px solid #ffffff14; border-radius: 12px; padding: 6px 10px 8px 6px; backdrop-filter: blur(6px); }
.dp-face { flex: none; width: 44px; height: 44px; border-radius: 10px; background: #2a3247 no-repeat; background-size: 900% auto; background-position: 0 -2px; border: 1px solid #ffffff1c; }
.dp-me-txt { flex: 1; min-width: 0; display: grid; gap: 3px; }
.dp-me-txt b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-me-txt span { font-size: 11px; color: var(--soft); margin-top: -3px; }
.dp-gold { margin-top: 6px; display: inline-block; background: #0b0e15d0; border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 13px; color: var(--gold); }
#dp-partybox { margin-top: 6px; display: grid; gap: 2px; }
#dp-partybox p { margin: 0; font-size: 12px; background: #0b0e15b0; border-radius: 8px; padding: 3px 8px; width: max-content; max-width: 100%; }
#dp-partybox p.lead { color: var(--gold); } #dp-partybox small { color: var(--soft); }
#dp-top { position: fixed; top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 60vw; }
.dp-chip { background: #0b0e15d0; border: 1px solid #ffffff14; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dp-ping.good { color: var(--ok); } .dp-ping.mid { color: var(--gold); } .dp-ping.bad { color: #ff7a7a; }
.dp-ico { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #ffffff1c; background: #0b0e15d0; font-size: 18px; }
.dp-ico:hover { background: #1e2638; }
#dp-stage { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: #0b0e15c0; border-radius: 999px; padding: 6px 14px; font-size: 13px; white-space: nowrap; }
#dp-boss { position: fixed; top: calc(46px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(520px, 60vw); text-align: center; }
#dp-boss b { display: inline-block; font-size: 14px; font-weight: 900; margin-bottom: 4px; padding: 2px 12px; border-radius: 999px; background: #0b0e15c8; color: #ffd0b0; }
#dp-banner { position: fixed; top: 30%; left: 0; right: 0; text-align: center; font-size: clamp(26px, 5vw, 44px); font-weight: 900; color: #fff; text-shadow: 0 4px 0 #0006, 0 0 24px #000a; opacity: 0; transform: translateY(10px); transition: .35s; }
#dp-banner.show { opacity: 1; transform: none; } #dp-banner.boss { color: #ff8a5a; }
#dp-toasts { position: fixed; top: calc(84px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; width: min(420px, 90vw); }
.dp-toast { background: #0b0e15e8; border: 1px solid #ffffff1c; border-radius: 10px; padding: 7px 14px; font-size: 13px; transition: opacity .4s, transform .4s; display: flex; gap: 8px; align-items: center; }
.dp-toast.big { font-size: 15px; font-weight: 800; border-color: #ffcf7080; }
.dp-toast.out { opacity: 0; transform: translateY(-6px); }
.dp-toast.drop i { width: 10px; height: 10px; border-radius: 3px; }
#dp-flash { position: fixed; inset: 0; background: #fff; opacity: 0; }
#dp-flash.go { animation: dpflash .45s ease-out; }
@keyframes dpflash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* 대화 */
#dp-chat { position: fixed; left: calc(8px + var(--safe-l)); bottom: calc(8px + var(--safe-b)); width: min(340px, 40vw); }
#dp-chatlog { max-height: 120px; overflow-y: auto; font-size: 12px; line-height: 1.45; padding: 4px 6px; scrollbar-width: thin; mask-image: linear-gradient(transparent, #000 25%); }
#dp-chatlog p { margin: 0; text-shadow: 0 1px 2px #000, 0 0 4px #000; word-break: break-all; }
#dp-chatlog p.pt { color: #8fe3ff; } #dp-chatlog b { color: var(--gold); }
#dp-chatform { display: flex; gap: 4px; }
#dp-chatform select, #dp-chatform input { background: #0b0e15d8; border: 1px solid #ffffff1c; border-radius: 8px; height: 32px; padding: 0 8px; font-size: 13px; }
#dp-chatform input { flex: 1; min-width: 0; }

/* 기술 줄 (PC) */
#dp-skills { position: fixed; bottom: calc(10px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.dp-sk-b { position: relative; width: 74px; height: 58px; border-radius: 10px; border: 1px solid #ffffff22; background: #121826e0; display: grid; place-items: center; padding: 4px; font-size: 11px; font-weight: 700; line-height: 1.2; overflow: hidden; --cd: 0; }
.dp-sk-b span { text-align: center; } .dp-sk-b kbd { position: absolute; top: 3px; left: 3px; }
.dp-sk-b.atk { background: #3a2410e0; border-color: #ffb54766; }
.dp-sk-b.pot { background: #3a1018e0; } .dp-sk-b.pot.mp { background: #10203ae0; }
.dp-sk-b.lock { opacity: .45; } .dp-sk-b em { position: absolute; bottom: 2px; right: 4px; font-style: normal; font-size: 10px; color: var(--gold); }
.dp-sk-b::after, #dp-btns button::after { content: ''; position: absolute; inset: 0; background: #000a; opacity: var(--cd); pointer-events: none; }
.dp-cdt { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 18px; font-weight: 900; z-index: 1; text-shadow: 0 2px 3px #000; pointer-events: none; }
#dp-talk { position: fixed; left: 50%; bottom: calc(82px + var(--safe-b)); transform: translateX(-50%); background: #0b0e15e0; border: 1px solid #ffcf7088; color: var(--text); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 14px; }

/* 폰 조작 */
#dp-pad { position: fixed; inset: auto 0 0 0; height: 0; }
#dp-joy { position: fixed; left: calc(24px + var(--safe-l)); bottom: calc(24px + var(--safe-b)); width: 136px; height: 136px; border-radius: 50%; background: radial-gradient(#ffffff10, #ffffff22); border: 2px solid #ffffff30; touch-action: none; }
#dp-joy i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: #ffffff55; border: 2px solid #fff8; box-shadow: 0 4px 10px #0006; }
#dp-btns { position: fixed; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 230px; height: 200px; }
#dp-btns button { position: absolute; border-radius: 50%; border: 2px solid #ffffff40; background: #121826c8; font-weight: 800; font-size: 11px; overflow: hidden; touch-action: none; --cd: 0; display: grid; place-items: center; line-height: 1.1; padding: 4px; word-break: keep-all; text-align: center; }
#dp-btns button.on { transform: scale(.92); background: #2a3550; }
#dp-btns .big { width: 84px; height: 84px; right: 6px; bottom: 6px; font-size: 16px; background: #5a3410d8; border-color: #ffb547aa; }
#dp-btns .mid { width: 58px; height: 58px; right: 104px; bottom: 0; }
#dp-btns .sk { width: 56px; height: 56px; } #dp-btns .sk.lock { opacity: .4; }
#dp-btns .sk:nth-of-type(3) { right: 100px; bottom: 70px; } #dp-btns .sk:nth-of-type(4) { right: 64px; bottom: 126px; } #dp-btns .sk:nth-of-type(5) { right: 0; bottom: 104px; }
#dp-btns .pot { width: 46px; height: 46px; right: 166px; bottom: 64px; background: #3a1018d8; font-size: 11px; } #dp-btns .pot small { display: block; font-size: 10px; color: var(--soft); }
body.dp-touch #dp-chat { bottom: auto; top: calc(130px + var(--safe-t)); width: min(280px, 36vw); }
body.dp-touch #dp-chatlog { max-height: 80px; }
body.dp-touch #dp-talk { bottom: auto; top: 58%; }

/* 쓰러짐 · 초대 */
#dp-dead { position: fixed; inset: 0; background: #1a0508b0; display: grid; place-content: center; text-align: center; z-index: 8; }
#dp-dead h2 { font-size: 34px; margin: 0; color: #ff8a8a; text-shadow: 0 3px 0 #000; }
#dp-pop { position: fixed; top: calc(70px + var(--safe-t)); right: calc(12px + var(--safe-r)); background: var(--panel); border: 1px solid #ffcf7088; border-radius: 12px; padding: 12px 14px; z-index: 9; width: min(300px, 90vw); box-shadow: 0 10px 30px #0008; }
#dp-pop p { margin: 0; font-size: 14px; }

/* 창 */
#dp-modal { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; z-index: 10; padding: 12px; }
.dp-win { width: min(560px, 100%); max-height: min(88vh, 720px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px #000a; overflow: hidden; }
.dp-win header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.dp-win header b { font-size: 16px; } .dp-win header small { color: var(--soft); font-weight: 600; margin-left: 6px; font-size: 12px; }
#dp-wbody { padding: 12px 16px 16px; overflow-y: auto; }
#dp-wbody > p:first-child { margin-top: 0; }
.dp-list { display: grid; gap: 6px; }
.dp-item { display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; }
.dp-item.on { border-color: #ffcf7066; } .dp-item.done { opacity: .55; }
.dp-item > div:not(.dp-acts) { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dp-item b { font-size: 14px; } .dp-item small { font-size: 12px; color: var(--soft); }
.dp-acts { display: flex; gap: 6px; align-items: center; flex: none; text-align: right; }
.dp-acts small { font-size: 11px; line-height: 1.3; }
.dp-ic { flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-style: normal; font-size: 17px; background: #0d1119; border: 2px solid var(--r, #3a4357); color: var(--r, var(--text)); }
.dp-ic.use { color: var(--hp); border-color: #5a2a33; } .dp-ic.mat { color: #8fd0ff; border-color: #2a4560; } .dp-ic.quest { color: var(--gold); border-color: #5a4a20; }
.dp-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dp-stats span { background: var(--panel2); border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--soft); }
.dp-stats b { color: var(--text); margin-left: 4px; } .dp-stats.big span { font-size: 15px; }
.dp-npc-say { background: #0d1119; border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 14px; }
.dp-chs { display: flex; gap: 6px; flex-wrap: wrap; }
input[type=range] { width: 100%; accent-color: var(--accent); }
#dp-wbody input:not([type]), #dp-cname { width: 100%; height: 44px; border-radius: 10px; background: #0d1119; border: 1px solid var(--line); padding: 0 12px; font-size: 16px; }

/* 캐릭터 만들기 */
.dp-cls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dp-card { display: grid; gap: 4px; justify-items: center; text-align: center; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 12px 10px; }
.dp-card.on { border-color: var(--accent); background: #2a2418; }
.dp-card b { font-size: 16px; } .dp-card small { color: var(--soft); font-size: 12px; line-height: 1.4; }
.dp-card .dp-st { color: var(--text); } .dp-card .dp-sk { color: #c8b0ff; }
.dp-port { display: block; width: 72px; height: 96px; background: no-repeat; background-size: 900% auto; background-position: 0 0; }
.dp-skins { display: flex; gap: 8px; }
.dp-skin { background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 4px 8px; }
.dp-skin.on { border-color: var(--accent); }
.dp-skin .dp-port { width: 48px; height: 64px; }

/* 클리어 */
.dp-rank { font-size: 88px; font-weight: 900; text-align: center; line-height: 1; margin: 4px 0 14px; text-shadow: 0 6px 0 #0007; }
.dp-rank.rS { color: #ffd84a; } .dp-rank.rA { color: #ff9a5a; } .dp-rank.rB { color: #8fd0ff; } .dp-rank.rC { color: #c8d0e0; }
.dp-first { background: #3a2a10; border: 1px solid #ffcf7066; border-radius: 10px; padding: 8px 12px; color: var(--gold); font-weight: 800; }

/* 개발자 창 */
#dp-dev { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 20; background: #0f131cf4; border-left: 1px solid var(--line); display: flex; flex-direction: column; backdrop-filter: blur(8px); }
#dp-dev header { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); color: var(--accent); }
.dv-body { overflow-y: auto; padding: 4px 14px 20px; }
.dv-body section { border-bottom: 1px solid #ffffff0d; padding: 10px 0; }
.dv-body section.dv-off { opacity: .4; pointer-events: none; }
.dv-body h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; color: var(--soft); }
.dv-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.dv-row select { flex: 1; min-width: 0; height: 32px; background: #0d1119; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: 13px; }
.dv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 12px; color: var(--soft); margin-bottom: 8px; }
.dv-grid b { color: var(--text); }
.dv-s { font-size: 12px; color: var(--soft); margin: 4px 0; line-height: 1.5; }
.dv-l { display: grid; gap: 4px; font-size: 12px; color: var(--soft); } .dv-c { font-size: 13px; display: flex; gap: 6px; align-items: center; }

/* AI 도우미 창 (hong-ai) */
.dp-ai { position: fixed; top: 0; right: 0; bottom: 0; width: var(--hai-w, 420px); z-index: 30; background: var(--panel); border-left: 1px solid var(--line); }
@media (max-width: 899px) { .dp-ai { top: auto; left: 0; width: auto; height: var(--hai-h, 70vh); border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; } }

/* 작은 화면 */
@media (max-width: 700px), (max-height: 430px) {
  #dp-hud { width: 200px; } .dp-face { width: 36px; height: 36px; }
  .dp-ico { width: 34px; height: 34px; font-size: 15px; } .dp-chip { font-size: 11px; padding: 4px 8px; }
  #dp-top { max-width: 52vw; }
  .dp-cls { grid-template-columns: 1fr; } .dp-card { grid-template-columns: auto 1fr; justify-items: start; text-align: left; } .dp-card .dp-port { grid-row: span 4; width: 54px; height: 72px; }
}
@media (max-height: 430px) {
  #dp-joy { width: 116px; height: 116px; left: calc(16px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); }
  #dp-btns { transform: scale(.86); transform-origin: right bottom; }
  #dp-stage { top: auto; bottom: calc(6px + var(--safe-b)); }
  #dp-boss { top: calc(40px + var(--safe-t)); }
  .dp-win { max-height: 96vh; } .dp-win header { padding: 4px 6px 4px 14px; } #dp-wbody { padding: 8px 14px 10px; }
  .dp-cls { grid-template-columns: 1fr 1fr; gap: 8px; } .dp-card { padding: 8px; gap: 2px; } .dp-card small:not(.dp-st):not(.dp-sk) { display: none; }
  .dp-card .dp-port { width: 40px; height: 54px; } .dp-skin .dp-port { width: 32px; height: 43px; } .dp-lab { margin: 8px 0 4px; }
  #dp-wbody > .dp-soft-t:first-child { display: none; } #dp-cname { height: 38px; } .dp-row { margin-top: 8px; } .dp-rank { font-size: 60px; margin-bottom: 8px; }
}
/* 세로 폰: 가로로 돌려 달라고 */
@media (orientation: portrait) and (max-width: 700px) {
  body.dp-touch::after { content: '폰을 가로로 돌려 주세요 ↻'; position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: #07090df2; color: var(--text); font-size: 18px; font-weight: 800; }
}
