/* ============================================================
   cnation STS — 모바일 세로형 스타일
   ============================================================ */
:root {
  --bg: #0b0910;
  --bg2: #15111d;
  --panel: rgba(24, 19, 32, 0.92);
  --panel-edge: #3d3350;
  --gold: #e8c34a;
  --gold-dim: #8a7028;
  --red: #d0392b;
  --green: #3fbf6a;
  --blue: #4aa8e8;
  --purple: #9a6ae0;
  --text: #e8e2d8;
  --text-dim: #9a92a8;
  --hp: #c0392b;
  --hp-bg: #3a1616;
  --hp-me: #2fbf7a;
  --hp-me-bg: #10382a;
  --block: #6ab0e8;
  --font: 'IBM Plex Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --card-w: 88px;
  --card-h: 126px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 14px; line-height: 1.45;
  overscroll-behavior: none; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
}
[hidden] { display: none !important; }

/* ---------- 공통 버튼 ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 700; color: #f0e6d0;
  background: linear-gradient(#4a3a28, #2a1f16);
  border: 1.5px solid #6a5436; border-radius: 10px;
  padding: 10px 18px; cursor: pointer;
  box-shadow: 0 2px 0 #12100c, inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform .08s, filter .15s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 #12100c; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.big { padding: 14px 34px; font-size: 17px; min-width: 200px; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: linear-gradient(#241d30, #16121e); border-color: #453a5a; }
.btn.danger { background: linear-gradient(#6a2020, #3a1010); border-color: #9a3a3a; }
.btn.gold { background: linear-gradient(#8a6a20, #5a4210); border-color: var(--gold); color: #fff4d0; }

/* ---------- 타이틀 ---------- */
#scr-title { align-items: center; justify-content: center; padding-bottom: calc(var(--safe-b) + 34px); }
.title-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(224,122,58,.28), transparent 58%),
    radial-gradient(ellipse at 50% 100%, rgba(120,60,200,.22), transparent 60%),
    linear-gradient(#120d18, #07060a 70%);
}
.title-bg::after {
  content: ''; position: absolute; inset: 0;
  background:
    conic-gradient(from 200deg at 50% 120%, transparent 0deg, rgba(255,140,60,.10) 40deg, transparent 80deg),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(255,255,255,.015) 38px 39px);
}
.title-wrap { position: relative; text-align: center; padding: 24px; }
.game-title {
  font-family: var(--font); margin: 0 0 6px; line-height: .96;
  display: flex; flex-direction: column; align-items: center;
  text-shadow: 0 0 22px rgba(255,150,60,.5), 0 3px 0 #2a1508;
}
.game-title span { font-size: 44px; letter-spacing: 3px; color: #ffd884; }
.game-title em { font-size: 20px; font-style: italic; color: #e8a24a; margin: -4px 0; }
.title-sub { color: var(--text-dim); margin: 0 0 34px; font-size: 13px; letter-spacing: .5px; }
/* 타이틀 맨 아래 : 버전 숫자 + 변경 이력 링크 */
.version-bar {
  position: absolute; left: 0; right: 0; bottom: calc(10px + var(--safe-b));
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 11.5px; letter-spacing: .4px; font-family: var(--font);
}
.version-num { color: var(--gold); font-weight: 700; }
.version-link {
  color: #8ab4e8; text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.version-link:active { color: #cfe4ff; }

/* ---------- 변경 이력 화면 ---------- */
#scr-history { background: linear-gradient(#120d18, #08070c 70%); }
.history-top {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: rgba(14,11,20,.96); border-bottom: 1px solid #2a2338;
}
.history-top h2 { margin: 0; font-size: 16px; color: var(--gold); font-family: var(--font); font-weight: 700; }
.history-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 12px 14px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px;
}
.rel {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; padding: 10px 12px;
}
.rel.latest { border-color: #6a5a2a; background: rgba(46,38,22,.55); }
.rel-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }
.rel-ver { font-size: 14px; font-weight: 700; color: var(--gold); font-family: var(--font); }
.rel-note { font-size: 11.5px; color: #9a92a8; }
.rel-now {
  font-size: 10px; color: #0d0a12; background: var(--gold);
  border-radius: 999px; padding: 1px 7px; font-weight: 700;
}
.rel-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.rel-list li { font-size: 12.2px; line-height: 1.55; color: #cfc8d8; }
.rel-list li::marker { color: #6a5f85; }
.rel-foot { margin: 4px 0 0; font-size: 10.5px; color: #6a6278; text-align: center; line-height: 1.6; }
.title-menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.title-foot { margin-top: 30px; font-size: 11px; color: #6a6278; }

/* ---------- 상단바 ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: linear-gradient(rgba(14,11,20,.96), rgba(14,11,20,.72));
  border-bottom: 1px solid #2a2338; flex: 0 0 auto; min-height: 46px;
}
.tb-floor { font-family: var(--font); font-size: 13px; color: var(--gold); white-space: nowrap; }
.tb-hp { flex: 1 1 auto; min-width: 90px; }
.hpbar {
  position: relative; height: 21px; background: var(--hp-me-bg);
  border: 1px solid #1f6b4a; border-radius: 4px; overflow: hidden;
}
.hpbar > i { display: block; height: 100%; background: linear-gradient(#5ce39a, #1f9e63); transition: width .3s; }
.hpbar > b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; text-shadow: 0 1px 2px #000; letter-spacing: .3px;
  line-height: 1;
}
.tb-gold { color: var(--gold); font-weight: 700; font-size: 13px; white-space: nowrap; }
.relic-row { display: flex; gap: 3px; overflow-x: auto; max-width: 40%; scrollbar-width: none; }
.relic-row::-webkit-scrollbar { display: none; }
.relic {
  width: 27px; height: 27px; flex: 0 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a5a3a, #2a2218);
  border: 1.5px solid var(--gold-dim); display: grid; place-items: center;
}
.relic.boss { border-color: #b04aff; box-shadow: 0 0 8px rgba(176,74,255,.5); }
.menu-btn {
  width: 30px; height: 28px; flex: 0 0 auto; border-radius: 7px; padding: 6px 5px;
  background: rgba(24,19,32,.9); border: 1px solid #453a5a;
  display: flex; flex-direction: column; justify-content: space-between;
}
.menu-btn span { display: block; height: 2px; background: var(--text-dim); border-radius: 2px; }
.relic svg { width: 16px; height: 16px; }

/* ---------- 지도 ---------- */
.map-legend {
  flex: 0 0 auto; display: flex; gap: 4px; justify-content: center; overflow-x: auto; padding: 5px 4px 6px;
  background: rgba(14,11,20,.92); border-bottom: 1px solid #2a2338; scrollbar-width: none;
}
.map-legend::-webkit-scrollbar { display: none; }
.legend-item {
  /* 아이콘은 위, 설명글은 아래로 두 줄 배치 — 아이콘 크기가 달라도 글씨 줄은 맞춘다 */
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px;
  flex: 0 0 auto; padding: 3px 6px 4px; border-radius: 10px; background: rgba(30,24,42,.9);
  border: 1px solid #453a5a; font-size: 10px; line-height: 1.15; white-space: nowrap;
}
/* 엘리트·보스는 아이콘이 커서 좌우 여백을 조금 넓힌다 */
.legend-item.big { padding-left: 4px; padding-right: 4px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; background: currentColor; }
/* 지도에서 쓰는 실제 3D 아이콘을 축소해 붙인 범례 마크 */
.legend-icon {
  width: 29px; height: 29px; flex: 0 0 auto; display: block;
  object-fit: contain; filter: drop-shadow(0 0 3px rgba(0,0,0,.6));
}
/* 아이콘 줄의 높이를 가장 큰 아이콘에 맞춰 글씨 baseline 을 정렬 */
.map-legend { align-items: stretch; }
.map3d-wrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  /* 완전한 검정 대신 위아래로 은은하게 깔리는 어두운 그라디언트 */
  background:
    radial-gradient(ellipse 130% 50% at 50% -6%, rgba(158,116,232,.34), transparent 66%),
    radial-gradient(ellipse 120% 42% at 50% 106%, rgba(226,126,60,.26), transparent 68%),
    radial-gradient(ellipse 85% 55% at 50% 48%, rgba(86,72,136,.26), transparent 74%),
    linear-gradient(#1d1733 0%, #171226 34%, #120e1e 62%, #0d0a16 100%);
}
/* 가장자리만 살짝 눌러 시선이 가운데로 모이게 (비네팅) */
.map3d-wrap::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 86% 70% at 50% 50%, transparent 62%, rgba(6,4,12,.5) 100%);
}
.map3d-wrap > * { position: relative; z-index: 1; }
#map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.map-title-3d {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--font); color: var(--gold); font-size: 14px; text-shadow: 0 2px 6px #000;
  pointer-events: none; white-space: nowrap;
}
.map-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--text-dim); background: rgba(12,10,18,.8);
  padding: 4px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap;
}
.map-row { display: none; }
.map-node {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(22,18,30,.92); border: 2px solid #453a5a; position: relative;
  color: var(--text-dim); transition: transform .15s, box-shadow .2s;
}
.map-node svg { width: 26px; height: 26px; }
.map-node.avail {
  border-color: var(--gold); color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,195,74,.16), 0 0 16px rgba(232,195,74,.35);
  animation: pulse 1.6s ease-in-out infinite;
}
.map-node.visited { opacity: .4; }
.map-node.current { border-color: #fff; box-shadow: 0 0 14px #fff8; }
.map-node.boss { width: 70px; height: 70px; border-color: #c03a3a; color: #ff7a5a; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.map-title { text-align: center; font-family: var(--font); color: var(--gold); padding: 6px; font-size: 15px; }
.mapfoot { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px; border-top: 1px solid #2a2338; background: rgba(14,11,20,.9); }
.mapfoot .potion-row { flex: 0 1 auto; }

/* ---------- 전투 무대 ---------- */
.stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.stage::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: linear-gradient(rgba(8,6,12,0), rgba(8,6,12,.55) 60%, rgba(8,6,12,.88));
  pointer-events: none;
}
#three-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay, .float-layer { position: absolute; inset: 0; pointer-events: none; }
.overlay > * { pointer-events: auto; }

/* 적/플레이어 상태 오버레이 */
.unit {
  position: absolute; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: max-content; max-width: 240px;
}
.unit.targetable::after {
  content: ''; position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 12px solid #ff5a4a; animation: bob .8s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 5px); } }
.unit-name { font-size: 10.5px; color: #ded6e8; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.unit-hp { width: 100%; height: 14px; background: #2a1212; border: 1px solid #5a2222; border-radius: 3px; position: relative; overflow: hidden; transition: width .25s; }
.unit-hp.me { background: var(--hp-me-bg); border-color: #1f6b4a; }
.unit-hp.me > i { background: linear-gradient(#5ce39a, #1f9e63); }
.unit-hp > i { display: block; height: 100%; background: linear-gradient(#d84f3a, #8a1f14); transition: width .25s; }
.unit-hp > b { position: absolute; inset: 0; font-size: 10px; line-height: 1; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 2px #000; font-weight: 700; }
.unit-block {
  position: absolute; left: -8px; top: 16px; width: 26px; height: 26px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #dff0ff;
  background: radial-gradient(circle at 35% 30%, #6ab4e8, #1d4a72);
  border: 1.5px solid #a8d8ff; border-radius: 50%; text-shadow: 0 1px 2px #000;
}
.intent {
  display: flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 11px;
  background: rgba(12,10,18,.86); border: 1px solid #4a3a5a; font-size: 12px; font-weight: 700;
  text-shadow: 0 1px 2px #000; white-space: nowrap;
}
.intent svg { width: 17px; height: 17px; }
.powers { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; max-width: 116px; }
.pw {
  display: flex; align-items: center; gap: 1px; padding: 1px 4px; border-radius: 8px;
  background: rgba(12,10,18,.85); border: 1px solid #4a3a5a; font-size: 10px; font-weight: 700;
}
.pw.debuff { border-color: #7a3a9a; color: #e0a0ff; }
.pw.buff { border-color: #7a6a2a; color: #ffe08a; }
.pw svg { width: 12px; height: 12px; }

/* 몬스터 본체 탭 영역 */
.unit-hit {
  position: absolute; border-radius: 50%; pointer-events: auto;
  background: transparent; border: 2px solid transparent; transition: background .15s, border-color .15s;
}
.unit-hit.targetable {
  border-color: rgba(255,90,74,.85);
  background: radial-gradient(circle, rgba(255,90,74,.22), rgba(255,90,74,.05) 65%, transparent 72%);
  animation: hitPulse 1s ease-in-out infinite;
}
@keyframes hitPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* 전투 로그 */
.battle-log {
  position: absolute; left: 6px; bottom: 40px; max-width: 60%;
  font-size: 10.5px; color: #9a92a8; text-shadow: 0 1px 2px #000; pointer-events: none;
}
.battle-log div { opacity: .85; }

/* 데미지 숫자 */
.pop {
  position: absolute; font-family: var(--font); font-weight: 700; font-size: 24px;
  text-shadow: 0 2px 6px #000, 0 0 12px currentColor; transform: translate(-50%, -50%);
  animation: popup 1s ease-out forwards; pointer-events: none;
}
.pop.dmg { color: #ff6a4a; } .pop.block { color: #7ac8ff; }
.pop.heal { color: #7cff9a; } .pop.buff { color: #ffd24a; } .pop.debuff { color: #c07aff; }
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.6); }
  18% { opacity: 1; transform: translate(-50%,-70%) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%,-160%) scale(1); }
}

/* ---------- 손패 ---------- */
.handbar { position: relative; flex: 0 0 auto; height: calc(var(--card-h) + 18px); }
.hand { position: absolute; inset: 0; }
.hand-side { position: absolute; bottom: calc(100% - 10px); display: flex; flex-direction: row; gap: 4px; z-index: 40; }
.hand-side.left { left: 3px; } .hand-side.right { right: 3px; }
.pile-btn {
  width: 36px; padding: 2px 0; border-radius: 8px; background: rgba(20,16,28,.92);
  border: 1px solid #453a5a; color: var(--text-dim); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
}
.pile-label { font-size: 8.5px; } .pile-num { font-size: 13px; font-weight: 700; color: var(--text); }

/* 카드 */
.card {
  position: absolute; bottom: 0; width: var(--card-w); height: var(--card-h);
  transform-origin: 50% 130%;
  transition: transform .18s cubic-bezier(.2,.8,.3,1), left .18s cubic-bezier(.2,.8,.3,1), filter .18s;
  will-change: transform; cursor: pointer;
}
.card-inner {
  position: relative; width: 100%; height: 100%; border-radius: 9px; overflow: hidden;
  background: linear-gradient(160deg, var(--c-a), #12101a 62%);
  border: 1.5px solid var(--c-edge);
  box-shadow: 0 4px 12px rgba(0,0,0,.65), inset 0 0 18px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
}
.card.upgraded .card-inner { border-color: #7cff9a; box-shadow: 0 0 12px rgba(124,255,154,.4), 0 4px 12px rgba(0,0,0,.6); }
.card.selected { transform: translateY(-70px) scale(1.55) rotate(0deg) !important; z-index: 60; filter: brightness(1.12) drop-shadow(0 0 16px rgba(255,220,140,.5)); transform-origin: 50% 100%; }
.card.unplayable-now { filter: grayscale(.7) brightness(.62); }
.card-art { height: 40%; position: relative; overflow: hidden; }
.card-art-svg { width: 100%; height: 100%; display: block; }
.card-namebar {
  position: absolute; top: 27%; left: 0; right: 0; text-align: center; z-index: 2;
  background: linear-gradient(rgba(10,8,14,0), rgba(10,8,14,.95) 55%, rgba(10,8,14,.98));
  padding: 8px 3px 3px;
}
.card-name { font-size: 10px; font-weight: 700; text-shadow: 0 1px 3px #000; letter-spacing: -.4px; line-height: 1.1; display: block; }
.card.upgraded .card-name { color: #9cffb0; }
.card-cost { position: absolute; top: -2px; left: -2px; width: 26px; height: 26px; z-index: 3; }
.card-cost svg { width: 100%; height: 100%; }
.card-cost span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font); font-weight: 700; font-size: 14px; color: #fff; text-shadow: 0 1px 3px #000;
}
.card-cost.cost-changed span { color: #7cff9a; }
.card-body { flex: 1 1 auto; padding: 4px 4px 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card-desc { font-size: 9.2px; line-height: 1.3; text-align: center; color: #e2dcea; word-break: keep-all; }
.card-desc .num { color: #fff; font-weight: 700; }
.card-desc .num.buffed { color: #7cff9a; text-shadow: 0 0 6px rgba(124,255,154,.7); }
.card-desc .num.nerfed { color: #ff9a6a; text-shadow: 0 0 6px rgba(255,154,106,.6); }
.card-desc .kw-debuff { color: #d99aff; } .card-desc .kw-buff { color: #ffd24a; }
.card-desc .kw-block { color: #7ac8ff; } .card-desc .kw-energy { color: #ffcf4a; }
.card-desc .kw-exhaust { color: #ff9a7a; } .card-desc .kw-key { color: #9aff9a; }
.card-footer { display: flex; justify-content: center; align-items: center; gap: 4px; padding: 1px 0 3px; flex: 0 0 auto; }
.card-type { font-size: 7.5px; color: #a099b0; letter-spacing: .5px; }
.card-rar { width: 7px; height: 7px; transform: rotate(45deg); background: var(--c-rar); border: .5px solid rgba(0,0,0,.5); }
.card.small { position: relative; width: 74px; height: 106px; }
.card.big { position: relative; width: 150px; height: 214px; }
.card.selected .card-desc { font-size: 9.2px; }
.card.big .card-desc { font-size: 14.4px; }
.card.big .card-name { font-size: 15px; }
.card.big .card-cost { width: 40px; height: 40px; }
.card.big .card-cost span { font-size: 20px; }

/* ---------- 액션바 ---------- */
.actionbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px;
  background: linear-gradient(rgba(12,10,18,.6), rgba(12,10,18,.95));
  border-top: 1px solid #2a2338;
}
.energy-orb { position: relative; width: 52px; height: 52px; flex: 0 0 auto; }
.energy-orb svg { width: 100%; height: 100%; }
.energy-orb span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font); font-weight: 700; font-size: 16px; color: #fff; text-shadow: 0 1px 4px #000;
}
.potion-row { flex: 1 1 auto; display: flex; gap: 6px; justify-content: center; }
.potion-slot {
  width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed #453a5a;
  display: grid; place-items: center; background: rgba(20,16,28,.6);
}
.potion-slot.filled { border-style: solid; }
.potion-slot svg { width: 20px; height: 20px; }
.end-turn { flex: 0 0 auto; background: linear-gradient(#6a2a2a, #3a1414); border-color: #a04a3a; }
.end-turn.ready { animation: glow 1.5s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 2px 0 #12100c; } 50% { box-shadow: 0 2px 0 #12100c, 0 0 16px rgba(255,120,80,.7); } }

/* 선택 취소 영역 — 액션바 아래 빈 띠. 라벨 없이 탭만 받는다. */
.cancel-zone {
  flex: 0 0 auto; height: 30px;
  margin-bottom: calc(-1 * var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(12,10,18,.95);
  -webkit-tap-highlight-color: transparent;
}
/* 카드를 고른 상태에서만 아주 옅은 기척을 남긴다 (문구·버튼 없음) */
.cancel-zone.armed { background: linear-gradient(rgba(255,255,255,.055), rgba(12,10,18,.95) 70%); }
.cancel-zone.armed:active { background: linear-gradient(rgba(255,255,255,.12), rgba(12,10,18,.95) 70%); }

/* ---------- 모달 ---------- */
.modal-screen { background: rgba(6,5,10,.9); backdrop-filter: blur(3px); z-index: 100; }

/* 모달 상단 상태 띠 — 체력·골드·물약칸을 항상 보여준다 */
.modal-status {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: rgba(20,16,30,.96);
  border-bottom: 1px solid #3a3050;
}
.ms-hp { flex: 1 1 auto; min-width: 96px; display: flex; align-items: center; gap: 5px; }
.ms-hp .hpbar { flex: 1 1 auto; height: 19px; }
.ms-label { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.ms-gold { font-size: 12px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.ms-potion { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.ms-slots { display: flex; gap: 3px; }
.ms-slot {
  width: 21px; height: 21px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px dashed #5b4d78; background: rgba(0,0,0,.3);
}
.ms-slot.filled { border-style: solid; background: rgba(255,255,255,.06); }
.ms-free { font-size: 10px; color: #8affc0; white-space: nowrap; }
.ms-free.none { color: #ff8a7a; }

/* 이번 선택과 직접 관련 있는 항목을 강조 */
.ms-hp.focus .hpbar { box-shadow: 0 0 0 2px rgba(92,227,154,.55); }
.ms-hp.low .hpbar { box-shadow: 0 0 0 2px rgba(255,106,90,.6); }
.ms-potion.focus .ms-slot:not(.filled) { animation: msFree 1.3s ease-in-out infinite; border-color: #8affc0; }
@keyframes msFree {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138,255,192,0); }
  50% { box-shadow: 0 0 0 3px rgba(138,255,192,.35); }
}
.modal-box {
  margin: auto; width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto;
  padding: 16px 14px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.modal-title { font-family: var(--font); font-size: 20px; color: var(--gold); text-align: center; margin: 4px 0; }
.modal-text { text-align: center; color: #cfc8d8; font-size: 13.5px; line-height: 1.6; white-space: pre-line; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.card-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.choice-row {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; text-align: left;
  font-family: inherit; color: var(--text); font-size: 13.5px;
}
.choice-row:active { background: #2a2238; }
.choice-row .ci { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; }
.choice-row b { display: block; color: var(--gold); font-size: 14px; }
.choice-row small { color: var(--text-dim); font-size: 11.5px; }
.reward-row {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px;
  font-family: inherit; color: var(--text); font-size: 14px;
}
.reward-row.taken { opacity: .35; pointer-events: none; }
.relic-big {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, #7a6a44, #2a2218);
  border: 2px solid var(--gold-dim); display: grid; place-items: center;
}
.relic-big svg { width: 26px; height: 26px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.price { color: var(--gold); font-weight: 700; font-size: 12px; }
.price.cant { color: #a05050; }
.price s { color: #7a7288; font-weight: 400; font-size: 11px; margin-right: 2px; }
.sale-badge {
  position: absolute; top: -6px; right: -8px; z-index: 5;
  background: linear-gradient(#ff5a4a, #b02020); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  border: 1px solid #ffb0a0; box-shadow: 0 2px 6px rgba(0,0,0,.6);
  transform: rotate(8deg);
}
.shop-item.on-sale .card-inner { box-shadow: 0 0 12px rgba(255,90,74,.55), 0 4px 12px rgba(0,0,0,.6); }
.sale-tag {
  display: inline-block; background: linear-gradient(#ff5a4a, #b02020); color: #fff;
  font-size: 9.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; vertical-align: middle;
}

/* 캐릭터 선택 */
.char-row {
  width: 100%; display: flex; gap: 11px; align-items: flex-start; padding: 12px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--acc) 14%, var(--panel)), var(--panel));
  border: 1.5px solid var(--acc); border-radius: 12px; text-align: left;
  font-family: inherit; color: var(--text);
}
.char-row:active { filter: brightness(1.2); }
.char-portrait {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--acc) 45%, #14101c), #14101c);
  border: 1px solid var(--acc);
}
.char-info { flex: 1 1 auto; min-width: 0; }
.char-info b { display: block; font-size: 16px; color: var(--acc); }
.char-tag { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 3px; }
.char-info small { display: block; font-size: 11.5px; color: #bdb5c8; line-height: 1.4; }
.char-stats { margin-top: 5px; font-size: 11px; color: var(--gold); }
.choice-row.risky { border-color: #a04a3a; background: linear-gradient(100deg, rgba(160,74,58,.18), var(--panel)); }

/* 자세 / 구체 */
.stance-badge {
  padding: 1px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  border: 1px solid; text-shadow: 0 1px 2px #000; letter-spacing: .5px;
}
.stance-badge.s-wrath { color: #ff9a6a; border-color: #d05a3a; background: rgba(180,60,30,.35); }
.stance-badge.s-calm { color: #8ad0ff; border-color: #3a7ad0; background: rgba(30,90,180,.35); }
.stance-badge.s-divinity { color: #ffe48a; border-color: #d0a83a; background: rgba(180,140,30,.4); box-shadow: 0 0 10px rgba(255,210,90,.5); }
/* 3D 구체 위에 겹쳐 그리는 수치 라벨 */
.orb-labels { position: absolute; inset: 0; pointer-events: none; }
.orb-label {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 11px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,.9); pointer-events: none;
}
.orb-label.dot { display: none; }

/* 토스트 */
.toast-layer { position: absolute; top: calc(52px + var(--safe-t)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; z-index: 200; }
.toast {
  background: rgba(16,13,24,.94); border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 6px 16px; font-size: 12.5px; animation: toastIn .25s ease-out, toastOut .3s ease-in 2s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* 툴팁 */
.tooltip {
  position: absolute; z-index: 300; max-width: 250px; padding: 8px 11px;
  background: rgba(14,11,20,.97); border: 1px solid var(--panel-edge); border-radius: 9px;
  font-size: 12px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.7); pointer-events: none;
}
.tooltip b { color: var(--gold); display: block; margin-bottom: 2px; }

.upgrade-compare { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.uc-side { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.uc-side .card.big { width: 132px; height: 190px; }
.uc-side .card.big .card-desc { font-size: 12px; }
.uc-side .card.big .card-name { font-size: 13px; }
.uc-label { font-size: 11px; color: var(--text-dim); }
.uc-label.up { color: #7cff9a; font-weight: 700; }
.uc-arrow { flex: 0 0 auto; transform: rotate(90deg); opacity: .9; }
.uc-diff { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.uc-diff span {
  background: rgba(124,255,154,.12); border: 1px solid rgba(124,255,154,.45);
  color: #9cffb0; border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 700;
}

/* 덱 목록 */
.deck-head { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.deck-count { color: var(--text-dim); font-size: 12px; }

/* 상단 안내 배너 */
.hint-banner {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(16,13,24,.9); border: 1px solid var(--gold-dim); color: var(--gold);
  padding: 5px 14px; border-radius: 999px; font-size: 12px; z-index: 10; white-space: nowrap;
}

/* 작은 화면 대응 */
@media (max-height: 700px) {
  :root { --card-w: 76px; --card-h: 108px; }
  .card-desc { font-size: 8.5px; }
  .card-name { font-size: 9px; }
}
@media (min-width: 520px) {
  :root { --card-w: 100px; --card-h: 142px; }
  .card-desc { font-size: 10.8px; }
  .card-name { font-size: 11.5px; }
}

