/* 마이크로 페글린: 파칭코 던전 */
:root {
  --bg: #0b0a1a; --panel: #1b1934; --line: rgba(168, 85, 247, .28);
  --text: #f1edff; --mute: #a39cc4; --gold: #fbbf24; --red: #f43f5e; --green: #34d399; --blue: #60a5fa; --purple: #c084fc;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, #241a4a 0%, var(--bg) 55%, #05040c 100%) fixed;
  color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
body.hurt::after { content: ''; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px rgba(244, 63, 94, .65); animation: fade .45s ease-out forwards; z-index: 40; }
@keyframes fade { to { opacity: 0; } }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
b { font-weight: 800; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px; flex-shrink: 0; }
.back-btn { color: var(--purple); text-decoration: none; font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 9px; background: rgba(168, 85, 247, .12); border: 1px solid var(--line); white-space: nowrap; }
.back-btn:hover { background: rgba(168, 85, 247, .24); }
.stats { display: flex; gap: 4px; flex: 1; min-width: 0; flex-wrap: wrap; justify-content: center; }
.st { font-size: .8rem; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .08); padding: 3px 7px; border-radius: 99px; white-space: nowrap; }
.st.hp b { color: #fda4af; } .st.gold b { color: var(--gold); } .st.blk b { color: #7dd3fc; } .st.psn b { color: #a3e635; }
.tools { display: flex; gap: 4px; margin-left: auto; }
.mini { min-width: 32px; height: 32px; padding: 0 7px; border-radius: 9px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12); font-size: .82rem; white-space: nowrap; }
.mini:hover { background: rgba(255, 255, 255, .14); }
.relic-bar { display: flex; gap: 4px; padding: 2px 10px 4px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.relic-bar::-webkit-scrollbar { display: none; }
.relic { font-size: 1.05rem; width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle, rgba(192, 132, 252, .3), rgba(0, 0, 0, .3)); border: 1px solid var(--line); flex-shrink: 0; }

