/* 황제 크아 전용 스타일. 색 토큰은 style.css 의 :root 를 그대로 쓴다. */
.ka-shell{min-height:100vh;background:radial-gradient(120% 90% at 50% 0,#1a2d16 0,#070d08 60%)}
.ka-main{position:relative;margin:0 auto;padding:8px 16px 8px;display:flex;flex-direction:column;gap:8px}

.ka-hud{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;min-height:42px;padding:5px 12px;border:1px solid #ffffff14;border-radius:20px;background:#141925cc;box-shadow:0 6px 20px #0006;box-sizing:border-box}
.ka-hud[hidden]{display:none}
.hud-left{display:flex;flex-direction:column;line-height:1.1}
.hud-left b{font-family:"Black Han Sans",sans-serif;font-size:20px;line-height:1;font-weight:400;color:#fff;font-variant-numeric:tabular-nums}
.hud-left b.warn{color:#ff7a6b}
.hud-left small{font-size:11px;color:var(--muted)}
.hud-mid{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.hud-mid span{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:999px;border:1px solid var(--c);color:#eaf2ff;font-size:12px;font-weight:700;white-space:nowrap;background:#0e1e12}
.hud-mid span b{color:var(--c)}
.hud-mid span.out{opacity:.4;text-decoration:line-through}
.hud-right{display:flex;gap:10px}
.hud-right span{display:inline-flex;align-items:center;gap:4px;font-size:13px;font-weight:900;color:#fff}
.hud-right span[hidden]{display:none}   /* 위 display 가 hidden 속성을 이겨 악마·탈것 칸이 늘 보였다 */
.hud-right img{width:22px;height:22px;image-rendering:pixelated}

/* 스테이지는 세로 기준으로 꽉 차게 — 오니와 같은 방식. 폭 = min(가용 폭, (세로 − 164px) × 680/600).
   164px = 헤더 60 + 위 여백 8 + HUD 42 + 간격 8 + 간격 8 + PING·나가기 줄 34 + 여유 4.
   비율 680/600 은 ka.js 의 BUF_W/BUF_H(격자 600×520 + 사방 40 여백 = 우주선이 나갈 바깥 띠)와 같아야 한다 —
   여백이 있어야 윗줄 머리·좌우 끝 캐릭터·맵 테두리가 둥근 모서리와 overflow 에 잘리지 않는다. */
.ka-stage{position:relative;width:min(100%,calc((100vh - 164px) * 680 / 600));margin:0 auto;aspect-ratio:680/600;border:1px solid #ffffff14;border-radius:22px;background:#050d08;box-shadow:0 10px 30px #0007;overflow:hidden}
@supports (height:100dvh){.ka-stage{width:min(100%,calc((100dvh - 164px) * 680 / 600))}}

/* ── 대전 중 몰입 배치(html.ka-playing — ka.js setImmersive) ──
   사이트 헤더·대기실 패널·규칙·조작 안내줄·뒤로 버튼을 숨기고, HUD 는 스테이지 위에 겹치는 얇은 반투명
   스테이지 바로 위 40px 한 줄로 줄인다. 그러면 세로 상한이 164px → 64px 로 줄어 스테이지 폭 = (100vh − 64px) × 648/556:
   1080p 에서 1,184px(1,068 → +11%), 2560×1440 에서 1,603px. 1080p 에서 +30%(1,388px)는 세로가
   1,191px 필요해 뷰포트(1,080)를 넘으므로 불가능하다 — 세로가 상한인 화면에서는 이것이 최대다.
   body 스크롤을 막아 fixed 배지 등으로 스크롤바가 생기지 않게 한다. */
html.ka-playing body{overflow:hidden}
html.ka-playing .ka-shell>header,html.ka-playing .ka-panels,html.ka-playing .ka-guide,html.ka-playing .ka-controls,html.ka-playing .global-back{display:none}
/* 사이트 공통 떠 있는 위젯(동물 CLICK 배지·접속자 수·지난 게임 결과)도 대전 중에는 맵을 가리므로 숨긴다 */
html.ka-playing #animalLayer,html.ka-playing #onlineCount,html.ka-playing .all-game-history{display:none}
html.ka-playing .ka-main{padding:8px 8px 8px;gap:8px}
/* HUD 를 스테이지 위에 겹치면 작은 창(배율이 낮아 위 여백 28px 가 HUD 보다 얇을 때)에서 맨 윗줄을 가린다 —
   사용자 스크린샷에서 스폰 칸이 HUD 뒤에 숨었다. 겹치지 않고 HUD 40px 를 위에 따로 둔다: 64 = 8 + 40 + 8 + 8. */
html.ka-playing .ka-stage{width:min(100%,calc((100vh - 64px) * 680 / 600))}
@supports (height:100dvh){html.ka-playing .ka-stage{width:min(100%,calc((100dvh - 64px) * 680 / 600))}}
html.ka-playing .ka-hud{position:static;width:min(100%,calc((100vh - 64px) * 680 / 600));margin:0 auto;min-height:40px;max-height:40px;padding:3px 12px;border-color:#ffffff14;background:#141925cc}
#stage{display:block;width:100%;height:100%;touch-action:none;image-rendering:pixelated}

.ka-overlay{position:absolute;inset:0;display:grid;place-items:center;padding:16px;background:#040b06e6;backdrop-filter:blur(4px);overflow-y:auto;transition:opacity .25s ease}
.ka-overlay.hidden{opacity:0;pointer-events:none}
.overlay-inner{width:min(560px,100%);text-align:center;display:flex;flex-direction:column;gap:12px}
.overlay-inner h1{margin:0;font-family:"Black Han Sans",sans-serif;font-size:clamp(26px,4vw,38px);font-weight:400}
.overlay-inner>p:not(.eyebrow){margin:0;font-size:13px;line-height:1.75;color:#b8d9c0}
.ov-status{min-height:18px;font-size:12px;color:var(--cyan)}
.ov-actions{display:flex;justify-content:center;align-items:center;gap:10px;flex-wrap:wrap}
.join-row{display:flex;gap:6px}
.join-row input{width:110px;padding:12px 14px;border:1px solid #ffffff14;border-radius:999px;background:#0c1a10;color:#fff;font-size:15px;font-weight:900;letter-spacing:3px;text-align:center;text-transform:uppercase}
.join-row input:focus{outline:none;border-color:#41d9ee88}

.ka-primary{padding:12px 28px;border:0;border-radius:999px;white-space:nowrap;background:linear-gradient(135deg,#5ee07a,#1f9a5b);color:#04210f;font-size:15px;font-weight:900;cursor:pointer;box-shadow:0 10px 26px #1f9a5b55}
.ka-primary:hover{filter:brightness(1.08)}
.ka-primary:disabled{opacity:.45;cursor:not-allowed;box-shadow:none}
.ka-ghost{padding:11px 20px;border:1px solid #ffffff14;border-radius:999px;white-space:nowrap;background:#0d1a10;color:#cfe5d4;font-size:13px;font-weight:800;cursor:pointer}
.ka-ghost:hover{border-color:#5ee07a66;color:#fff}
.ka-ghost.on{border-color:#5ee07a88;background:#5ee07a1f;color:#9ff0c4}
.ka-ghost.small{padding:5px 11px;font-size:11px}
.ka-ghost.danger{border-color:#ff526555;color:#ff8b9a}

.ov-rooms{margin-top:6px;padding:10px 12px;border:1px solid #ffffff14;border-radius:18px;background:#0a140d}
.rooms-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px;font-size:12px}
.room-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px;max-height:110px;overflow-y:auto}
.room-list button{display:flex;flex-direction:column;gap:1px;padding:7px 9px;border:1px solid #ffffff14;border-radius:14px;background:#0e1c12;color:#dbe6f5;text-align:left;cursor:pointer}
.room-list button:hover{border-color:#5ee07a66}
.room-list button:disabled{opacity:.5;cursor:not-allowed}
.room-list button b{font-size:14px;letter-spacing:2px;color:var(--cyan)}
.room-list button span{font-size:11px}
.room-list button small{font-size:10px;color:var(--muted)}
.ka-empty{margin:6px 0;font-size:11px;color:var(--muted);list-style:none}

.lobby-code{display:flex;align-items:center;justify-content:center;gap:8px;font-size:12px;color:var(--muted)}
.lobby-code b{font-size:30px;font-weight:900;letter-spacing:8px;color:var(--cyan);text-shadow:0 0 22px #41d9ee55}
.lobby-slots{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
@media (max-width:520px){.lobby-slots{grid-template-columns:repeat(2,minmax(0,1fr))}}
.slot{position:relative;aspect-ratio:5/4;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:24px 6px 10px;border:2px solid rgba(255,255,255,.13);border-radius:18px;background:#0c1a10}
.slot.empty{border-style:dashed;background:#0a140d}
.slot.empty::before,.slot.empty::after{content:'';position:absolute;left:50%;top:50%;width:54%;height:6px;border-radius:3px;background:rgba(120,190,150,.2)}
.slot.empty::before{transform:translate(-50%,-50%) rotate(45deg)}
.slot.empty::after{transform:translate(-50%,-50%) rotate(-45deg)}
.slot.filled{border-color:color-mix(in srgb,var(--c) 60%,transparent)}
.slot.me{box-shadow:0 0 0 1px #41d9ee44,0 0 18px #41d9ee38}
.slot.off{opacity:.45;filter:grayscale(.55)}
.slot-name{position:absolute;top:6px;left:50%;transform:translateX(-50%);max-width:88%;padding:2px 9px;border:1px solid rgba(255,255,255,.26);border-radius:7px;background:rgba(6,12,8,.74);font-size:11px;font-weight:800;color:#eaf2ff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.slot-char{display:flex;align-items:center;justify-content:center;font-size:18px;font-style:normal;width:36px;height:36px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff8,var(--c) 60%);box-shadow:0 3px 7px rgba(0,0,0,.45)}
.slot small{font-size:11px;color:#cfe5d4}
/* 맵 고르기 카드. 썸네일(150×130)은 app/static/ka/maps/<key>_thumb.png */
.map-pick{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
@media (max-width:520px){.map-pick{grid-template-columns:repeat(3,minmax(0,1fr))}}
.map-card{display:flex;flex-direction:column;align-items:center;gap:4px;padding:5px 4px;border:2px solid rgba(255,255,255,.13);border-radius:14px;background:#0c1a10;color:#cfe5d4;font-size:11px;font-weight:800;cursor:pointer}
.map-card img{width:100%;aspect-ratio:150/130;object-fit:cover;border-radius:6px;image-rendering:auto}
.map-card .map-random{display:grid;place-items:center;width:100%;aspect-ratio:150/130;border-radius:6px;background:#0a140d;font-style:normal;font-size:28px}
.map-card.on{border-color:#5ee07a;box-shadow:0 0 0 1px #5ee07a44,0 0 14px #5ee07a33;color:#fff}
.map-card:disabled{cursor:default;opacity:.75}
.map-card:not(:disabled):hover{border-color:#5ee07a88}
.map-label{margin:0;font-size:12px;color:var(--cyan)}

.ka-banner{position:absolute;left:50%;top:38%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:6px;pointer-events:none;animation:kaPop .35s ease}
.ka-banner[hidden]{display:none}
.ka-banner.out{animation:kaSlideOut .3s ease-in forwards}
@keyframes kaSlideOut{to{transform:translate(60vw,-50%);opacity:0}}
.ka-banner img{max-width:min(70%,350px);image-rendering:pixelated;filter:drop-shadow(0 6px 14px #000)}
.ka-banner img[hidden]{display:none}
.ka-banner b{padding:6px 14px;border-radius:999px;background:#000b;color:#fff;font-size:15px;font-weight:900}
@keyframes kaPop{from{transform:translate(-50%,-50%) scale(.6);opacity:0}to{transform:translate(-50%,-50%) scale(1);opacity:1}}
.ka-feed{position:absolute;left:10px;bottom:10px;display:flex;flex-direction:column-reverse;gap:3px;pointer-events:none}
.ka-feed div{padding:4px 9px;border-radius:8px;background:#000a;color:#eaf2ff;font-size:11px;font-weight:700}

.ka-controls{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:34px;padding:4px 14px;border:1px solid #ffffff14;border-radius:999px;background:#141925aa;box-sizing:border-box}
/* 채팅은 스테이지 오른쪽에 붙은 고정 패널이다(대기실·대전 모두 펼쳐 둔다). 예전엔 화면 구석에 떠 있는 접힌 창이라
   대전 중에 아무도 못 봤다. 왼쪽 칸(.ka-arena-main)이 남는 폭을 다 받고 스테이지는 그 안에서 가운데 선다 —
   그래서 스테이지 폭 계산(100% = 채팅을 뺀 폭)을 그대로 쓸 수 있다. 대전 중 말은 캐릭터 머리 위 말풍선으로도 뜬다. */
.ka-arena{display:flex;align-items:stretch;gap:10px}
.ka-arena-main{flex:1 1 0;min-width:0;display:flex;flex-direction:column;gap:8px}
.ka-chat{flex:0 0 280px;display:flex;flex-direction:column;min-height:0;border:1px solid #ffffff14;border-radius:22px;background:#0a140df2;box-shadow:0 12px 34px #0008;overflow:hidden}
.ka-chat[hidden]{display:none}
.ka-chat-head{display:flex;align-items:center;gap:8px;padding:10px 14px;background:#122318;color:#eaf2ff;font-weight:900}
.ka-chat-head span{color:var(--cyan);font-size:11px}
.ka-chat-head small{margin-left:auto;color:var(--muted);font-size:11px;font-weight:600}
.ka-chat-body{flex:1 1 0;min-height:0;display:flex;flex-direction:column}
.ka-chat-log{flex:1 1 0;min-height:0;padding:10px 12px;overflow:auto;overscroll-behavior:contain}
.ka-chat-log p{display:grid;grid-template-columns:auto 1fr;gap:8px;margin:0;padding:5px 0;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
.ka-chat-log b{color:#f4d477}
.ka-chat-log span{color:#e6efe8;white-space:pre-wrap}
.ka-chat-form{display:grid;grid-template-columns:1fr auto;gap:6px;padding:8px;border-top:1px solid var(--line)}
.ka-chat-form input{min-width:0;padding:10px;border:1px solid #ffffff14;border-radius:999px;background:#07100a;color:#fff;font-size:16px}
.ka-chat-form button{padding:0 14px;border:0;border-radius:999px;background:#5ee07a;color:#04210f;font-weight:900;cursor:pointer}
@media(max-width:760px){.ka-arena{flex-direction:column}.ka-chat{flex:none}.ka-chat-log{flex:none;height:140px}.ka-chat-head small{display:none}}
.ka-keys{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:11px;color:var(--muted)}
.ka-keys b{color:#dbe6f5;font-size:12px}
.ka-keys i{display:inline-grid;place-items:center;min-width:22px;height:20px;margin:0 1px;padding:0 5px;border:1px solid var(--line);border-radius:5px;background:#13251a;color:#fff;font-style:normal;font-size:10px;font-weight:800}
.ka-net{display:flex;align-items:center;gap:8px;font-size:11px;font-weight:800;color:var(--muted);white-space:nowrap}
.ka-net .stalled{color:#ff8b9a;animation:kaStall 1s ease-in-out infinite}
@keyframes kaStall{0%,100%{opacity:1}50%{opacity:.45}}

.ka-panels{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.ka-panels[hidden]{display:none}
.ka-panel{padding:10px 14px;border:1px solid #ffffff14;border-radius:20px;background:#141925aa;box-shadow:0 6px 20px #0005;min-width:0}
.panel-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
.panel-head b{font-size:13px}
.panel-head small{font-size:10px;color:var(--muted)}
.ka-rank{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:4px;max-height:76px;overflow-y:auto}
.ka-rank li{display:grid;grid-template-columns:22px 1fr auto auto;align-items:center;gap:8px;padding:5px 7px;border-radius:8px;background:#0e1e12;font-size:12px}
.ka-rank li i{font-style:normal;font-weight:900;color:var(--muted);text-align:center}
.ka-rank li:nth-child(1) i{color:#ffd36a}
.ka-rank li:nth-child(2) i{color:#dfe7f2}
.ka-rank li:nth-child(3) i{color:#e0a97a}
.ka-rank li b{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ka-rank li span{font-weight:900;color:var(--cyan)}
.ka-rank li small{font-size:10px;color:var(--muted)}
.ka-history{display:flex;flex-direction:column;gap:4px;max-height:76px;overflow-y:auto}
.ka-history div{display:grid;grid-template-columns:22px 1fr auto auto;align-items:center;gap:8px;padding:5px 7px;border-radius:8px;background:#0e1e12;font-size:12px}
.ka-history div b{font-weight:900;text-align:center}
.ka-history div.win b{color:#54e6d0}
.ka-history div.lose b{color:#ff5265}
.ka-history div span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ka-history div i{font-style:normal;font-weight:800;color:#cfdaea}
.ka-history div small{font-size:10px;color:var(--muted)}

.ka-guide{position:relative;padding:10px 18px;border:1px solid #ffffff14;border-radius:999px;background:#141925aa;font-size:12px;color:#b8d9c0}
/* 규칙을 펼쳐도 페이지가 길어지지 않게 위로 뜨는 카드로 연다(스크롤 방지) */
.ka-guide[open]{border-radius:20px}
.ka-guide[open] ul{position:absolute;left:0;right:0;bottom:calc(100% + 8px);max-height:min(60vh,520px);overflow-y:auto;margin:0;padding:14px 18px 14px 36px;border:1px solid #ffffff14;border-radius:20px;background:#0d121c;box-shadow:0 14px 40px #000a;z-index:20}
.ka-guide summary{font-size:13px;font-weight:800;color:#fff;cursor:pointer}
.ka-guide ul{margin:10px 0 0;padding-left:18px;line-height:1.85}
.ka-guide b{color:var(--gold)}

@media (max-width:760px){
  .ka-panels{grid-template-columns:1fr}
  .ka-hud{grid-template-columns:1fr 1fr}
  .hud-mid{display:none}
  .ka-controls{flex-direction:column;align-items:flex-start}
}

/* ` 화면 가리기. 오니와 같은 모양 — 화면 전체를 검게 덮고 스크린샷을 비율 유지로 띄운다. */
.boss-cover{position:fixed;inset:0;z-index:9999;overflow:hidden;background:#000}
.boss-cover[hidden]{display:none}
.boss-image{display:block;width:100%;height:100%;object-fit:contain;user-select:none}
/* HUD 의 보라색 악마 아이콘: 그림이 붉은 악마와 같아 색상을 보라로 돌린다(붉은 악마 아이콘은 그대로) */
#statDevil img{filter:hue-rotate(-85deg) saturate(1.4)}
/* 대기실: 대전 방식(방장)·내 색(팀). 색 버튼은 그 색 테두리, 고른 것은 채운다 */
.lobby-opts{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:10px 16px}
.color-pick{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.color-label{font-size:11px;font-weight:800;color:var(--muted)}
.color-btn{min-width:44px;padding:7px 10px;border:2px solid var(--c);border-radius:999px;background:#0d1a10;color:#eaf2ff;font-size:12px;font-weight:900;cursor:pointer}
.color-btn.on{background:var(--c);color:#06110a}
.color-btn:disabled{opacity:.3;cursor:not-allowed}
.char-pick{margin-top:6px}
.char-btn{padding:7px 11px;border:2px solid #6b8f73;border-radius:10px;background:#0d1a10;color:#eaf2ff;font-size:12px;font-weight:900;cursor:pointer}
.char-btn.on{background:#f5b700;border-color:#f5b700;color:#06110a}
.char-btn:disabled{opacity:.3;cursor:not-allowed}
.char-stat{flex-basis:100%;font-size:11px;color:var(--muted)}
.slot-charname{display:block;font-size:11px;font-style:normal;color:#f5b700;font-weight:800}
.slot-charsel{font-size:11px;margin-top:2px;background:#0d1a10;color:#eaf2ff;border:1px solid #6b8f73;border-radius:6px}
.slot-team{position:absolute;bottom:-9px;left:50%;transform:translateX(-50%);padding:1px 8px;border-radius:999px;background:var(--c);color:#06110a;font-size:10px;font-style:normal;font-weight:900;white-space:nowrap}
/* 테스트 방: 방장이 봇 색을 바꾸는 점 */
.slot-colors{display:flex;gap:4px}
.slot-colors button{width:14px;height:14px;padding:0;border:2px solid var(--c);border-radius:50%;background:transparent;cursor:pointer}
.slot-colors button.on{background:var(--c)}
/* 색 고르기는 방 제목 바로 아래에 있다(대기실 밖 홈 화면에서는 숨긴다) */
.overlay-inner:has(#ovLobby[hidden]) .lobby-color{display:none}

/* 대기실이 스테이지(세로 약 600px)에 들어가도록 안내 문구를 접고 칸을 낮춘다 — 방 코드·슬롯·맵 고르기·버튼은 그대로 */
.overlay-inner{gap:8px}
.overlay-inner:has(#ovLobby:not([hidden])) #ovText,.overlay-inner:has(#ovLobby:not([hidden])) .eyebrow{display:none}
.overlay-inner:has(#ovLobby:not([hidden])) h1{font-size:clamp(22px,3vw,28px)}
.overlay-inner:has(#ovLobby:not([hidden])) .slot{aspect-ratio:5/3;padding-top:22px}
.overlay-inner:has(#ovLobby:not([hidden])) .slot-char{width:30px;height:30px}
.ov-lobby:not([hidden]){display:flex;flex-direction:column;gap:8px}
.ka-keys span{white-space:nowrap}
.ka-keys{flex-wrap:nowrap;overflow:hidden}
.ka-overlay{border-radius:inherit}
@media (max-height:760px){.ka-guide[open] ul{max-height:50vh}}
.ka-rank li.ka-empty,.ka-rank .ka-empty{display:block;background:none;padding:2px 0;white-space:nowrap}
/* 대기실 스테이지 높이 보정: 위 규칙의 164px 는 패널·규칙 줄을 세지 않아 1440×900 에서 페이지 스크롤이 생겼다.
   패널(~72px)·규칙(~36px)·간격을 더해 300px 를 뺀다. 대전 중(html.ka-playing)은 위의 64px 규칙이 그대로 이긴다. */
html:not(.ka-playing) .ka-stage{width:min(100%,calc((100vh - 300px) * 680 / 600))}
@supports (height:100dvh){html:not(.ka-playing) .ka-stage{width:min(100%,calc((100dvh - 300px) * 680 / 600))}}

/* 첫 화면 「컴퓨터와 대결」 줄 */
.ov-home .ai-row{display:flex;align-items:center;justify-content:center;gap:6px;flex-wrap:wrap;margin-top:4px}
.ov-home .ai-row b{font-size:13px;white-space:nowrap}

/* 승리 랭킹 · 내 기록 · 규칙은 뺐다(사용자 지정). JS 가 hidden 을 풀어도 보이지 않게 — 요소는 남겨 둔다(ka.js 가 쓴다) */
#kaPanels,.ka-guide{display:none!important}
/* 패널 · 규칙이 빠진 만큼 대기실 스테이지를 키운다(300px → 190px) */
html:not(.ka-playing) .ka-stage{width:min(100%,calc((100vh - 190px) * 680 / 600))}
@supports (height:100dvh){html:not(.ka-playing) .ka-stage{width:min(100%,calc((100dvh - 190px) * 680 / 600))}}
