:root {
  --bg: #0f0d16; --bg2: #17141f; --card: #1d1928; --line: #2e2940; --tx: #ece8f6; --tx2: #9a93b0;
  --acc: #ffcf5a; --red: #ff5a6e; --green: #5fd38a; --blue: #5aa8ff;
  --kr: 'Jua', system-ui, sans-serif; --title: 'Black Han Sans', 'Jua', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font-family: var(--kr); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input { font-family: inherit; font-size: 15px; }
.hide { display: none !important; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.scr { position: fixed; inset: 0; overflow: auto; background: radial-gradient(ellipse at 50% -20%, #2a1f45 0%, var(--bg) 60%); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 18px; font-weight: normal; color: var(--acc); }
.logo { font-family: var(--title); font-size: 56px; margin: 0; letter-spacing: 2px; color: var(--acc); text-shadow: 0 4px 0 #6b3d10; }
.logo.sm { font-size: 26px; text-shadow: 0 2px 0 #6b3d10; cursor: default; user-select: none; }
.sub { color: var(--tx2); margin: 6px 0 14px; }
.btn { background: #2b2640; color: var(--tx); border: 1px solid #3c3557; border-radius: 10px; padding: 10px 16px; cursor: pointer; transition: transform .06s, background .15s; }
.btn:hover { background: #352f4e; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--acc); color: #2a1a05; border-color: #e0a830; }
.btn.primary:hover { background: #ffd977; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.on { background: var(--green); color: #052; border-color: #3fae6a; }
.btn:disabled { opacity: .45; cursor: default; }
input { background: #120f1a; border: 1px solid var(--line); color: var(--tx); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%; }
input:focus { border-color: var(--acc); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row input { flex: 1; }
.pill { background: #2b2640; border-radius: 99px; padding: 3px 10px; font-size: 13px; color: var(--tx2); }
.pill.code { color: var(--acc); letter-spacing: 2px; }
.err { color: var(--red); min-height: 20px; margin: 10px 0 0; font-size: 14px; }
.hint { color: var(--tx2); font-size: 14px; margin: 0; }
.grow { flex: 1; }

/* 로그인 */
#scr-login { display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); text-align: center; padding: 28px 24px; }
.srv { font-size: 13px; color: var(--tx2); margin-bottom: 14px; }
.srv.ok { color: var(--green); } .srv.bad { color: var(--red); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; background: transparent; border: none; border-bottom: 2px solid var(--line); color: var(--tx2); padding: 8px; cursor: pointer; }
.tabs button.on { color: var(--tx); border-color: var(--acc); }
.form { display: flex; flex-direction: column; gap: 8px; }

/* 로비 */
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(15,13,22,.8); position: sticky; top: 0; z-index: 2; flex-wrap: wrap; }
.bar .title { font-size: 20px; }
.nick { color: var(--acc); }
.lobby { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; padding: 16px; max-width: 1100px; margin: 0 auto; }
.rooms { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.room-item { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: #15121e; border: 1px solid var(--line); cursor: pointer; }
.room-item:hover { border-color: var(--acc); }
.room-item .n { margin-left: auto; color: var(--tx2); }
.room-item.busy { opacity: .55; cursor: default; }
.empty { color: var(--tx2); text-align: center; padding: 30px 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #15121e; border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; color: var(--acc); font-weight: normal; }
.stat span { font-size: 12px; color: var(--tx2); }
.keys { margin: 0; padding-left: 18px; color: var(--tx2); line-height: 1.9; font-size: 14px; }
.keys b { color: var(--tx); font-weight: normal; }

/* 방 */
.room { display: grid; grid-template-columns: 340px 1fr; gap: 16px; padding: 16px; max-width: 1300px; margin: 0 auto; }
.col-left { display: flex; flex-direction: column; gap: 12px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); min-height: 56px; }
.slot.emptyslot { color: #4f4866; justify-content: center; border-style: dashed; }
.sq { width: 34px; height: 34px; border-radius: 6px; flex: none; display: grid; place-items: center; font-family: var(--title); font-size: 15px; color: #0008; border: 3px solid; }
.slot .who { display: flex; flex-direction: column; line-height: 1.25; }
.slot .who small { color: var(--tx2); font-size: 12px; }
.slot .tag { margin-left: auto; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #2b2640; color: var(--tx2); }
.slot .tag.ready { background: var(--green); color: #052; }
.slot .tag.host { background: var(--acc); color: #2a1a05; }
.chat { padding: 10px; display: flex; flex-direction: column; gap: 8px; height: 230px; }
.chat-log { flex: 1; overflow-y: auto; font-size: 14px; line-height: 1.5; }
.chat-log b { color: var(--acc); font-weight: normal; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ch { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; position: relative; display: flex; gap: 10px; align-items: center; }
.ch:hover { border-color: #5a5078; }
.ch.mine { border-color: var(--acc); box-shadow: 0 0 0 3px #ffcf5a33; }
.ch.taken { opacity: .45; }
.ch.view { outline: 2px dashed #ffffff44; outline-offset: 2px; }
.ch .nm { font-size: 15px; line-height: 1.2; }
.ch .nm small { display: block; color: var(--tx2); font-size: 11px; }
.ch .owner { position: absolute; right: 8px; bottom: 3px; font-size: 11px; color: var(--acc); }
.ch.mine, .ch.taken { padding-bottom: 18px; }
.detail { margin-top: 12px; }
.detail .head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.detail .head .sq { width: 54px; height: 54px; font-size: 22px; }
.detail .head h3 { margin: 0; font-weight: normal; font-size: 22px; }
.detail .head small { color: var(--tx2); }
.role-badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; color: #111; margin-left: 6px; }
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.sk { background: #15121e; border-radius: 10px; padding: 10px; font-size: 13px; color: var(--tx2); line-height: 1.5; }
.sk b { color: var(--tx); font-weight: normal; font-size: 14px; }
.sk .key { display: inline-block; min-width: 22px; text-align: center; background: #2b2640; color: var(--acc); border-radius: 5px; margin-right: 6px; font-size: 12px; padding: 1px 4px; }
.augs-prev { display: flex; flex-wrap: wrap; gap: 6px; }
.aug-chip { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: #15121e; border: 1px solid; }

/* 전투 덮개 */
.ov { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8,6,14,.72); z-index: 10; padding: 16px; }
.pick { width: min(980px, 100%); text-align: center; }
.pick h2 { font-weight: normal; color: var(--acc); font-size: 26px; margin: 0 0 16px; }
.pick-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.aug { background: linear-gradient(180deg, #241f33, #16131f); border: 2px solid; border-radius: 16px; padding: 22px 16px; cursor: pointer; transition: transform .12s; min-height: 210px; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; }
.aug:hover { transform: translateY(-6px); }
.aug .tier { font-size: 13px; padding: 2px 10px; border-radius: 99px; color: #111; }
.aug .an { font-size: 22px; }
.aug .ad { color: var(--tx2); font-size: 15px; line-height: 1.5; }
.aug.done { opacity: .35; pointer-events: none; }
.pick-stats { margin-top: 18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { color: var(--tx2); font-weight: normal; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid #241f33; text-align: left; }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-in { height: 6px; border-radius: 3px; background: var(--acc); margin-top: 3px; }
.end { width: min(760px, 100%); text-align: center; }
.end h1 { font-family: var(--title); font-size: 46px; margin: 0; font-weight: normal; }
.end p { color: var(--tx2); }
.end #end-table { margin: 16px 0; text-align: left; max-height: 50vh; overflow: auto; }
.tabinfo { width: min(900px, 100%); max-height: 86vh; overflow: auto; }
.game-chat { position: fixed; left: 12px; bottom: 110px; width: min(360px, 60vw); z-index: 5; pointer-events: none; font-size: 14px; }
.game-chat #gchat-log div { background: rgba(10,8,16,.6); padding: 2px 8px; border-radius: 6px; margin-top: 2px; width: fit-content; max-width: 100%; }
.game-chat #gchat-log b { color: var(--acc); font-weight: normal; }
.game-chat input { pointer-events: auto; margin-top: 6px; }
.dev { position: fixed; right: 10px; top: 120px; z-index: 6; display: flex; flex-direction: column; gap: 4px; background: rgba(40,10,20,.85); padding: 8px; border-radius: 10px; border: 1px solid #ff5a6e; font-size: 12px; }
.dev button { background: #3a1626; color: #fff; border: 1px solid #ff5a6e66; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.modal { width: min(360px, 100%); }
.modal p { margin: 0 0 10px; }
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: #2b2640; border: 1px solid var(--acc); padding: 10px 16px; border-radius: 10px; z-index: 20; font-size: 14px; }

/* 터치 */
.touch { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.stick { position: absolute; left: 24px; bottom: 24px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.15); pointer-events: auto; touch-action: none; }
.knob { position: absolute; left: 45px; top: 45px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.3); }
.tbtns { position: absolute; right: 20px; bottom: 30px; display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }
.tbtns button { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,207,90,.2); color: #fff; border: 2px solid rgba(255,207,90,.6); font-size: 20px; touch-action: none; }
.tbtns .ult { width: 78px; height: 78px; background: rgba(255,90,110,.25); border-color: rgba(255,90,110,.7); }

@media (max-width: 860px) {
  .lobby, .room { grid-template-columns: 1fr; }
  .pick-cards { grid-template-columns: 1fr; }
  .aug { min-height: 0; padding: 14px; }
  .logo { font-size: 44px; }
  .skills { grid-template-columns: 1fr; }
}

/* Sheet-derived portraits retain hard pixel edges. */
.sprite-portrait { background: #191725 !important; overflow: visible; }
.sprite-portrait img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; transform: scale(1.3); }

.practice-tools { position:fixed;bottom:112px;left:50%;transform:translateX(-50%);display:flex;gap:8px;align-items:center;padding:8px 12px;background:#151523ee;border:1px solid #49425e;border-radius:8px;font:12px system-ui;z-index:40;white-space:nowrap; }
.practice-tools select,.practice-tools button{background:#28233a;color:#eee;border:1px solid #524b69;padding:5px;border-radius:4px;font-size:12px;}
.practice-tools a {color:#c6b8ea;} .practice-link {display:block;text-align:center;margin-top:12px;text-decoration:none;}
@media(max-width:700px){.practice-tools{top:4px;bottom:auto;max-width:98vw;gap:4px;flex-wrap:wrap}.practice-tools span{display:none}}

.practice-tools {display:block;font-size:12px;} .practice-tools summary{cursor:pointer;color:#d6c8a1;} .practice-options{display:flex;gap:8px;align-items:center;margin-top:8px;flex-wrap:wrap;}
@media(pointer:coarse){.practice-tools{top:8px;bottom:auto;left:auto;right:8px;transform:none;max-width:85vw;padding:6px}.practice-tools[open]{background:#151523}.practice-options{max-width:480px}.tbtns{gap:8px;right:14px;bottom:20px}.tbtns button{width:56px;height:56px}.tbtns .ult{width:66px;height:66px}}
