/* ══════════ 기본 ══════════ */
* { margin:0; padding:0; box-sizing:border-box; }
html,body { height:100%; }
body {
  font-family:'Segoe UI','Malgun Gothic',sans-serif;
  background:#0e1420; color:#e8e6e0;
  overflow:hidden;
}
button { cursor:pointer; font-family:inherit; }

/* ══════════ 공통 화면 레이아웃 ══════════ */
.center-screen {
  height:100%; display:flex; align-items:flex-start; justify-content:center;
  background:radial-gradient(ellipse at center,#1a2540 0%,#0e1420 75%);
  overflow-y:auto;
  /* 하단 고정 고지문(#legal-footer)에 내용이 깔리지 않게 실측 높이(--legal-h)만큼 여백 확보 */
  padding:14px 8px calc(var(--legal-h, 12vh) + 14px);
}
/* align-items:center는 내용이 화면보다 길 때 위쪽이 잘려 스크롤로도 못 본다(플렉스 오버플로 클리핑)
   → flex-start + 자식 margin:auto로 "공간 있으면 중앙, 넘치면 위부터 스크롤" */
.center-screen > * { margin:auto; }
.full-screen {
  height:100%; display:flex; flex-direction:column;
  background:#0e1420; overflow:hidden;
  /* 게임 외 화면(덱 편집 등)에서 고정 고지문이 하단 내용을 가리지 않게 — 게임 화면은 푸터가 숨겨져 0 */
  padding-bottom:var(--legal-h, 0px);
}
.screen-head {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:12px 18px; background:#141c30; border-bottom:1px solid #2e3d5e; flex-wrap:wrap;
}
.screen-head h2 { color:#d8c27a; font-size:19px; }
.screen-head input, .screen-head select {
  padding:7px 10px; border-radius:6px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:13px;
}
.mid-btn {
  padding:8px 16px; border-radius:8px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:14px;
}
.mid-btn:hover { background:#2e4370; }
.mid-btn.primary-btn { background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; }
.link-btn { background:none; border:none; color:#7fa8d8; text-decoration:underline; font-size:13px; padding:6px; }
.err-msg { color:#ff9b9b; font-size:13px; min-height:18px; margin-top:8px; }

/* 로그인 */
.login-box { max-width:320px; margin:0 auto; display:flex; flex-direction:column; gap:8px; }
.login-box input {
  padding:11px; border-radius:8px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:15px;
}
.login-btns { display:flex; gap:8px; }
.login-btns .big-btn { flex:1; font-size:16px; padding:11px; }
.login-btns .mid-btn { flex:1; }
.menu-btns { display:flex; flex-direction:column; gap:12px; max-width:320px; margin:0 auto; }
.menu-btns .big-btn { font-size:18px; padding:14px; }

/* 덱 목록 */
.deck-list { flex:1; overflow-y:auto; padding:16px; display:flex; flex-wrap:wrap; gap:12px; align-content:flex-start; }
.deck-card {
  width:250px; background:#182238; border:1px solid #2e3d5e; border-radius:12px; padding:14px;
}
.deck-card h3 { color:#d8c27a; font-size:15px; margin-bottom:4px; }
.deck-card .dk-info { font-size:12px; color:#9aa4bd; line-height:1.6; margin-bottom:8px; }
.deck-card .dk-btns { display:flex; gap:6px; }
.deck-card .dk-btns button { flex:1; padding:5px; font-size:12px; border-radius:6px; border:1px solid #4a6a9a; background:#22335a; color:#dde; }
.deck-card .dk-btns button:hover { background:#2e4370; }
.room-card { width:280px; }
.room-card .join-btn { background:#2a5a2a !important; border-color:#7fe07f !important; }

/* 덱 편집기 */
#editor-body { flex:1; display:flex; min-height:0; }
#ed-pool-panel { flex:1.3; display:flex; flex-direction:column; border-right:1px solid #2e3d5e; min-width:0; }
.ed-filters { display:flex; gap:8px; padding:8px 12px; align-items:center; background:#121a2c; font-size:12px; color:#9aa4bd; flex-wrap:wrap; }
.ed-filters select, .ed-filters input[type=text] {
  padding:6px 8px; border-radius:6px; border:1px solid #3a4a70; background:#0e1626; color:#e8e6e0; font-size:12px;
}
.ed-pool { flex:1; overflow-y:auto; padding:10px; display:flex; flex-wrap:wrap; gap:6px; align-content:flex-start; }
.ed-pool .card-mini { width:86px; height:120px; }
.ed-pool .card-mini .cm-inpool {
  position:absolute; top:-6px; right:-6px; background:#2a5a2a; color:#9f9; border:1px solid #7fe07f;
  border-radius:50%; width:20px; height:20px; font-size:11px; font-weight:bold;
  display:flex; align-items:center; justify-content:center;
}
#ed-deck-panel { flex:1; overflow-y:auto; padding:12px; }
/* 덱 편집기: 선택 카드 상세 영역 */
#ed-inspector { margin-top:12px; padding-top:12px; border-top:1px solid #2a3550; overflow:hidden; }
#ed-inspector img { width:200px; border-radius:10px; float:left; margin:0 14px 8px 0; }
#ed-inspector .insp-name { font-size:20px; }
#ed-inspector .insp-name-en { font-size:12px; }
#ed-inspector .insp-type { font-size:14px; }
#ed-inspector .insp-text { font-size:14px; line-height:1.7; }
/* 덱 편집기: 선택된 풀 카드 + 카드 위 ＋/− 버튼 */
.ed-pool .card-mini.ed-selected { border-color:#d8c27a; box-shadow:0 0 10px #d8c27a99; }
.cm-ctl {
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  gap:8px; background:#00000055; border-radius:4px;
}
.cm-ctl button {
  width:30px; height:30px; border-radius:50%; border:none; color:#fff;
  font-size:16px; font-weight:bold; cursor:pointer; line-height:1;
  box-shadow:0 2px 6px #000a; opacity:.94;
}
.cm-ctl button:hover { opacity:1; transform:scale(1.1); }
.cm-ctl .cm-minus { background:#e05555; }
.cm-ctl .cm-plus  { background:#3fbf6f; }
.ed-section { margin-bottom:14px; font-size:13px; color:#c8d2ea; }
.ed-cardlist { display:flex; flex-wrap:wrap; gap:4px; margin-top:6px; }
.ed-row {
  background:#1c2846; border:1px solid #33436a; border-radius:6px; padding:3px 8px;
  font-size:12px; cursor:pointer; display:flex; gap:6px; align-items:center;
}
.ed-row:hover { background:#3a2a2a; border-color:#a05a5a; }
.ed-row .cnt { color:#ffe07f; font-weight:bold; }
.ed-runes { display:flex; gap:10px; margin-top:6px; flex-wrap:wrap; }
.ed-rune-ctl { display:flex; align-items:center; gap:4px; font-size:13px; background:#1c2846; border-radius:8px; padding:4px 8px; }
.ed-rune-ctl button { width:22px; height:22px; border-radius:4px; border:1px solid #4a6a9a; background:#22335a; color:#dde; }

#net-info { color:#8fe08f; font-size:12px; }

/* ══════════ 설정 화면 ══════════ */
#setup-screen {
  background:radial-gradient(ellipse at center,#1a2540 0%,#0e1420 75%);
}
.setup-box { text-align:center; max-width:900px; padding:24px; }
.setup-box h1 { font-size:34px; margin-bottom:6px; color:#d8c27a; }
.logo-img { height:1.15em; vertical-align:-0.2em; margin-right:4px; }
.subtitle { color:#9aa4bd; margin-bottom:24px; line-height:1.5; }
.setup-players { display:flex; gap:24px; justify-content:center; margin-bottom:24px; flex-wrap:wrap; }
.setup-player {
  background:#182238; border:1px solid #2e3d5e; border-radius:12px;
  padding:18px; width:340px;
}
.setup-player h2 { color:#d8c27a; font-size:18px; margin-bottom:10px; }
.setup-player input, .setup-player select {
  width:100%; padding:8px; margin-bottom:10px; border-radius:6px;
  border:1px solid #3a4a70; background:#0e1626; color:#e8e6e0; font-size:14px;
}
.setup-player label { display:block; text-align:left; font-size:12px; color:#8fa; margin-bottom:4px; }
.legend-preview { min-height:150px; }
.legend-preview img { width:180px; border-radius:8px; }
.legend-preview .lp-text { font-size:12px; color:#b8c2da; margin-top:6px; line-height:1.5; text-align:left; }
.big-btn {
  font-size:20px; padding:14px 42px; border-radius:10px; border:none;
  background:linear-gradient(180deg,#d8c27a,#a8883c); color:#1a1408; font-weight:bold;
}
.big-btn:hover { filter:brightness(1.1); }
.hint { margin-top:16px; font-size:12px; color:#7c86a0; line-height:1.7; }

/* ══════════ 게임 레이아웃 (스크린샷 스타일: 풀보드 + 우측 플로팅 패널) ══════════ */
#game-screen {
  display:flex; height:100%; position:relative;
  background:radial-gradient(ellipse at center,#1a2540 0%,#0e1420 75%);
}
#board {
  position:absolute; top:0; left:0; right:300px; bottom:0;
  display:flex; flex-direction:column; padding:8px 10px; gap:6px;
}
#sidebar {
  position:absolute; top:0; right:0; width:300px; bottom:0;
  display:flex; flex-direction:column; gap:8px; padding:8px;
  background:transparent;
}

/* 우측 턴 정보 패널 */
#turn-panel {
  background:rgba(20,28,48,.92); border:1px solid #2e3d5e; border-radius:10px;
  padding:10px 12px; position:relative; line-height:1.7; font-size:13px;
}
#turn-info { font-weight:bold; color:#fff; font-size:16px; }
#phase-info { color:#9fd8ff; font-size:14px; }
#score-info { font-weight:bold; font-size:13px; }
#btn-help {
  position:absolute; top:8px; right:8px;
  background:none; border:1px solid #3a4a70; border-radius:50%;
  width:24px; height:24px; color:#aab; font-size:12px;
}

/* 덱/손패 카운트 (스크린샷의 Deck/Hand 텍스트) */
.count-display {
  flex:0 0 auto; display:flex; flex-direction:column; justify-content:center;
  font-size:19px; font-weight:bold; color:#fff; line-height:1.5;
  padding:0 10px; white-space:nowrap; text-shadow:0 1px 4px #000c;
}

/* 플레이어 영역 */
.player-area { flex:1; display:flex; gap:8px; min-height:0; }
.player-area.top { flex-direction:row; }
.player-area.bottom { flex-direction:row; }
/* 보드 뒤집기(온라인 게스트가 아래): 내부 요소 순서가 HTML에 고정돼 있어 자리만 바꾸면
   좌우가 반대가 된다 → 역순으로 배치해 원래 모양(위: 사이드 왼쪽 / 아래: 사이드 오른쪽)을 유지 */
.player-area.flipped { flex-direction:row-reverse; }
/* 가로 배분: 기지는 필요한 만큼만 쓰고(상한 있음), 남는 폭은 손패가 가져간다.
   기지는 보통 몇 기만 두는데 예전엔 flex:1이라 넓은 화면에서 빈 공간을 다 차지했다. */
.side-zone {
  flex:0 0 400px; display:flex; flex-wrap:wrap; gap:4px; align-content:flex-start;
  padding:8px; background:rgba(24,34,56,.75); border-radius:10px;
  min-height:0; overflow-y:auto;   /* 룬이 많아도 보드 전체를 밀어내지 않게 */
}
/* 넓은 화면에서는 전설·챔피언 카드를 크게 보여준다 (칸이 넓어진 만큼 실제로 활용) */
@media (min-width:1500px){
  .legend-slot .card-mini, .champ-slot .card-mini { width:112px; height:157px; }
  .legend-slot .card-mini .cm-name, .champ-slot .card-mini .cm-name { font-size:10px; }
}
.base-zone {
  flex:1 2 220px; max-width:360px; border-radius:10px; padding:8px 10px;
  background:rgba(24,34,56,.75);
  display:flex; flex-wrap:wrap; gap:4px; align-content:flex-start; position:relative;
  min-height:0; overflow-y:auto;
}
.zone-label { position:absolute; top:4px; right:10px; font-size:11px; color:#7a8ab0; pointer-events:none; font-weight:bold; }
/* 손패는 가로 스크롤 대신 줄바꿈 — 세로 여백이 남으므로 손패가 많아도 한눈에 다 보인다 */
.hand-zone {
  flex:2 1 340px; max-width:none; min-width:0; display:flex; gap:3px;
  flex-wrap:wrap; align-items:center; align-content:center;
  overflow-x:hidden; overflow-y:auto; padding:8px; background:rgba(24,34,56,.75); border-radius:10px;
}
.hand-zone.opp .card-mini { filter:grayscale(0.2); }
/* '손패 확인'으로 들여다본 봇 손패 — 내 손패와 헷갈리지 않게 점선 테두리로 구분하고,
   보기 전용임을 커서로도 알린다 (확대·정보 표시는 그대로 동작한다) */
.card-mini.peeked { outline:1px dashed #6a7aa0; outline-offset:-2px; opacity:.82; cursor:zoom-in; }
/* 봇 손패 공개 토글 (상대 손패 옆 카운트 영역에 붙는다) */
.peek-btn {
  margin-top:6px; padding:3px 8px; font-size:11px; font-weight:bold; line-height:1.4;
  color:#9aa4bd; background:#16203a; border:1px solid #3a4a70; border-radius:6px;
  cursor:pointer; white-space:nowrap; text-shadow:none;
}
.peek-btn:hover { color:#e8e6e0; border-color:#5a6a90; }
.peek-btn.on { color:#ffd98a; border-color:#8a7a4a; background:#231d12; }

/* 전장 */
#battlefields { flex:0 0 210px; display:flex; gap:12px; align-items:stretch; justify-content:center; }
.battlefield {
  flex:1; max-width:44%; border:2px solid #3a4a70; border-radius:12px;
  background:rgba(22,32,58,.85); padding:6px 8px; position:relative;
  display:flex; flex-direction:column;
}
.battlefield.contested { border-color:#e05a5a; box-shadow:0 0 14px #e05a5a55; }
.battlefield.controlled-0 { border-color:#5a9de0; }
.battlefield.controlled-1 { border-color:#e0a05a; }
.bf-header { display:flex; gap:8px; align-items:center; font-size:12px; margin-bottom:4px; }
.bf-header img { width:88px; border-radius:6px; cursor:pointer; box-shadow:0 2px 8px #0008; }
.bf-name { font-weight:bold; color:#d8c27a; font-size:13px; }
.bf-status { font-size:11px; color:#9aa4bd; }
.bf-units { flex:1; display:flex; gap:4px; flex-wrap:wrap; align-content:flex-start; overflow-y:auto; }
.bf-units .bf-row { display:flex; gap:4px; flex-wrap:wrap; width:100%; }
.bf-row-label { font-size:10px; color:#667; width:100%; }
#center-info { flex:0 0 130px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; }
#pool-display {
  font-size:12px; text-align:center; color:#9fd8ff; line-height:1.6;
  background:rgba(20,28,48,.85); border-radius:8px; padding:8px 12px;
}
#pool-display:empty { display:none; }
#showdown-banner {
  background:#8a2a2a; border:1px solid #e05a5a; padding:6px 10px; border-radius:8px;
  font-size:13px; font-weight:bold; text-align:center; line-height:1.5;
}

/* ══════════ 카드 ══════════ */
.card-mini {
  width:74px; height:104px; border-radius:6px; position:relative; flex:0 0 auto;
  background:#223; background-size:cover; background-position:center;
  border:2px solid #445; cursor:pointer; transition:transform .08s;
  box-shadow:0 2px 5px #0006;
}
.card-mini:hover { transform:scale(1.06); z-index:3; border-color:#d8c27a; }
.card-mini.selected { border-color:#7fe07f; box-shadow:0 0 10px #7fe07f88; }
.card-mini.exhausted { transform:rotate(90deg) scale(0.82); margin:0 14px; }
.card-mini.exhausted:hover { transform:rotate(90deg) scale(0.9); }
.card-mini.playable { border-color:#7fc8ff; box-shadow:0 0 8px #7fc8ff66; }
.card-mini.targetable { border-color:#ffe07f; box-shadow:0 0 12px #ffe07faa; animation:pulse .8s infinite alternate; }
.card-mini.stunned::after { content:'💫'; position:absolute; top:-6px; right:-6px; }
.card-mini.hidden-card { background:#1a2238 !important; display:flex; align-items:center; justify-content:center; font-size:22px; }
@keyframes pulse { from{box-shadow:0 0 6px #ffe07f66;} to{box-shadow:0 0 16px #ffe07fee;} }

.cm-cost {
  position:absolute; top:-5px; left:-5px; background:#123; color:#9fd8ff;
  border:1px solid #4a6a9a; border-radius:50%; width:20px; height:20px;
  font-size:12px; font-weight:bold; display:flex; align-items:center; justify-content:center;
}
.cm-might {
  position:absolute; bottom:-5px; left:-5px; background:#5a1a1a; color:#ffb2b2;
  border:1px solid #a05a5a; border-radius:50%; min-width:20px; height:20px; padding:0 3px;
  font-size:12px; font-weight:bold; display:flex; align-items:center; justify-content:center;
}
.cm-might.buffed { color:#7fe07f; border-color:#7fe07f; }
.cm-might.weakened { color:#ffdf80; }
.cm-dmg {
  position:absolute; bottom:-5px; right:-5px; background:#402; color:#ff8;
  border-radius:50%; min-width:18px; height:18px; font-size:11px; font-weight:bold;
  display:flex; align-items:center; justify-content:center;
}
.cm-buff {
  position:absolute; top:-5px; right:-5px; background:#1a4a1a; color:#9f9;
  border:1px solid #4a8a4a; border-radius:50%; min-width:18px; height:18px; font-size:10px;
  display:flex; align-items:center; justify-content:center;
}
.cm-name {
  position:absolute; bottom:0; left:0; right:0; background:rgba(10,14,24,.85);
  font-size:9px; padding:1px 2px; text-align:center; border-radius:0 0 4px 4px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; pointer-events:none;
}
.card-back { background:linear-gradient(135deg,#26304e,#141c30) !important; }

/* 룬 */
.rune-mini {
  width:40px; height:56px; border-radius:4px; border:2px solid #556; font-size:16px;
  display:flex; align-items:center; justify-content:center; cursor:pointer; flex:0 0 auto;
  background:#1a2238;
}
.rune-mini.exhausted { transform:rotate(90deg) scale(.85); opacity:.55; margin:0 7px; }
.runes-zone { display:flex; gap:3px; flex-wrap:wrap; width:100%; }

/* 전설/챔피언 슬롯 */
.legend-slot,.champ-slot { position:relative; }
.legend-slot .card-mini { border-color:#d8c27a; }
.slot-caption { font-size:10px; color:#8a94b0; text-align:center; }

/* 더미 */
.piles { display:flex; gap:6px; width:100%; }
.pile {
  width:56px; height:74px; border-radius:6px; border:1px solid #33436a;
  background:#182238; display:flex; flex-direction:column; align-items:center; justify-content:center;
  font-size:11px; color:#8a94b0; cursor:pointer;
}
.pile-count { font-size:16px; font-weight:bold; color:#c8d2ea; }

/* ══════════ 카드 정보 패널 (호버 — 작게 표시, 확대는 Alt+클릭/꾹 누르기) ══════════ */
#inspector {
  flex:0 0 auto; max-height:40%; overflow-y:auto; padding:10px;
  background:rgba(20,28,48,.92); border:1px solid #2e3d5e; border-radius:10px;
}
/* 모달(멀리건 등)이 열린 동안엔 어두운 오버레이 위로 올려, 카드 호버 정보가 밝게 보이게 */
body.modal-open #inspector {
  position:relative; z-index:110;
  background:rgba(20,28,48,.98);
}
.insp-placeholder { color:#5a6a90; font-size:12px; text-align:center; padding:14px 0; line-height:1.8; }
#inspector img { width:130px; border-radius:8px; float:left; margin-right:10px; }
.insp-name { font-size:15px; font-weight:bold; color:#d8c27a; }
.insp-name-en { font-size:11px; color:#7c86a0; margin-bottom:4px; }
.insp-type { font-size:12px; color:#9fd8ff; margin-bottom:6px; }
.insp-text { font-size:13px; line-height:1.6; }
.insp-text .kw { color:#ffd27f; font-weight:bold; }
.insp-tags { margin-top:6px; font-size:11px; color:#8a94b0; }
.icon-might { color:#ff9b9b; font-weight:bold; }
.icon-energy { color:#9fd8ff; font-weight:bold; }
.icon-rune { font-weight:bold; }

/* ══════════ 우측 프롬프트/버튼/로그 ══════════ */
#prompt-area {
  flex:0 0 auto; padding:10px 12px; font-size:14px; line-height:1.55;
  background:rgba(20,28,48,.92); border:1px solid #2e3d5e; border-radius:10px;
  min-height:44px; color:#fff;
}
#prompt-area .prompt-title { color:#ffe07f; font-weight:bold; font-size:15px; }
#prompt-area .prompt-btns { margin-top:8px; display:flex; gap:6px; flex-wrap:wrap; }
#prompt-area button {
  padding:5px 13px; border-radius:6px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:13px;
}
#prompt-area button:hover { background:#2e4370; }

#log {
  flex:1; overflow-y:auto; padding:8px 10px; font-size:12px; line-height:1.7;
  background:rgba(18,26,44,.85); border:1px solid #2e3d5e; border-radius:10px;
  min-height:0;
}
#log .log-entry { border-bottom:1px dotted #223; padding:2px 0; }
#log .log-p0 { color:#9fc8ff; }
#log .log-p1 { color:#ffc89f; }
#log .log-sys { color:#8a94b0; }
#log .log-score { color:#ffe07f; font-weight:bold; }
/* 채팅 (온라인 대전 전용) — 사이드바에는 버튼만, 대화는 팝업(#chat-pop)에서 */
#chat-bar { flex:0 0 auto; padding:4px 0; }
#chat-bar button {
  width:100%; padding:6px 10px; border-radius:8px; border:1px solid #3a4a70;
  background:#141c30; color:#b8f0b8; font-size:13px; cursor:pointer; font-family:inherit;
}
#chat-bar button:hover { border-color:#7fe07f; }
#chat-dot {
  display:inline-block; width:9px; height:9px; border-radius:50%;
  background:#ff5252; margin-left:7px; vertical-align:middle;
  box-shadow:0 0 6px #ff5252;
}
/* 채팅 팝업 — 선택 모달(z-index 100+) 아래에 둔다 (게임 진행 방해 금지) */
#chat-pop {
  position:fixed; right:14px; bottom:60px; width:300px; height:360px; z-index:95;
  background:#182238; border:1px solid #3a4a70; border-radius:12px;
  display:flex; flex-direction:column; box-shadow:0 8px 30px rgba(0,0,0,.55);
}
#chat-pop-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 12px; border-bottom:1px solid #2a3856; color:#d8c27a; font-size:14px;
}
#chat-pop-head button {
  background:none; border:none; color:#8090b8; font-size:15px; cursor:pointer; padding:2px 6px;
}
#chat-pop-head button:hover { color:#fff; }
#chat-pop-msgs { flex:1; overflow-y:auto; padding:8px 10px; font-size:13px; }
#chat-pop-msgs .chat-msg { margin-bottom:6px; color:#c8d4ee; word-break:break-word; }
#chat-pop-msgs .chat-msg b { color:#7fe07f; font-weight:600; }
#chat-pop-msgs .chat-msg.mine b { color:#d8c27a; }
#chat-pop input {
  margin:8px; padding:8px 10px; border-radius:8px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:13px; font-family:inherit;
}
#chat-pop input:focus { outline:none; border-color:#7fe07f; }
#log .log-combat { color:#ff9b9b; }

#action-buttons { flex:0 0 auto; display:flex; flex-direction:column; gap:8px; }
.act-btn {
  padding:11px 8px; border-radius:8px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:15px;
  box-shadow:0 2px 6px #0007;
}
.act-btn:hover:not(:disabled) { background:#2e4370; }
.act-btn.primary { background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; }
.act-btn:disabled { opacity:.35; cursor:default; }
.act-btn.armed { background:#2a5a2a; border-color:#7fe07f; }

/* ══════════ 모달 ══════════ */
#modal-overlay {
  position:fixed; inset:0; background:rgba(5,8,16,.8); z-index:100;
  display:flex; align-items:center; justify-content:center;
}
#modal-box {
  background:#182238; border:1px solid #3a4a70; border-radius:14px;
  padding:20px; max-width:860px; max-height:84vh; overflow-y:auto;
}
#modal-box h3 { color:#d8c27a; margin-bottom:12px; font-size:17px; }
.modal-cards { display:flex; gap:8px; flex-wrap:wrap; justify-content:center; }
.modal-cards .card-mini { width:100px; height:140px; }
.modal-cards .card-mini .cm-name { font-size:10px; }
.modal-btns { margin-top:14px; display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
.modal-btns button {
  padding:8px 20px; border-radius:8px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:14px;
}
.modal-btns button.primary { background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; }
.modal-btns button:hover { filter:brightness(1.2); }

/* 컨텍스트 메뉴 */
#ctx-menu {
  position:fixed; z-index:200; background:#1c2846; border:1px solid #4a6a9a;
  border-radius:8px; padding:4px; min-width:160px; box-shadow:0 4px 18px #000a;
}
#ctx-menu .ctx-item { padding:6px 12px; font-size:13px; border-radius:5px; cursor:pointer; }
#ctx-menu .ctx-item:hover { background:#2e4370; }
#ctx-menu .ctx-sep { border-top:1px solid #33436a; margin:3px 0; }
#ctx-menu .ctx-title { padding:4px 12px; font-size:11px; color:#8a94b0; }
/* 선택 메뉴는 바깥 클릭으로 닫히지 않으므로 항상 명시적 닫기를 둔다 */
#ctx-menu .ctx-close { margin-top:3px; border-top:1px solid #33436a; border-radius:0 0 5px 5px; color:#8a94b0; font-size:12px; }
#ctx-menu .ctx-close:hover { background:#3a2a2a; color:#ffb8b8; }

/* 밴 카드 표시 */
.card-mini.banned { outline:2px solid #d05050; outline-offset:-2px; }
.cm-ban {
  position:absolute; top:-6px; right:-6px; font-size:13px;
  background:#4a1a1a; border:1px solid #d05050; border-radius:50%;
  width:20px; height:20px; display:flex; align-items:center; justify-content:center;
}
.ban-flag { color:#ff8a8a; font-weight:bold; }

/* 대회 우승 덱 브라우저 */
.td-meta-head { margin:10px 0 6px; padding:6px 10px; background:#1c2846; border:1px solid #3a4a70; border-radius:8px; color:#d8c27a; font-weight:bold; font-size:14px; }
.td-meta-head .td-period { color:#8a94b0; font-weight:normal; font-size:12px; margin-left:6px; }
.td-event-head { margin:8px 0 2px; font-size:12px; color:#9fd8ff; font-weight:bold; }
.td-row.unavail { opacity:.55; cursor:default; }
.td-row.unavail:hover { background:#182238; border-color:#2e3d5e; }
.td-row { display:flex; gap:8px; align-items:center; padding:7px 10px; margin:4px 0; background:#182238; border:1px solid #2e3d5e; border-radius:8px; cursor:pointer; font-size:13px; }
.td-row:hover { background:#22335a; border-color:#4a6a9a; }
.td-place { flex:0 0 auto; font-size:11px; padding:2px 8px; border-radius:10px; background:#33436a; color:#c8d2ea; }
.td-place.win { background:#6a4a1a; color:#ffe6a0; border:1px solid #d8c27a; }
.td-name { font-weight:bold; color:#e8e6e0; flex:0 0 auto; }
.td-info { color:#8a94b0; font-size:12px; }
.td-cardlist { display:flex; flex-wrap:wrap; gap:4px; margin-top:10px; max-width:760px; }

/* 빌드 버전 표시 (우하단, 클릭 통과) */
/* 선택지 카드 미리보기 — 선택 모달(z-index 110) 위, 전체 확대(400) 아래에 뜬다.
   커서를 따라다니므로 pointer-events는 반드시 none (자기 자신이 hover를 가로채면 깜빡인다) */
#card-hover {
  position:fixed; display:none; z-index:250; pointer-events:none;
  width:240px; overflow:hidden;
  background:#141c30; border:1px solid #4a6a9a; border-radius:10px;
  padding:8px; box-shadow:0 8px 28px #000b;
}
/* aspect-ratio로 높이를 미리 확보한다 — 이미지가 나중에 로드되면서 커지면
   위치 계산이 이미 끝난 뒤라 패널이 화면 밖으로 밀려난다 */
#card-hover img {
  width:100%; aspect-ratio:744/1039; max-height:270px; object-fit:cover;
  border-radius:6px; display:block; margin-bottom:6px;
}
/* 카드가 걸린 선택지 버튼임을 알린다 */
.modal-btns button.has-card { cursor:help; }
.modal-btns button.has-card::after { content:' 🔍'; font-size:11px; opacity:.6; }
/* 폐기장 목록 — 버려진 순서 배지 + 더미 클릭 유도 */
.pile.trash { cursor:pointer; }
.pile.trash:hover { border-color:#8a7a4a; }
.modal-cards .cm-order {
  position:absolute; top:2px; left:2px; min-width:16px; padding:0 3px;
  background:#0a1120e0; border:1px solid #4a6a9a; border-radius:8px;
  font-size:10px; font-weight:bold; color:#ffd98a; text-align:center; line-height:15px;
  pointer-events:none;
}

#build-tag { position:fixed; right:8px; bottom:6px; z-index:50; font-size:11px; color:#5a6a90; pointer-events:none; }

/* 토스트 */
#toast-area { position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:300; display:flex; flex-direction:column; gap:6px; align-items:center; }
.toast {
  background:#26304e; border:1px solid #4a6a9a; color:#e8e6e0;
  padding:8px 18px; border-radius:20px; font-size:13px; box-shadow:0 4px 14px #000a;
  animation:toastIn .2s;
}
.toast.warn { background:#5a3a1a; border-color:#e0a05a; }
@keyframes toastIn { from{opacity:0; transform:translateY(-8px);} to{opacity:1;} }

/* 승리 화면 */
.victory-box { text-align:center; padding:20px 40px; }
.victory-box h2 { font-size:30px; color:#ffe07f; margin-bottom:10px; }

/* ══════════ 카드 확대 (롱프레스 / Alt+클릭) ══════════ */
#card-zoom {
  position:fixed; inset:0; z-index:400; display:none;
  align-items:center; justify-content:center;
  background:rgba(5,8,16,.82); cursor:zoom-out; padding:20px;
}
.cz-box {
  display:flex; gap:20px; max-width:820px; max-height:90vh; cursor:default;
  background:#141c30; border:1px solid #3a4a70; border-radius:16px;
  padding:20px; box-shadow:0 10px 40px #000b; animation:czIn .12s ease-out;
}
@keyframes czIn { from{opacity:0; transform:scale(.94);} to{opacity:1; transform:scale(1);} }
.cz-img { width:340px; max-width:44vw; border-radius:12px; object-fit:contain; align-self:center; }
.cz-noimg { width:280px; height:390px; display:flex; align-items:center; justify-content:center; font-size:80px; background:#1a2238; border-radius:12px; }
.cz-info { flex:1; min-width:0; overflow-y:auto; }
.cz-name { font-size:26px; font-weight:bold; color:#d8c27a; }
.cz-en { font-size:13px; color:#7c86a0; margin-bottom:8px; }
.cz-type { font-size:15px; color:#9fd8ff; margin-bottom:12px; }
.cz-text { font-size:17px; line-height:1.75; color:#e8e6e0; }
.cz-text .kw { color:#ffd27f; font-weight:bold; }
.cz-kw { font-size:13px; color:#9aa4bd; margin-top:8px; line-height:1.6; }
.cz-tags { margin-top:10px; font-size:12px; color:#8a94b0; }
.cz-hint { margin-top:16px; font-size:12px; color:#5a6a90; }
@media (max-width:640px){ .cz-box{flex-direction:column} .cz-img{width:auto;max-width:70vw} }

/* ══════════ 튜토리얼 패널 ══════════ */
#tut-panel {
  position:absolute; top:12px; left:12px; z-index:90;
  width:430px; max-width:42vw; max-height:70vh; overflow-y:auto;
  background:#141c30f2; border:1px solid #d8c27a; border-radius:14px;
  padding:14px 16px; box-shadow:0 8px 30px #000b; font-size:13px;
}
.tut-head { color:#ffe6a0; font-weight:bold; font-size:15px; margin-bottom:8px; }
.tut-step {
  background:#6a4a1a; border-radius:10px; padding:1px 8px; font-size:11px;
  margin-right:6px; color:#ffe6a0;
}
.tut-body { line-height:1.75; color:#e8e6e0; }
.tut-body b { color:#ffd27f; }
.tut-hint {
  margin-top:10px; background:#1a2a4a; border-left:3px solid #7fc8ff;
  padding:6px 10px; border-radius:6px; color:#bfe0ff; font-size:12px;
}
.tut-btns { margin-top:12px; display:flex; gap:8px; align-items:center; }
.tut-btn {
  padding:7px 16px; border-radius:8px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:13px;
}
.tut-btn.primary { background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; }
.tut-btn:hover { filter:brightness(1.2); }
.tut-wait { color:#8a94b0; font-size:12px; flex:1; }

/* ══════════ 페이즈 시작 배너 ══════════ */
#phase-banner {
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  pointer-events:none; z-index:80; opacity:0;
}
#phase-banner.show { animation:pbShow 1.5s ease-out forwards; }
.pb-inner {
  display:flex; align-items:center; gap:14px; padding:16px 44px;
  background:linear-gradient(90deg, transparent, rgba(14,20,32,.92) 18%, rgba(14,20,32,.92) 82%, transparent);
  border-top:2px solid #d8c27a88; border-bottom:2px solid #d8c27a88;
}
.pb-icon { font-size:34px; filter:drop-shadow(0 2px 6px #000a); }
.pb-text { font-size:30px; font-weight:bold; color:#ffe6a0; letter-spacing:4px; text-shadow:0 2px 8px #000c; }
.pb-sub { font-size:14px; color:#9fd8ff; margin-left:8px; text-shadow:0 1px 4px #000a; }
.pb-inner[data-phase="action"] { border-color:#e05a5a99; }
.pb-inner[data-phase="action"] .pb-text { color:#ffb2a0; }
.pb-inner[data-phase="draw"] { border-color:#7fc8ff88; }
.pb-inner[data-phase="draw"] .pb-text { color:#bfe0ff; }
@keyframes pbShow {
  0%   { opacity:0; transform:scale(.92); }
  12%  { opacity:1; transform:scale(1); }
  72%  { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(1.04); }
}

/* 드래그 앤 드롭 이동 */
.drop-hint { outline:3px dashed #7fe07f; outline-offset:-3px; background:rgba(30,80,45,.35) !important; }
.card-mini[draggable="true"] { cursor:grab; }

/* ══════════ P2P 직접 대전 화면 ══════════ */
.p2p-body { flex:1; overflow-y:auto; padding:16px 22px; max-width:1000px; margin:0 auto; width:100%; }
.p2p-common { max-width:460px; margin-bottom:16px; }
.p2p-common label { display:block; font-size:12px; color:#8fa; margin:8px 0 4px; }
.p2p-common input, .p2p-common select {
  width:100%; padding:9px; border-radius:8px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:14px;
}
.p2p-cols { display:flex; gap:16px; flex-wrap:wrap; }
.p2p-col {
  flex:1; min-width:320px; background:#182238; border:1px solid #2e3d5e;
  border-radius:12px; padding:16px; display:flex; flex-direction:column; gap:8px;
}
.p2p-col h3 { color:#d8c27a; font-size:16px; }
.p2p-steps { font-size:12px; color:#9aa4bd; line-height:1.7; padding-left:18px; }
.p2p-col textarea {
  width:100%; height:74px; resize:vertical; border-radius:8px; padding:8px;
  border:1px solid #3a4a70; background:#0e1626; color:#9fd8ff; font-size:11px; font-family:monospace;
}
.p2p-status { min-height:20px; font-size:13px; color:#ffe07f; line-height:1.5; }
/* ── 6자리 방 코드 ── */
.p2p-code-box {
  background:#0e1626; border:1px solid #3a4a70; border-radius:10px;
  padding:12px; display:flex; flex-direction:column; gap:8px; align-items:center;
}
.p2p-code-label { font-size:11px; color:#8fa; letter-spacing:.5px; }
.p2p-code {
  font-family:monospace; font-size:34px; font-weight:700; letter-spacing:6px;
  color:#ffe07f; text-shadow:0 0 12px rgba(255,224,127,.35); user-select:all;
}
.p2p-code-in {
  width:100%; padding:12px; border-radius:8px; border:1px solid #3a4a70;
  background:#0e1626; color:#ffe07f; font-family:monospace; font-weight:700;
  font-size:26px; letter-spacing:5px; text-align:center; text-transform:uppercase;
}
.p2p-code-in::placeholder { color:#44557a; letter-spacing:5px; }

/* ── 고급(폴백) 접이식 ── */
.p2p-adv { margin-top:18px; border-top:1px solid #2e3d5e; padding-top:12px; }
.p2p-adv > summary {
  cursor:pointer; font-size:13px; color:#9aa4bd; padding:6px 2px; user-select:none;
}
.p2p-adv > summary:hover { color:#d8c27a; }
.p2p-adv-body { padding-top:10px; }
.p2p-adv-body > label { display:block; font-size:12px; color:#8fa; margin:6px 0 4px; }
.p2p-adv-body > input {
  width:100%; max-width:520px; padding:9px; border-radius:8px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:13px;
}
.hint-inline { color:#6b7a99; font-weight:400; }


/* ══════════ Riot 팬 콘텐츠 정책 필수 고지 ══════════ */
#legal-footer {
  position:fixed; left:0; right:0; bottom:0; z-index:50;
  background:rgba(10,14,24,.9); border-top:1px solid #2e3d5e;
  color:#7c86a0; font-size:10px; line-height:1.5; text-align:center;
  padding:5px 14px; max-height:22vh; overflow-y:auto;
}
#legal-footer .legal-en { color:#5a6a90; }

/* 규칙 처리 모드 체크박스 */
.mode-chk { display:inline-flex; align-items:center; gap:5px; font-size:13px; color:#c8d2ea; cursor:pointer; }
.mode-chk input { width:15px; height:15px; }

/* 로그 안의 카드명: 호버 시 인스펙터 표시 */
.log-card { color:#d8c27a; text-decoration:underline dotted; cursor:help; }
.log-card:hover { color:#ffe6a0; }

/* 폭이 넉넉하지 않은 데스크톱 창에서는 사이드(전설·룬·더미) 칸을 조금 줄여 손패에 양보 */
@media (max-width:1500px){ .side-zone{ flex-basis:248px; } }

/* ══════════ 모바일 반응형 (세로 화면) ══════════ */
@media (max-width:820px){
  #turn-panel{ font-size:12px; padding:6px 8px; }
  #turn-info{ font-size:14px; } #phase-info{ font-size:12px; }
  .player-area{ gap:4px; }
  .side-zone{ flex-basis:104px; padding:4px; gap:3px; }
  #battlefields{ flex:0 0 auto; gap:6px; }
  .battlefield{ padding:4px; }
  /* 좁은 화면에서는 예전 배분(기지가 남는 폭을 차지)이 더 낫다 — 데스크톱 전용 배분을 되돌린다 */
  .base-zone{ flex:1 1 auto; max-width:none; }
  .hand-zone{ flex:0 0 auto; max-width:100%; padding:5px; }
  .card-mini{ width:58px; height:82px; }
  .rune-mini{ width:26px; height:36px; font-size:13px; }
  #log{ font-size:11px; }
  /* 메뉴/설정 화면: 카드 폭 축소, 세로 정렬 */
  .setup-box{ padding:16px 12px; }
  .setup-box h1{ font-size:26px; }
  .setup-players{ flex-direction:column; align-items:center; }
  .setup-player{ width:100%; max-width:360px; }
  .screen-head{ flex-direction:column; align-items:stretch; gap:6px; }
  .screen-head > div{ display:flex; flex-wrap:wrap; gap:6px; }
  .p2p-cols{ flex-direction:column; }
  .ed-pool .card-mini{ width:64px; height:90px; }
  #editor-body{ flex-direction:column; }
  /* 세로 배치에서는 세로축이 주축이 된다 — min-height:0이 없으면 카드 풀이 내용만큼
     화면 밖까지 커져(overflow:hidden에 잘림) 아래 카드를 스크롤로도 못 본다 */
  #ed-pool-panel{ min-height:0; border-right:none; border-bottom:1px solid #2e3d5e; }
  #ed-deck-panel{ min-height:0; }
  .ed-pool{ min-height:0; }
  .cz-box{ flex-direction:column; max-width:94vw; }
  .cz-img{ width:auto; max-width:80vw; max-height:52vh; }
  /* ── 모달(멀리건 등) 모바일 보정 ── */
  /* 모바일은 호버가 없어 탭 순간 인스펙터가 모달 버튼을 덮는 문제 → 승격 해제 (카드 확대는 꾹 누르기) */
  body.modal-open #inspector{ position:static; z-index:auto; }
  #modal-box{ max-width:94vw; max-height:86vh; padding:14px; }
  .modal-cards{ gap:6px; }
  .modal-cards .card-mini{ width:76px; height:106px; }
  .modal-btns{ margin-top:10px; }
  .modal-btns button{ padding:12px 16px; font-size:15px; } /* 터치 타깃 확대 */
  .card-mini{ -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; } /* 꾹 누르기 확대와 텍스트 선택 충돌 방지 */
  .td-row{ flex-wrap:wrap; }
}
/* 가로가 매우 좁은 소형 폰 */
@media (max-width:480px){
  .card-mini{ width:50px; height:70px; }
  .cm-name{ font-size:8px; }
}

/* ══════════ 모바일 세로: 게임 화면 = 보드(스크롤) + 하단 고정 버튼 바 ══════════ */
@media (max-width:820px) and (orientation:portrait){
  #game-screen{ display:flex; flex-direction:column; }
  #board{ position:static; inset:auto; flex:1 1 auto; padding:4px; gap:4px; min-height:0; overflow-y:auto; }
  /* 사이드바: 버튼 바 높이만큼 하단 여백을 두고 내부 스크롤 — 어떤 내용이 와도 버튼을 밀어내지 못함 */
  #sidebar{
    position:static; width:auto; flex:0 0 auto; max-height:42vh;
    padding:4px 4px calc(58px + env(safe-area-inset-bottom)); gap:4px; overflow-y:auto;
  }
  #inspector{ flex:0 0 auto; max-height:20vh; }
  #inspector img{ width:84px; }
  #log{ flex:0 0 auto; max-height:14vh; }
  /* 턴 종료/이동/패스: 화면 하단 고정 가로 바 (항상 보임) */
  #action-buttons{
    position:fixed; left:0; right:0; bottom:0; z-index:60;
    flex-direction:row; gap:6px;
    padding:6px 8px calc(6px + env(safe-area-inset-bottom));
    background:rgba(20,28,48,.97); border-top:1px solid #2e3d5e;
  }
  #action-buttons .act-btn{ flex:1 1 0; padding:12px 2px; font-size:14px; }
  #build-tag{ bottom:calc(56px + env(safe-area-inset-bottom)); }
}

/* ══════════ 모바일 가로 (APK 기본): 스크롤 없이 전체 보드 + 로그 상시 표시 ══════════ */
@media (orientation:landscape) and (max-height:520px){
  #game-screen{ display:flex; flex-direction:row; }
  /* 보드/사이드바 모두 overflow:hidden — 내부 섹션 높이를 통제해 '잘려서 안 보이는' 상황 자체를 없앤다 */
  #board{ position:absolute; top:0; left:0; right:206px; bottom:0; padding:3px 4px; gap:3px; overflow:hidden; }
  #sidebar{ position:absolute; top:0; right:0; bottom:0; width:206px; padding:3px; gap:3px; overflow:hidden; }

  /* ── 보드: 상대/전장/나 3행이 항상 모두 보이게 비례 축소 ── */
  .player-area{ flex:1 1 0; min-height:0; gap:3px; }
  .side-zone{ flex:0 0 150px; padding:3px; gap:2px; overflow-y:auto; }
  .base-zone{ flex:1 1 auto; max-width:none; padding:3px 4px; gap:2px; }
  /* 모바일 가로는 높이가 빠듯해 줄바꿈 대신 기존처럼 가로 스크롤 유지 */
  .hand-zone{ flex:0 0 auto; max-width:42%; padding:3px; gap:2px; flex-wrap:nowrap; overflow-x:auto; }
  .zone-label{ font-size:8px; top:2px; right:5px; }
  .card-mini{ width:40px; height:56px; border-width:1px; }
  .cm-name{ font-size:6px; }
  .cm-cost{ width:14px; height:14px; font-size:9px; top:-3px; left:-3px; }
  .cm-might{ min-width:14px; height:14px; font-size:9px; padding:0 2px; bottom:-3px; left:-3px; }
  .cm-dmg{ min-width:13px; height:13px; font-size:8px; bottom:-3px; right:-3px; }
  .cm-buff{ min-width:13px; height:13px; font-size:8px; top:-3px; right:-3px; }
  .rune-mini{ width:18px; height:26px; font-size:9px; }
  .rune-mini.exhausted{ margin:0 4px; }
  .piles{ gap:3px; }
  .pile{ width:32px; height:44px; font-size:8px; border-radius:4px; }
  .pile-count{ font-size:11px; }
  .slot-caption{ font-size:7px; }
  #battlefields{ flex:0 0 auto; gap:4px; min-height:0; }
  .battlefield{ padding:3px 4px; max-width:none; }
  .bf-header{ gap:4px; margin-bottom:2px; }
  .bf-header img{ width:34px; }
  .bf-name{ font-size:10px; }
  .bf-status{ font-size:8px; }
  .bf-units{ gap:2px; }
  .bf-row-label{ font-size:7px; }

  /* ── 사이드바: 인스펙터를 제한하고 로그는 최소 높이를 보장 (항상 보임) ── */
  #turn-panel{ flex:0 0 auto; font-size:10px; padding:3px 5px; }
  #turn-info{ font-size:11px; } #phase-info{ font-size:10px; }
  #inspector{ flex:0 0 auto; max-height:88px; padding:4px 5px; }
  #inspector img{ width:44px; margin-right:5px; }
  .insp-name{ font-size:11px; }
  .insp-name-en{ font-size:8px; margin-bottom:1px; }
  .insp-type{ font-size:9px; margin-bottom:2px; }
  .insp-text{ font-size:9.5px; line-height:1.45; }
  .insp-tags{ font-size:8px; margin-top:2px; }
  #prompt-area{ flex:0 0 auto; max-height:78px; overflow-y:auto; font-size:10.5px; line-height:1.45; min-height:26px; padding:4px 6px; }
  #prompt-area .prompt-title{ font-size:11px; }
  #prompt-area button{ padding:3px 8px; font-size:10px; }
  #log{ flex:1 1 auto; min-height:44px; font-size:9px; line-height:1.5; padding:3px 5px; }
  /* 버튼: 하단 가로 1줄 (섹션 높이 통제로 밀려날 수 없음) */
  #action-buttons{
    position:static; margin-top:0; flex:0 0 auto;
    flex-direction:row; gap:3px; padding:0; background:none; border:0;
  }
  #action-buttons .act-btn{ flex:1 1 0; padding:9px 2px; font-size:11px; }
  #build-tag{ display:none; }
  #modal-box{ max-height:94vh; padding:10px; }
  .modal-cards .card-mini{ width:64px; height:90px; }
  .modal-cards .card-mini .cm-name{ font-size:8px; }
}

/* ══════════ 리플레이: 보관함 카드 + 재생 컨트롤 바 ══════════ */
.rp-card { width:300px; }
.rp-card .dk-btns button.rp-play { background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; }
#rp-path { color:#7d879e; font-size:12px; }

#replay-bar {
  position:fixed; left:0; right:0; bottom:0; z-index:90;
  display:flex; flex-direction:column; gap:5px;
  padding:8px 14px calc(8px + env(safe-area-inset-bottom));
  background:rgba(14,20,32,.96); border-top:1px solid #4a6a9a;
  box-shadow:0 -4px 16px #0009;
}
#replay-bar .rb-head { display:flex; align-items:center; gap:12px; font-size:12px; color:#9aa4bd; }
#replay-bar .rb-tag { color:#ffd9a8; font-weight:bold; }
#replay-bar #rb-pos { margin-left:auto; color:#dde; font-variant-numeric:tabular-nums; }
#replay-bar #rb-close {
  padding:5px 12px; border-radius:6px; border:1px solid #4a6a9a;
  background:#22335a; color:#dde; font-size:12px;
}
#replay-bar #rb-close:hover { background:#2e4370; }
#rb-slider { width:100%; accent-color:#d8c27a; height:18px; }
#replay-bar .rb-ctrls { display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap; }
#replay-bar .rb-ctrls button {
  min-width:46px; padding:7px 12px; border-radius:7px;
  border:1px solid #4a6a9a; background:#22335a; color:#dde; font-size:14px;
}
#replay-bar .rb-ctrls button:hover { background:#2e4370; }
#replay-bar .rb-ctrls button.primary {
  background:#6a4a1a; border-color:#d8c27a; color:#ffe6a0; font-weight:bold; min-width:104px;
}
#replay-bar .rb-ctrls select {
  padding:6px 8px; border-radius:6px; border:1px solid #3a4a70;
  background:#0e1626; color:#e8e6e0; font-size:12px; margin-left:6px;
}
/* 관전 중에는 보드/사이드바를 컨트롤 바 위로 올린다 (#board·#sidebar보다 우선순위가 높다) */
body.replay-mode #board, body.replay-mode #sidebar { bottom:118px; }
body.replay-mode .card-mini { cursor:default; }
body.replay-mode #legal-footer { display:none; }

@media (max-width:820px){
  .rp-card { width:100%; }
  #replay-bar .rb-ctrls button { min-width:40px; padding:6px 8px; font-size:13px; }
  #replay-bar .rb-ctrls button.primary { min-width:88px; }
}
/* 모바일 가로(APK): 한 줄로 압축 */
@media (orientation:landscape) and (max-height:520px){
  #replay-bar { padding:3px 6px calc(3px + env(safe-area-inset-bottom)); gap:2px; }
  #replay-bar .rb-head { font-size:9px; gap:6px; }
  #replay-bar #rb-close { padding:2px 7px; font-size:9px; }
  #rb-slider { height:12px; }
  #replay-bar .rb-ctrls { gap:3px; flex-wrap:nowrap; }
  #replay-bar .rb-ctrls button { min-width:30px; padding:4px 5px; font-size:10px; }
  #replay-bar .rb-ctrls button.primary { min-width:58px; }
  #replay-bar .rb-ctrls select { font-size:9px; padding:3px 4px; margin-left:3px; }
  body.replay-mode #board, body.replay-mode #sidebar { bottom:72px; }
}

/* ══════════ 룬: 실제 카드 이미지 + 영역 배지 ══════════ */
.rune-mini { background:#1a2238 center/cover no-repeat; position:relative; overflow:hidden; }
.rune-mini .rm-dom {
  position:absolute; right:1px; bottom:0; font-size:11px; line-height:1;
  text-shadow:0 0 3px #000,0 0 3px #000,0 1px 2px #000; pointer-events:none;
}

/* ══════════ 연출(이펙트) — 표시 전용, 클릭을 가로채지 않는다 ══════════ */
#fx-layer { position:fixed; inset:0; pointer-events:none; z-index:95; overflow:hidden; }
#fx-layer > * { position:absolute; pointer-events:none; }

/* 유닛 반응 */
.fx-unit { border-radius:6px; display:flex; align-items:center; justify-content:center; }
.fx-num {
  position:absolute; bottom:60%; font-weight:bold; font-size:20px; white-space:nowrap;
  text-shadow:0 0 4px #000,0 2px 4px #000; animation:fxRise .9s ease-out forwards;
}
@keyframes fxRise { 0%{opacity:0;transform:translateY(6px) scale(.8)} 20%{opacity:1;transform:translateY(-2px) scale(1.15)}
                    70%{opacity:1;transform:translateY(-16px) scale(1)} 100%{opacity:0;transform:translateY(-30px) scale(.95)} }

.fx-hit { box-shadow:0 0 0 2px #ff5a5a inset, 0 0 18px #ff3b3b; background:rgba(255,60,60,.28);
          animation:fxShake .42s ease-out forwards; }
.fx-hit .fx-num { color:#ff8a8a; }
@keyframes fxShake { 0%{transform:translate(0)} 15%{transform:translate(-4px,2px)} 30%{transform:translate(4px,-2px)}
                     45%{transform:translate(-3px,-1px)} 60%{transform:translate(3px,1px)} 100%{transform:translate(0);opacity:0} }

.fx-buff { box-shadow:0 0 0 2px #7fe07f inset, 0 0 20px #6ade6a; background:rgba(90,220,120,.22);
           animation:fxFade .8s ease-out forwards; }
.fx-buff .fx-num { color:#a8f5a8; }

.fx-ready { box-shadow:0 0 0 2px #ffe07f inset, 0 0 22px #ffd24a; background:rgba(255,220,120,.2);
            animation:fxFade .8s ease-out forwards; }

.fx-die { background:radial-gradient(circle,rgba(255,80,80,.55),rgba(20,0,0,.15) 70%);
          animation:fxDie .7s ease-in forwards; }
@keyframes fxDie { 0%{opacity:1;transform:scale(1) rotate(0)} 100%{opacity:0;transform:scale(.55) rotate(12deg)} }
@keyframes fxFade { 0%{opacity:0} 15%{opacity:1} 100%{opacity:0} }

/* 카드/능력 발동 */
.fx-cast {
  left:50%; top:38%; transform:translate(-50%,-50%);
  display:flex; flex-direction:column; align-items:center; gap:6px;
  animation:fxCast 1.1s cubic-bezier(.16,.9,.3,1) forwards;
}
.fx-cast img { width:150px; border-radius:9px; box-shadow:0 0 26px #000c, 0 0 46px currentColor; }
.fx-cast-cap {
  font-size:15px; font-weight:bold; color:#fff; padding:3px 12px; border-radius:20px;
  background:rgba(10,14,24,.85); border:1px solid currentColor; text-shadow:0 1px 3px #000;
  max-width:60vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.fx-cast-p0 { color:#9fc8ff; } .fx-cast-p1 { color:#ffc89f; }
@keyframes fxCast { 0%{opacity:0;transform:translate(-50%,-50%) scale(.72)}
                    18%{opacity:1;transform:translate(-50%,-50%) scale(1.04)}
                    70%{opacity:1;transform:translate(-50%,-50%) scale(1)}
                    100%{opacity:0;transform:translate(-50%,-58%) scale(1.02)} }

/* 턴 종료 띠 */
.fx-band {
  left:0; right:0; top:44%; height:66px; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(90deg,transparent,rgba(10,14,24,.92) 18%,rgba(10,14,24,.92) 82%,transparent);
  animation:fxBand 1s ease-out forwards;
}
.fx-band span { font-size:23px; font-weight:bold; letter-spacing:2px; text-shadow:0 2px 8px #000; }
.fx-band-p0 span { color:#9fc8ff; } .fx-band-p1 span { color:#ffc89f; }
.fx-band-p0 { border-top:2px solid #4a7ab8; border-bottom:2px solid #4a7ab8; }
.fx-band-p1 { border-top:2px solid #b87a4a; border-bottom:2px solid #b87a4a; }
.fx-band { animation-duration:1.6s; }
@keyframes fxBand { 0%{opacity:0;transform:scaleX(.2)} 14%{opacity:1;transform:scaleX(1)}
                    80%{opacity:1;transform:scaleX(1)} 100%{opacity:0;transform:scaleX(1.05)} }

/* 턴 시작 대형 띠 — 턴 전환은 가장 중요한 신호라 크고 길게 (2.4초) */
.fx-turnstart { height:96px; animation:fxBandBig 2.4s cubic-bezier(.2,.7,.3,1) forwards; }
.fx-turnstart span { font-size:34px; letter-spacing:5px; }
.fx-turnstart.fx-band-p0 {
  background:linear-gradient(90deg,transparent,rgba(18,36,72,.95) 16%,rgba(18,36,72,.95) 84%,transparent);
  border-top:3px solid #5a90d8; border-bottom:3px solid #5a90d8; box-shadow:0 0 44px rgba(90,144,216,.45);
}
.fx-turnstart.fx-band-p1 {
  background:linear-gradient(90deg,transparent,rgba(72,40,16,.95) 16%,rgba(72,40,16,.95) 84%,transparent);
  border-top:3px solid #d8905a; border-bottom:3px solid #d8905a; box-shadow:0 0 44px rgba(216,144,90,.45);
}
@keyframes fxBandBig { 0%{opacity:0;transform:scaleX(.12)} 10%{opacity:1;transform:scaleX(1.02)}
                       16%{transform:scaleX(1)} 84%{opacity:1;transform:scaleX(1)}
                       100%{opacity:0;transform:scaleX(1.04)} }

/* 행동 차례 전환 배지 — 1.8초, 크게 */
.fx-turnbadge {
  left:50%; top:14%; transform:translateX(-50%);
  padding:8px 22px; border-radius:22px; font-size:19px; font-weight:bold;
  background:rgba(10,14,24,.94); border:2px solid currentColor; text-shadow:0 1px 3px #000;
  box-shadow:0 0 22px currentColor;
  animation:fxBadge 1.8s ease-out forwards;
}
.fx-turnbadge-p0 { color:#9fc8ff; } .fx-turnbadge-p1 { color:#ffc89f; }
@keyframes fxBadge { 0%{opacity:0;transform:translateX(-50%) translateY(-12px) scale(.9)}
                     10%{opacity:1;transform:translateX(-50%) translateY(0) scale(1.05)}
                     16%{transform:translateX(-50%) scale(1)}
                     85%{opacity:1} 100%{opacity:0;transform:translateX(-50%) translateY(-6px)} }
/* 진영 테두리 펄스 — 진영 색으로, 두 박자(강→약)로 길게 */
.player-area.fx-pulse { animation:fxPulse 1.8s ease-out; border-radius:10px; }
.player-area.fx-pulse-p0 { --pulse:90,150,255; }
.player-area.fx-pulse-p1 { --pulse:255,160,84; }
@keyframes fxPulse { 0%{box-shadow:0 0 0 0 rgba(var(--pulse,255,224,127),0)}
                     15%{box-shadow:0 0 0 5px rgba(var(--pulse,255,224,127),.9),0 0 38px rgba(var(--pulse,255,224,127),.5)}
                     60%{box-shadow:0 0 0 3px rgba(var(--pulse,255,224,127),.45),0 0 20px rgba(var(--pulse,255,224,127),.25)}
                     100%{box-shadow:0 0 0 0 rgba(var(--pulse,255,224,127),0)} }

/* 득점 */
.fx-score {
  left:50%; top:30%; transform:translateX(-50%);
  font-size:40px; font-weight:bold; color:#ffe07f; text-shadow:0 0 14px #ffb84a,0 3px 8px #000;
  animation:fxScore 1.2s ease-out forwards;
}
@keyframes fxScore { 0%{opacity:0;transform:translateX(-50%) scale(.5)}
                     20%{opacity:1;transform:translateX(-50%) scale(1.25)}
                     45%{transform:translateX(-50%) scale(1)}
                     100%{opacity:0;transform:translateX(-50%) translateY(-40px) scale(1)} }

/* 좁은 화면에서는 연출을 줄인다 */
@media (orientation:landscape) and (max-height:520px){
  .fx-cast img { width:88px; } .fx-cast-cap { font-size:11px; padding:2px 8px; }
  .fx-band { height:40px; } .fx-band span { font-size:15px; }
  .fx-turnstart { height:58px; } .fx-turnstart span { font-size:21px; letter-spacing:3px; }
  .fx-turnbadge { font-size:13px; padding:5px 14px; top:8%; }
  .fx-score { font-size:24px; }
  .fx-num { font-size:14px; }
  .rune-mini .rm-dom { font-size:8px; }
}
@media (max-width:820px){
  .fx-cast img { width:110px; } .fx-cast-cap { font-size:12px; }
  .fx-band span { font-size:17px; } .fx-score { font-size:30px; }
}
/* 동작 최소화를 선호하는 사용자: 움직임 없이 짧게만 표시 */
@media (prefers-reduced-motion:reduce){
  #fx-layer * { animation-duration:.2s !important; animation-timing-function:linear !important; }
  .fx-hit { animation-name:fxFade !important; }
}

/* 체인 적재 연출: 발동 연출과 같은 모양이되 2초간 유지 */
.fx-cast.fx-chain { animation-duration:2s; }

/* ── 확대 화면의 일러스트 선택 ── */
.cz-arts { margin:10px 0 4px; }
.cz-arts-title { font-size:12px; color:#8fa; margin-bottom:6px; }
.cz-arts-row { display:flex; gap:8px; flex-wrap:wrap; }
.cz-art {
  width:56px; height:78px; border-radius:6px; cursor:pointer;
  background-size:cover; background-position:center;
  border:2px solid #3a4a70; padding:0; transition:border-color .12s, transform .12s;
}
.cz-art:hover { transform:translateY(-2px); border-color:#8fa; }
.cz-art.on { border-color:#ffe07f; box-shadow:0 0 8px rgba(255,224,127,.5); }
