:root {
  --ink: #4a3040; --ink2: #7d6a78; --paper: #fff8ec; --paper2: #f6ead8; --line: #e6d6bf;
  --violet: #8f7bff; --violet-d: #6a56dc; --pink: #ff6f91; --gold: #ffb31f; --mint: #3fbf8f; --red: #e0334a;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #2f2a55; font-family: 'Jua', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif; color: var(--ink); }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; user-select: text; }
.stroke, #hName, #floorTxt, #bossName { color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 7px 16px; border-radius: 14px; background: #fff; border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 16px; white-space: nowrap; transition: transform .06s, box-shadow .06s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, .chip:focus-visible, .card:focus-visible, .swatch:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.btn.primary { background: var(--violet); color: #fff; }
.btn.gold { background: var(--gold); }
.btn.danger { background: var(--pink); color: #fff; }
.btn.small { min-height: 32px; padding: 3px 11px; font-size: 14px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: 0 3px 0 var(--ink); transform: none; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
#hudL { position: absolute; left: 14px; top: 12px; width: 260px; }
#hName { font-size: 21px; margin-bottom: 4px; }
.bar { position: relative; height: 22px; border-radius: 12px; background: rgba(255,255,255,.72); border: 3px solid #fff; box-shadow: 0 2px 0 rgba(74,48,64,.3); overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 9px; transition: width .12s; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 13px; line-height: 16px; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.hp i { background: linear-gradient(#ff9bb5, #ff5f8a); }
.hp i#shFill { background: rgba(120, 200, 255, .75); width: 0; }
.pf .mini i.sh { background: #6fc4ff; }
.pf .mini i.rv { background: #3fbf8f; }
#downMsg .rv { margin-top: 6px; height: 16px; min-width: 240px; } #downMsg .rv i { background: linear-gradient(#a8ffcf, #3fbf8f); transition: none; }
.mpb { margin-top: 5px; height: 18px; } .mpb i { background: linear-gradient(#8fc8ff, #4a8dff); } .mpb span { font-size: 12px; line-height: 12px; }
.ult { margin-top: 5px; height: 17px; } .ult i { background: linear-gradient(#ffe27a, #ffb31f); width: 0; } .ult span { font-size: 11px; line-height: 11px; }
.ult.ready { animation: pulse .5s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.2); transform: scale(1.03); } }
#rageChip { display: inline-block; margin-top: 6px; padding: 1px 10px; border-radius: 10px; background: #ffe2dc; border: 2px solid var(--ink); font-size: 13px; }
#cryChip { display: inline-block; margin-top: 6px; padding: 1px 10px; border-radius: 10px; background: #fff3cf; border: 2px solid var(--ink); font-size: 13px; }
#rageChip.heal { background: #d9f7e6; }
#picks { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
#picks span { pointer-events: auto; width: 26px; height: 26px; display: grid; place-items: center; font-size: 15px; border-radius: 8px; background: rgba(255,255,255,.85); border: 2px solid var(--ink); }
#picks span.pact { background: #ffd8df; }
#partyFrames { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.pf { background: rgba(255,248,236,.9); border: 2px solid var(--ink); border-radius: 11px; padding: 3px 8px; font-size: 13px; }
.pf .row { display: flex; justify-content: space-between; gap: 5px; }
.pf .where { color: var(--ink2); font-size: 11px; }
.pf .mini { height: 6px; border-radius: 4px; background: #e8dac8; overflow: hidden; margin-top: 2px; } .pf .mini i { display: block; height: 100%; background: var(--pink); }
.pf.down { background: #ffd8df; }
#hudC { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: min(560px, 46vw); text-align: center; }
#floorTxt { font-size: 32px; line-height: 1.1; }
#floorSub { font-size: 14px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
#bossBar { margin-top: 6px; } #bossName { font-size: 18px; } .boss { height: 22px; } .boss i { background: linear-gradient(#ff8a7a, #e0334a); }
#hudR { position: absolute; right: 14px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
#goldBox { background: rgba(255,248,236,.94); border: 3px solid var(--ink); border-radius: 13px; padding: 3px 12px; font-size: 17px; }
#hudBtns { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; max-width: 280px; }
#prompt { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); pointer-events: auto; cursor: pointer; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 15px; font-size: 17px; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
#prompt kbd { font: inherit; display: inline-block; min-width: 25px; text-align: center; background: var(--violet); color: #fff; border-radius: 7px; padding: 0 5px; margin-right: 5px; }
#downMsg { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(74,48,64,.88); color: #fff; padding: 9px 18px; border-radius: 14px; font-size: 18px; text-align: center; }
#skillRow { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; align-items: flex-end; }
.sk { position: relative; width: 54px; height: 54px; border-radius: 15px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; overflow: hidden; touch-action: none; }
.sk.big { width: 68px; height: 68px; }
.sk b { position: absolute; left: 5px; top: 1px; font-size: 12px; font-weight: 400; color: var(--ink2); z-index: 2; }
.sk em { font-style: normal; font-size: 25px; line-height: 1; z-index: 1; }
.sk small { position: absolute; right: 5px; bottom: 1px; font-size: 14px; z-index: 2; }
.sk .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(74,48,64,.55); }
.sk.off { opacity: .55; }
.sk.ready { background: #ffe27a; }
.sk.atk { background: #ffd8df; }

#tip { position: fixed; z-index: 30; width: 250px; padding: 9px 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: 13px; box-shadow: 0 3px 0 var(--ink); pointer-events: none; font-size: 13px; line-height: 1.4; }
#tip strong { display: block; font-weight: 400; font-size: 16px; }
#tip .meta { color: #2f6fd8; font-size: 12px; }
#tip .ds { color: var(--ink2); margin-top: 3px; }
.sk.nomp { box-shadow: 0 3px 0 var(--ink), inset 0 0 0 40px rgba(74,141,255,.35); }

/* 떠오르는 글자 */
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.ft { position: absolute; transform: translate(-50%, -50%); font-size: 20px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; animation: ft .7s forwards; white-space: nowrap; }
.ft.crit { font-size: 30px; color: #ffe27a; } .ft.me { color: #ff8fa8; font-size: 25px; } .ft.heal { color: #8dffb8; } .ft.big { font-size: 26px; color: #ffe27a; }
@keyframes ft { 0% { opacity: 0; margin-top: 6px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -48px; } }

/* 패널 */
#panelWrap, #rewardWrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(47,42,85,.35); }
#panel { width: min(760px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 7px 0 var(--ink); overflow: hidden; }
.pHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--paper2); border-bottom: 3px solid var(--line); }
.pHead h2 { font-size: 23px; font-weight: 400; } .pHead p { font-size: 13px; color: var(--ink2); }
.pGold { font-size: 17px; margin-left: auto; }
.pBody { padding: 14px 16px; overflow-y: auto; flex: 1; user-select: none; }
.tabs { display: flex; gap: 5px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 11px; background: #fff; border: 2px solid var(--line); font-size: 15px; min-height: 34px; }
.chip.on { background: var(--violet); border-color: var(--violet-d); color: #fff; }
.sec { font-size: 15px; color: var(--ink2); margin: 12px 0 6px; } .sec:first-child { margin-top: 0; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }
.card { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 9px 11px; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.card .nm { font-size: 16px; } .card .ty { font-size: 12px; color: var(--ink2); }
.card ul { list-style: none; font-size: 13px; color: #3f7a68; flex: 1; }
.card .acts { display: flex; gap: 4px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.card .price { font-size: 14px; margin-right: auto; }
.rar-rare { border-color: #5fa8ff; } .rar-epic { border-color: #b06cff; } .rar-legend { border-color: #ffb31f; background: #fffaf0; }
.empty { color: var(--ink2); padding: 16px; text-align: center; font-size: 15px; }
.eqRow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 8px; }
.eqRow .card { min-height: 90px; }
.statGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 2px 14px; font-size: 14px; background: #fff; border-radius: 12px; padding: 8px 12px; border: 2px solid var(--line); }
.statGrid div { display: flex; justify-content: space-between; } .statGrid b { font-weight: 400; color: var(--violet-d); }
.field { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.field input { flex: 1; min-width: 140px; min-height: 40px; padding: 5px 11px; border-radius: 11px; border: 3px solid var(--line); background: #fff; outline: none; }
.field input:focus { border-color: var(--violet); }
.member { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 11px; padding: 6px 10px; margin-bottom: 5px; font-size: 15px; }
.member .sp { margin-left: auto; font-size: 13px; color: var(--ink2); } .crown { color: #e39b00; }
.codeBox { font-size: 22px; letter-spacing: 3px; color: var(--violet-d); }
.note { font-size: 13px; color: var(--ink2); line-height: 1.45; }
.warn { color: var(--red); }
.floorBtns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rank { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 8px; align-items: center; background: #fff; border-radius: 10px; padding: 6px 10px; margin-bottom: 4px; font-size: 15px; }
kbd.k { font: inherit; background: var(--paper2); border: 2px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 13px; }
.help { display: grid; grid-template-columns: auto 1fr; gap: 6px 11px; font-size: 15px; align-items: baseline; }

/* 보상 */
#rewardWrap { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; align-items: center; justify-content: center; }
#rewardWrap h2 { font-size: 34px; font-weight: 400; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-align: center; }
#rewardWrap .timer { color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; font-size: 15px; }
.rewards { display: flex; gap: 13px; justify-content: center; flex-wrap: wrap; width: min(860px, 100%); }
.reward { width: 240px; min-height: 280px; padding: 13px; background: var(--paper); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; transition: transform .12s; }
.reward:hover, .reward:focus-visible { transform: translateY(-6px); outline: none; }
.reward .tag { font-size: 13px; padding: 2px 11px; border-radius: 9px; color: #fff; }
.reward.blessing .tag { background: var(--mint); } .reward.item .tag, .reward.potion .tag { background: var(--gold); color: var(--ink); } .reward.pact .tag { background: var(--red); }
.reward.pact { background: #fff0f0; }
.reward .ic { font-size: 54px; line-height: 1.15; } .reward .nm { font-size: 21px; } .reward .ds { font-size: 13px; color: var(--ink2); line-height: 1.35; }
.reward ul { list-style: none; font-size: 15px; margin-top: auto; }
.up { color: #1f9d6f; } .down { color: var(--red); }
.resultStat { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 8px 0 14px; }
.resultStat div { background: #fff; border: 3px solid var(--line); border-radius: 13px; padding: 10px; text-align: center; font-size: 13px; color: var(--ink2); }
.resultStat b { display: block; font-weight: 400; font-size: 26px; color: var(--ink); }

/* 캐릭터 만들기 */
#createWrap { position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: linear-gradient(#bfe8ff, #fff0d9); display: flex; flex-direction: column; align-items: center; padding: 14px; }
.logo { text-align: center; margin-bottom: 8px; }
.logo h1 { font-size: clamp(42px, 8vh, 72px); font-weight: 400; line-height: 1; color: #fff; -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; letter-spacing: 3px; }
.logo p { font-size: 17px; color: var(--ink); margin-top: 4px; }

.gLogin { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; min-height: 40px; }
.maker { width: min(980px, 100%); display: grid; grid-template-columns: minmax(250px, 340px) 1fr; gap: 12px; background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 7px 0 var(--ink); padding: 13px; }
.previewBox { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.previewBox canvas { width: 100%; aspect-ratio: 1 / 1.05; border-radius: 16px; background: linear-gradient(#d7f0ff, #e5f6d7); cursor: grab; touch-action: none; display: block; }
.opts { min-width: 0; }
.classRow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 7px; }
.classRow button { background: #fff; border: 3px solid var(--line); border-radius: 12px; padding: 5px; font-size: 15px; min-height: 52px; line-height: 1.15; }
.classRow button small { display: block; font-size: 11px; color: var(--ink2); }
.classRow button.on { border-color: var(--violet); background: #f1eeff; }
.classInfo { background: #fff; border-radius: 11px; padding: 7px 10px; font-size: 12.5px; line-height: 1.4; margin-bottom: 8px; color: var(--ink2); border: 2px solid var(--line); }
.classInfo b { font-weight: 400; color: var(--ink); }
.optRow { display: flex; align-items: flex-start; gap: 7px; margin-bottom: 6px; }
.optRow > label { flex: 0 0 52px; font-size: 14px; padding-top: 5px; }
.optRow > div { display: flex; flex-wrap: wrap; gap: 3px; }
.optRow .chip { padding: 2px 8px; min-height: 28px; font-size: 13px; }
.swatch { width: 27px; height: 27px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--violet); }
.swatchInput { width: 31px; height: 29px; padding: 0; border: 0; background: none; cursor: pointer; }
.makerFoot { grid-column: 1 / -1; display: flex; gap: 8px; }

/* 배너, 토스트 */
#banner { position: fixed; left: 50%; top: 24%; transform: translateX(-50%); z-index: 15; text-align: center; pointer-events: none; animation: bn .28s cubic-bezier(.2,1.5,.5,1); width: 96%; }
#banner strong { display: block; font-size: clamp(38px, 7vw, 62px); font-weight: 400; color: #fff; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; line-height: 1.1; }
#banner span { font-size: 21px; color: #ffe27a; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
@keyframes bn { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
#toasts { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 5px; align-items: center; pointer-events: none; width: min(460px, 94vw); }
.toast { background: var(--paper); border: 3px solid var(--ink); border-radius: 13px; padding: 6px 13px; font-size: 15px; box-shadow: 0 3px 0 var(--ink); pointer-events: auto; animation: bn .2s; text-align: center; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.toast.err { background: #ffe2e6; }
#connMsg { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 7px 16px; border-radius: 12px; z-index: 50; }

/* 대화 */
#chat { position: absolute; left: 14px; bottom: 14px; width: min(340px, 30vw); min-width: 230px; pointer-events: auto; }
#chatLog { height: 132px; overflow-y: auto; padding: 5px 8px; font-size: 13px; line-height: 1.35; color: #fff; background: rgba(47,42,85,.45); border-radius: 12px 12px 0 0; user-select: text; overflow-wrap: anywhere; }
#chatLog p .who { color: #ffe27a; margin-right: 4px; }
#chatLog p.party { color: #a8ffcf; } #chatLog p.party .who { color: #6fffb0; }
#chatLog p.me .who { color: #9fd0ff; }
#chatBar { display: flex; background: rgba(255,248,236,.94); border: 2px solid var(--ink); border-radius: 0 0 12px 12px; overflow: hidden; }
#chatCh { flex: 0 0 auto; padding: 0 10px; min-height: 32px; font-size: 13px; background: var(--paper2); border-right: 2px solid var(--ink); }
#chatCh.party { background: #c9f5dc; }
#chatInput { flex: 1; min-width: 0; border: 0; outline: none; padding: 0 8px; font-size: 13px; background: transparent; }
body.touch #chat { bottom: 160px; width: 240px; }
body.touch #chatLog { height: 58px; }
@media (max-width: 1150px) { #chat { width: 230px; } #chatLog { height: 96px; } #skillRow { left: calc(50% + 110px); } }

/* 터치 */
#joy { position: absolute; left: 24px; bottom: 24px; width: 126px; height: 126px; border-radius: 50%; background: rgba(255,255,255,.3); border: 3px solid rgba(255,255,255,.7); pointer-events: auto; touch-action: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255,255,255,.85); border: 3px solid var(--ink); }
body.touch #skillRow { left: auto; right: 12px; transform: none; flex-wrap: wrap; justify-content: flex-end; width: 215px; }
body.touch .sk b { display: none; }

@media (max-width: 760px) {
  .maker { grid-template-columns: 1fr; }
  .previewBox canvas { aspect-ratio: 1.5 / 1; }
  .eqRow { grid-template-columns: repeat(2, 1fr); }
  #hudL { width: 170px; } #hName { font-size: 16px; }
  #hudC { top: 58px; width: 80vw; } #floorTxt { font-size: 24px; }
  .classRow { grid-template-columns: repeat(2, 1fr); }
  .reward { width: 100%; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { .ult.ready, .ft, #banner, .toast { animation-duration: .01s; } }
