/* 행동 주체의 진영 경계를 감싸는 표시. 상대는 같은 모양을 위아래로 뒤집는다. */
#turn-glow {
  display:none; position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:90;
  --turn-glow-rgb:65,160,255;
  --turn-glow-radius:clamp(20px,3vw,32px);
  --turn-glow-rise:clamp(44px,62%,140px);
  border-radius:0 0 var(--turn-glow-radius) var(--turn-glow-radius);
  box-shadow:inset 0 -10px 22px -14px rgba(var(--turn-glow-rgb),.65);
}
.player-area > #turn-glow[data-side="mine"], .player-area > #turn-glow[data-side="opponent"] { display:block; }
#turn-glow[data-side="opponent"] { transform:scaleY(-1); --turn-glow-rgb:245,75,85; }
#turn-glow::before, #turn-glow::after { content:""; position:absolute; transform-origin:center bottom; }
#turn-glow::before {
  inset:auto 0 0; height:clamp(22px,24%,58px);
  background:linear-gradient(to top,rgba(var(--turn-glow-rgb),.34),rgba(var(--turn-glow-rgb),.1) 42%,transparent),
    radial-gradient(ellipse at 40% 110%,rgba(var(--turn-glow-rgb),.26),transparent 72%);
  animation:turn-glow-base 4.8s ease-in-out infinite;
}
#turn-glow::after {
  inset:0;
  background:
    radial-gradient(ellipse 68px 60px at 24px calc(100% - 18px),rgba(var(--turn-glow-rgb),.3),transparent 85%),
    radial-gradient(ellipse 68px 60px at calc(100% - 24px) calc(100% - 18px),rgba(var(--turn-glow-rgb),.3),transparent 85%),
    radial-gradient(ellipse at left bottom,rgba(var(--turn-glow-rgb),.55),rgba(var(--turn-glow-rgb),.18) 34%,transparent 76%) left bottom / 32px var(--turn-glow-rise) no-repeat,
    radial-gradient(ellipse at right bottom,rgba(var(--turn-glow-rgb),.55),rgba(var(--turn-glow-rgb),.18) 34%,transparent 76%) right bottom / 32px var(--turn-glow-rise) no-repeat,
    linear-gradient(to top,rgba(var(--turn-glow-rgb),.55),transparent) left bottom / 1px var(--turn-glow-rise) no-repeat,
    linear-gradient(to top,rgba(var(--turn-glow-rgb),.55),transparent) right bottom / 1px var(--turn-glow-rise) no-repeat;
  animation:turn-glow-sides 5.7s ease-in-out -1.4s infinite;
}
@keyframes turn-glow-base {
  0%,100% { transform:scaleY(.75); opacity:.6; }
  50% { transform:scaleY(1); opacity:.9; }
}
@keyframes turn-glow-sides {
  0%,100% { transform:scaleY(.88); opacity:.6; }
  50% { transform:scaleY(1); opacity:.85; }
}
@media (prefers-reduced-motion:reduce) {
  #turn-glow[data-side]::before, #turn-glow[data-side]::after { animation:none; opacity:.4; }
}

/* ══════════ 기본 ══════════ */
* { 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; isolation:isolate;
}
#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; }
#turn-panel #turn-info, #turn-panel #phase-info { padding-right:40px; }
#btn-settings {
  position:absolute; top:8px; right:8px;
  background:none; border:1px solid #3a4a70; border-radius:50%;
  width:34px; height:34px; padding:0; color:#cbd5e8; font-size:24px;
  display:flex; align-items:center; justify-content:center; line-height:1;
}

/* 덱/손패 카운트 (스크린샷의 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 { position:relative; flex:1; display:flex; gap:8px; min-height:0; }
.player-area.top { flex-direction:row; }
.player-area.bottom { flex-direction:row; }
#board.playmat-upper::before, #board.playmat-lower::after {
  content:""; position:absolute; pointer-events:none; z-index:-1;
  left:var(--playmat-left); width:var(--playmat-width);
  background-position:center; background-size:100% auto; background-repeat:no-repeat;
  opacity:.75; border-radius:10px;
}
#board.playmat-upper::before {
  top:var(--playmat-upper-top); height:var(--playmat-upper-height);
  background-image:var(--playmat-upper-image);
  transform:rotate(180deg);
}
#board.playmat-lower::after {
  top:var(--playmat-lower-top); height:var(--playmat-lower-height);
  background-image:var(--playmat-lower-image);
}
#board.has-playmat .battlefield {
  background:linear-gradient(to bottom,var(--playmat-upper-shade) 50%,var(--playmat-lower-shade) 50%);
}
.player-area.has-playmat > .side-zone,
.player-area.has-playmat > .base-zone,
.player-area.has-playmat > .hand-zone { background-color:rgba(18,26,44,.35); }
.player-area.has-playmat .zone-label { color:#d5dbea; text-shadow:0 1px 3px #000; }
.playmat-hint { color:#b9c4da; font-size:13px; line-height:1.5; }
.playmat-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; max-height:48vh; overflow-y:auto; padding:3px; }
.playmat-option { min-width:0; padding:4px; border:2px solid #3a4a70; border-radius:8px; background:#141c30; color:#e8e6e0; font:inherit; font-size:13px; }
.playmat-option img, .playmat-default { display:block; width:100%; aspect-ratio:2.5; object-fit:cover; border-radius:4px; margin-bottom:5px; }
.playmat-default { background:radial-gradient(ellipse at center,#1a2540 0%,#0e1420 75%); }
.playmat-option[aria-pressed="true"] { border-color:#d8c27a; color:#ffe6a0; background:#302719; }
.playmat-option:hover, .playmat-option:focus-visible { outline:2px solid #9fc8ff; outline-offset:0; }
/* 보드 뒤집기(온라인 게스트가 아래): 내부 요소 순서가 HTML에 고정돼 있어 자리만 바꾸면
   좌우가 반대가 된다 → 역순으로 배치해 원래 모양(위: 사이드 왼쪽 / 아래: 사이드 오른쪽)을 유지 */
.player-area.flipped { flex-direction:row-reverse; }
/* 가로 배분: 기지는 필요한 만큼만 쓰고(상한 있음), 남는 폭은 손패가 가져간다.
   기지는 보통 몇 기만 두는데 예전엔 flex:1이라 넓은 화면에서 빈 공간을 다 차지했다. */