#screen { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow-y: auto; padding: 4px 10px 10px; }
.scr { display: flex; flex-direction: column; flex: 1; min-height: 0; }
h2 { text-align: center; font-size: 1.3rem; margin: 6px 0; background: linear-gradient(135deg, #fde68a, #f472b6, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { text-align: center; color: var(--mute); font-size: .85rem; margin: 2px 0 10px; line-height: 1.45; }
.row { display: flex; gap: 10px; justify-content: center; margin: 12px 0 6px; flex-wrap: wrap; }
.btn { padding: 11px 18px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15); font-weight: 700; transition: transform .12s, background .2s; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .15); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, #8b5cf6, #db2777); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(219, 39, 119, .35); }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn small { display: block; font-weight: 500; font-size: .75rem; opacity: .85; margin-top: 2px; }
.btn:disabled { opacity: .4; }

/* 타이틀 */
.scr.title { align-items: center; justify-content: safe center; gap: 16px; padding: 10px 0; }
.logo { text-align: center; }
.logo .orbs { font-size: 3.2rem; display: inline-block; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 18px rgba(192, 132, 252, .55)); }
.logo h1 { font-size: 1.7rem; font-weight: 900; background: linear-gradient(135deg, #fbbf24, #f472b6, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo p { color: var(--mute); font-size: .88rem; margin-top: 6px; line-height: 1.5; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.records { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(360px, 100%); }
.rec { text-align: center; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; padding: 8px 4px; }
.rec b { display: block; font-size: 1.1rem; color: var(--gold); }
.rec small { font-size: .7rem; color: var(--mute); }

/* 지도 */
.map { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 10px; }
.floor { display: flex; align-items: center; gap: 8px; }
.floor .fl { width: 34px; text-align: right; font-size: .75rem; color: var(--mute); flex-shrink: 0; }
.floor .opts { display: flex; gap: 6px; flex: 1; }
.node { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .07); font-size: .85rem; opacity: .55; }
.node .e { font-size: 1.25rem; }
.floor.past .node { opacity: .25; }
.floor.past .node.taken { opacity: .9; border-color: rgba(168, 85, 247, .5); background: rgba(168, 85, 247, .14); }
.floor.cur .node { opacity: 1; border-color: var(--gold); background: rgba(251, 191, 36, .1); animation: glow 1.6s ease-in-out infinite; }
.floor.cur .node:hover { background: rgba(251, 191, 36, .22); }
.node.boss { border-color: rgba(244, 63, 94, .5); }
@keyframes glow { 50% { box-shadow: 0 0 14px rgba(251, 191, 36, .35); } }
.act-head { text-align: center; padding: 6px 0 2px; }
.act-head .big { font-size: 2rem; }

/* 전투 */
.scr.combat { gap: 4px; overflow: hidden; }
.foes { display: flex; gap: 6px; justify-content: center; flex-shrink: 0; min-height: 96px; }
.foe { position: relative; flex: 1; max-width: 132px; display: flex; flex-direction: column; align-items: center; padding: 4px 4px 5px; border-radius: 12px; border: 2px solid transparent; background: rgba(0, 0, 0, .28); transition: border-color .15s, opacity .4s, transform .15s; }
.foe.tgt { border-color: var(--red); background: rgba(244, 63, 94, .1); }
.foe.dead { opacity: 0; pointer-events: none; }
.foe .em { font-size: 2rem; line-height: 1.1; }
.foe.boss .em { font-size: 2.6rem; }
.foe .nm { font-size: .68rem; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.foe .bar { width: 100%; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 2px; }
.foe .bar i { display: block; height: 100%; background: linear-gradient(90deg, #f43f5e, #fb7185); transition: width .3s; }
.foe .hpt { font-size: .7rem; font-weight: 700; }
.foe .badges { display: flex; gap: 3px; font-size: .66rem; min-height: 14px; }
.foe .intent { position: absolute; top: -2px; right: -2px; background: #2b1d4f; border: 1px solid var(--line); border-radius: 9px; padding: 1px 6px; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.foe .intent.atk { color: #fca5a5; border-color: rgba(244, 63, 94, .5); }
.foe.shake { animation: shake .3s; }
.foe.lunge { animation: lunge .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes lunge { 40% { transform: translateY(10px) scale(1.08); } }
.board-wrap { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; align-items: flex-start; }
#cv { display: block; border-radius: 14px; touch-action: none; box-shadow: 0 0 0 1px rgba(168, 85, 247, .3), 0 10px 30px rgba(0, 0, 0, .5); cursor: crosshair; }
.shot-total { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 1.05rem; padding: 3px 12px; border-radius: 99px; background: rgba(0, 0, 0, .55); pointer-events: none; opacity: 0; transition: opacity .2s; white-space: nowrap; }
.shot-total.on { opacity: 1; }
.shot-total.crit { color: var(--gold); text-shadow: 0 0 10px rgba(251, 191, 36, .7); }
.orbbar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
.cur-orb { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px; padding: 5px 8px; text-align: left; }
.cur-orb .oe { font-size: 1.6rem; }
.cur-orb .on { font-weight: 800; font-size: .85rem; }
.cur-orb .od { font-size: .7rem; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dmgs { font-size: .74rem; } .dmgs .c { color: var(--gold); }
.next { display: flex; gap: 3px; align-items: center; font-size: .7rem; color: var(--mute); }
.next span { font-size: 1.1rem; opacity: .8; }
.fire-hint { font-size: .68rem; color: var(--mute); text-align: center; flex-shrink: 0; }

/* 구슬 카드·유물 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ocard { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px; border-radius: 14px; background: linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .25)); border: 1px solid rgba(255, 255, 255, .12); text-align: center; transition: transform .12s, border-color .15s; }
.ocard:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--purple); }
.ocard .oe { font-size: 2rem; }
.ocard .on { font-weight: 800; }
.ocard .od { font-size: .74rem; color: var(--mute); line-height: 1.4; }
.ocard .rar { font-size: .66rem; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, .08); }
.ocard.r1 .rar { color: #7dd3fc; } .ocard.r2 .rar { color: #f0abfc; }
.ocard.r1 { border-color: rgba(96, 165, 250, .35); } .ocard.r2 { border-color: rgba(240, 171, 252, .45); }
.ocard.sold { opacity: .35; }
.price { font-weight: 800; color: var(--gold); font-size: .85rem; }
.sec { margin: 14px 0 6px; font-weight: 800; font-size: .9rem; color: #ddd6fe; }
.panel-box { background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: 12px; margin: 6px 0; }
.ev-emoji { font-size: 3rem; text-align: center; }
.result-line { text-align: center; margin: 8px 0; font-weight: 700; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(4, 3, 12, .78); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 30; }
.modal[hidden], [hidden] { display: none !important; }
.panel { width: min(480px, 100%); max-height: 88dvh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.panel p, .panel li { font-size: .88rem; line-height: 1.55; color: #ddd6fe; }
.panel ul { padding-left: 18px; margin: 6px 0; }
.panel pre { white-space: pre-wrap; font-size: .75rem; background: rgba(0, 0, 0, .4); padding: 8px; border-radius: 8px; margin-top: 8px; }
.legend { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin: 8px 0; font-size: .85rem; }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.olist { display: flex; flex-direction: column; gap: 6px; }
.oitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .08); text-align: left; width: 100%; }
button.oitem:hover:not(:disabled) { border-color: var(--purple); }
.oitem .oe { font-size: 1.5rem; }
.oitem .od { font-size: .74rem; color: var(--mute); }
.oitem:disabled { opacity: .4; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: rgba(20, 16, 40, .95); border: 1px solid var(--line); padding: 9px 16px; border-radius: 12px; font-size: .88rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 35; }
.fnum { position: absolute; font-weight: 900; font-size: 1.25rem; text-shadow: 0 2px 6px #000; animation: up .9s ease-out forwards; transform: translateX(-50%); white-space: nowrap; }
.fnum.crit { color: var(--gold); font-size: 1.5rem; } .fnum.bomb { color: #fb923c; } .fnum.poison { color: #a3e635; } .fnum.heal { color: var(--green); } .fnum.blk { color: #7dd3fc; } .fnum.dmg { color: #fda4af; }
@keyframes up { to { transform: translate(-50%, -46px); opacity: 0; } }
.noscript { padding: 30px; text-align: center; }

@media (max-height: 700px) {
  .foes { min-height: 82px; } .foe .em { font-size: 1.6rem; } .foe.boss .em { font-size: 2rem; }
  .fire-hint { display: none; }
}
@media (max-width: 520px) {
  .back-txt { display: none; } .back-btn { padding: 6px 8px; }
  .stats { flex-wrap: nowrap; gap: 3px; } .st { padding: 3px 5px; font-size: .74rem; }
  .mini { min-width: 30px; height: 30px; padding: 0 5px; font-size: .76rem; } .tools { gap: 3px; }
}
