:root {
  --bg: #120d09;
  --board-1: #3a2918;
  --board-2: #1c140d;
  --panel: #241a12;
  --panel-2: #2e2216;
  --line: #5a4429;
  --gold: #d9b263;
  --text: #f3e8d0;
  --muted: #a8967a;

  --wei: #3c6cc0;
  --shu: #3f9b58;
  --wu: #b8433a;
  --none: #8a6d3e;

  --r-c: #9c9c9c;
  --r-r: #4b93e6;
  --r-e: #a660e6;
  --r-l: #ef9f2c;

  --t-inf: #c8873a;
  --t-cav: #d4483b;
  --t-arc: #3ea86a;
  --t-str: #6f7fe0;
  --t-geo: #2fa3a8;

  --atk: #e6a23a;
  --hp: #c9343c;
  --cost: #3a78d0;
  --ok: #57e07a;
  --target: #ff5a4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  user-select: none;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
/* 1600×900 무대. ui.js의 fitStage()가 창 크기에 맞춰 --s 배율을 정한다 */
#stage {
  position: absolute; left: 50%; top: 50%; width: 1600px; height: 900px; overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--s, 1));
}
[hidden] { display: none !important; }

/* ───────── 시작 화면 ───────── */
.screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, #3d2b19 0%, #120d09 75%);
}
#start {
  background: linear-gradient(#100b09a6, #100b09b5), url('images/ui/start-background.webp') center / cover no-repeat;
}
.start-box { text-align: center; padding: 20px; }
.start-box h1 {
  width: 850px; height: 260px; display: grid; place-items: center; margin: 0 auto 10px;
  background: url('images/ui/start-title.webp') center / contain no-repeat;
  font-family: 'Malgun Gothic', serif; font-size: 36px; font-weight: 900; letter-spacing: 2px;
  color: #ffe4a0; text-shadow: 0 3px 1px #512600, 0 5px 8px #000, 0 0 24px #e7a03d;
}
.pick { display: flex; gap: 28px; justify-content: center; }
.pick-btn {
  position: relative; width: 240px; height: 330px; padding: 0; border-radius: 8px; border: 2px solid #a78047;
  background-position: center; background-size: cover; color: var(--text); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px #000b, inset 0 0 0 2px #f4d48b33;
  transition: transform .18s, border-color .18s, box-shadow .18s, filter .18s;
}
.pick-btn[data-faction="wei"] { background-image: url('images/ui/start-wei-fortress.webp'); }
.pick-btn[data-faction="shu"] { background-image: url('images/ui/start-shu-fortress.webp'); }
.pick-btn[data-faction="wu"] { background-image: url('images/ui/start-wu-fortress.webp'); }
/* 위쪽 깃발은 잘리지 않게 내리고, 아래 풍경은 원래 위치를 유지한다. */
.pick-btn::before {
  content: ''; position: absolute; z-index: 1; inset: 0; background-image: inherit;
  background-size: cover; background-position: center top;
  -webkit-mask-image: linear-gradient(#000 32%, transparent 68%);
  mask-image: linear-gradient(#000 32%, transparent 68%);
}
.pick-btn[data-faction="wu"]::after { content: ''; position: absolute; inset: 0; background: inherit; transform: scaleX(-1); }
.pick-btn[data-faction="wu"]::before { transform: scaleX(-1); }
.pick-btn:hover, .pick-btn:focus-visible { transform: translateY(-6px); border-color: #ffe2a0; box-shadow: 0 10px 22px #000c, 0 0 20px #dfb65888; filter: brightness(1.14); }
.pick-btn:active { transform: translateY(1px) scale(.98); }
.pick-name { position: relative; z-index: 2; display: grid; place-items: center; width: 100%; height: 100%; font-size: 58px; font-weight: 900; color: #ffebbd; text-shadow: 0 2px 4px #000, 0 0 14px #000, 0 0 24px #000; background: radial-gradient(ellipse at center, #100a0780, transparent 60%); }
/* 위·촉·오의 붓글씨는 투명 이미지로 표시하고 이름 텍스트는 접근성을 위해 유지한다. */
.pick-btn:is([data-faction="wei"], [data-faction="shu"], [data-faction="wu"]) .pick-name { font-size: 0; line-height: 0; }
.pick-btn:is([data-faction="wei"], [data-faction="shu"], [data-faction="wu"]) .pick-name::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 90px; height: 90px;
  transform: translate(-50%, -50%); background: url('images/ui/start-faction-calligraphy.webp') left center / 300% 100% no-repeat;
  filter: drop-shadow(0 2px 3px #000) drop-shadow(0 0 8px #000);
}
.pick-btn[data-faction="shu"] .pick-name::after { background-position: center; }
.pick-btn[data-faction="wu"] .pick-name::after { background-position: right; }
.note { margin-top: 24px; color: var(--muted); font-size: 13px; }
.foe-pick { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 32px auto 0; padding: 15px 24px; width: max-content; border: 1px solid #a47a3d; border-radius: 8px; background: linear-gradient(#332014e8, #120b08f2); box-shadow: inset 0 0 0 3px #b88c4126, 0 5px 18px #000a; }
.foe-pick span { color: #ebcc8d; font-size: 16px; font-weight: bold; margin-right: 12px; }
.foe-pick .chip { min-width: 62px; padding: 9px 16px; font-size: 15px; cursor: pointer; border: 1px solid #8d6a3a; border-radius: 4px; color: #ead7ae; background: linear-gradient(#4c3421, #24160e); transition: filter .15s, transform .15s, box-shadow .15s; }
.foe-pick .chip:hover, .foe-pick .chip:focus-visible { filter: brightness(1.3); }
.foe-pick .chip:active { transform: translateY(2px); }
.foe-pick .chip.on { color: #fff2ca; border-color: #f3d28a; background: linear-gradient(#a77532, #533213); box-shadow: 0 0 12px #e5b45c88, inset 0 0 0 1px #ffdb8955; }
.foe-pick [data-foe="wei"].on { background: linear-gradient(#aa4037, #59201c); }
.foe-pick [data-foe="shu"].on { background: linear-gradient(#4c8552, #21442b); }
.foe-pick [data-foe="wu"].on { background: linear-gradient(#4475a1, #1b3858); }

.f-wei { --fc: var(--wei); }
.f-shu { --fc: var(--shu); }
.f-wu { --fc: var(--wu); }
.f-none { --fc: var(--none); }
.r-c { --rc: var(--r-c); }
.r-r { --rc: var(--r-r); }
.r-e { --rc: var(--r-e); }
.r-l { --rc: var(--r-l); }
.t-inf { --tc: var(--t-inf); }
.t-cav { --tc: var(--t-cav); }
.t-arc { --tc: var(--t-arc); }
.t-str { --tc: var(--t-str); }
.t-geo { --tc: var(--t-geo); }

/* ───────── 게임 레이아웃 ───────── */
/* 가운데 전체가 전장. 군주 블록은 왼쪽 위·아래 구석, 덱·군량은 오른쪽 위·아래 구석에 겹쳐 놓는다 */
#game { display: grid; grid-template-columns: 1fr 280px; height: 100%; }
#board {
  position: relative; display: grid; gap: 8px; padding: 10px 14px; min-height: 0;
  grid-template-columns: 1fr;
  grid-template-rows: 70px 1fr 1fr 178px;
  grid-template-areas: "ehand" "efield" "pfield" "phand";
  background:
    radial-gradient(ellipse at center, var(--board-1) 0%, var(--board-2) 85%);
}
#enemy-hand { grid-area: ehand; }
#player-hand { grid-area: phand; }
#enemy-field { grid-area: efield; }
#player-field { grid-area: pfield; }
#board::before {
  content: ''; position: absolute; inset: 78px 14px 188px; pointer-events: none;
  border: 1px solid #c9a96b55; border-radius: 18px;
  background: linear-gradient(90deg, #100c09aa, #100c0940 30%, #100c0940 70%, #100c09aa), var(--terrain-image) center top / cover;
  box-shadow: inset 0 0 50px 18px #120c08a8, 0 0 0 3px #130e0acc;
}
#board[data-terrain="plain"] { --terrain-image: url('images/terrain/plain-v3.webp'); }
#board[data-terrain="mountain"] { --terrain-image: url('images/terrain/mountain-v4.webp'); }
#board[data-terrain="water"] { --terrain-image: url('images/terrain/water.webp'); }
.hand-row { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 0 200px 0 200px; }
.hand-row { position: relative; isolation: isolate; border-radius: 9px; }
.hand-row::before { content: ''; position: absolute; inset: 0 -14px; z-index: -1; background: var(--table-image) center / cover no-repeat; box-shadow: inset 0 0 18px #0008; pointer-events: none; }
.hand-row::after { content: ''; position: absolute; left: -14px; right: -14px; height: 17px; z-index: 2; pointer-events: none; background: url('images/ui/board-trim.webp') center top / auto 150px repeat-x; }
#enemy-hand::after { bottom: -9px; }
#player-hand::after { top: -9px; }
#player-hand { --table-image: url('images/ui/table-lower-wide.webp'); }
#enemy-hand { --table-image: url('images/ui/table-upper-wide.webp'); }
.field {
  position: relative;
  display: flex; justify-content: center; align-items: center; gap: 14px;
  min-height: 0; border-radius: 16px; padding: 0 140px;
  background: #100d0a40; box-shadow: inset 0 0 0 1px #e3c78524;
}
#enemy-field { align-items: flex-end; padding-bottom: 14px; }
#player-field { align-items: flex-start; padding-top: 14px; }

/* 턴·지형: 오른쪽 패널의 턴 종료 버튼 위 */
#midline { display: flex; flex-direction: column; gap: 5px; }
#midline .turn {
  align-self: stretch; text-align: center; padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 800;
  background: #00000055; color: var(--muted); border: 1px solid var(--line);
}
#midline .turn.mine { color: #1a1208; background: var(--gold); border-color: var(--gold); }
#midline .terrain { padding: 5px 10px; border-radius: 10px; font-size: 11px; line-height: 1.45; background: #00000055; color: #cfe8c0; border: 1px solid #5d7a4a; }
#midline .terrain b { color: #e6ffd8; font-size: 12px; }

/* ───────── 왼쪽 구석: 군주 카드 + 능력·시설 아이콘 ───────── */
.lord-side {
  position: absolute; left: 14px; width: 184px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.lord-side.foe { top: 20px; }
.lord-side.mine { bottom: 10px; }
.lord-card { border-color: var(--gold); }
.lord-card .u-type { background: #6b4e1e; }
.lord-card.sortie { border-color: #ff7a5a; box-shadow: 0 0 0 2px #ff7a5a88, 0 0 16px #ff7a5a66; }
.l-bar { width: 88%; height: 6px; margin-top: auto; margin-bottom: 10px; border-radius: 99px; background: #00000088; overflow: hidden; }
.l-bar div { height: 100%; background: linear-gradient(90deg, #8f1f26, var(--hp)); transition: width .4s; }
.lord-slot {
  width: 126px; height: 156px; flex: none; border-radius: 12px; border: 2px dashed #ff7a5a66; background: #0000004d;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #ff9a7a;
}
.lord-slot b { font-family: serif; font-size: 40px; opacity: .35; }
.lord-slot span { font-size: 12px; font-weight: 800; }
.lord-slot small { padding: 0 6px; font-size: 10px; line-height: 1.35; text-align: center; color: #ffd0c0; }

.lord-icons { display: flex; gap: 5px; justify-content: center; }
/* 군주 능력: 둥근 아이콘 (이름 첫 글자 + 비용) */
.power {
  position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #5a4426, #1d150e); border: 2px solid var(--line); color: var(--muted);
}
.power.usable { border-color: var(--ok); color: var(--text); cursor: pointer; box-shadow: 0 0 10px #57e07a88; }
.power.used { opacity: .4; }
.power.selected { border-color: #fff; box-shadow: 0 0 14px #fff; }
.power.extra { border-style: double; border-width: 3px; }
.p-glyph { font-size: 17px; font-weight: 900; }
.p-cost {
  position: absolute; top: -6px; left: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--cost); display: grid; place-items: center; font-size: 10px; font-weight: 800; color: #fff; border: 1px solid #c9e0ff;
}
.p-star { position: absolute; top: -7px; right: -5px; font-size: 12px; color: var(--gold); text-shadow: 0 1px 2px #000; }
.power small {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); font-size: 9px; padding: 0 4px;
  border-radius: 4px; background: #000c; color: var(--muted); white-space: nowrap;
}
/* 시설: 네모 아이콘 */
.fac {
  width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center;
  background: #4a3720; border: 2px solid var(--gold);
}
.fac b { font-family: serif; font-size: 20px; line-height: 1; }
.fac small { font-size: 9px; }
.fac.empty { background: #0000004d; border: 2px dashed #5a442999; color: #6a5236; }

.forms { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.form { font-size: 10px; padding: 1px 6px; border-radius: 99px; color: #fff; background: var(--tc); border: 1px solid var(--tc); font-weight: 800; box-shadow: 0 0 8px var(--tc); }

/* ───────── 오른쪽 구석: 덱 더미·군량 ───────── */
.res-col { position: absolute; right: 14px; width: 110px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.res-col.foe { top: 10px; }
.res-col.mine { bottom: 22px; }
.food-box {
  width: 96px; padding: 6px 4px; border-radius: 12px; text-align: center;
  background: #0b1626cc; border: 2px solid #3a78d0aa; box-shadow: 0 0 12px #3a78d044;
}
.food-box small { display: block; font-size: 11px; color: #8fc2ff; }
.food-box b { font-size: 24px; color: #cfe6ff; line-height: 1.1; }
.food-box b span { font-size: 13px; color: #8fc2ff; }
.pips { display: grid; grid-template-columns: repeat(5, 12px); gap: 3px; justify-content: center; margin-top: 4px; }
.pips i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #3a78d0aa; }
.pips i.on { background: radial-gradient(circle at 35% 35%, #9fd0ff, var(--cost)); }
.pips i.off { background: #0e1d33; }
.pips i.none { opacity: .25; }
.food-box { background: linear-gradient(#160e0a99, #160e0ae8), url('images/ui/granary.webp') center / cover; border-color: #ae8c55; box-shadow: 0 2px 12px #000a, inset 0 0 8px #000a; }
.food-box b { color: #fff1c8; text-shadow: 0 2px 3px #000; }
.food-box b span { color: #e5cf9e; }
.pips { grid-template-columns: repeat(5, 16px); gap: 2px; }
.pips i { width: 16px; height: 19px; border: 0; border-radius: 2px; background: url('images/ui/sack-v2.webp') center / contain no-repeat; }
.pips i.on { background: url('images/ui/sack-v2.webp') center / contain no-repeat; filter: brightness(1.2); }
.pips i.off { background: url('images/ui/sack-v2.webp') center / contain no-repeat; filter: grayscale(1) brightness(.45); }
.pips i.none { opacity: .2; filter: grayscale(1) brightness(.4); }
.power { background: url('images/ui/power.webp') center / cover; border-color: #967443; }
.power.extra { background-image: url('images/ui/power-extra.webp'); }
.fac { background: linear-gradient(#120c0944, #120c09aa), url('images/ui/facility.webp') center / cover; }
.fac b { color: #fff3cb; text-shadow: 0 1px 4px #000, 0 0 5px #000; }
.fac.empty { background: linear-gradient(#1b1511aa, #0b0908cc), url('images/ui/facility.webp') center / cover; }

/* ───────── 손패 ───────── */
.hand { flex: 1; display: flex; justify-content: center; align-items: flex-end; min-width: 0; padding: 10px 0 10px; }
.enemy-hand { flex: 1; display: flex; justify-content: center; gap: 4px; }
.enemy-hand .back {
  width: 34px; height: 48px; border-radius: 6px; border: 2px solid var(--gold);
  background: repeating-linear-gradient(45deg, #5b2a1a 0 6px, #43200f 6px 12px);
}

/* ───────── 카드 ───────── */
.card {
  position: relative; width: 118px; height: 166px; flex: none;
  margin: 0 calc(-8px - max(0, var(--n, 0) - 7) * 5px); /* 손패가 많으면 더 겹친다 */
  border-radius: 10px; border: 3px solid var(--rc);
  background: linear-gradient(175deg, var(--fc) -30%, #1d150e 75%);
  display: flex; flex-direction: column; align-items: center; padding: 6px 6px 8px;
  box-shadow: 0 4px 10px #000a; transition: transform .15s, box-shadow .15s; cursor: pointer;
}
.hand .card:hover { transform: translateY(-34px) scale(1.18); z-index: 10; }
.card.playable { box-shadow: 0 0 0 2px var(--ok), 0 0 14px #57e07a88; }
.card.selected { transform: translateY(-26px) scale(1.1); box-shadow: 0 0 0 3px #fff, 0 0 20px #fff; z-index: 9; }
.card.k-spell { background: linear-gradient(175deg, #6b4b8a -30%, #1d150e 75%); }
.card.k-facility { background: linear-gradient(175deg, #8a6a2c -30%, #1d150e 75%); }
.card.k-treasure { background: linear-gradient(175deg, #a07a24 -30%, #1d150e 75%); }

.c-cost {
  position: absolute; top: -9px; left: -9px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--cost); border: 2px solid #c9e0ff; display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #fff; text-shadow: 0 1px 2px #000; z-index: 2;
}
.c-cost.discount { background: var(--ok); color: #0b2a12; text-shadow: none; }
.c-rar {
  position: absolute; top: 4px; right: 5px; font-size: 9px; font-weight: 800; padding: 0 4px; border-radius: 4px;
  background: var(--rc); color: #120d09;
}
.c-art {
  width: 100%; height: 50px; margin-top: 10px; border-radius: 6px; display: grid; place-items: center;
  background: radial-gradient(circle, #ffffff22, #00000044); border: 1px solid #ffffff1c;
}
.c-art span { font-family: serif; font-size: 34px; text-shadow: 0 2px 6px #000; }
.c-name { margin-top: 3px; font-size: 13px; font-weight: 800; }
.c-kind {
  font-size: 9px; padding: 0 6px; border-radius: 99px; background: var(--tc, #00000077); color: #fff; margin-top: 1px;
}
.c-text {
  flex: 1; width: 100%; margin-top: 3px; padding: 3px 4px; border-radius: 5px; background: #00000055;
  font-size: 9.5px; line-height: 1.3; text-align: center; overflow: hidden;
}
.c-text b { color: #ffe39a; }
.c-text .owner { color: var(--gold); }

.stat {
  position: absolute; bottom: -9px; width: 34px; height: 24px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px; color: #fff;
  text-shadow: 0 1px 2px #000; border: 2px solid #0008; z-index: 2;
}
.stat.atk { left: -8px; background: var(--atk); }
.stat.hp { right: -8px; background: var(--hp); }
.stat.atk.int { background: var(--t-str); }
.t-geo .stat.atk.int { background: var(--t-geo); }
.stat.up { color: #b6ffb0; }
.stat.down { color: #ffd0d0; }
.stat.hurt { color: #ffc2c2; }

.card.big { width: 200px; height: 282px; margin: 0; cursor: default; }
.card.big .c-art { height: 92px; }
.card.big .c-art span { font-size: 64px; }
.card.big .c-name { font-size: 20px; }
.card.big .c-kind { font-size: 12px; }
.card.big .c-text { font-size: 12.5px; padding: 6px; }
.card.big .c-cost { width: 38px; height: 38px; font-size: 20px; }
.card.big .stat { width: 48px; height: 32px; font-size: 17px; }
.card.big .c-rar { font-size: 11px; }

/* ───────── 전장의 장수 ───────── */
.unit {
  position: relative; width: 106px; height: 132px; border-radius: 12px;
  border: 3px solid var(--rc);
  background: linear-gradient(175deg, var(--fc) -30%, #1d150e 80%);
  display: flex; flex-direction: column; align-items: center; padding: 16px 4px 4px;
  box-shadow: 0 4px 10px #000a; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.unit.taunt { border-radius: 12px 12px 40px 40px; border-width: 4px; border-color: #d7d7d7; }
.unit.shield { box-shadow: 0 0 0 3px #ffe680, 0 0 16px #ffd84a; }
.unit.ready { box-shadow: 0 0 0 3px var(--ok), 0 0 14px var(--ok); }
.unit.spent { filter: saturate(.55) brightness(.85); }
.unit.selected { transform: translateY(-10px) scale(1.06); box-shadow: 0 0 0 3px #fff, 0 0 22px #fff; filter: none; }
.targetable, .unit.targetable, .lord.targetable {
  box-shadow: 0 0 0 3px var(--target), 0 0 18px var(--target) !important;
  animation: pulse 0.9s infinite alternate; cursor: crosshair;
}
@keyframes pulse { to { transform: scale(1.04); } }
@keyframes shake { 25% { translate: -5px 0; } 50% { translate: 5px 0; } 75% { translate: -3px 0; } }

.u-type {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  padding: 0 8px; border-radius: 99px; font-size: 10px; font-weight: 800; background: var(--tc); color: #fff;
  border: 1px solid #0006; white-space: nowrap;
}
.u-art { font-family: serif; font-size: 36px; line-height: 1.1; text-shadow: 0 2px 6px #000; }
.u-name { font-size: 13px; font-weight: 800; }
.u-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin-top: 2px; min-height: 14px; }
.u-badges i { font-style: normal; font-size: 9px; padding: 0 4px; border-radius: 4px; background: #000a; }
.u-badges .b-taunt { background: #8b8b8b; color: #111; }
.u-badges .b-shield { background: #e0be3a; color: #111; }
.u-badges .b-frozen { background: #4a9ad8; }
.u-badges .b-merit { background: var(--gold); color: #111; }
.u-badges .b-temp { background: var(--ok); color: #111; }
.u-tr { display: flex; gap: 2px; margin-top: 2px; }
.u-tr .tr {
  font-style: normal; font-family: serif; font-size: 12px; width: 18px; height: 18px; border-radius: 4px;
  display: grid; place-items: center; background: #a07a24; border: 1px solid var(--gold);
}
.slot { width: 106px; height: 132px; border-radius: 12px; border: 1px dashed #f4dcaa70; background: #130f0a60; box-shadow: inset 0 0 18px #0004; }

.pv {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); white-space: nowrap;
  padding: 2px 6px; border-radius: 6px; background: #000d; color: #ffb3a8; font-size: 11px; font-weight: 800;
  text-align: center; line-height: 1.25; z-index: 3; pointer-events: none; border: 1px solid var(--target);
}
.lord-card .pv { bottom: 26px; }

/* ───────── 사이드바 ───────── */
#sidebar {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
#detail { min-height: 290px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#detail ul { font-size: 11px; color: var(--muted); padding-left: 16px; align-self: stretch; }
.howto { font-size: 12px; line-height: 1.55; color: var(--muted); padding: 6px; }
.howto b { color: var(--gold); font-size: 14px; }
.howto p { margin-top: 8px; }
#end-turn {
  padding: 12px; border-radius: 10px; border: 2px solid var(--gold); font-size: 17px; font-weight: 900;
  background: linear-gradient(#e7c477, #b98a35); color: #1a1208;
}
#end-turn:disabled { background: #3a2c1d; color: var(--muted); border-color: var(--line); cursor: default; }
#end-turn.glow { animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 18px var(--gold); } }
#hint { min-height: 36px; font-size: 12px; color: #ffe39a; line-height: 1.4; }
#log {
  flex: 1; min-height: 0; overflow-y: auto; font-size: 11px; line-height: 1.5; color: var(--muted);
  background: #0000004d; border-radius: 8px; padding: 6px 8px;
}
#log div:last-child { color: var(--text); }
.side-buttons { display: flex; gap: 6px; }
.side-buttons button {
  flex: 1; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}

/* ───────── 효과 ───────── */
.float {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none; z-index: 50;
  font-size: 26px; font-weight: 900; text-shadow: 0 2px 4px #000, 0 0 2px #000;
  animation: floatUp 1.2s forwards;
}
.float.damage { color: #ff5a4a; }
.float.heal { color: #6dff8f; }
.float.shield { color: #ffe680; font-size: 20px; }
.float.buff { color: #8fffb0; font-size: 16px; }
.float.debuff { color: #ffb0a8; font-size: 16px; }
.float.spend { color: #8fc2ff; font-size: 16px; }
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -60px; } }

#played {
  position: fixed; left: 40%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 40; opacity: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#played.show { animation: playedIn .3s ease-out forwards; }
#played.hide { animation: playedOut .18s ease-in forwards; }
@keyframes playedIn { from { opacity: 0; transform: translate(-50%, -40%) scale(.8); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes playedOut { from { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -55%) scale(.95); } }

/* 특수효과·군주 능력 설명 상자 */
.info-box {
  position: fixed; left: 40%; top: 50%; transform: translate(-50%, -50%); z-index: 57; pointer-events: none;
  width: max-content; min-width: 300px; max-width: 460px; height: auto; padding: 14px 20px; border-radius: 14px; text-align: center;
  background: #1a120cf2; border: 2px solid var(--gold); box-shadow: 0 8px 30px #000c, 0 0 24px #d9b26355;
  animation: infoIn .22s ease-out;
}
.info-box b { display: block; font-size: 20px; color: var(--gold); margin-bottom: 6px; }
.info-box p { font-size: 15px; line-height: 1.5; color: var(--text); }
.info-box.info-power, .info-box.info-skill { width: 600px; max-width: 85%; min-width: 0; min-height: 200px; padding: 58px 95px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; box-shadow: none; background: url('images/ui/ability-popup-transparent.webp') center / contain no-repeat; }
.info-box.info-power b, .info-box.info-skill b { font-size: 21px; margin-bottom: 3px; text-shadow: 0 2px 4px #000; }
.info-box.info-power p, .info-box.info-skill p { font-size: 14px; line-height: 1.2; text-shadow: 0 2px 4px #000; }
.info-box.info-terrain { width: 500px; max-width: 80%; min-width: 0; min-height: 185px; padding: 45px 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; box-shadow: none; background: url('images/ui/terrain-popup-transparent.webp') center / contain no-repeat; }
.info-box.info-terrain b { font-size: 22px; margin-bottom: 3px; text-shadow: 0 2px 4px #000; }
.info-box.info-terrain p { line-height: 1.15; text-shadow: 0 2px 4px #000; }
.info-box.out { opacity: 0; transition: opacity .2s; }
@keyframes infoIn { from { opacity: 0; transform: translate(-50%, -40%) scale(.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* 덱 더미 */
.pile { position: relative; width: 64px; height: 92px; flex: none; margin-right: 6px; }
.pile i {
  position: absolute; left: 0; bottom: calc(var(--k) * 3px); width: 58px; height: 80px; border-radius: 7px;
  border: 2px solid var(--gold); background: repeating-linear-gradient(45deg, #5b2a1a 0 6px, #43200f 6px 12px);
  box-shadow: 0 2px 3px #000a;
}
.pile span { position: absolute; left: 0; right: 6px; bottom: -14px; text-align: center; font-size: 10px; color: var(--muted); }
.pile-count, .pile-empty {
  position: absolute; left: 29px; top: 42%; transform: translate(-50%, -50%); z-index: 2;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center;
  background: #000d; border: 2px solid #ffb0a8; color: #ffb0a8; font-size: 16px; font-weight: 900;
}
.pile-empty { font-size: 11px; height: 22px; border-color: var(--muted); color: var(--muted); }
.pile.low i { border-color: #ffb0a8; }
.played-label {
  padding: 4px 14px; border-radius: 99px; background: #000c; border: 1px solid var(--gold);
  color: var(--gold); font-weight: 800; font-size: 14px; white-space: nowrap;
}

/* ───────── 연출 ───────── */
/* 공격 대상이 맞을 때 */
.unit.hit, .lord.hit { animation: shake .35s, hitflash .35s; }
@keyframes hitflash { 0%, 100% { filter: none; } 30% { filter: brightness(2.2) saturate(.3) drop-shadow(0 0 10px #ff5a4a); } }
.slash {
  position: fixed; width: 90px; height: 90px; pointer-events: none; z-index: 45;
  transform: translate(-50%, -50%) rotate(-35deg) scale(.3); opacity: 0;
  background: linear-gradient(90deg, transparent 44%, #fff 49%, #ffd36a 51%, transparent 56%);
  filter: drop-shadow(0 0 8px #ff8a3a);
  animation: slash .32s ease-out forwards;
}
@keyframes slash {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-35deg) scale(.3); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-35deg) scale(1.5); }
}

/* 병종별 AI 공격·치료 효과: 원본의 다섯 칸을 각각 보여 준다. */
.combat-fx { position: fixed; z-index: 45; pointer-events: none; width: 132px; height: 220px; background-image: url('images/ui/combat-effects-ai.webp'); background-size: 500% 100%; background-repeat: no-repeat; }
.combat-fx-sword { background-position: 0% 50%; }
.combat-fx-spear { background-position: 25% 50%; }
.combat-fx-bow { background-position: 50% 50%; }
.combat-fx-strategy { background-position: 75% 50%; }
.combat-fx-heal { background-position: 100% 50%; }
/* 기술·군주 능력을 쓰는 장수·군주 */
.casting { animation: casting .9s ease-out; }
@keyframes casting {
  0% { box-shadow: 0 0 0 0 #ffd36a; }
  30% { box-shadow: 0 0 0 6px #ffd36acc, 0 0 30px 10px #ffd36a99; filter: brightness(1.3); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* 계략·능력의 대상 */
.aimed { animation: aimed .6s ease-out; }
@keyframes aimed {
  0% { box-shadow: 0 0 0 0 #7fd0ff; }
  40% { box-shadow: 0 0 0 5px #7fd0ffcc, 0 0 24px 8px #7fd0ff88; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* 기술 이름이 위로 떠오른다 */
.pop {
  position: fixed; transform: translate(-50%, -100%); pointer-events: none; z-index: 55; white-space: nowrap;
  padding: 3px 10px; border-radius: 8px; font-weight: 900; text-shadow: 0 1px 2px #000;
  animation: popUp 1s ease-out forwards;
}
.skill-pop { font-size: 18px; padding: 4px 14px; color: #fff3c4; background: #5a3a10ee; border: 1px solid var(--gold); }
.power-pop { font-size: 22px; color: #1a1208; background: linear-gradient(#ffe7a3, #d9a441); border: 2px solid #fff3c4; box-shadow: 0 0 20px #ffd36a; }
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -110%) scale(1.1); }
  25% { transform: translate(-50%, -110%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -170%); }
}
/* 턴 시작 */
.turn-banner {
  position: fixed; left: 40%; top: 50%; z-index: 58; pointer-events: none;
  width: 440px; height: 145px; padding: 0 40px 0 100px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 34px; font-weight: 900; letter-spacing: 6px; white-space: nowrap;
  border: 0; text-shadow: 0 2px 5px #000, 0 0 8px #000; animation: banner .9s ease-out forwards;
}
.turn-banner.mine { color: #ffe6a0; background: url('images/ui/turn-banner-transparent.webp') center / contain no-repeat; }
.turn-banner.foe { color: #ffd1bb; background: url('images/ui/turn-banner-transparent.webp') center / contain no-repeat; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-80%, -50%); }
  20%, 75% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-20%, -50%); }
}
/* 상대가 카드를 뽑을 때 날아가는 카드 뒷면 */
.fly-back {
  position: fixed; width: 34px; height: 48px; border-radius: 6px; z-index: 45; pointer-events: none;
  border: 2px solid var(--gold); background: repeating-linear-gradient(45deg, #5b2a1a 0 6px, #43200f 6px 12px);
}

/* ───────── 덱 구성 화면 ───────── */
.deck-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px;
  background: radial-gradient(ellipse at center, #3a2918 0%, #140e0a 85%);
}
.deck-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dh-lord { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 12px; border: 2px solid var(--gold); background: linear-gradient(110deg, var(--fc) -30%, #1d150e 70%); }
.dh-lord span { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: serif; font-size: 28px; border: 2px solid var(--gold); background: #0006; }
.dh-lord b { display: block; font-size: 16px; }
.dh-lord small { color: var(--muted); }
.meter { position: relative; width: 190px; height: 34px; border-radius: 10px; background: #0007; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; font-size: 13px; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; background: #3a78d066; z-index: 0; transition: width .2s; }
.meter span, .meter b { position: relative; z-index: 1; }
.meter.full i { background: #57e07a66; }
.meter.over i { background: #ff5a4a88; }
.dh-rule { color: var(--muted); font-size: 12px; }
/* 화면이 커지면 가운데·오른쪽 칸과 큰 카드도 같이 커진다 */
.deck-body {
  flex: 1; min-height: 0; display: grid; gap: 12px;
  grid-template-columns: 1fr 336px 290px;
  --ch: 400px; /* 큰 카드 높이 */
}
/* 가운데: 큰 카드 + 덱 정보. 칸 높이를 넘으면 이 칸만 스크롤 */
.deck-detail-col {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 16px 10px 10px; border-radius: 12px; background: #0000004d; border: 1px solid var(--line);
}
#deck-detail { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(var(--ch) + 10px); flex: none; }
#deck-detail .howto { align-self: center; text-align: center; }
:is(#deck-detail, .gallery-card) .card.big { width: calc(var(--ch) * 0.71); height: var(--ch); }
:is(#deck-detail, .gallery-card) .card.big .c-art { height: calc(var(--ch) * 0.34); }
:is(#deck-detail, .gallery-card) .card.big .c-art span { font-size: calc(var(--ch) * 0.23); }
:is(#deck-detail, .gallery-card) .card.big .c-name { font-size: calc(var(--ch) * 0.062); }
:is(#deck-detail, .gallery-card) .card.big .c-kind { font-size: calc(var(--ch) * 0.034); }
:is(#deck-detail, .gallery-card) .card.big .c-text { font-size: calc(var(--ch) * 0.04); padding: 8px; }
:is(#deck-detail, .gallery-card) .card.big .stat { width: calc(var(--ch) * 0.15); height: calc(var(--ch) * 0.095); font-size: calc(var(--ch) * 0.05); }
.deck-summary {
  flex: 1; align-self: stretch; display: flex; flex-direction: column; gap: 4px;
  padding: 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
}
.deck-summary .curve { flex: 1; min-height: 70px; max-height: 180px; height: auto; }
.deck-pool { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.deck-filters { display: flex; gap: 14px; flex-wrap: wrap; }
.deck-filters > div { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: #0006; color: var(--muted); font-size: 12px; }
.chip.on { background: var(--gold); color: #1a1208; border-color: var(--gold); font-weight: 800; }
.deck-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 18px 12px; padding: 14px 10px 18px; align-content: start;
}
.deck-grid .card { margin: 0; }
.pool-card { cursor: pointer; }
.pool-card:hover { transform: translateY(-4px); }
.pool-card.picked { box-shadow: 0 0 0 3px var(--ok), 0 0 14px #57e07a88; }
.pool-card.blocked { opacity: .45; filter: grayscale(.6); }
.lead-badge { position: absolute; top: -9px; right: -6px; padding: 1px 6px; border-radius: 6px; background: #000d; border: 1px solid var(--gold); color: var(--gold); font-size: 10px; font-weight: 800; z-index: 3; }
.pick-mark { position: absolute; left: -8px; top: 24px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #0b2a12; font-weight: 900; font-size: 14px; box-shadow: 0 2px 6px #000; z-index: 3; }
/* 오른쪽: 선택 목록만 스크롤되고, 메시지와 버튼은 아래에 고정 */
.deck-side { min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.deck-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; }
/* 남는 공간이 있으면 줄이 늘어나 목록이 칸을 채운다 (최대 54px) */
.deck-list .pick-row { flex: 1 0 auto; min-height: 30px; max-height: 54px; }
.deck-msg, .deck-buttons { flex: none; }
.deck-list h4 { position: sticky; top: 0; z-index: 1; color: var(--gold); font-size: 13px; padding-bottom: 4px; background: var(--panel); }
.deck-list .pick-row { padding: 7px 8px; font-size: 13px; }
.deck-list .empty { color: var(--muted); font-size: 12px; }
.pick-row { display: grid; grid-template-columns: 22px 1fr auto 18px; gap: 6px; align-items: center; padding: 3px 6px; margin-bottom: 2px; border-radius: 6px; background: #0005; border-left: 3px solid var(--rc); font-size: 12px; cursor: pointer; }
.pick-row:hover { background: #5a1a1a99; }
.pr-cost { width: 20px; height: 20px; border-radius: 50%; background: var(--cost); display: grid; place-items: center; font-weight: 800; font-size: 11px; }
.pr-type { font-size: 10px; padding: 0 6px; border-radius: 99px; background: var(--tc); }
.pr-lead { color: var(--gold); font-weight: 800; text-align: right; }
.sum-row { display: flex; gap: 4px; flex-wrap: wrap; }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; height: 70px; align-items: end; margin-top: 6px; }
.curve div { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.curve i { display: block; width: 100%; min-height: 2px; background: var(--cost); border-radius: 3px 3px 0 0; }
.curve b { position: absolute; top: 0; font-size: 10px; }
.curve small { font-size: 10px; color: var(--muted); }
.note-small { font-size: 11px; color: var(--muted); margin-top: 4px; }
.others { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.other { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #0006; border: 1px solid var(--line); cursor: help; }
.other.k-spell { border-color: #8a6bb0; } .other.k-facility { border-color: #b08a3c; } .other.k-treasure { border-color: var(--gold); }
.deck-msg { min-height: 18px; color: #ffb0a8; font-size: 12px; }
.deck-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.deck-buttons button { padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.deck-buttons button:disabled { opacity: .4; cursor: default; }
.deck-buttons .back { grid-column: span 2; }
.deck-buttons .go { grid-column: span 2; padding: 12px; font-size: 17px; font-weight: 900; border: 2px solid var(--gold); background: linear-gradient(#e7c477, #b98a35); color: #1a1208; }
.deck-buttons .go:disabled { background: #3a2c1d; color: var(--muted); border-color: var(--line); cursor: default; }

#overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: #000b; }
.over-box {
  min-width: 320px; max-width: 560px; padding: 28px; border-radius: 16px; text-align: center;
  background: var(--panel); border: 2px solid var(--gold);
}
.over-box h2 { font-size: 34px; color: var(--gold); margin-bottom: 8px; }
.over-box p { color: var(--muted); margin-bottom: 18px; }
.over-box button {
  padding: 10px 28px; border-radius: 10px; border: 2px solid var(--gold); font-weight: 800; font-size: 15px;
  background: linear-gradient(#e7c477, #b98a35); color: #1a1208;
}
.over-box.help { text-align: left; }
.over-box.help h2 { text-align: center; font-size: 24px; }
.over-box.help ul { margin: 10px 0 18px 18px; font-size: 13px; line-height: 1.7; }
.over-box.help button { display: block; margin: 0 auto; }
.over-box.result-box {
  width: 440px; height: 660px; max-width: 90%; padding: 155px 80px 105px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 0; border-radius: 0; background: url('images/ui/result-defeat.webp') center / contain no-repeat;
  text-shadow: 0 2px 5px #000;
}
.over-box.result-box.victory { background-image: url('images/ui/result-victory.webp'); }
.result-box h2 { color: #e8c17e; font-size: 40px; margin-bottom: 12px; }
.result-box.victory h2 { color: #ffe097; text-shadow: 0 2px 6px #000, 0 0 20px #d49b42aa; }
.result-box p { color: #eee0c5; font-size: 16px; margin-bottom: 24px; }
.result-box #again { min-width: 150px; padding: 12px 24px; color: #fff2ce; border: 1px solid #d3a963; background: url('images/ui/button-gold.webp') center / cover; text-shadow: 0 1px 4px #000; transition: transform .12s ease, filter .12s ease; }
.result-box #again:hover { filter: brightness(1.22); }
.result-box #again:active { transform: translateY(2px) scale(.95); }
.result-box #again:focus-visible { outline: 2px solid #ffe6a4; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .result-box #again { transition: none; } }


/* ───────── 화면 개편 (2026-11-03) ───────── */
.hand-row .hand { width: 100%; height: 100%; }
/* 손패 카드는 설명 없이 그림을 크게 */
.hand .card .c-art { flex: 1; height: auto; min-height: 0; margin-bottom: 14px; }
.hand .card .c-art span { font-size: 46px; }
.hand .card.k-spell .c-art, .hand .card.k-facility .c-art, .hand .card.k-treasure .c-art { margin-bottom: 4px; }

/* 장수에 걸린 상태 아이콘 (설명은 오른쪽 패널) */
.u-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin-top: 2px; }
.ic {
  position: relative; font-style: normal; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10px; font-weight: 900; line-height: 1;
  background: #000a; border: 1px solid #ffffff44; color: #fff;
}
.ic.good { background: #1f6b3a; border-color: #6dff8f88; }
.ic.bad { background: #7a1f1f; border-color: #ff8a7a88; }
.ic.off { opacity: .45; }
.ic sub { position: absolute; right: -4px; bottom: -4px; font-size: 8px; background: #000; border-radius: 4px; padding: 0 2px; }
.st-list { align-self: stretch; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text); }
.st-list div { display: flex; gap: 6px; align-items: center; }
.st-list .ic { flex: none; }

/* 군주 정보 큰 카드 */
.lord-big { border-color: var(--gold); }
.lord-big .c-art { margin-top: 4px; }
.lord-big .c-text { font-size: 11px !important; text-align: left; }

/* 전투에 적용된 효과 이름표 */
.fx-tags {
  position: fixed; transform: translate(-50%, -100%); z-index: 56; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  animation: tagsLife 1.7s forwards;
}
.fx-tags span {
  padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 900; white-space: nowrap;
  background: #1a120cee; border: 2px solid var(--gold); color: #fff3c4; text-shadow: 0 1px 2px #000;
  box-shadow: 0 2px 8px #000a; animation: tagIn .25s ease-out backwards;
}
.fx-tags span.up { border-color: #ff7a5a; color: #ffc4b4; background: #4a140ee6; }
.fx-tags span.down { border-color: #7fc0ff; color: #cfe6ff; background: #0e2a4ae6; }
.fx-tags span.ctr { border-color: #fff; color: #fff; background: #5a3a10ee; }
@keyframes tagIn { from { opacity: 0; transform: translateY(8px) scale(.7); } }
@keyframes tagsLife { 0%, 80% { opacity: 1; } 100% { opacity: 0; margin-top: -16px; } }

/* 기술을 쓴 장수 주변으로 퍼지는 고리 */
.burst {
  position: fixed; width: 60px; height: 60px; border-radius: 50%; pointer-events: none; z-index: 44;
  transform: translate(-50%, -50%) scale(.4); border: 4px solid #ffd36a; box-shadow: 0 0 20px #ffd36a, inset 0 0 14px #ffd36a;
  animation: burst .7s ease-out forwards;
}
.burst.big { border-color: #fff3c4; width: 90px; height: 90px; }
@keyframes burst { to { transform: translate(-50%, -50%) scale(2.6); opacity: 0; } }
.fx-tags.below { transform: translate(-50%, 0); flex-direction: column-reverse; }
.card.big.lord-big { height: auto; min-height: 282px; padding-bottom: 24px; }
.card.big.lord-big .c-art { height: 64px; flex: none; }
.card.big.lord-big .c-art span { font-size: 46px; }
.lord-big .c-text { overflow: visible; }
/* 오른쪽 큰 카드: 설명이 길면 카드가 아래로 늘어난다 (잘리지 않게) */
#detail .card.big, #played .card.big { height: auto; min-height: 282px; padding-bottom: 24px; }
#detail .card.big .c-art, #played .card.big .c-art { flex: none; }
#detail .card.big .c-text, #played .card.big .c-text { flex: none; overflow: visible; }

/* ───────── 크기 위계: 전장 카드 > 손패 카드 (2026-11-03) ───────── */
.unit, .slot { width: 126px; height: 156px; }
.unit { padding-top: 18px; }
.unit .u-art { font-size: 46px; }
.unit .u-name { font-size: 14px; }
.unit .stat { width: 38px; height: 26px; font-size: 14px; }
.hand .card { width: 102px; height: 144px; }
.hand .card .c-art span { font-size: 38px; }
.hand .card .c-name { font-size: 12px; }
.hand .card .c-cost { width: 25px; height: 25px; font-size: 13px; }
.hand .card .stat { width: 30px; height: 21px; font-size: 12px; }
.hand { padding: 0; }
/* 덱 더미를 크게 */
.pile { width: 90px; height: 128px; margin: 0; }
.pile i { width: 84px; height: 116px; border-radius: 9px; }
.pile-count, .pile-empty { left: 42px; }
.pile-count { min-width: 38px; height: 38px; font-size: 20px; }

/* ───────── 지형 정하기 화면 (진영 선택 → 지형 → 덱 구성) ───────── */
#terrain { background: linear-gradient(#100b09a8, #100b09bf), url('images/ui/terrain-select-background.webp') center / cover no-repeat; }
.terrain-box { text-align: center; padding: 24px; width: 900px; }
.terrain-box h2 { font-size: 40px; letter-spacing: 6px; color: var(--gold); text-shadow: 0 3px 0 #000, 0 0 30px #d9b26355; }
.terrain-box .sub { color: var(--muted); margin: 8px 0 28px; }
.terrain-cards { display: flex; gap: 26px; justify-content: center; cursor: pointer; }
.t-card {
  width: 230px; height: 260px; border-radius: 16px; padding: 18px 14px; border: 3px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--text);
  background: linear-gradient(170deg, var(--tc, #555) -40%, #1b130c 80%);
  transition: transform .12s, border-color .12s, box-shadow .12s, opacity .3s, filter .3s;
}
.t-card.t-plain { --tc: #7fa04a; }
.t-card.t-mountain { --tc: #8a7a5a; }
.t-card.t-water { --tc: #3a78b0; }
.t-card.t-plain { background: linear-gradient(#100d0966, #100d09dd), url('images/terrain/plain-v3.webp') center / cover; }
.t-card.t-mountain { background: linear-gradient(#100d0966, #100d09dd), url('images/terrain/mountain-v4.webp') center / cover; }
.t-card.t-water { background: linear-gradient(#100d0966, #100d09dd), url('images/terrain/water.webp') center / cover; }
.t-card b { color: #f1d397; }
#sidebar { background: linear-gradient(#120c0840, #120c0840), url('images/ui/sidebar-pattern.webp') center / cover; border-left: 2px solid #9b7945; box-shadow: -8px 0 24px #0009; }
#log { border: 1px solid #92734355; background: #0b09072b; padding: 10px; text-shadow: 0 1px 3px #000; }
#midline .terrain { background: linear-gradient(100deg, #242e20, #171a13); border-color: #8d9a65; }
#end-turn { box-shadow: inset 0 1px #fff8, 0 3px 0 #60401c, 0 5px 12px #0008; letter-spacing: 2px; }
.side-buttons button { background: linear-gradient(#403022, #1e1712); border-color: #80633d; }
.side-buttons button:hover, .deck-buttons button:hover:not(:disabled) { border-color: #e5c17b; color: #ffe7b3; }
#midline .turn, #midline .turn.mine { background: url('images/ui/button-wide.webp') center / cover; color: #fff2ce; border: 0; text-shadow: 0 1px 3px #000; }
#midline .terrain { background: linear-gradient(#112015aa,#112015aa), url('images/ui/bar-terrain.webp') center / cover; border: 0; text-shadow: 0 1px 4px #000, 0 0 4px #000; }
#end-turn { background: url('images/ui/button-gold.webp') center / cover; color: #fff5d1; border: 1px solid #e7be75; box-shadow: 0 0 12px #d7a13e55; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
#end-turn:disabled { background: linear-gradient(#1a090975, #1a090975), url('images/ui/button-gold.webp') center / cover; color: #e3c9ad; border: 1px solid #a0784f; }
.side-buttons button { background: url('images/ui/button-wide.webp') center / cover; color: #fff2cb; border: 0; box-shadow: none; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
/* 버튼 조작 반응: 기존 턴 종료 강조 연출을 덮어쓰지 않는다. */
#end-turn:not(:disabled), .side-buttons button, .power.usable[data-power] { transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; }
#end-turn:not(:disabled):hover, .side-buttons button:hover, .power.usable[data-power]:hover { filter: brightness(1.22); box-shadow: 0 0 14px #f3c46a99; }
#end-turn:not(:disabled):active, .side-buttons button:active, .power.usable[data-power]:active { transform: translateY(2px) scale(.94); filter: brightness(1.4); }
#end-turn:focus-visible, .side-buttons button:focus-visible { outline: 2px solid #ffe6a4; outline-offset: 3px; }
.button-feedback { position: absolute; z-index: 65; pointer-events: none; border: 2px solid #ffdd8f; border-radius: 999px; box-shadow: 0 0 14px 4px #ffbf4c99, inset 0 0 12px #ffdc8a88; animation: button-feedback .42s ease-out forwards; }
@keyframes button-feedback { from { opacity: .95; transform: translate(-50%, -50%) scale(.72); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.35); } }
@media (prefers-reduced-motion: reduce) {
  #end-turn:not(:disabled), .side-buttons button, .power.usable[data-power] { transition: none; }
  .button-feedback { display: none; }
}
.t-card b { font-family: serif; font-size: 84px; line-height: 1.1; text-shadow: 0 3px 8px #000; }
.t-card span { font-size: 34px; font-weight: 900; color: #ffebbd; text-shadow: 0 2px 5px #000, 0 0 16px #000; }
.t-card small { font-size: 12px; line-height: 1.5; color: #e2d6bc; }
.t-card.lit { border-color: var(--gold); transform: translateY(-8px); box-shadow: 0 0 24px #d9b26388; }
.t-card.chosen { transform: translateY(-12px) scale(1.06); box-shadow: 0 0 0 3px var(--gold), 0 0 40px #d9b263aa; }
.t-card.out { opacity: .4; filter: grayscale(.6); }
.terrain-info { min-height: 110px; margin: 26px auto 18px; max-width: 760px; padding: 10px 20px; border: 1px solid #a5804a88; border-radius: 8px; background: linear-gradient(#25180edb, #110b08eb); box-shadow: inset 0 0 0 3px #c6a3661c, 0 5px 18px #0009; }
.terrain-info h3 { font-size: 26px; color: var(--gold); }
.terrain-info p { margin-top: 6px; font-size: 15px; line-height: 1.6; }
.t-strong { color: #cfe8c0; font-size: 14px !important; }
.t-strong b { color: #e6ffd8; }
.t-rolling { color: var(--muted); }
.terrain-buttons { display: flex; gap: 12px; justify-content: center; }
.terrain-buttons button { min-width: 120px; padding: 13px 26px; border-radius: 5px; border: 1px solid #b48b4b; background: url('images/ui/button-wide.webp') center / cover; color: #fff0c5; font-size: 16px; font-weight: 800; text-shadow: 0 2px 4px #000; box-shadow: 0 4px 12px #000a; transition: filter .15s, transform .15s, box-shadow .15s; }
.terrain-buttons .go { min-width: 190px; border-color: #e1b75e; background: url('images/ui/button-gold.webp') center / cover; color: #fff3d0; }
.terrain-buttons button:hover:not(:disabled), .terrain-buttons button:focus-visible { filter: brightness(1.25); box-shadow: 0 0 14px #e7ba6899; }
.terrain-buttons button:active:not(:disabled) { transform: translateY(2px) scale(.97); }
.terrain-buttons .go:disabled { filter: grayscale(.8) brightness(.6); cursor: default; }

/* 덱 구성 화면의 지형 표시 */
.dh-terrain { padding: 4px 12px; border-radius: 10px; background: #00000066; border: 1px solid #5d7a4a; color: #cfe8c0; display: flex; flex-direction: column; }
.dh-terrain b { font-size: 14px; color: #e6ffd8; }
.dh-terrain small { font-size: 11px; }

/* 덱 구성: 전장의 작전 탁자와 청동 장식 */
.deck-screen {
  background: linear-gradient(#0d0907a8, #0d0907c9), url('images/ui/deck-background.webp') center / cover no-repeat;
}
.deck-head {
  padding: 8px 12px; gap: 10px 16px; border: 1px solid #a7844b99; border-radius: 8px;
  background: linear-gradient(100deg, #2d1d13ed, #140d09e8); box-shadow: inset 0 0 0 3px #bd98571c, 0 5px 16px #0009;
}
.dh-lord { border-radius: 6px; border-color: #bd995d; box-shadow: inset 0 0 0 2px #e6c38220; }
.dh-lord span { background: #100b08ad; }
.meter { border-radius: 5px; border-color: #987644; background: #0b0807c9; color: #f3dfb8; }
.meter i { background: #af793b77; }
.dh-terrain { border-radius: 5px; background: #172316d9; border-color: #879869; }
.dh-rule { color: #d2b78c; }
.deck-pool { padding: 8px; border: 1px solid #8d6d4199; border-radius: 8px; background: #100b08b8; box-shadow: inset 0 0 0 3px #c29d5a14, 0 5px 14px #0008; }
.deck-filters { gap: 10px 16px; padding: 3px 2px; }
.deck-filters .chip { padding: 6px 10px; border-radius: 4px; border-color: #765934; background: linear-gradient(#3b2a1c, #1d130d); color: #dfc79f; transition: filter .15s, transform .15s; }
.deck-filters .chip.on { border-color: #eac97d; color: #2a170a; background: linear-gradient(#edcf8c, #b9883b); }
.deck-filters .chip:hover { filter: brightness(1.25); }
.deck-filters .chip:active { transform: translateY(2px); }
.deck-grid { scrollbar-color: #9b7846 #21170f; scrollbar-width: thin; }
.deck-detail-col, .deck-side { border-radius: 8px; border-color: #a7834f; background: linear-gradient(#25180fe8, #100b09f2); box-shadow: inset 0 0 0 3px #d8b36c19, 0 5px 16px #0009; }
.deck-summary { border-color: #8d6b3c; border-radius: 6px; background: #160f0be8; }
.deck-list h4 { padding: 8px; border-bottom: 1px solid #8a6b3c; background: #25180f; color: #f1cf88; font-size: 15px; }
.deck-list .empty { padding: 10px 8px; color: #c9ad82; }
.deck-list .pick-row { background: linear-gradient(90deg, #3f2c1cbb, #1a120da8); }
.deck-list .pick-row:hover { background: #6b4a2ec9; }
.deck-buttons button { min-height: 38px; border-radius: 4px; border-color: #967343; background: url('images/ui/button-wide.webp') center / cover; color: #ffedc6; font-weight: 700; text-shadow: 0 2px 4px #000; transition: filter .15s, transform .15s, box-shadow .15s; }
.deck-buttons .go { border-color: #e4bd6f; color: #fff4d2; background: url('images/ui/button-gold.webp') center / cover; text-shadow: 0 2px 4px #000; }
.deck-buttons .go:disabled { background: url('images/ui/button-gold.webp') center / cover; color: #e1d1b4; border-color: #80684a; filter: grayscale(.8) brightness(.6); }
.deck-buttons button:hover:not(:disabled), .deck-buttons button:focus-visible { filter: brightness(1.25); box-shadow: 0 0 12px #e6b86388; }
.deck-buttons button:active:not(:disabled) { transform: translateY(2px) scale(.97); }
.terrain-mark { position: absolute; left: -6px; top: 24px; z-index: 3; padding: 1px 5px; border-radius: 6px; font-size: 11px; font-weight: 900; background: #000d; border: 1px solid; }
.terrain-mark.up { color: #8fffb0; border-color: #57e07a; }
.terrain-mark.down { color: #ffb0a8; border-color: #ff5a4a; }
.terrain-mark.mix { color: #ffe39a; border-color: var(--gold); }
.pool-card.picked .terrain-mark { top: 52px; }
.deck-terrain-eff { margin-top: 6px; font-size: 13px; color: var(--muted); text-align: center; }
.deck-terrain-eff .up { color: #8fffb0; font-weight: 800; }
.deck-terrain-eff .down { color: #ffb0a8; font-weight: 800; }

/* 장수 카드: 세로 3:가로 2 일러스트와 청동 테두리 */
.card.k-unit { background: #211913 url('images/ui/unit-card-premium.webp') center / cover no-repeat; }
.card.k-unit .c-art, :is(#deck-detail, .gallery-card) .card.big.k-unit .c-art, .hand .card.k-unit .c-art {
  flex: none; width: auto; height: 45%; aspect-ratio: 2 / 3; min-height: 0;
  margin: 7px 0 0; overflow: hidden; border-radius: 3px;
  border: 1px solid #c9a86c88; background: linear-gradient(150deg, #594a3c, #1d1714);
}
.card.k-unit .c-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card.k-unit .c-art span { font-size: 30px; color: #e8d3a8; }
.card.k-unit .c-name { margin-top: 2px; color: #fff0cb; text-shadow: 0 2px 3px #000; }
.card.k-unit .c-text { margin-top: 2px; background: #100c0ab8; }
.card.big.k-unit .c-art span, :is(#deck-detail, .gallery-card) .card.big.k-unit .c-art span { font-size: 52px; }
:is(#deck-detail, .gallery-card) .card.big.k-unit { height: auto; min-height: var(--ch); padding-bottom: 24px; }
:is(#deck-detail, .gallery-card) .card.big.k-unit .c-art { height: calc(var(--ch) * .48); }
:is(#deck-detail, .gallery-card) .card.big.k-unit .c-text { flex: none; overflow: visible; }
.hand .card.k-unit .c-art { height: 58%; margin: 4px 0 0; }
.hand .card.k-unit .c-art span { font-size: 34px; }

/* 일러스트 위에 이름과 효과를 올리는 장수 카드 */
.card.k-unit.has-art {
  padding: 0; overflow: visible; border-width: 2px; border-radius: 8px;
  background: #18362e url('images/ui/unit-card-landscape.webp') center / cover no-repeat;
  box-shadow: inset 0 0 0 2px #e8cc8e, 0 4px 10px #000a;
}
.card.k-unit.has-art .c-art, :is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-art, .hand .card.k-unit.has-art .c-art {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; aspect-ratio: auto;
  border: 0; border-radius: 5px; background: transparent; overflow: hidden;
}
.card.k-unit.has-art .c-art img { width: 100%; height: 100%; object-fit: contain; }
.card.k-unit.has-art .c-art::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, #080c0b9c, transparent 25%, transparent 46%, #0b100fd9 75%, #0b100fee); box-shadow: inset 0 0 0 2px #e8c47a; border-radius: 5px; }
.card.k-unit.has-art .c-name { position: absolute; z-index: 1; top: 5%; left: 20%; margin: 0; font-size: 14px; color: #fff4d5; text-align: left; text-shadow: 0 2px 4px #000, 0 0 6px #000; }
.card.k-unit.has-art .c-kind { position: absolute; z-index: 1; top: 19%; left: 8%; margin: 0; }
.card.k-unit.has-art .c-text { position: absolute; z-index: 1; left: 7%; bottom: 9%; width: 86%; max-height: 46%; margin: 0; padding: 0; background: transparent; text-align: left; font-size: 8px; line-height: 1.25; color: #fff9e9; text-shadow: 0 1px 3px #000, 0 0 4px #000; overflow: hidden; }
.card.k-unit.has-art .c-cost, .card.k-unit.has-art .c-rar, .card.k-unit.has-art .stat { z-index: 3; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art { height: var(--ch); min-height: 0; padding: 0; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-name, .card.big.k-unit.has-art .c-name { font-size: 23px; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-text, .card.big.k-unit.has-art .c-text { font-size: 11px; line-height: 1.35; overflow: hidden; }
.hand .card.k-unit.has-art .c-name { font-size: 13px; }

/* 관우 카드: 얇은 삼국지 테두리와 군량·능력치 장식 */
.card.k-unit.has-art::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 5px; background: url('images/ui/unit-frame-thin.webp') center / cover no-repeat; }
.card.k-unit.has-art .c-name { z-index: 3; top: 3%; left: 9%; max-width: 42%; font-size: 12px; }
.card.k-unit.has-art .c-kind { z-index: 3; top: 10%; left: 9%; padding: 0 4px; font-size: 8px; }
.card.k-unit.has-art .c-rar { z-index: 3; top: 3%; right: 7%; font-size: 8px; }
.card.k-unit.has-art .c-food { position: absolute; z-index: 3; top: 10%; right: 7%; width: 35%; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0; filter: drop-shadow(0 1px 2px #000); }
.card.k-unit.has-art .c-food i { width: 19%; aspect-ratio: 1; background: url('images/ui/sack-v2.webp') center / contain no-repeat; }
.card.k-unit.has-art .c-food.discount { filter: drop-shadow(0 0 3px #6eff88); }
.card.k-unit.has-art .c-text { z-index: 3; bottom: 6%; max-height: 46%; }
.card.k-unit.has-art .c-text .effect-name { color: #ffda75; }
.card.k-unit.has-art .stat { width: 34px; height: 34px; bottom: -8px; border: 0; border-radius: 50%; background-color: transparent; background-position: center; background-size: contain; background-repeat: no-repeat; font-size: 12px; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.card.k-unit.has-art .stat.atk { left: -7px; background-image: url('images/ui/unit-stat-attack.webp'); }
.card.k-unit.has-art .stat.hp { right: -7px; background-image: url('images/ui/unit-stat-health.webp'); }
.card.big.k-unit.has-art .stat, :is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .stat { width: 54px; height: 54px; bottom: -10px; font-size: 17px; }
.card.big.k-unit.has-art .c-name, :is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-name { font-size: 19px; }
.card.big.k-unit.has-art .c-kind { font-size: 11px; }
.card.big.k-unit.has-art .c-rar { font-size: 10px; }
.hand .card.k-unit.has-art .stat { width: 30px; height: 30px; font-size: 11px; }
.card.k-unit.has-art .lead-badge { top: auto; bottom: 1px; left: 38%; right: auto; z-index: 4; }

/* 등급별 테두리와 상단 이름표 */
.card.k-unit { --unit-frame: url('images/ui/unit-frame-common-v4.webp'); }
.card.k-unit.r-c { --unit-frame: url('images/ui/unit-frame-common-v4.webp'); border-color: #806246; }
.card.k-unit.r-r { --unit-frame: url('images/ui/unit-frame-rare-v4.webp'); border-color: #8e5fb2; }
.card.k-unit.r-e { --unit-frame: url('images/ui/unit-frame-hero-v4.webp'); border-color: #b54943; }
.card.k-unit.r-l { --unit-frame: url('images/ui/unit-frame-legend-v4.webp'); border-color: #d4aa58; }
.card.k-unit.has-art::after { background-image: var(--unit-frame); }
.card.k-unit:not(.has-art)::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: 5px; background: var(--unit-frame) center / cover no-repeat; }
.card.k-unit:not(.has-art) { background: linear-gradient(175deg, var(--fc) -30%, #1d150e 75%); }
.card.k-unit:not(.has-art) .c-art, .card.k-unit:not(.has-art) .c-name, .card.k-unit:not(.has-art) .c-kind, .card.k-unit:not(.has-art) .c-text { position: relative; z-index: 2; }
.card.k-unit:not(.has-art) .c-rar { z-index: 2; }
.card.k-unit.has-art .c-name { top: 3%; left: 5%; width: 29%; max-width: none; text-align: center; }
.card.k-unit.has-art .c-kind { top: 9%; left: 5%; width: 29%; padding: 0; text-align: center; background: transparent; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.card.k-unit.has-art .c-rar { top: 3%; right: 5%; width: 18%; padding: 0; background: transparent; text-align: center; color: #fff0ca; text-shadow: 0 1px 3px #000, 0 0 5px #000; }
.card.k-unit.has-art .c-food { top: 3%; left: 35%; right: auto; width: 41%; flex-wrap: nowrap; justify-content: center; }
.card.k-unit.has-art .c-food i { flex: 0 0 12%; width: 12%; background-image: url('images/ui/sack-transparent.webp'); }
.card.k-unit.has-art .stat.hp { background-size: auto 120%; }

/* 모든 등급의 이름·병종·등급 칸을 같은 위치와 크기로 표시한다. */
.card.k-unit.has-art::after { -webkit-mask-image: none; mask-image: none; background-size: contain; }
.card.k-unit.has-art .c-name, .card.k-unit.has-art .c-kind, .card.k-unit.has-art .c-rar {
  display: grid; place-items: center; box-sizing: border-box; padding: 0; margin: 0;
  line-height: 1; border: 0; background: transparent;
  border-radius: 3px; text-align: center; text-shadow: 0 1px 3px #000;
}
.card.k-unit.has-art .c-name { top: 2%; left: 7%; width: 32%; height: 8%; font-size: 12px; color: #fff3d6; }
.card.k-unit.has-art .c-kind { top: 11.5%; left: 7%; width: 25%; height: 4.5%; font-size: 8px; color: #f8e3bf; }
.card.k-unit.has-art .c-rar { top: 2.5%; right: 6%; width: 15%; height: 5%; font-size: 8px; }
.card.k-unit.r-c.has-art .c-rar { color: #d8c6aa; }
.card.k-unit.r-r.has-art .c-rar { color: #d49eff; }
.card.k-unit.r-e.has-art .c-rar { color: #ff7770; }
.card.k-unit.r-l.has-art .c-rar { color: #ffdc79; }
.card.big.k-unit.has-art .c-name, :is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-name { font-size: 19px; }
.card.big.k-unit.has-art .c-kind, .card.big.k-unit.has-art .c-rar { font-size: 10px; }
.card.k-unit.has-art .c-food { top: 2%; left: 38%; width: 42%; }
.card.k-unit.has-art .stat.atk { background-image: url('images/ui/unit-stat-attack-diagonal.webp'); }

/* 프레임의 실제 테두리를 카드 가장자리에 맞춘다. */
.card.k-unit.has-art::after { background-size: 100% 100%; }
.card.k-unit.has-art .c-name { left: 10%; }
.card.k-unit.has-art .c-kind { left: 10%; font-size: 7px; }
.card.k-unit.has-art .c-rar { right: 8%; }
.card.big.k-unit.has-art .c-kind, :is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-kind { font-size: 8px; }
.card.k-unit.has-art::after, .card.k-unit:not(.has-art)::after {
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 17% no-repeat, linear-gradient(#000 0 0) bottom / 100% 4% no-repeat, linear-gradient(#000 0 0) left / 4% 100% no-repeat, linear-gradient(#000 0 0) right / 4% 100% no-repeat;
  mask: linear-gradient(#000 0 0) top / 100% 17% no-repeat, linear-gradient(#000 0 0) bottom / 100% 4% no-repeat, linear-gradient(#000 0 0) left / 4% 100% no-repeat, linear-gradient(#000 0 0) right / 4% 100% no-repeat;
}

/* 프레임은 일러스트 위에 놓고 장식 이외의 흐린 배경은 표시하지 않는다. */
.card.k-unit.has-art::after, .card.k-unit:not(.has-art)::after {
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 3% no-repeat, linear-gradient(#000 0 0) left top / 43% 10.5% no-repeat, linear-gradient(#000 0 0) left top / 33% 16% no-repeat, linear-gradient(#000 0 0) right top / 21% 9% no-repeat, linear-gradient(#000 0 0) bottom / 100% 3% no-repeat, linear-gradient(#000 0 0) bottom / 24% 7% no-repeat, linear-gradient(#000 0 0) left / 4% 100% no-repeat, linear-gradient(#000 0 0) right / 4% 100% no-repeat;
  mask: linear-gradient(#000 0 0) top / 100% 3% no-repeat, linear-gradient(#000 0 0) left top / 43% 10.5% no-repeat, linear-gradient(#000 0 0) left top / 33% 16% no-repeat, linear-gradient(#000 0 0) right top / 21% 9% no-repeat, linear-gradient(#000 0 0) bottom / 100% 3% no-repeat, linear-gradient(#000 0 0) bottom / 24% 7% no-repeat, linear-gradient(#000 0 0) left / 4% 100% no-repeat, linear-gradient(#000 0 0) right / 4% 100% no-repeat;
}
.card.k-unit.has-art .c-art { z-index: 0; }
.card.k-unit.has-art .c-art img { object-fit: cover; }
.card.k-unit.has-art .c-art::after { box-shadow: none; }
.card.k-unit.has-art .c-name { left: 7%; width: 35%; top: 2%; height: 7%; }
.card.k-unit.has-art .c-kind { left: 6%; width: 26%; top: 11.5%; height: 4.5%; }
.card.k-unit.has-art .c-rar { right: 4%; width: 16%; top: 2.5%; height: 5%; }
.card.k-unit.has-art .c-food { top: 3%; left: 43%; width: 37%; justify-content: center; }
.card.k-unit.has-art .c-food i { flex-basis: 11%; width: 11%; }

/* 투명 PNG 전체 장식을 그대로 표시한다. */
.card.k-unit.has-art::after, .card.k-unit:not(.has-art)::after { -webkit-mask: none; mask: none; }

/* 이름표 안의 글씨와 장수 일러스트 배치 */
.card.k-unit.has-art .c-name { top: 2.6%; }
.card.k-unit.has-art .c-kind { top: 12%; }
.card.k-unit.has-art .c-rar { right: 5.5%; }
.card.k-unit.has-art .c-art img { position: absolute; left: 4%; top: 4%; width: 92%; height: 92%; object-fit: contain; }

/* 덱 구성 화면에서 선택한 카드를 더 크게 보여 준다. */
.deck-body { grid-template-columns: minmax(0, 1fr) clamp(300px, 29vw, 400px) clamp(190px, 18vw, 250px); --ch: clamp(340px, 58vh, 500px); }
.deck-detail-col { padding: 14px 10px 10px; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-text { font-size: clamp(10px, 1.5vh, 12.5px); }
:is(#deck-detail, .gallery-card) .card.big:is(.k-spell, .k-treasure, .k-facility) .c-text { font-size: clamp(10px, 1.5vh, 12.5px); }
@media (max-width: 900px) {
  .deck-body { grid-template-columns: minmax(260px, 1fr) minmax(240px, 32vw) minmax(160px, 21vw); --ch: clamp(300px, 52vh, 400px); gap: 6px; }
}

/* 덱 구성: 군주와 통솔력 중심의 카드 목록 */
.dh-rule { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: #e1ca9e; }
.dh-rule strong { color: #ffe2a0; font-size: 15px; }
.deck-grid .pool-card .c-cost, .deck-grid .pool-card .c-food, .deck-grid .pool-card .c-kind, .deck-grid .pool-card .c-text { display: none; }
.deck-grid .pool-card .c-rar { position: absolute; z-index: 6; top: 4px; right: 4px; padding: 2px 5px; border-radius: 4px; font-size: 11px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px #000; }
.deck-grid .r-c .c-rar { background: #6a625a; }
.deck-grid .r-r .c-rar { background: #673796; }
.deck-grid .r-e .c-rar { background: #a32e30; }
.deck-grid .r-l .c-rar { background: #a77619; }
.deck-lead { position: absolute; z-index: 6; top: -8px; left: -8px; display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid #ead398; border-radius: 50%; background: #58391e; color: #fff2c6; font-size: 15px; font-weight: 900; box-shadow: 0 2px 4px #000; }
.deck-grid .pool-card .stat { width: 32px; height: 32px; bottom: -8px; border: 0; background-color: transparent; background-position: center; background-size: contain; background-repeat: no-repeat; font-size: 11px; }
.deck-grid .pool-card .stat.atk { background-image: url('images/ui/unit-stat-attack-diagonal.webp'); }
.deck-grid .pool-card .stat.hp { background-image: url('images/ui/unit-stat-health.webp'); background-size: auto 120%; }
.deck-grid .pool-card .pick-mark { top: 28px; z-index: 7; }
.deck-grid .pool-card .terrain-mark { top: 42px; z-index: 7; }
.deck-grid .deck-pool-lord { box-shadow: 0 0 0 2px #d1a64f, 0 0 10px #d6a73988; }
.deck-lord-mark { margin-top: 7px; color: #f6d890; font-size: 10px; font-weight: bold; text-align: center; }
.deck-lord-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px; margin-bottom: 6px; border: 1px solid #b58a3a; border-radius: 6px; background: #3a2917; color: #f5d89b; text-align: left; }
.deck-lord-row .lord-glyph { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #d4b96e; border-radius: 50%; font: 21px serif; }
.deck-lord-row span:nth-child(2) { flex: 1; }
.deck-lord-row small { display: block; font-size: 10px; }
.deck-card-info { align-self: stretch; display: flex; justify-content: center; gap: 7px 14px; flex-wrap: wrap; margin-top: 16px; padding: 9px; border: 1px solid #886a3e; border-radius: 6px; color: #e8d4b0; font-size: 12px; text-align: center; }
.deck-card-info b { color: #ffe5a7; }
.deck-card-info small { flex-basis: 100%; color: #bdb092; }
.deck-card-info .up { color: #8fffb0; }.deck-card-info .down { color: #ffb0a8; }
.card.k-unit.has-art .deck-placeholder { display: grid; place-items: start center; padding-top: 28%; background: radial-gradient(ellipse at 50% 30%, #496051aa, transparent 65%); }
.card.k-unit.has-art .deck-placeholder span { font: 110px serif; color: #e6d1a4; text-shadow: 0 3px 8px #000; opacity: .85; }
:is(#deck-detail, .gallery-card) .deck-lord-preview .c-text { font-size: clamp(10px, 1.4vh, 12px); line-height: 1.3; }
.deck-grid .pool-card .stat.atk.int, .deck-grid .pool-card.t-geo .stat.atk.int { background-color: transparent; background-image: url('images/ui/unit-stat-attack-diagonal.webp'); }

/* 덱 목록의 이름과 등급을 일러스트 유무와 관계없이 같은 곳에 표시한다. */
.deck-grid .pool-card.has-art .c-name { top: 61%; left: 8%; width: 84%; height: auto; font-size: 14px; color: #fff4d6; text-align: center; text-shadow: -1px -1px 2px #000, 1px 1px 2px #000, 0 2px 5px #000; }
.deck-grid .pool-card .c-name { font-size: 14px; text-shadow: -1px -1px 2px #000, 1px 1px 2px #000, 0 2px 5px #000; }
.deck-grid .pool-card.has-art .c-rar { top: 4px; right: 4px; width: auto; height: auto; }
.deck-grid .pool-card .c-rar { font-size: 12px; padding: 2px 6px; }
.deck-grid .pool-card.r-c .c-rar { background: #6a625a; color: #fff; }
.deck-grid .pool-card.r-r .c-rar { background: #673796; color: #fff; }
.deck-grid .pool-card.r-e .c-rar { background: #a32e30; color: #fff; }
.deck-grid .pool-card.r-l .c-rar { background: #a77619; color: #fff; }
.deck-lead { width: 32px; height: 32px; font-size: 17px; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-name { left: 5.5%; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-kind { font-size: 10px; }
.deck-formations { display: grid; gap: 5px; padding: 6px 2px; color: #e8d6b7; font-size: 12px; line-height: 1.35; }
.deck-formations b { color: #f4d284; }
.deck-formations small { color: #c0aa86; font-size: 11px; }
.deck-card-info { justify-content: flex-start; text-align: left; gap: 6px 12px; }

/* 작은 덱 카드의 이름·병종·등급을 같은 위치에 배치한다. */
.deck-grid .card.k-unit.pool-card .c-name { position: absolute; z-index: 6; top: 61%; left: 8%; width: 84%; height: auto; margin: 0; text-align: center; }
.deck-grid .card.k-unit.pool-card:not(.deck-pool-lord) .c-kind { position: absolute; z-index: 6; display: block; top: 75%; left: 50%; width: auto; height: auto; transform: translateX(-50%); margin: 0; padding: 1px 6px; border-radius: 8px; background: var(--tc, #514438); color: #fff; font-size: 10px; font-weight: 800; line-height: 1.3; text-align: center; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.deck-grid .deck-type-icon, .deck-grid .deck-keyword-icons { position: absolute; z-index: 7; top: 74%; display: flex; flex-wrap: wrap; gap: 0; pointer-events: none; }
.deck-grid .deck-type-icon { right: 68%; }
.deck-grid .deck-keyword-icons { left: 69%; width: 29%; }
.deck-grid .deck-type-icon .battle-icon { width: 19px; height: 19px; object-fit: contain; }
.deck-grid .deck-keyword-icons .battle-icon { width: 15px; height: 15px; object-fit: contain; }
.deck-grid .card.k-unit.pool-card.has-art.r-c .c-rar { background: #6a625a; color: #fff; }
.deck-grid .card.k-unit.pool-card.has-art.r-r .c-rar { background: #673796; color: #fff; }
.deck-grid .card.k-unit.pool-card.has-art.r-e .c-rar { background: #a32e30; color: #fff; }
.deck-grid .card.k-unit.pool-card.has-art.r-l .c-rar { background: #a77619; color: #fff; }
.deck-grid .card.k-unit.pool-card.has-art .c-rar { display: block; line-height: 1.3; border-radius: 4px; }
.deck-grid .deck-lord-mark { position: absolute; top: 75%; }
.deck-card-info .deck-keyword { text-align: left; line-height: 1.4; }
.deck-grid .card.k-unit.pool-card.has-art .c-rar { font-size: 12px; padding: 2px 6px; }

/* 책사와 풍수사의 지력은 부채 문양으로 표시한다. */
.deck-grid .card.k-unit.pool-card .stat.atk.int,
.deck-grid .card.k-unit.pool-card.t-geo .stat.atk.int,
:is(#deck-detail, .gallery-card) .card.k-unit.has-art .stat.atk.int { background-color: transparent; background-image: url('images/ui/unit-stat-intellect.webp'); background-position: center; background-size: contain; background-repeat: no-repeat; }
:is(#deck-detail, .gallery-card) .card.big.k-unit.has-art .c-kind { top: 11.4%; }

/* 밝은 그림 위에서도 능력치 숫자가 선명하게 보이도록 한다. */
.card .stat, .card.k-unit.has-art .stat, .deck-grid .pool-card .stat {
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 3px #000, 0 0 4px #000;
}

/* 진영별 장수 카드 풍경 */
.card.k-unit.has-art.f-wei { background-image: url('images/ui/unit-card-landscape-wei.webp'); }
.card.k-unit.has-art.f-wu { background-image: url('images/ui/unit-card-landscape-wu.webp'); }
.card.k-unit:not(.has-art).f-wei { background: linear-gradient(#1b0b0b55, #140b0dc9), url('images/ui/unit-card-landscape-wei.webp') center / cover no-repeat; }
.card.k-unit:not(.has-art).f-wu { background: linear-gradient(#07152255, #07101cc9), url('images/ui/unit-card-landscape-wu.webp') center / cover no-repeat; }
/* 장수 고유 효과 이름을 설명에서 구분한다. */
.card.k-unit .c-text .effect-name { color: #ffda75; }

/* 게임 화면의 장수 카드와 정보 영역 */
.field .board-card, .field .slot { width: 138px; height: 172px; flex: none; }
.board-card {
  --unit-frame: url('images/ui/unit-frame-common-v4.webp');
  isolation: isolate; overflow: visible; padding: 0; border: 0; border-radius: 6px;
  background: #18362e url('images/ui/unit-card-landscape.webp') center / cover no-repeat;
}
.board-card.r-r { --unit-frame: url('images/ui/unit-frame-rare-v4.webp'); }
.board-card.r-e { --unit-frame: url('images/ui/unit-frame-hero-v4.webp'); }
.board-card.r-l { --unit-frame: url('images/ui/unit-frame-legend-v4.webp'); }
.board-card.f-wei { background-image: url('images/ui/unit-card-landscape-wei.webp'); }
.board-card.f-wu { background-image: url('images/ui/unit-card-landscape-wu.webp'); }
/* 새 진영 카드: 전장, 손패, 덱 목록과 군주 카드에 같은 풍경을 쓴다. */
.f-dongtak { --faction-landscape: url('images/ui/unit-card-landscape-dongtak.webp'); }
.f-wonso { --faction-landscape: url('images/ui/unit-card-landscape-wonso.webp'); }
.f-wonsul { --faction-landscape: url('images/ui/unit-card-landscape-wonsul.webp'); }
.f-yupyo { --faction-landscape: url('images/ui/unit-card-landscape-yupyo.webp'); }
.f-hwanggeon { --faction-landscape: url('images/ui/unit-card-landscape-hwanggeon.webp'); }
.card.k-unit.has-art:is(.f-dongtak, .f-wonso, .f-wonsul, .f-yupyo, .f-hwanggeon),
.board-card:is(.f-dongtak, .f-wonso, .f-wonsul, .f-yupyo, .f-hwanggeon) { background-image: var(--faction-landscape); }
.card.k-unit:not(.has-art):is(.f-dongtak, .f-wonso, .f-wonsul, .f-yupyo, .f-hwanggeon) {
  background: linear-gradient(#100d0a55, #100d0ac9), var(--faction-landscape) center / cover no-repeat;
}
.board-card::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: var(--unit-frame) center / 100% 100% no-repeat; }
.board-card.taunt { border: 0; border-radius: 6px; box-shadow: 0 0 0 2px #d7d7d7, 0 0 12px #d7d7d777; }
.board-card .u-art { position: absolute; inset: 4%; display: grid; place-items: center; overflow: hidden; }
.board-card .u-art img { width: 100%; height: 100%; object-fit: contain; }
.board-card .u-art span { font: 48px serif; color: #f5dfb2; }
.board-card .u-name { position: absolute; z-index: 3; top: 2.6%; left: 7%; width: 35%; height: 7%; display: grid; place-items: center; color: #fff3d6; font-size: 11px; line-height: 1; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.board-card .u-icons, .board-card .u-tr { position: absolute; z-index: 4; left: 7%; bottom: 12%; margin: 0; }
.board-card .u-tr { left: auto; right: 6%; }
/* 전장 장수: 병종·보물은 위, 효과·키워드는 아래에 구분해 표시한다. */
.board-card .battle-type, .board-card .battle-effects,
.board-card .battle-keywords, .board-card .battle-treasures {
  position: absolute; z-index: 5; display: flex; flex-wrap: wrap; gap: 1px;
  width: 44%; align-items: center; pointer-events: auto;
}
.board-card .battle-type { top: 10%; left: 2%; }
.board-card .battle-treasures { top: 10%; right: 2%; justify-content: flex-end; }
.board-card .battle-effects { top: 59%; left: 2%; }
.board-card .battle-keywords { top: 59%; right: 2%; justify-content: flex-end; }
.board-card .battle-icon { display: block; width: 25px; height: 25px; object-fit: contain; }
.board-card .battle-treasures .tr { display: grid; place-items: center; width: 20px; height: 20px; background: #20170de0; color: #ffe4a1; border: 1px solid #c7a45c; border-radius: 50%; font: 11px serif; }
.board-card .stat { z-index: 4; width: 38px; height: 38px; bottom: -8px; border: 0; background: transparent center / contain no-repeat; font-size: 13px; text-shadow: -1px -1px 2px #000, 1px 1px 2px #000, 0 2px 4px #000; }
.board-card .stat.atk { background-image: url('images/ui/unit-stat-attack-diagonal.webp'); }
.board-card .stat.atk.int, .board-card.t-geo .stat.atk.int { background: transparent url('images/ui/unit-stat-intellect.webp') center / contain no-repeat; }
.board-card .stat.hp { background-image: url('images/ui/unit-stat-health.webp'); background-size: auto 120%; }
.board-card .l-bar { position: absolute; z-index: 3; bottom: 6%; left: 14%; width: 72%; margin: 0; }
.board-card .pv { z-index: 5; }
.hand .card .c-kind, .hand .card .c-rar, .hand .card .stat { display: none; }
.hand .card .c-cost { left: auto; right: -6px; top: -7px; z-index: 6; }
.hand .card.k-unit.has-art .c-name { z-index: 4; }
#detail { flex: 0 0 clamp(330px, 48vh, 410px); min-height: 0; overflow-y: auto; padding: 2px 4px 8px; }
#detail .card.big { flex: none; width: 180px; height: 254px; min-height: 254px; padding-bottom: 8px; }
#detail .card.big.k-unit.has-art { padding: 0; }
.game-card-description { align-self: stretch; flex: none; padding: 8px; border: 1px solid #a7834f; border-radius: 6px; background: #160e0bdc; color: #f7ead1; font-size: 11px; line-height: 1.45; }
.game-card-description b, .game-card-description .owner { color: #f5ce78; }

/* 게임 화면: 손패가 많아도 프레임을 겹치지 않는다. */
.lord-side.foe { top: 28px; }
.lord-side .lord-card { width: 140px; height: 174px; flex: none; }
.hand { gap: 4px; }
.hand .card { flex: 0 1 102px; min-width: 0; width: 102px; height: auto; aspect-ratio: 102 / 144; margin: 0; }
#player-hand .hand .card .c-kind, #player-hand .hand .card .c-rar { display: none; }
.hand .card.k-unit .c-name, .hand .card.k-unit.has-art .c-name {
  position: absolute; z-index: 4; top: auto; bottom: 8%; left: 5%; width: 90%; height: auto;
  margin: 0; color: #fff3d6; font-size: 12px; line-height: 1.2; text-align: center;
  white-space: nowrap; text-shadow: -1px -1px 2px #000, 1px 1px 2px #000, 0 2px 5px #000;
}
#detail { flex: 0 0 565px; }
#detail .card.big { width: 230px; height: 324px; min-height: 324px; }
#detail .card.k-unit.has-art .c-art::after { background: none; }
#detail .card.k-unit.has-art .stat.atk.int { background: transparent url('images/ui/unit-stat-intellect.webp') center / contain no-repeat; }
.game-card-description { font-size: 12px; line-height: 1.4; }

/* 추가 뽑기와 전투 카드 연출 */
.game-actions { display: flex; gap: 6px; }
.game-actions #end-turn { flex: 1; min-width: 0; }
#draw-card { flex: 0 0 92px; padding: 5px; border: 1px solid #d6b268; border-radius: 7px; background: url('images/ui/button-wide.webp') center / cover; color: #fff0c9; font-size: 12px; font-weight: 800; text-shadow: 0 1px 3px #000; }
#draw-card small { display: block; font-size: 10px; color: #f5d48c; }
#draw-card:disabled { opacity: .5; filter: grayscale(.7); }
#draw-card:not(:disabled):hover { filter: brightness(1.25); }
#draw-card:not(:disabled):active { transform: translateY(2px) scale(.95); }
#detail { padding-top: 12px; }
#detail .card.big { margin-left: 10px; }
#detail .card.big .c-cost { left: -18px; top: -3px; }
#played .card.big { width: 280px; min-height: 394px; }
#played .card.big.k-unit.has-art { height: 394px; min-height: 394px; padding: 0; }
#played .card.big.k-unit.has-art .c-text { font-size: 13px; }

/* 카드 연출 제목과 군량 비용 */
.played-label {
  width: 240px; min-height: 76px; display: grid; place-items: center; padding: 0 36px;
  border: 0; border-radius: 0; background: url('images/ui/combat-command-plaque.webp') center / contain no-repeat;
  color: #ffe2a0; font-size: 26px; font-weight: 900; line-height: 1.1;
  text-align: center; text-shadow: -1px -1px 2px #240700, 1px 2px 2px #240700, 0 0 8px #000;
}
.c-cost, .p-cost, .c-cost.discount {
  border: 0; border-radius: 0; background: url('images/ui/sack-transparent.webp') center / contain no-repeat;
  color: #fff7db; text-shadow: -1px -1px 2px #251005, 1px 1px 2px #251005, 0 1px 3px #000; padding-top: 4px;
}
.c-cost.discount { color: #caffad; filter: drop-shadow(0 0 3px #4ee474); }
.hand .card .c-cost { width: 30px; height: 30px; font-size: 14px; }
.p-cost { width: 21px; height: 21px; font-size: 11px; }

/* 긴 규칙은 내용만 스크롤하고 닫기 버튼은 항상 보인다. */
.over-box.help { display: flex; flex-direction: column; width: 620px; max-width: 90%; max-height: 820px; }
.over-box.help h2, .over-box.help button { flex: none; }
.over-box.help ul { min-height: 0; overflow-y: auto; padding-right: 12px; }

/* 덱 구성: 장수 / 책략 카드 탭, 책략 비용 표시(보라) */
.deck-tabs .chip { font-size: 14px; font-weight: 800; padding: 7px 14px; }
.deck-lead.tactic { border-color: #c9a7f0; background: #4a2c6e; color: #f1e4ff; }
.pr-lead.tactic { color: #c9a7f0; }

/* 멀리건: 시작 손패 5장 중 바꿀 카드를 고른다 */
.over-box.mull { width: 1140px; max-width: 96%; }
.mull-cards { display: flex; gap: 14px; justify-content: center; margin: 6px 0 18px; }
.mull-cards .card { position: relative; width: 160px; height: 226px; cursor: pointer; transition: transform .15s, filter .15s, box-shadow .15s; }
.mull-cards .card .c-text { display: block; font-size: 11px; line-height: 1.35; overflow: hidden; }
.mull-cards .card:hover { transform: translateY(-6px); }
.mull-cards .card.out { filter: grayscale(.8) brightness(.55); box-shadow: 0 0 0 3px #ff6a5a; }
.mull-cards .card.out::after { content: '교체'; position: absolute; inset: 0; display: grid; place-items: center; z-index: 10; font-size: 30px; font-weight: 900; color: #ff8a7a; text-shadow: 0 2px 6px #000; }
.mull-kind { display: block; margin-bottom: 4px; text-align: center; font-size: 12px; color: var(--muted); }

/* 위·촉·오 공통 카드 뒷면과 보물·계략·시설 카드 디자인 */
.enemy-hand .back, .pile i, .fly-back {
  background: #21150f url('images/ui/card-back-simple.webp') center / cover no-repeat;
  border-color: #a9834b;
}
.card.k-spell, .card.k-treasure, .card.k-facility {
  --special-frame: none;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  border-width: 1px;
}
.card.k-spell { --special-frame: url('images/ui/card-frame-spell.webp'); background-image: url('images/ui/card-bg-spell.webp'); }
.card.k-treasure { --special-frame: url('images/ui/card-frame-treasure.webp'); background-image: url('images/ui/card-bg-treasure.webp'); }
.card.k-facility { --special-frame: url('images/ui/card-frame-facility.webp'); background-image: url('images/ui/card-bg-facility.webp'); }
.card.k-spell::before, .card.k-treasure::before, .card.k-facility::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: var(--special-frame) center / 100% 100% no-repeat;
}
.card.k-spell .c-art, .card.k-treasure .c-art, .card.k-facility .c-art {
  position: relative; z-index: 2; background: none; border: 0;
}
.card.k-spell .c-name, .card.k-treasure .c-name, .card.k-facility .c-name,
.card.k-spell .c-kind, .card.k-treasure .c-kind, .card.k-facility .c-kind,
.card.k-spell .c-text, .card.k-treasure .c-text, .card.k-facility .c-text { position: relative; z-index: 2; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.card.k-spell .c-cost, .card.k-treasure .c-cost, .card.k-facility .c-cost,
.card.k-spell .c-rar, .card.k-treasure .c-rar, .card.k-facility .c-rar { z-index: 3; }

/* 보물·계략·시설 일러스트는 카드 프레임 안에 비율을 유지해 표시한다. */
.card.has-tactic-art .c-art, :is(#deck-detail, .gallery-card) .card.big.has-tactic-art .c-art {
  flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden;
}
.card.has-tactic-art .tactic-artwork { width: 100%; height: 100%; object-fit: contain; padding: 7%; box-sizing: border-box; }
.card.has-tactic-art .c-text { flex: 0 1 auto; }
.deck-grid .pool-card.has-tactic-art .c-art { flex: 1 1 auto; }

/* 시작 손패의 그림이 설명 영역과 겹치지 않게 남은 공간에 맞춘다. */
.mull-cards .card.has-tactic-art .c-art { display: block; flex: 1 1 0; height: 0; min-height: 0; }
.mull-cards .card.has-tactic-art .tactic-artwork { display: block; }

/* 큰 책략 카드의 그림은 빈 공간을 채우고 글자는 아래에 배치한다. */
#played .card.big.has-tactic-art { height: 394px; }
#played .card.big.has-tactic-art .c-art,
#detail .card.big.has-tactic-art .c-art {
  flex: 1 1 0; height: 0; min-height: 0; width: 100%;
}
#played .card.big.has-tactic-art .c-name,
#played .card.big.has-tactic-art .c-kind,
#played .card.big.has-tactic-art .c-text,
#detail .card.big.has-tactic-art .c-name,
#detail .card.big.has-tactic-art .c-kind { flex: none; }

/* 신화: 무지갯빛 테두리와 어두운 환상 배경 */
.card.k-unit.r-m.has-art, .board-card.r-m {
  --unit-frame: url('images/ui/unit-frame-mythic.webp');
  background: radial-gradient(ellipse at 50% 35%, #453969 0%, #171425 58%, #080914 100%);
  border: 0;
  border-radius: 9px;
  box-shadow: 0 0 0 2px #c59aff, 0 0 18px #8f6fffa0, inset 0 0 24px #080514;
}
.card.k-unit.r-m.has-art::after, .board-card.r-m::after {
  background: var(--unit-frame) center / 100% 100% no-repeat;
  border: 0;
  -webkit-mask-image: none; mask-image: none;
  box-shadow: none;
}
.card.k-unit.r-m.has-art .c-rar { color: #fff0ff; text-shadow: 0 0 7px #ef9dff, 0 1px 3px #000; }
.board-card.r-m .u-name { color: #fff; text-shadow: 0 0 6px #ecb8ff, 0 1px 3px #000; }
#played:has(.r-m) .played-label { color: #fff; text-shadow: 0 0 8px #f9aaff, 0 0 18px #86dfff; }
#played .card.r-m { animation: mythic-arrive .7s ease-out; }
@keyframes mythic-arrive { from { transform: scale(.55); filter: brightness(2.5); opacity: 0; } to { transform: scale(1); filter: brightness(1); opacity: 1; } }

/* 손패 초과: 버릴 카드 고르기 (최대 11장이 보이도록 작게, 줄바꿈) */
.over-box.discard .mull-cards { flex-wrap: wrap; gap: 10px; }
.over-box.discard .mull-cards .card { width: 120px; height: 170px; }
.over-box.discard .mull-cards .card .c-text { font-size: 9px; }
.over-box.discard .mull-cards .card:hover { box-shadow: 0 0 0 3px #ff6a5a; }

/* 신규 진영 (2026-11-05): 시작 화면 버튼 5개, 진영 색, 그림이 없는 군주 */
:root { --dongtak: #7a3b8f; --wonso: #b88a2a; --wonsul: #5c7a2e; --yupyo: #2e7a78; --hwanggeon: #c9a521; }
.f-dongtak { --fc: var(--dongtak); } .f-wonso { --fc: var(--wonso); } .f-wonsul { --fc: var(--wonsul); } .f-yupyo { --fc: var(--yupyo); } .f-hwanggeon { --fc: var(--hwanggeon); }
.lord-glyph-art { display: grid; place-items: center; width: 100%; height: 100%; font-family: serif; font-size: 64px; color: #f4d48b; background: radial-gradient(circle, color-mix(in srgb, var(--fc, #6b4e1e) 60%, #000), #0d0906); text-shadow: 0 2px 6px #000; }
.battle-icon.text-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #c9a521; color: #2a1a05; font-size: 12px; font-weight: 900; }

/* 작은 카드에서도 선과 바탕의 대비가 뚜렷한 상태 아이콘 */
.battle-icon, .board-card .battle-icon {
  box-sizing: border-box; display: inline-grid; place-items: center; flex: none;
  width: 25px; height: 25px; border: 2px solid #fff; border-radius: 50%;
  background: #26323e; color: #fff; box-shadow: 0 1px 3px #000d;
}
.battle-icon svg { width: 84%; height: 84%; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.battle-icon.bi-keyword { background: #814018; border-color: #ffe0a0; }
.battle-icon.bi-treasure { background: #805000; border-color: #ffdd59; }
.battle-icon.bi-increase { background: #ad2525; border-color: #ffd1c6; }
.battle-icon.bi-decrease { background: #15599c; border-color: #c7ebff; }
.battle-icon-name { display: none; }
.deck-grid .deck-type-icon { right: 73%; }
.deck-grid .card.k-unit.pool-card:not(.deck-pool-lord) .c-kind { left: 50%; }
.deck-grid .deck-type-icon .battle-icon { width: 21px; height: 21px; }
.deck-grid .deck-keyword-icons { left: 67%; right: auto; width: 33%; gap: 0; }
.deck-grid .deck-keyword-icons .battle-icon {
  width: auto; min-width: 0; height: 16px; padding: 0 2px; border-width: 1px;
  border-radius: 5px; background: #713810; color: #fff; font-size: 11px; font-weight: 900; line-height: 1;
}
.deck-grid .deck-keyword-icons .battle-icon svg { display: none; }
.deck-grid .deck-keyword-icons .battle-icon-name { display: block; }

/* 검토한 AI 아이콘 모음에서 지정된 칸을 원형으로 보여 준다. */
.battle-icon.sprite-icon, .board-card .battle-icon.sprite-icon,
.deck-grid .deck-type-icon .battle-icon.sprite-icon,
.deck-grid .deck-keyword-icons .battle-icon.sprite-icon {
  display: inline-block; box-sizing: border-box; flex: none; padding: 0; border: 0;
  border-radius: 50%; background-color: transparent;
  background-image: url('images/ui/battle-icon-sheet-ai.webp');
  background-size: 500% 300%; background-position: var(--sprite-x) var(--sprite-y);
  background-repeat: no-repeat; box-shadow: 0 1px 3px #000b;
}
.deck-grid .deck-type-icon .battle-icon.sprite-icon { width: 23px; height: 23px; }
.deck-grid .deck-keyword-icons .battle-icon.sprite-icon { width: 18px; height: 18px; }

/* 황건적 병종 로고와 덱 화면의 병종·효과 설명 */
.battle-icon.yellow-icon, .board-card .battle-icon.yellow-icon {
  border: 0; background: transparent url('images/ui/battle-icon-yellow-turban.webp') center / contain no-repeat;
  box-shadow: 0 1px 3px #000b;
}
.deck-grid .deck-type-icon .battle-icon.yellow-icon { width: 23px; height: 23px; }
.deck-filters .chip-with-icon { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 7px; white-space: nowrap; }
.deck-filters .chip-with-icon .battle-icon { width: 20px; height: 20px; flex: none; }
.deck-card-info .deck-keyword { display: flex; align-items: center; gap: 5px; }
.deck-card-info .deck-keyword .battle-icon { width: 20px; height: 20px; flex: none; }

/* 작은 덱 카드용 AI 아이콘 그림. */
.deck-symbol { box-sizing: border-box; display: inline-block; flex: none; width: 22px; height: 22px; border-radius: 50%; background-image: url('images/ui/deck-symbols-copper.webp'); background-size: 300% 300%; background-repeat: no-repeat; }
.deck-grid .deck-type-icon { top: 50%; right: 100%; transform: translateY(-50%); }
.deck-grid .deck-type-icon .deck-symbol, .deck-grid .deck-type-icon .battle-icon.yellow-icon { width: 21px; height: 21px; }
.deck-grid .deck-keyword-icons { flex-wrap: nowrap; left: auto; right: 0; width: max-content; }
.deck-grid .deck-keyword-icons .deck-symbol { flex: 0 0 21px; width: 21px; height: 21px; }
.deck-filters .chip-with-icon .deck-symbol, .deck-card-info .deck-keyword .deck-symbol { width: 20px; height: 20px; }

/* 손패 카드 크기 통일: 계략·보물·시설 카드는 안쪽 여백과 내용 때문에 더 크게 늘어나던 문제 (2026-11-05) */
.hand .card { box-sizing: border-box; min-height: 0; overflow: hidden; }
.hand .card.has-tactic-art .c-art { flex: 1 1 0; min-height: 0; }
/* 줄어드는 비율을 장수 카드와 같게: 여백 대신 안쪽 요소 간격으로 */
.hand .card.has-tactic-art, .hand .card.k-spell, .hand .card.k-treasure, .hand .card.k-facility { padding: 0; border-width: 2px; }
.hand .card.has-tactic-art .c-art { margin: 6px 6px 0; }
.hand .card.has-tactic-art .c-name { margin: 0 4px 6px; }

/* 시작 화면 (2026-11-05): 위·촉·오 큰 버튼, 그 아래 동탁군·원소군 작은 버튼, 상대 진영은 난이도별 묶음 */
.pick-sub { display: flex; justify-content: center; gap: 14px; margin: 14px 0 6px; }
.pick-btn.small { width: 170px; height: 58px; border-radius: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 75%, #000), #1a120b); }
.pick-btn.small::before, .pick-btn.small::after { display: none; }
.pick-btn.small .pick-name { font-size: 22px; }
.foe-pick { flex-wrap: wrap; justify-content: center; row-gap: 8px; }
.foe-group { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; border-radius: 6px; border: 1px solid #ffffff1a; background: #0000002e; }
.foe-group b { padding: 2px 8px; border-radius: 4px; font-size: 12px; color: #1a1208; }
.foe-group.lv-hard b { background: #d9534f; color: #fff; }
.foe-group.lv-normal b { background: #e0a43a; }
.foe-group.lv-easy b { background: #7cbf5a; }
.foe-group.lv-veasy b { background: #8fd0e8; }

/* 시작 화면: 고른 내 진영 표시, 다음 단계 버튼 (2026-11-05) */
.pick-btn.on { border-color: #ffe2a0; box-shadow: 0 0 0 3px #f4d48b, 0 0 24px #dfb658aa; transform: translateY(-6px); }
.start-go { display: block; margin: 12px auto 0; padding: 10px 28px; border-radius: 6px; border: 1px solid #eac97d; font-size: 17px; font-weight: 800;
  color: #2a170a; background: linear-gradient(#edcf8c, #b9883b); cursor: pointer; }
.start-go:disabled { color: #a08a6a; border-color: #5a4429; background: #1d130d; cursor: default; }

/* 첫 화면 (2026-11-05): 가운데 제목, 아래 "시작"·"갤러리" 버튼 */
#title, #gallery { background: linear-gradient(#100b09a6, #100b09b5), url('images/ui/start-background.webp') center / cover no-repeat; }
.title-box { text-align: center; }
.title-logo {
  width: 850px; max-width: 92vw; height: 260px; display: grid; place-items: center; margin: 0 auto 30px;
  background: url('images/ui/start-title.webp') center / contain no-repeat;
  font-family: 'Malgun Gothic', serif; font-size: 36px; font-weight: 900; letter-spacing: 2px;
  color: #ffe4a0; text-shadow: 0 3px 1px #512600, 0 5px 8px #000, 0 0 24px #e7a03d;
}
.title-buttons { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.title-buttons .start-go { width: 240px; margin: 0; font-size: 20px; padding: 12px 0; }
.start-buttons { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }
.start-buttons .start-go { margin: 0; }
.start-back { padding: 10px 22px; border-radius: 6px; font-size: 15px; }

/* 카드 갤러리: 왼쪽 작은 카드 목록, 오른쪽 고른 카드 크게 */
.gallery-screen { position: fixed; inset: 0; display: flex; flex-direction: column; color: var(--text); }
.gallery-head { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: #0d0907d9; border-bottom: 1px solid #a7804766; flex-wrap: wrap; }
.gallery-head h2 { margin: 0; font-size: 20px; color: #ffe4a0; }
.gallery-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 42vw); }
.gallery-list { overflow-y: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; align-content: start; }
.gallery-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 6px; border: 1px solid transparent; background: #0000004d; cursor: pointer; color: var(--text); font-size: 12px; }
.gallery-item:hover { border-color: #a78047; }
.gallery-item.on { border-color: #f4d48b; box-shadow: 0 0 0 2px #f4d48b88; background: #3a28157a; }
.gallery-card { --ch: 500px; pointer-events: none; }
.gallery-card .card.big { margin: 0; }
.gallery-card.mini { zoom: .21; }
.gallery-view { display: flex; align-items: center; justify-content: center; overflow: hidden; border-left: 1px solid #a7804766; background: #0000004d; }
.gallery-sep { margin-left: 10px; padding-left: 12px; border-left: 1px solid #a7804788; font-size: 12px; color: #c9a86a; align-self: center; }
/* 첫 화면 갤러리 버튼은 시작보다 작게, 뒤로 버튼 디자인 (2026-11-05) */
.title-buttons .start-go.small { width: 150px; padding: 7px 0; font-size: 15px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px 7px 12px; border-radius: 6px;
  border: 1px solid #a78047; background: linear-gradient(#3a2716, #1d130c); color: #f4d48b;
  font-size: 14px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  box-shadow: inset 0 1px 0 #f4d48b33, 0 3px 8px #0009; transition: border-color .15s, filter .15s, transform .15s;
}
.back-btn::before { content: '◀'; font-size: 10px; color: #dfb658; }
.back-btn:hover { border-color: #f4d48b; filter: brightness(1.2); transform: translateX(-2px); }
.start-buttons .back-btn { padding: 10px 18px 10px 14px; font-size: 15px; }
/* 첫 화면 갤러리 버튼: 시작 버튼과 구별되게 어두운 바탕·작은 크기 (2026-11-05) */
.title-buttons { gap: 18px; }
.title-gallery {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px;
  border: 1px solid #a7804799; background: #120c08cc; color: #d9bd85;
  font-size: 13px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 2px 6px #0008; transition: border-color .15s, color .15s, background .15s;
}
.title-gallery::before { content: '❖'; font-size: 11px; color: #a78047; }
.title-gallery:hover { border-color: #f4d48b; color: #ffe4a0; background: #2a1c10e6; }

/* 첫 화면 제목: 위아래로 천천히 흔들림, 시작 버튼 마우스 효과 (2026-11-05) */
.title-logo { animation: title-float 4.5s ease-in-out infinite; }
@keyframes title-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
#title-start { position: relative; overflow: hidden; transition: transform .18s, box-shadow .18s, filter .18s; }
#title-start::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, #fff8e0cc, transparent); transform: skewX(-20deg); opacity: 0;
}
#title-start:hover {
  transform: translateY(-3px) scale(1.04); filter: brightness(1.12);
  box-shadow: 0 0 0 2px #ffe9b0, 0 0 22px 4px #f2c35caa, 0 8px 18px #000a;
}
#title-start:hover::after { opacity: 1; animation: title-shine .9s ease-out; }
#title-start:active { transform: translateY(0) scale(.98); }
@keyframes title-shine { from { left: -60%; } to { left: 120%; } }
@media (prefers-reduced-motion: reduce) { .title-logo, #title-start:hover::after { animation: none; } }

/* 덱 구성 화면 머리줄 오른쪽 끝: 규칙 버튼 (2026-11-06, 전투 화면에서 옮김) */
.deck-head .dh-help {
  margin-left: auto; padding: 7px 16px; border-radius: 6px; border: 1px solid #a78047;
  background: linear-gradient(#3a2716, #1d130c); color: #f4d48b; font-size: 14px; font-weight: 700; cursor: pointer;
}
.deck-head .dh-help:hover { border-color: #f4d48b; filter: brightness(1.2); }

/* 덱 구성: 고른 카드가 잘 보이게 (2026-11-06) — 밝은 초록 테두리·빛, 살짝 위로, 가운데 큰 체크 표시 */
.deck-grid .pool-card.picked {
  outline: 3px solid #6dff95; outline-offset: 1px;
  box-shadow: 0 0 0 1px #0b2a12, 0 0 18px 4px #57e07acc, 0 6px 14px #000c;
  transform: translateY(-4px); z-index: 2;
}
.deck-grid .pool-card .pick-mark {
  left: 50%; top: 36%; transform: translate(-50%, -50%); width: 40px; height: 40px; font-size: 24px;
  border: 2px solid #eaffef; box-shadow: 0 0 0 3px #0b2a12aa, 0 0 16px #57e07a;
}
/* 정보 패널: 효과 설명·수치 이유를 읽기 쉽게 (2026-11-06) */
#detail ul { font-size: 12px; line-height: 1.45; color: #dccaa6; }
#detail ul li { margin-bottom: 3px; }

/* 기병 병종 로고는 창 없이 말만 표시한다. */
.battle-icon.sprite-icon[data-icon="기병"],
.board-card .battle-icon.sprite-icon[data-icon="기병"],
.deck-grid .deck-type-icon .battle-icon.sprite-icon[data-icon="기병"] {
  background-image: url('images/ui/battle-icon-cavalry-horse.webp');
  background-size: contain;
  background-position: center;
}

/* 피해 감소와 증가는 화살표 대신 빛나는 방패와 부서진 방패로 구분한다. */
.battle-icon.sprite-icon[data-icon="피해_감소"],
.board-card .battle-icon.sprite-icon[data-icon="피해_감소"] {
  background-image: url('images/ui/battle-icon-damage-reduced.webp');
  background-size: 120% 120%;
  background-position: center;
}
.battle-icon.sprite-icon[data-icon="받는피해_증가"],
.board-card .battle-icon.sprite-icon[data-icon="받는피해_증가"] {
  background-image: url('images/ui/battle-icon-damage-increased.webp');
  background-size: 120% 120%;
  background-position: center;
}

/* 전투 화면에도 덱 화면과 같은 선명한 병종·키워드 그림을 쓴다. */
.board-card :is(.battle-type, .battle-keywords, .battle-treasures) .battle-icon.sprite-icon {
  background-image: url('images/ui/deck-symbols-copper.webp');
  background-size: 300% 300%;
  flex: 0 0 auto;
}
.board-card .battle-type [data-icon="보병"] { background-position: 0% 0%; }
.board-card .battle-type .battle-icon[data-icon="기병"] { background-position: 50% 0%; }
.board-card .battle-type [data-icon="궁병"] { background-position: 100% 0%; }
.board-card .battle-type [data-icon="풍수사"] { background-position: 0% 50%; }
.board-card .battle-type [data-icon="책사"] { background-position: 50% 50%; }
.board-card .battle-keywords [data-icon="돌진"] { background-position: 100% 50%; }
.board-card .battle-keywords [data-icon="수비"] { background-position: 0% 100%; }
.board-card .battle-keywords [data-icon="유언"] { background-position: 50% 100%; }
.board-card .battle-keywords [data-icon="철벽"] { background-position: 100% 100%; }
/* 보물은 같은 단순한 칼·말 그림을 금빛으로 구분한다. */
.board-card .battle-treasures [data-icon="칼"] { background-position: 0% 0%; filter: sepia(1) saturate(4) hue-rotate(355deg) brightness(1.15); }
.board-card .battle-treasures [data-icon="말"] { background-position: 50% 0%; filter: sepia(1) saturate(4) hue-rotate(355deg) brightness(1.15); }
.board-card :is(.battle-keywords, .battle-treasures) { flex-wrap: nowrap; width: max-content; }

/* 가운데 팝업·정보 패널의 계략·보물·시설 그림: 그림 칸에 꼭 맞춰 위아래가 잘리지 않게 (2026-11-06) */
#played .card.big.has-tactic-art .c-art, #detail .card.big.has-tactic-art .c-art { position: relative; }
#played .card.big.has-tactic-art .tactic-artwork, #detail .card.big.has-tactic-art .tactic-artwork {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 4%;
}

/* 덱 더미: 남은 장수(5장 이하)는 맨 위 카드 왼쪽 위에, 빈 덱은 점선 빈 칸으로 크게 (2026-11-06) */
.pile .pile-count { left: 4px; top: 6px; transform: none; min-width: 30px; height: 30px; font-size: 17px; }
.pile.empty::before {
  content: ''; position: absolute; left: 0; bottom: 0; width: 84px; height: 116px; border-radius: 9px; box-sizing: border-box;
  border: 2px dashed #ff8f84; background: repeating-linear-gradient(45deg, #2a0f0c 0 8px, #1a0907 8px 16px);
  box-shadow: inset 0 0 18px #000c, 0 0 10px #ff5a4a66;
}
.pile.empty .pile-empty {
  left: 42px; top: 50%; transform: translate(-50%, -50%) rotate(-12deg); height: auto; padding: 4px 8px; border-radius: 6px;
  font-size: 17px; letter-spacing: 1px; white-space: nowrap; color: #fff; background: #b3261ecc; border: 2px solid #ffd2cc; box-shadow: 0 0 12px #ff5a4a;
}
/* 덱 미리보기·갤러리의 계략·보물·시설 그림도 그림 칸에 꼭 맞춰 잘리지 않게 (2026-11-06) */
:is(#deck-detail, .gallery-card) .card.big.has-tactic-art .c-art { position: relative; }
:is(#deck-detail, .gallery-card) .card.big.has-tactic-art .tactic-artwork { position: absolute; inset: 0; width: 100%; height: 100%; padding: 4%; }

/* 풍수사가 회복할 수 있는 대상은 공격 대상과 다른 색과 문구로 표시한다. */
.unit.heal-target { --target: #6dffb1; }


/* 활성 진형을 해당 전장 카드 바로 아래에 표시한다. */
.field-formations { position: absolute; z-index: 8; left: 50%; transform: translateX(-50%); display: flex; justify-content: center; gap: 5px; width: max-content; max-width: 100%; pointer-events: none; }
#player-field .field-formations { top: 190px; }
#enemy-field .field-formations { bottom: 0; }
.field-formations .form { display: inline-block; padding: 3px 12px; border: 1px solid #d6b268; border-radius: 5px; background: #26170fe8; color: #ffe7a3; font-size: 13px; font-weight: bold; white-space: nowrap; }

/* 신화 승급: 전장 섬광과 중앙 카드 뒤에서 퍼지는 빛의 고리 */
.mythic-stage-effect { position: absolute; inset: 0; z-index: 39; pointer-events: none; overflow: hidden; background: radial-gradient(circle at 50% 50%, #fff9 0%, #be78ff66 22%, #5c29a633 50%, transparent 75%); animation: mythic-flash 2s ease-out both; }
.mythic-stage-effect i { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: #fff5b7; box-shadow: 0 0 12px 4px #f8d9ff, 0 0 24px #e6a0ff; animation: mythic-spark 1.5s ease-out both; }
.mythic-stage-effect i:nth-child(1) { --x: -280px; --y: -210px; }
.mythic-stage-effect i:nth-child(2) { --x: 260px; --y: -240px; animation-delay: .12s; }
.mythic-stage-effect i:nth-child(3) { --x: -340px; --y: 80px; animation-delay: .18s; }
.mythic-stage-effect i:nth-child(4) { --x: 330px; --y: 100px; animation-delay: .08s; }
.mythic-stage-effect i:nth-child(5) { --x: -150px; --y: 260px; animation-delay: .2s; }
.mythic-stage-effect i:nth-child(6) { --x: 150px; --y: 280px; animation-delay: .14s; }
.mythic-stage-effect i:nth-child(7) { --x: -100px; --y: -300px; animation-delay: .24s; }
.mythic-stage-effect i:nth-child(8) { --x: 100px; --y: -290px; animation-delay: .28s; }
#played.mythic-presentation { isolation: isolate; }
#played.mythic-presentation::before, #played.mythic-presentation::after { content: ''; position: absolute; z-index: -1; left: 50%; top: 53%; width: 420px; aspect-ratio: 1; border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%); }
#played.mythic-presentation::before { background: repeating-conic-gradient(from 0deg, #ffd78288 0deg, transparent 8deg, #bd88ff77 18deg, transparent 27deg); filter: blur(8px); animation: mythic-rays 4s linear infinite; }
#played.mythic-presentation::after { width: 340px; border: 4px solid #fff0b5; box-shadow: 0 0 20px 8px #f3d1ff, inset 0 0 25px #a26dff; animation: mythic-ring 1.4s ease-out infinite; }
.board-card.mythic-awaken { filter: brightness(1.7) drop-shadow(0 0 18px #f8d5ff); }
@keyframes mythic-flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: .2; } }
@keyframes mythic-spark { from { transform: translate(0,0) scale(.4); opacity: 0; } 20% { opacity: 1; } to { transform: translate(var(--x),var(--y)) scale(0); opacity: 0; } }
@keyframes mythic-rays { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes mythic-ring { from { transform: translate(-50%, -50%) scale(.65); opacity: 1; } to { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mythic-stage-effect, .mythic-stage-effect i, #played.mythic-presentation::before, #played.mythic-presentation::after { animation: none; } .mythic-stage-effect i { display: none; } }

/* 진형에 속한 카드들 밑에 연결선을 놓아 구성원을 한눈에 보여 준다. */
.formation-link { position: absolute; z-index: 9; left: -8px; right: -8px; bottom: -18px; height: 12px; border-bottom: 2px solid #eac979; filter: drop-shadow(0 1px 2px #000); pointer-events: none; }
.formation-link.start { left: 50%; border-left: 2px solid #eac979; border-radius: 0 0 0 5px; }
.formation-link.end { right: 50%; border-right: 2px solid #eac979; border-radius: 0 0 5px 0; }
.formation-link b { position: absolute; left: 50%; top: 7px; transform: translateX(-50%); padding: 2px 10px; border: 1px solid #d8b36c; border-radius: 12px; color: #ffe8aa; background: linear-gradient(#513b23,#1e150e); font-size: 11px; line-height: 1.2; white-space: nowrap; }
.heal-marker, .retreat-marker { position: absolute; z-index: 15; left: 50%; top: 55%; transform: translate(-50%,-50%); display: inline-flex; align-items: center; gap: 4px; width: max-content; height: auto; padding: 3px 8px; border: 1px solid #a9e5be; border-radius: 20px; background: linear-gradient(120deg,#163c2feF,#0a1f1aea); color: #e9ffdf; box-shadow: 0 2px 5px #000b, 0 0 10px #79e9ad66; font-size: 10px; font-weight: bold; line-height: 1.3; white-space: nowrap; pointer-events: none; }
.heal-marker i { font-style: normal; color: #ffe49c; font-size: 12px; }
.retreat-marker { border-color: #e4bc77; background: #372516ed; color: #ffe4ad; }
.retreat-chosen { filter: grayscale(.65) brightness(.7); }
/* 긴 신화 승급 제목도 장식 배경 안에 들어가도록 넓힌다. */
#played.mythic-presentation .played-label { width: 420px; min-height: 100px; padding: 8px 70px; font-size: 24px; white-space: normal; line-height: 1.15; }