.side-zone {
  flex:0 0 424px; 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:821px) and (max-width:1499px) and (min-height:521px){
  .side-zone { --side-card-width:64px; --side-card-height:90px; padding:6px; gap:3px; }
  .legend-slot .card-mini, .champ-slot .card-mini {
    width:var(--side-card-width); height:var(--side-card-height);
  }
  .side-zone .pile { width:46px; height:62px; }
  .side-zone .piles { gap:5px; }
}
/* 넓은 창의 전설·챔피언 및 더미 크기는 기존 설정을 유지한다. */
@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 {
  position:relative;
  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); }
/* 양쪽 진영의 별도 개수 칸을 없애고 남는 가로 공간은 기지에 배분한다. */
.player-area > .count-display { display:none; }
.player-area > .base-zone { max-width:none; }
/* 손패는 넓을수록 좋다 — 좁으면 줄바꿈으로 쌓여 카드가 서로 가려진다.
   화면이 넓으면 전장 중앙선 부근(42%)까지 쓰되,
   기지가 320px 아래로 눌리지 않게 하고, 좁은 창에서는 예전 폭(340px)을 지킨다.
   (760px = 진영 칸 424 + 칸 사이 여백 16 + 기지 최소 320) */
.player-area > .hand-zone {
  flex-grow:0;
  flex-basis:max(340px, min(42%, calc(100% - 760px)));
}
/* '손패 확인'으로 들여다본 봇 손패 — 내 손패와 헷갈리지 않게 점선 테두리로 구분하고,
   보기 전용임을 커서로도 알린다 (확대·정보 표시는 그대로 동작한다) */
.card-mini.peeked { outline:1px dashed #6a7aa0; outline-offset:-2px; opacity:.82; cursor:zoom-in; }
/* 카드의 줄바꿈과 간격에 영향을 주지 않고 손패 칸 오른쪽 위에 겹쳐 표시한다. */
.peek-btn {
  position:absolute; top:4px; right:4px; z-index:4;
  margin:0; 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; }
/* iOS 전체 화면에서 위쪽 버튼이 잘 눌리지 않아 조금 내린다 (데스크톱은 그대로) */
@media (pointer:coarse) {
  .player-area.top .peek-btn { top:12px; }
}

/* 전장 */
#battlefields {
  --bf-unit-height:clamp(88px,15vh,104px); --bf-card-width:160px; --bf-divider-height:28px;
  /* 큰 전장 이미지는 중앙 칸 밖으로 겹쳐 그린다. 구역 높이는 유닛 두 줄에 맞춘다. */
  flex:0 0 calc(2 * var(--bf-unit-height) + var(--bf-divider-height) + 40px);
  display:flex; gap:12px; align-items:stretch; justify-content:center;
}
.battlefield {
  flex:1; min-width:0; min-height:0; max-width:44%; border:2px solid #3a4a70; border-radius:12px;
  background:rgba(22,32,58,.85); padding:4px; position:relative;
  display:grid; grid-template-rows:minmax(0,1fr) var(--bf-divider-height) minmax(0,1fr);
  container: battlefield / inline-size;
}
.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 { position:relative; z-index:0; display:flex; justify-content:center; align-items:center; min-width:0; }
.bf-header::before {
  content:""; position:absolute; left:0; right:0; top:50%; height:1px; pointer-events:none;
  background:linear-gradient(to right,transparent,#7186ad66 18%,#7186ad66 82%,transparent);
}
.bf-header img {
  position:relative; flex:none; width:min(var(--bf-card-width),calc(100cqw - 12px)); height:auto; object-fit:contain;
  border-radius:7px; cursor:zoom-in; box-shadow:0 4px 15px #0009,0 0 0 1px #a0bde32b;
}
.bf-info {
  display:none; position:absolute; left:calc(50% + var(--bf-card-width) / 2 + 10px); right:6px;
  padding:7px 8px; border-radius:8px;
  background:linear-gradient(100deg,rgba(12,23,40,.78),rgba(17,31,50,.3));
  box-shadow:inset 1px 0 #a2c7ee33; text-shadow:0 1px 3px #050b16;
}
.bf-name { font-weight:bold; color:#d8c27a; font-size:13px; }
.bf-status { font-size:11px; color:#c0cede; margin-top:3px; }
.bf-name, .bf-status { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bf-hidden-count {
  position:absolute; left:6px;
  padding:2px 3px; border-radius:4px; background:#16203a; color:#b5c2da; font-size:10px; white-space:nowrap;
}
/* 이미지 중앙을 기준으로 양쪽 카드 줄을 고정한다. 넘치는 카드는 각 진영 안에서 스크롤한다. */
.bf-lane { position:relative; z-index:1; display:flex; min-width:0; min-height:0; pointer-events:none; }
.bf-row {
  flex:1; display:flex; gap:6px; align-items:center; justify-content:safe center; min-width:0; min-height:0;
  overflow-x:auto; overflow-y:hidden; padding:6px 6px 8px; scrollbar-width:thin;
}
.bf-row .card-mini { height:var(--bf-unit-height); width:calc(var(--bf-unit-height) * 74 / 104); pointer-events:auto; }
.bf-scroll {
  display:none; flex:0 0 20px; align-self:center; height:44px; place-items:center;
  border:0; border-radius:5px; background:#31446555; color:#bbd5f5; font-size:20px;
  touch-action:manipulation; pointer-events:auto;
}
.bf-lane.has-overflow > .bf-scroll { display:grid; }
.bf-scroll:disabled { opacity:.25; cursor:default; }
.bf-scroll:focus-visible { outline:1px solid #9fc8ff; }
@media (min-width:821px) and (min-height:600px) {
  @container battlefield (min-width:420px) { .bf-info { display:block; } }
}
#center-info { flex:0 0 130px; min-height:0; min-width:0; 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:radial-gradient(ellipse at center,rgba(14,27,47,.8),rgba(14,27,47,.12));
  border-radius:12px; padding:10px 12px; color:#c4def4; text-shadow:0 1px 3px #000b;
}
#pool-display:empty { display:none; }
#showdown-banner {
  background:linear-gradient(125deg,#512631e6,#271e32bb); border:1px solid #d77d7d66; padding:6px 10px; border-radius:8px;
  font-size:13px; font-weight:bold; text-align:center; line-height:1.5;
  min-height:0; overflow-y:auto; overflow-wrap:anywhere;
}

/* ══════════ 카드 ══════════ */
.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-zoom-trigger, .card-zoom-trigger * {
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
}
.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 url('../assets/playcard_back.png') 50.318471% 45.662100% / 117.386489% 117.312253% no-repeat !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;
}
/* PNG의 투명 여백을 제외한 카드 영역이 표시 칸을 채우도록 크기와 위치를 보정한다. */
.card-back { background:#141c30 url('../assets/playcard_back.png') 50.318471% 45.662100% / 117.386489% 117.312253% no-repeat !important; }

/* 룬 */
.rune-mini {
  width:var(--rune-width); height:var(--rune-height); 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;
}
.runes-zone {
  --rune-width:40px; --rune-height:56px;
  display:flex; flex-direction:column; gap:4px; width:100%; min-width:0;
  overflow:hidden; padding:3px;
}
.rune-row { display:flex; flex:0 0 auto; gap:0; flex-wrap:nowrap; align-items:center; width:100%; }
/* 다음 카드가 앞 카드 너비의 오른쪽 1/3을 덮는다. 탈진 시에는 회전 후 너비로 계산한다. */
.rune-slot {
  --slot-width:var(--rune-width);
  position:relative; flex:0 0 var(--slot-width); height:var(--rune-height); pointer-events:none;
}
.rune-slot.exhausted { --slot-width:var(--rune-height); }
.rune-slot:not(:last-child) { margin-right:calc(var(--slot-width) / -3); }
.rune-row.compact-runes > .rune-slot:not(:last-child) { margin-right:calc(var(--slot-width) / -2); }
.rune-slot > .rune-mini {
  position:absolute; left:50%; top:50%; margin:0;
  transform:translate(-50%,-50%); pointer-events:auto;
}
.rune-slot > .rune-mini.exhausted { transform:translate(-50%,-50%) rotate(90deg); opacity:.55; }
.rune-slot > .rune-mini:hover, .rune-slot > .rune-mini:focus-visible {
  outline:2px solid #ffe07f; outline-offset:0;
}

/* 전설/챔피언 슬롯 */
.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; }
.pile.deck { --pile-image:url('../assets/playcard_back.png'); background:#182238 var(--pile-image) 50.318471% 45.662100% / 117.386489% 117.312253% no-repeat; }
.pile.runedeck { --pile-image:url('../assets/runecard_back.png'); background:#182238 var(--pile-image) 50.000000% 51.155116% / 125.890736% 125.656224% no-repeat; }
.pile.trash { background-image:var(--pile-image,none); background-position:center; background-size:cover; background-repeat:no-repeat; }
.pile.deck > span, .pile.runedeck > span, .pile.trash.has-card-image > span {
  background:rgba(10,14,24,.8); color:#e8edf7; padding:0 4px; border-radius:3px;
}

/* ══════════ 카드 정보 패널 (호버 — 작게 표시, 확대는 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; }

/* 푸른 마력 질감: 구슬 외곽 없이 버튼 내부만 채운다. 글자와 클릭 영역은 원래 버튼 그대로다. */
.act-btn.arcane-button {
  position:relative; isolation:isolate; overflow:hidden;
  background:#16294f; color:#b7c9e3;
  text-shadow:0 1px 3px #000,0 0 7px #081645;
}
.act-btn.arcane-button.primary:not(:disabled) {
  color:#f5faff; border-color:#d8c27a;
  background:radial-gradient(ellipse at 25% 5%,#226bd3 0%,#1552bf 30%,#12399e 62%,#111f64 100%);
  box-shadow:inset 0 1px 2px #7cbbef66,inset 0 -2px 7px #081340cc,0 2px 6px #0007;
}
.arcane-button::before, .arcane-button::after {
  content:""; position:absolute; z-index:-1; pointer-events:none;
  opacity:0;
}
/* 윤곽선 없는 농도 차이만 겹친다. 서로 다른 주기로 흘러가며 사라지고, 투명할 때 위치를 되돌린다. */
.arcane-button::before {
  inset:-90% -45%;
  background:
    url('../assets/arcane-flow.svg') center / 100% 100% no-repeat,
    radial-gradient(ellipse at 40% 52%,#3c9aff60 0%,#277aff28 24%,transparent 58%);
  animation:arcane-current 11.3s linear -3.2s infinite paused;
}
.arcane-button::after {
  inset:-110% -55%;
  background:
    url('../assets/arcane-flow.svg') 70% 30% / 165% 135% no-repeat,
    radial-gradient(ellipse at 64% 62%,#235bf040 0%,transparent 53%);
  animation:arcane-undertow 17.9s linear -11.6s infinite paused;
}
.arcane-button.primary:not(:disabled)::before,
.arcane-button.primary:not(:disabled)::after { animation-play-state:running; }
@keyframes arcane-current {
  0% { transform:translate(-22%,12%) rotate(-8deg) scale(1.1); opacity:0; }
  18% { opacity:.3; }
  46% { opacity:.38; }
  73% { opacity:.2; }
  100% { transform:translate(22%,-14%) rotate(6deg) scale(1.22); opacity:0; }
}
@keyframes arcane-undertow {
  0% { transform:translate(-18%,-15%) rotate(168deg) scale(1.25); opacity:0; }
  24% { opacity:.23; }
  57% { opacity:.32; }
  81% { opacity:.14; }
  100% { transform:translate(18%,18%) rotate(184deg) scale(1.05); opacity:0; }
}
@media (hover:hover) {
  .act-btn.arcane-button.primary:hover:not(:disabled) {
    border-color:#f3e1a7; box-shadow:inset 0 1px 3px #91c9ef80,inset 0 -2px 7px #081340cc,0 0 10px #317dff40;
  }
}
.act-btn.arcane-button:active:not(:disabled) { box-shadow:inset 0 2px 9px #06163db3; }
.act-btn.arcane-button:focus-visible { outline:3px solid #a6e6ff; outline-offset:2px; }
body:is(.fx-disabled,.modal-open) .arcane-button.primary::before,
body:is(.fx-disabled,.modal-open) .arcane-button.primary::after { animation-play-state:paused; }
.arcane-button:not(.primary)::before, .arcane-button:not(.primary)::after,
.arcane-button:disabled::before, .arcane-button:disabled::after { visibility:hidden; }
@media (prefers-reduced-motion:reduce) {
  .arcane-button::before, .arcane-button::after { animation:none; }
}
/* 파장·시작 위상·출렁임 주기를 분리한 연속 물결. 이동과 그라데이션은 같은 한 파장을 반복한다. */
.arcane-filaments { position:absolute; inset:0; width:100%; height:100%; z-index:-1; pointer-events:none; }
.arcane-wave {
  --wave-x:360px; --wave-y:-34px;
  animation:arcane-wave-travel 27.7s linear -9.8s infinite paused,
    arcane-wave-breathe 17.3s ease-in-out -3.9s infinite alternate paused;
}
.arcane-wave-soft {
  --wave-x:264px; --wave-y:-24px;
  animation-duration:38.3s,23.9s; animation-delay:-28.4s,-17.2s;
}
.arcane-wave-thread {
  --wave-x:432px; --wave-y:-40px;
  animation-duration:46.9s,31.1s; animation-delay:-36.7s,-8.6s;
}
.arcane-wave path {
  fill:url(#arcane-thread-color); stroke:none; opacity:.36;
  animation:arcane-wave-swell 16.9s ease-in-out -11.7s infinite alternate paused;
}
.arcane-wave-soft path {
  fill:url(#arcane-violet-color); opacity:.28;
  animation-name:arcane-soft-swell; animation-duration:26.3s; animation-delay:-4.8s;
}
.arcane-wave-thread path {
  fill:none; stroke:url(#arcane-fine-color); stroke-width:.7px; vector-effect:non-scaling-stroke;
  opacity:.48; animation-name:arcane-thread-swell; animation-duration:37.1s; animation-delay:-29.6s;
}
.arcane-hue { animation:arcane-color-tide 24.9s ease-in-out -7.1s infinite alternate paused; }
#arcane-violet-color .arcane-hue { animation-name:arcane-violet-tide; animation-duration:34.7s; animation-delay:-23.6s; }
#arcane-fine-color .arcane-hue { animation-duration:43.1s; animation-delay:-31.4s; }
@keyframes arcane-color-tide { from { stop-color:#6ce9dd; } to { stop-color:#93bcff; } }
@keyframes arcane-violet-tide { from { stop-color:#a8a2ff; } to { stop-color:#69c5ed; } }
@keyframes arcane-wave-travel { to { transform:translate(var(--wave-x),var(--wave-y)); } }
@keyframes arcane-wave-breathe { from { opacity:.58; } to { opacity:1; } }
@keyframes arcane-wave-swell {
  from { d:path("M -720 108 c 60 -12 120 -29 180 -17 c 60 12 120 -5 180 -17 c 60 -12 120 -29 180 -17 c 60 12 120 -5 180 -17 c 60 -12 120 -29 180 -17 c 60 12 120 -5 180 -17 c 60 -12 120 -29 180 -17 c 60 12 120 -5 180 -17 c 60 -12 120 -29 180 -17 c 60 12 120 -5 180 -17 v 5 c -60 14 -120 31 -180 17 c -60 -14 -120 3 -180 17 c -60 14 -120 31 -180 17 c -60 -14 -120 3 -180 17 c -60 14 -120 31 -180 17 c -60 -14 -120 3 -180 17 c -60 14 -120 31 -180 17 c -60 -14 -120 3 -180 17 c -60 14 -120 31 -180 17 c -60 -14 -120 3 -180 17 Z"); }
  to { d:path("M -720 110 c 60 -14 120 -31 180 -17 c 60 14 120 -3 180 -17 c 60 -14 120 -31 180 -17 c 60 14 120 -3 180 -17 c 60 -14 120 -31 180 -17 c 60 14 120 -3 180 -17 c 60 -14 120 -31 180 -17 c 60 14 120 -3 180 -17 c 60 -14 120 -31 180 -17 c 60 14 120 -3 180 -17 v 5 c -60 16 -120 33 -180 17 c -60 -16 -120 1 -180 17 c -60 16 -120 33 -180 17 c -60 -16 -120 1 -180 17 c -60 16 -120 33 -180 17 c -60 -16 -120 1 -180 17 c -60 16 -120 33 -180 17 c -60 -16 -120 1 -180 17 c -60 16 -120 33 -180 17 c -60 -16 -120 1 -180 17 Z"); }
}
@keyframes arcane-soft-swell {
  from { d:path("M -528 96 c 44 -6 88 -18 132 -12 c 44 6 88 -6 132 -12 c 44 -6 88 -18 132 -12 c 44 6 88 -6 132 -12 c 44 -6 88 -18 132 -12 c 44 6 88 -6 132 -12 c 44 -6 88 -18 132 -12 c 44 6 88 -6 132 -12 c 44 -6 88 -18 132 -12 c 44 6 88 -6 132 -12 v 3 c -44 8 -88 20 -132 12 c -44 -8 -88 4 -132 12 c -44 8 -88 20 -132 12 c -44 -8 -88 4 -132 12 c -44 8 -88 20 -132 12 c -44 -8 -88 4 -132 12 c -44 8 -88 20 -132 12 c -44 -8 -88 4 -132 12 c -44 8 -88 20 -132 12 c -44 -8 -88 4 -132 12 Z"); }
  to { d:path("M -528 93 c 44 -11 88 -23 132 -12 c 44 11 88 -1 132 -12 c 44 -11 88 -23 132 -12 c 44 11 88 -1 132 -12 c 44 -11 88 -23 132 -12 c 44 11 88 -1 132 -12 c 44 -11 88 -23 132 -12 c 44 11 88 -1 132 -12 c 44 -11 88 -23 132 -12 c 44 11 88 -1 132 -12 v 3 c -44 13 -88 25 -132 12 c -44 -13 -88 -1 -132 12 c -44 13 -88 25 -132 12 c -44 -13 -88 -1 -132 12 c -44 13 -88 25 -132 12 c -44 -13 -88 -1 -132 12 c -44 13 -88 25 -132 12 c -44 -13 -88 -1 -132 12 c -44 13 -88 25 -132 12 c -44 -13 -88 -1 -132 12 Z"); }
}
@keyframes arcane-thread-swell {
  from { d:path("M -864 124 c 72 -13 144 -33 216 -20 c 72 13 144 -7 216 -20 c 72 -13 144 -33 216 -20 c 72 13 144 -7 216 -20 c 72 -13 144 -33 216 -20 c 72 13 144 -7 216 -20 c 72 -13 144 -33 216 -20 c 72 13 144 -7 216 -20 c 72 -13 144 -33 216 -20 c 72 13 144 -7 216 -20 "); }
  to { d:path("M -864 123 c 72 -16 144 -36 216 -20 c 72 16 144 -4 216 -20 c 72 -16 144 -36 216 -20 c 72 16 144 -4 216 -20 c 72 -16 144 -36 216 -20 c 72 16 144 -4 216 -20 c 72 -16 144 -36 216 -20 c 72 16 144 -4 216 -20 c 72 -16 144 -36 216 -20 c 72 16 144 -4 216 -20 "); }
}
/* 빛 입자는 세 개만 두고, 사라져 있는 동안 출발점으로 돌아간다. */
.arcane-spark {
  --spark-x:82px; --spark-y:-28px; fill:#c0f6ff; stroke:#70cde8; stroke-width:.2px;
  vector-effect:non-scaling-stroke; opacity:0;
  animation:arcane-spark-drift 17.9s ease-in-out -12.8s infinite paused;
}
.arcane-spark:nth-child(2) { --spark-x:94px; --spark-y:-29px; animation-duration:25.7s; animation-delay:-3.4s; fill:#bdd1ff; }
.arcane-spark:nth-child(3) { --spark-x:101px; --spark-y:-25px; animation-duration:31.3s; animation-delay:-20.6s; }
@keyframes arcane-spark-drift {
  0% { transform:translate(0,0); opacity:0; }
  24% { opacity:.38; }
  52% { opacity:.56; }
  78% { opacity:.18; }
  100% { transform:translate(var(--spark-x),var(--spark-y)); opacity:0; }
}
.arcane-button.primary:not(:disabled) :is(.arcane-wave,.arcane-wave path,.arcane-hue,.arcane-spark) { animation-play-state:running; }
body:is(.fx-disabled,.modal-open) :is(.arcane-wave,.arcane-wave path,.arcane-hue,.arcane-spark) { animation-play-state:paused !important; }
.arcane-button:not(.primary) .arcane-filaments, .arcane-button:disabled .arcane-filaments { visibility:hidden; }
@media (prefers-reduced-motion:reduce) {
  .arcane-wave, .arcane-wave path, .arcane-hue, .arcane-spark { animation:none !important; }
  .arcane-spark { opacity:0; }
}

/* 안내 패널은 배경 톤을 살리면서 글자 뒤에는 충분한 명암을 남긴다. */
#game-screen :is(#turn-panel,#inspector,#prompt-area,#log) {
  background:linear-gradient(135deg,rgba(14,24,42,.86),rgba(19,32,52,.62));
  border-color:#8eb4dc2e; box-shadow:0 3px 12px #0002; text-shadow:0 1px 2px #050b16;
}

/* 체인: 적재 순서를 한 줄로 유지하고, 긴 체인은 가로로 스크롤한다. */
#btn-chain {
  position:relative; display:flex; flex:0 0 64px; width:64px; height:64px;
  align-items:center; justify-content:center; flex-direction:column; gap:3px;
  border:1px solid #a494d2; border-radius:50%; color:#e0d2ff;
  background:linear-gradient(145deg,#393052,#1a223c); box-shadow:0 0 0 3px #181f3488,0 3px 12px #0007;
}
#btn-chain:hover { border-color:#e0d2ff; background:linear-gradient(145deg,#51416f,#293452); }
#btn-chain[aria-expanded="true"] { border-color:#ffe49a; color:#ffe49a; }
#btn-chain svg { width:25px; height:25px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.chain-button-label { font-size:11px; font-weight:600; line-height:1; }
#btn-chain-count {
  position:absolute; top:-3px; right:-5px; display:flex; align-items:center; justify-content:center;
  min-width:23px; height:23px; padding:0 5px; border:2px solid #192138; border-radius:12px;
  background:#dfd1ff; color:#251c3b; font-size:12px; font-weight:700; line-height:1;
}
#btn-modal-chain { border-color:#8a79bf; color:#e0d2ff; }
#btn-modal-chain { position:absolute; right:10px; top:10px; z-index:1; padding:7px 12px; white-space:nowrap; }
.has-chain #modal-box { padding-top:60px; }
#chain-overlay {
  position:fixed; inset:0; z-index:220; background:rgba(5,8,16,.84);
  display:flex; align-items:center; justify-content:center; padding:16px;
}
#chain-panel {
  display:flex; flex-direction:column; width:min(1120px,100%); min-width:0; max-height:calc(100vh - 32px);
  padding:18px; border:1px solid #6975a1; border-radius:14px;
  background:#141e32; box-shadow:0 12px 44px #0009;
}
.chain-header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex:0 0 auto; }
.chain-header h3 { margin:0; color:#e0d2ff; font-size:19px; }
#btn-chain-close { padding:7px 18px; }
.chain-meta { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:3px 12px; margin:4px 0 6px; flex:0 0 auto; }
#chain-guide { margin:0; color:#a9b8d4; font-size:11px; line-height:1.3; }
#chain-legend { display:flex; flex-wrap:wrap; gap:3px 10px; min-width:0; font-size:11px; line-height:1.3; }
.chain-player-0 { --chain-color:#9fc8ff; --chain-tint:rgba(75,126,200,.15); }
.chain-player-1 { --chain-color:#ffc89f; --chain-tint:rgba(206,135,75,.15); }
.chain-owner { color:var(--chain-color); font-weight:600; overflow-wrap:anywhere; }
#chain-cards {
  display:flex; flex:1 1 auto; align-items:stretch; gap:14px; min-height:0;
  overflow:auto; overscroll-behavior:contain; list-style:none; padding:2px 2px 12px; margin:0;
  scrollbar-color:#7381a5 #10182a;
}
.chain-entry {
  flex:0 0 208px; height:max-content; min-height:100%; min-width:0; padding:12px; border:1px solid var(--chain-color);
  border-top:4px solid var(--chain-color); border-radius:10px; background:var(--chain-tint);
}
.chain-order { display:flex; align-items:center; justify-content:space-between; gap:6px; color:#c6cfe3; font-size:12px; margin-bottom:8px; }
.chain-next { background:#58451d; color:#ffe49a; border-radius:4px; padding:3px 6px; font-size:11px; }
.chain-entry > .chain-owner { font-size:12px; }
.chain-entry h4 { margin:7px 0 10px; min-height:2.7em; color:#f0f3fb; font-size:14px; line-height:1.35; overflow-wrap:anywhere; }
.chain-source-card {
  display:flex; align-items:center; justify-content:center; width:100%; aspect-ratio:744 / 1039;
  padding:0; overflow:hidden; border:1px solid var(--chain-color); border-radius:8px; background:#10182a;
}
.chain-source-card img { display:block; width:100%; height:100%; object-fit:contain; }
.chain-card-fallback { color:#e0e8fa; padding:10px; font-size:14px; }
.chain-countered .chain-source-card { opacity:.55; filter:grayscale(.8); }
.chain-ability, .chain-state { margin:8px 0; font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.chain-ability { color:#c6cfe3; }
.chain-state { color:#ffe49a; }
.chain-target-heading { margin-top:12px; margin-bottom:7px; color:#e0d2ff; font-size:13px; font-weight:600; }
.chain-target-number { color:#c6cfe3; font-size:11px; margin-bottom:5px; }
.chain-target { margin-top:6px; padding-top:6px; border-top:1px solid #495875; }
.chain-target-card {
  display:flex; align-items:center; gap:8px; width:100%; padding:5px; border:1px solid #495875;
  border-left:3px solid var(--chain-color); border-radius:6px; background:#10182a; text-align:left;
}
.chain-target-card img { flex:0 0 46px; width:46px; height:65px; object-fit:contain; border-radius:3px; }
.chain-target-card > .chain-card-fallback { flex:0 0 46px; padding:2px; font-size:10px; }
.chain-target-info { display:flex; flex-direction:column; gap:5px; min-width:0; color:#e1e7f5; font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.chain-target-info small { color:#a9b8d4; font-size:11px; }
.chain-hint { margin:8px 0 0; color:#a9b8d4; font-size:12px; line-height:1.5; }
.chain-footer { margin-top:4px; font-size:11px; line-height:1.3; flex:0 0 auto; }
#chain-panel button { cursor:pointer; font-family:inherit; }
#chain-panel button:hover { border-color:#ffe49a; }
#chain-panel button:focus-visible, #btn-chain:focus-visible, #btn-modal-chain:focus-visible { outline:3px solid #ffe49a; outline-offset:2px; }
@media(max-width:600px), (max-height:540px) {
  #chain-overlay { padding:8px; }
  #chain-panel { padding:10px; max-height:calc(100vh - 16px); max-height:calc(100dvh - 16px); }
  #chain-cards { gap:8px; }
  .chain-entry { flex-basis:160px; padding:8px; min-height:0; }
  .chain-entry h4 { margin:4px 0 6px; min-height:0; font-size:13px; }
  .chain-order { margin-bottom:4px; }
  .chain-source-card {
    width:min(100%, 110px, 22vh);
    width:min(100%, 110px, 22dvh);
    margin-inline:auto;
  }
  .chain-target-heading { margin-top:7px; margin-bottom:4px; }
  .chain-target-card { gap:5px; padding:4px; }
  .chain-target-card img { flex-basis:32px; width:32px; height:45px; }
  .chain-header h3 { font-size:16px; }
  #btn-chain-close { min-height:44px; }
  #btn-modal-chain { padding:5px 10px; font-size:12px; }
  .has-chain #modal-box { padding-top:52px; }
}

/* ══════════ 모달 ══════════ */
#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-shell { position:relative; min-width:0; max-width:calc(100vw - 72px); }
#modal-shell #modal-box { max-width:min(860px,calc(100vw - 72px)); }
#modal-visibility-toggle { position:absolute; left:-44px; top:50%; transform:translateY(-50%);
  width:36px; height:36px; padding:7px; border-radius:50%; border:1px solid #d8c27a;
  background:#182238; color:#ffe6a0; box-shadow:0 2px 8px #0008; z-index:1; }
#modal-visibility-toggle svg { display:block; width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
#modal-visibility-toggle .eye-closed { display:none; }
#modal-visibility-toggle:focus-visible { outline:3px solid #7fc8ff; outline-offset:2px; }
#modal-overlay.modal-peeking { background:transparent; }
.modal-peeking #modal-box { visibility:hidden; }
.modal-peeking #modal-visibility-toggle .eye-open { display:none; }
.modal-peeking #modal-visibility-toggle .eye-closed { display:block; }
body.modal-peeking #inspector { z-index:auto; }
.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); }
.battlefield-source { display:flex; align-items:center; gap:14px; padding:12px; margin-bottom:14px;
  border:1px solid #566b91; border-radius:8px; background:#101a2e; max-width:620px; }
.battlefield-source-card { flex:0 0 190px; padding:0; border:0; background:transparent; cursor:zoom-in; }
.battlefield-source-card img { display:block; width:100%; border-radius:6px; }
.battlefield-source-info { min-width:0; font-size:13px; line-height:1.6; }
.battlefield-source-info strong { color:#ffe6a0; }
.battlefield-source-text { margin-top:6px; white-space:pre-wrap; overflow-wrap:anywhere; }
#prompt-area .battlefield-source { flex-direction:column; gap:8px; padding:8px; }
#prompt-area .battlefield-source-card { flex-basis:auto; width:150px; max-width:100%; }
@media(max-width:600px) {
  .battlefield-source { flex-direction:column; align-items:stretch; gap:8px; }
  .battlefield-source-card { flex-basis:auto; width:170px; max-width:100%; align-self:center; }
}

/* 컨텍스트 메뉴 */
#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:has(.ctx-card-choice) { max-width:min(420px,94vw); max-height:80vh; overflow-y:auto; }
#ctx-menu .ctx-card-choice { display:flex; align-items:center; gap:10px; }
#ctx-menu .ctx-card-choice .card-mini { width:64px; height:90px; flex-shrink:0; }
.card-select-button { max-width:100%; white-space:normal; text-align:left; }
#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:contain;
  border-radius:6px; display:block; margin-bottom:6px;
}
#card-hover img.landscape { aspect-ratio:1039/744; max-height:none; }
/* 카드가 걸린 선택지 버튼임을 알린다 */
.modal-btns button.has-card { cursor:help; }
.modal-btns button.has-card::after { content:' 🔍'; font-size:11px; opacity:.6; }
.modal-btns.card-options { align-items:center; }
.modal-btns button.card-option {
  width:144px; padding:6px; display:flex; flex-direction:column; gap:7px;
  align-items:center; align-self:stretch; cursor:pointer; white-space:normal;
}
.modal-btns button.card-option::after { content:none; }
.card-option .option-art {
  display:flex; align-items:center; justify-content:center; width:100%; aspect-ratio:744/1039;
  overflow:hidden; border-radius:5px; background:#101828;
}
.card-option .option-art.landscape { aspect-ratio:1039/744; margin:auto 0; }
.card-option .option-art img { display:block; width:100%; height:100%; object-fit:contain; }
.card-option .option-label { font-size:12px; line-height:1.4; overflow-wrap:anywhere; }
.option-unit-owner {
  display:block; width:100%; padding:3px 5px; border-radius:4px;
  font-size:11px; line-height:1.4; font-weight:bold; overflow-wrap:anywhere;
}
.option-unit-owner.mine { background:#18364e; color:#b8e1ff; }
.option-unit-owner.opponent { background:#4a252c; color:#ffd0d0; }
.modal-btns button.card-option:focus-visible { outline:3px solid #7fc8ff; outline-offset:2px; }
@media(max-width:600px) {
  .modal-btns button.card-option { width:112px; padding:5px; }
}
/* 폐기장 목록 — 버려진 순서 배지 + 더미 클릭 유도 */
.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:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
}
.cz-box {
  display:flex; flex-direction:column; width:820px; max-width:100%; max-height:100%; min-height:0; cursor:default;
  background:#141c30; border:1px solid #3a4a70; border-radius:16px;
  overflow:hidden; box-shadow:0 10px 40px #000b; animation:czIn .12s ease-out;
}
.cz-toolbar { flex:none; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:6px 10px 6px 18px; border-bottom:1px solid #3a4a7066; color:#b4c5de; font-size:13px; }
.cz-close { flex:none; min-width:80px; min-height:44px; display:flex; align-items:center; justify-content:center; gap:10px; border:1px solid #57749c; border-radius:9px; background:#223656; color:#f1f6ff; font-size:15px; touch-action:manipulation; }
.cz-close span { font-size:25px; line-height:1; }
.cz-close:hover { background:#2d456b; }
.cz-close:focus-visible { outline:2px solid #a6d8ff; outline-offset:2px; }
.cz-body { display:flex; gap:20px; min-height:0; overflow:auto; overscroll-behavior:contain; padding:18px 20px; }
@keyframes czIn { from{opacity:0; transform:scale(.94);} to{opacity:1; transform:scale(1);} }
.cz-img { width:340px; max-width:44%; height:auto; flex:none; border-radius:12px; object-fit:contain; align-self:flex-start; }
.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 0 auto; min-width:0; width:0; }
.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; }

/* ══════════ 튜토리얼 패널 ══════════ */
#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; }
.hand-draggable { cursor:grab; }
.touch-draggable { touch-action:none; -webkit-touch-callout:none; }
.hand-dragging { opacity:.5; outline:2px solid #7fe07f; }
.touch-drag-preview { position:fixed; z-index:1000; pointer-events:none; margin:0; transform:none; opacity:.9; box-shadow:0 5px 18px #0009; }
.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; }
@media (max-width:820px), (max-height:540px) and (pointer:coarse) {
  #legal-footer {
    font-size:9px; line-height:1.3; padding:3px 8px;
    max-height:16vh; max-height:16dvh;
    -webkit-text-size-adjust:100%; text-size-adjust:100%;
  }
}

/* 규칙 처리 모드 체크박스 */
.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:272px; } }

/* ══════════ 모바일 반응형 (세로 화면) ══════════ */
@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{ --bf-unit-height:82px; --bf-card-width:120px; --bf-divider-height:24px; 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; }
  .runes-zone{ --rune-width:26px; --rune-height:36px; }
  .rune-mini{ 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-body{ flex-direction:column; gap:14px; padding:14px; }
  .cz-img{ width:auto; max-width:100%; max-height:44vh; align-self:center; }
  .cz-info{ width:auto; }
  .cz-noimg{ max-width:100%; max-height:32vh; align-self:center; }
  .cz-name{ font-size:22px; }
  /* ── 모달(멀리건 등) 모바일 보정 ── */
  /* 모바일은 호버가 없어 탭 순간 인스펙터가 모달 버튼을 덮는 문제 → 승격 해제 (카드 확대는 꾹 누르기) */
  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){
  #battlefields{ --bf-unit-height:70px; --bf-card-width:84px; --bf-divider-height:20px; }
  .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:relative; 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){
  .cz-body{ flex-direction:row; gap:14px; padding:12px; }
  .cz-img, .cz-noimg{ width:30%; max-width:220px; max-height:none; align-self:flex-start; }
  .cz-info{ width:0; }
  #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; }
  .runes-zone{ --rune-width:18px; --rune-height:26px; }
  .rune-mini{ font-size:9px; }
  .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{
    --bf-unit-height:56px; --bf-card-width:100px; --bf-divider-height:12px;
    flex-basis:calc(2 * var(--bf-unit-height) + var(--bf-divider-height) + 34px); gap:4px; min-height:0;
  }
  .battlefield{ padding:3px 4px; max-width:none; }
  .bf-row{ gap:4px; padding:5px 4px 7px; }
  .bf-hidden-count{ font-size:8px; padding:1px 2px; }

  /* ── 사이드바: 인스펙터를 제한하고 로그는 최소 높이를 보장 (항상 보임) ── */
  #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; }
}

/* 모바일: 챔피언 오른쪽에 덱·룬 덱·폐기를 세로로 모은다. 전개한 룬은 아래 줄을 쓴다. */
@media (max-width:820px), (orientation:landscape) and (max-height:520px) {
  .side-zone {
    --mobile-side-card-width:58px;
    --mobile-pile-width:50px;
    flex:0 0 calc(2 * var(--mobile-side-card-width) + var(--mobile-pile-width) + 28px);
    display:grid; grid-template-columns:var(--mobile-side-card-width) var(--mobile-side-card-width) var(--mobile-pile-width);
    grid-template-areas:"legend champion piles" "runes runes runes";
    grid-template-rows:auto auto; align-items:start; align-content:start;
  }
  .side-zone > .legend-slot { grid-area:legend; }
  .side-zone > .champ-slot { grid-area:champion; }
  .side-zone > .runes-zone { grid-area:runes; }
  .side-zone > .piles { grid-area:piles; flex-direction:column; width:auto; gap:3px; }
  .side-zone .pile {
    position:relative; isolation:isolate; overflow:hidden;
    width:100%; height:auto; aspect-ratio:88 / 63; flex:none; flex-direction:row; justify-content:center;
    background-image:none; padding:0 2px; gap:2px; border-radius:4px; font-size:9px; text-shadow:0 1px 3px #000;
  }
  /* 카드 그림만 시계 방향으로 회전한다. 글자와 터치 영역은 가로 방향을 유지한다. */
  .side-zone .pile::before {
    content:""; position:absolute; z-index:-1; pointer-events:none;
    left:50%; top:50%; width:calc(100% * 63 / 88); height:calc(100% * 88 / 63);
    transform:translate(-50%,-50%) rotate(90deg);
    background-image:var(--pile-image,none); background-position:inherit; background-size:inherit; background-repeat:no-repeat;
  }
  .side-zone .pile > span:is(.pile-label,.pile-count) { padding:0; white-space:nowrap; flex:none; }
  .side-zone .pile-count { font-size:11px; }
}
@media (max-width:480px) { .side-zone { --mobile-side-card-width:50px; } }
@media (max-width:820px) and (orientation:portrait) {
  .player-area { min-height:148px; }
  .player-area > .hand-zone, .player-area > .base-zone { flex:1 1 0; min-width:0; }
}
@media (orientation:landscape) and (max-height:520px) {
  .side-zone { --mobile-side-card-width:40px; --mobile-pile-width:40px; flex-basis:calc(2 * var(--mobile-side-card-width) + var(--mobile-pile-width) + 20px); }
  .side-zone > .piles { gap:2px; }
}
@media (orientation:landscape) and (max-height:360px) {
  .side-zone { --mobile-pile-width:31px; }
  .side-zone .pile { padding:0; gap:1px; font-size:7px; }
  .side-zone .pile-count { font-size:9px; }
}

/* ══════════ 리플레이: 보관함 카드 + 재생 컨트롤 바 ══════════ */
.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); }

/* ---------- 패치 노트 ---------- */
.patch-body {
  flex:1; overflow:auto; margin:0; padding:16px 22px;
  white-space:pre-wrap; word-break:break-word;
  font-family:'Consolas','D2Coding','Malgun Gothic',monospace;
  font-size:13px; line-height:1.75; color:#c3cbdc;
}
.patch-body b { color:#d8c27a; font-weight:600; }

/* ---------- 아이디 저장 ---------- */
.save-id {
  display:flex; align-items:center; gap:6px;
  font-size:12px; color:#8fa; cursor:pointer; user-select:none;
}
.save-id input { width:auto; margin:0; }

/* ---------- 내 전적 ---------- */
.record-body { flex:1; overflow:auto; padding:14px 22px 24px; }
.record-sum {
  background:#161b26; border:1px solid #2b3446; border-radius:8px;
  padding:12px 16px; margin-bottom:14px; font-size:14px; color:#c3cbdc;
}
.record-sum b { color:#d8c27a; font-size:17px; }
.record-list { display:flex; flex-direction:column; gap:6px; }
.record-row {
  display:grid; grid-template-columns:1fr 110px 62px 120px; align-items:center; gap:10px;
  background:#131822; border:1px solid #232c3c; border-radius:6px; padding:8px 12px; font-size:13px;
}
.record-row .rr-name { color:#dfe6f2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.record-row .rr-wl { color:#8f9bb3; text-align:right; }
.record-row .rr-rate { text-align:right; font-weight:600; color:#d8c27a; }
.record-row .rr-bar { height:8px; background:#232c3c; border-radius:4px; overflow:hidden; }
.record-row .rr-bar i { display:block; height:100%; background:linear-gradient(90deg,#5aa0e0,#7fe0b0); }
.record-empty { color:#7c86a0; font-size:13px; padding:18px 2px; }
@media (max-width:640px){
  .record-row { grid-template-columns:1fr 92px 54px; }
  .record-row .rr-bar { display:none; }
}

/* ---------- 사이드덱 교체 (게임 사이) ---------- */
.sb-note { font-size:12px; color:#8f9bb3; margin-bottom:8px; }
.sb-cols { display:flex; gap:10px; }
.sb-col { flex:1; min-width:0; }
.sb-head { font-size:12px; color:#9aa4bd; margin-bottom:4px; }
.sb-head b { color:#7fe0b0; font-size:14px; }
.sb-head b.bad { color:#ff9c6e; }
.sb-head small { color:#5f6a83; }
.sb-list {
  height:260px; overflow:auto; background:#0e1626;
  border:1px solid #2b3446; border-radius:6px; padding:4px;
}
.sb-row {
  padding:3px 6px; border-radius:4px; font-size:12px; color:#dfe6f2;
  cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.sb-row:hover { background:#1b2740; }
.sb-row .cnt { color:#8f9bb3; margin-right:4px; }
.sb-empty { color:#5f6a83; font-size:12px; padding:8px; }
.sb-champ { margin-top:10px; font-size:13px; color:#9aa4bd; }
.sb-champ select {
  margin-left:6px; padding:5px 8px; border-radius:6px;
  border:1px solid #3a4a70; background:#0e1626; color:#e8e6e0; font-size:13px;
}
@media (max-width:560px){ .sb-cols { flex-direction:column; } .sb-list { height:170px; } }
