/* =========================================
   COMBAT v2 — Pixel Battle UI
   Game colors + pixel aesthetic
   ========================================= */

:root {
  --cb-bg: #0f1115;
  --cb-panel: #11141a;
  --cb-card: #171a21;
  --cb-border: #2b3142;
  --cb-border-light: #3a4055;
  --cb-text: #e6ebff;
  --cb-text-dim: #8a93a5;
  --cb-accent: #8ad7ff;
  --cb-hp: #3cb54a;
  --cb-mana: #4a8ad7;
  --cb-stamina: #8a8a8a;
  --cb-rage: #d74a4a;
  --cb-crit: #ffd700;
  --cb-enemy-hp: #d74a4a;
  --cb-enemy-border: #5a2a2a;
  --cb-selected: #8ad7ff;
}

/* ---- OVERLAY & GRID ---- */
/* ---- Full-page (standalone combat.html) ---- */
.combat-fullpage {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--cb-bg);
  display: grid;
  grid-template-rows: 44px 1fr auto;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--cb-text);
  image-rendering: pixelated;
  overflow: hidden;
}

.combat-fullpage::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.03) 3px, rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ---- Embedded overlay (inside main game) ---- */
.combat-overlay-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.combat-overlay {
  position: fixed;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 2000;
  background: var(--cb-bg);
  display: grid;
  grid-template-rows: 44px 1fr auto;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--cb-text);
  image-rendering: pixelated;
  overflow: hidden;
  border: 2px solid var(--cb-border);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 15px rgba(138, 215, 255, 0.15);
}

.combat-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    transparent 0px, transparent 3px,
    rgba(0,0,0,0.03) 3px, rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
  border-radius: 8px;
}

/* ---- HEADER ---- */
.cb-header {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid var(--cb-border);
  background: var(--cb-panel);
}

.cb-round {
  font-size: 16px;
  color: var(--cb-accent);
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(138, 215, 255, 0.3);
}

/* ---- BATTLEFIELD (3 columns) ---- */
.cb-battlefield {
  display: grid;
  grid-template-columns: 230px 1fr 230px;
  overflow: hidden;
  min-height: 0;
}

/* ---- PARTY (left) ---- */
.cb-party {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  border-right: 1px solid rgba(76, 175, 80, 0.12);
  border-right: 2px solid var(--cb-border);
  overflow-y: auto;
  align-items: center;
  background: var(--cb-panel);
}
.cb-party::-webkit-scrollbar { width: 4px; }
.cb-party::-webkit-scrollbar-thumb { background: var(--cb-border); }

/* ---- ENEMIES (right) ---- */
.cb-enemies {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  border-left: 1px solid rgba(215, 74, 74, 0.12);
  border-left: 2px solid var(--cb-border);
  overflow-y: auto;
  align-items: center;
  background: var(--cb-panel);
}
.cb-enemies::-webkit-scrollbar { width: 4px; }
.cb-enemies::-webkit-scrollbar-thumb { background: var(--cb-border); }

/* ---- UNIT CARD ---- */
.cb-unit {
  width: 100%;
  max-width: 200px;
  background: var(--cb-card);
  border: 2px solid var(--cb-border);
  padding: 10px;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cb-unit.dead {
  opacity: 0.2;
  filter: grayscale(0.8);
}

.cb-unit.ally-unit:not(.dead) {
  border-color: #2a4a2a;
}

.cb-unit.enemy-unit:not(.dead) {
  cursor: pointer;
  border-color: #5a2a2a;
}

.cb-unit.enemy-unit:not(.dead):hover {
  border-color: #e05555;
  box-shadow: 0 0 12px rgba(215, 74, 74, 0.25);
}

.cb-unit.selected {
  border-color: var(--cb-selected) !important;
  box-shadow: 0 0 14px rgba(138, 215, 255, 0.35), inset 0 0 0 1px rgba(138, 215, 255, 0.15) !important;
}

/* ---- UNIT IMAGE ---- */
.cb-unit-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin: 0 auto 8px;
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--cb-border);
  background: rgba(0,0,0,0.3);
}

.cb-unit-placeholder {
  width: 90px;
  height: 90px;
  margin: 0 auto 8px;
  border: 1px dashed var(--cb-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--cb-border);
  background: rgba(0,0,0,0.2);
}

.cb-unit-name {
  font-size: 12px;
  color: var(--cb-text);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-unit.ally-unit .cb-unit-name { color: #8ee68e; }
.cb-unit.enemy-unit .cb-unit-name { color: #f28b8b; }

.cb-unit-class {
  font-size: 10px;
  color: var(--cb-text-dim);
  margin-bottom: 8px;
}

.cb-boss-tag {
  font-size: 9px;
  color: var(--cb-crit);
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  display: inline-block;
  padding: 3px 6px;
  margin-bottom: 6px;
  letter-spacing: 2px;
}

/* ---- HP / RESOURCE BARS ---- */
.cb-bar {
  position: relative;
  height: 18px;
  width: 100%;
  background: #0a0c10;
  border: 1px solid var(--cb-border);
  margin: 3px 0;
  overflow: hidden;
}

.cb-bar-fill {
  height: 100%;
  background: var(--cb-hp);
  transition: width 0.35s steps(12);
}

.cb-bar-fill.enemy-hp { background: var(--cb-enemy-hp); }
.cb-bar-fill.res-mana { background: var(--cb-mana); }
.cb-bar-fill.res-stamina { background: var(--cb-stamina); }
.cb-bar-fill.res-rage { background: var(--cb-rage); }

.cb-bar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px 0 0 #000, 0 1px 0 #000;
  z-index: 1;
  letter-spacing: 1px;
}

.cb-bar-fill.low-hp {
  animation: cb-low-hp-blink 0.8s steps(2) infinite;
}

@keyframes cb-low-hp-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- CENTER AREA ---- */
.cb-center {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--cb-bg);
}

.cb-anim-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

/* ---- COMBAT LOG ---- */
.cb-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 22px;
  font-size: 13px;
  line-height: 2.2;
  z-index: 1;
}

.cb-log::-webkit-scrollbar { width: 4px; }
.cb-log::-webkit-scrollbar-thumb { background: var(--cb-border); }
.cb-log::-webkit-scrollbar-track { background: var(--cb-bg); }

.cb-log-entry {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(43, 49, 66, 0.3);
  border-left: 3px solid transparent;
  color: var(--cb-text-dim);
}

.cb-log-entry.log-system {
  color: #7a8399;
  font-style: italic;
  border-left-color: transparent;
}
.cb-log-entry.log-player {
  color: #8ee68e;
  border-left-color: rgba(76, 175, 80, 0.5);
  background: rgba(76, 175, 80, 0.04);
}
.cb-log-entry.log-enemy {
  color: #f28b8b;
  border-left-color: rgba(229, 85, 85, 0.5);
  background: rgba(229, 85, 85, 0.04);
}

.cb-log-crit {
  color: var(--cb-crit);
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.cb-log-fumble { color: #5a4040; text-decoration: line-through; }

.cb-log-dice {
  color: #4a5060;
  font-size: 11px;
}

/* =========================================
   CONTROLS PANEL (bottom) — big & readable
   ========================================= */

.cb-controls {
  display: flex;
  border-top: 2px solid var(--cb-border);
  background: var(--cb-panel);
  flex-shrink: 0;
  min-height: 220px;
}

.cb-section {
  flex: 1;
  padding: 10px 12px;
  border-right: 1px solid rgba(43, 49, 66, 0.5);
}

.cb-section:last-of-type { border-right: none; }

.cb-section-label {
  font-size: 13px;
  color: var(--cb-accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--cb-border);
  text-shadow: 0 0 6px rgba(138, 215, 255, 0.2);
}

.cb-btn-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}

.cb-btn-list::-webkit-scrollbar { width: 3px; }
.cb-btn-list::-webkit-scrollbar-thumb { background: var(--cb-border); }

/* ---- ACTION BUTTON WITH ICON ---- */
.cb-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--cb-border);
  background: var(--cb-card);
  color: var(--cb-text-dim);
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1.6;
}

.cb-btn:hover {
  background: #1f2330;
  border-color: var(--cb-border-light);
  color: var(--cb-text);
}

.cb-btn.selected {
  background: rgba(138, 215, 255, 0.12);
  color: var(--cb-accent);
  border-color: var(--cb-accent);
  box-shadow: 0 0 8px rgba(138, 215, 255, 0.2);
}

.cb-btn.disabled,
.cb-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
  pointer-events: none;
}
.cb-btn.disabled .cb-btn-cost,
.cb-btn[disabled] .cb-btn-cost {
  color: #e04040;
  opacity: 1;
}

.cb-btn-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border: 1px solid var(--cb-border);
  background: rgba(0,0,0,0.3);
}

.cb-btn-icon.no-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--cb-text-dim);
  border: 1px dashed var(--cb-border);
}

.cb-btn-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-btn-cost {
  color: var(--cb-text-dim);
  font-size: 10px;
  flex-shrink: 0;
}

.cb-btn-cost.cost-mana { color: var(--cb-mana); }
.cb-btn-cost.cost-stamina { color: var(--cb-stamina); }
.cb-btn-cost.cost-rage { color: var(--cb-rage); }

.cb-btn-dmg-pct {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--cb-crit);
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 3px;
  padding: 1px 3px;
  flex-shrink: 0;
}

/* ---- SKILL LEVEL & XP PROGRESS ---- */
.cb-btn-skill-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  min-width: 44px;
}

.cb-skill-lvl {
  font-size: 10px;
  color: var(--cb-crit);
  font-weight: bold;
  letter-spacing: 0.5px;
}

.cb-skill-lvl.max-level {
  color: #ff6b6b;
  text-shadow: 0 0 4px rgba(255, 107, 107, 0.4);
}

.cb-skill-xp-bar {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.cb-skill-xp-fill {
  height: 100%;
  background: var(--cb-crit);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.cb-skill-xp-fill.maxed {
  background: #ff6b6b;
}

.cb-log-levelup {
  color: var(--cb-crit) !important;
  font-weight: bold;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
  border-left-color: rgba(255, 215, 0, 0.5) !important;
  background: rgba(255, 215, 0, 0.06) !important;
  animation: cb-levelup-flash 0.6s ease 2;
}

.cb-log-reward {
  color: #66bb6a !important;
  font-weight: bold;
  border-left-color: rgba(102, 187, 106, 0.5) !important;
  background: rgba(102, 187, 106, 0.06) !important;
}

.cb-log-victory {
  color: #4caf50 !important;
  font-weight: bold;
  font-size: 14px;
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
  border-left-color: rgba(76, 175, 80, 0.6) !important;
  background: rgba(76, 175, 80, 0.08) !important;
}

.cb-log-defeat {
  color: #ef5350 !important;
  font-weight: bold;
  font-size: 14px;
  text-shadow: 0 0 10px rgba(239, 83, 80, 0.5);
  border-left-color: rgba(239, 83, 80, 0.6) !important;
  background: rgba(239, 83, 80, 0.08) !important;
}

@keyframes cb-levelup-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; color: #fff; }
}

.cb-log-status-effect {
  color: #c62828 !important;
  font-style: italic;
}

.cb-log-dmg {
  color: #ff8a80;
  font-weight: bold;
}

.cb-log-heal {
  color: #69f0ae;
  font-weight: bold;
}

.cb-log-stun {
  color: #f9a825 !important;
  font-style: italic;
}

/* ---- ENTER KEY BUTTON ---- */
.cb-confirm {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  min-width: 170px;
  flex-direction: column;
  gap: 8px;
}

.cb-submit {
  position: relative;
  padding: 16px 28px;
  min-width: 140px;
  border: 2px solid var(--cb-border-light);
  border-bottom: 5px solid #0a0c10;
  background: linear-gradient(180deg, #252a36 0%, #1a1f28 100%);
  color: var(--cb-text-dim);
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.1s;
  letter-spacing: 1px;
  text-align: center;
  box-shadow:
    0 3px 0 #0a0c10,
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.cb-submit:hover:not(:disabled) {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
  background: linear-gradient(180deg, #2a3040 0%, #1f2530 100%);
  box-shadow:
    0 3px 0 #0a0c10,
    0 0 12px rgba(138, 215, 255, 0.15),
    inset 0 1px 0 rgba(138, 215, 255, 0.06);
}

.cb-submit:active:not(:disabled) {
  border-bottom-width: 2px;
  box-shadow: 0 1px 0 #0a0c10;
  transform: translateY(3px);
}

.cb-submit:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

.cb-submit-icon {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

/* ---- BATTLE RESULT ---- */
.cb-result {
  text-align: center;
  padding: 16px;
}

.cb-result-title {
  font-size: 22px;
  color: var(--cb-crit);
  margin-bottom: 10px;
  letter-spacing: 4px;
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.5);
}

.cb-result.defeat .cb-result-title {
  color: var(--cb-enemy-hp);
  text-shadow: 0 0 14px rgba(215, 74, 74, 0.5);
}

.cb-result-text {
  font-size: 13px;
  color: var(--cb-text-dim);
  margin-bottom: 16px;
}

.cb-exit-btn {
  padding: 14px 30px;
  border: 2px solid var(--cb-border-light);
  border-bottom: 4px solid #0a0c10;
  background: linear-gradient(180deg, #252a36 0%, #1a1f28 100%);
  color: var(--cb-text);
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 3px 0 #0a0c10;
}

.cb-exit-btn:hover {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
}

/* ---- INFO BUTTON ON ENEMY CARD ---- */
.cb-info-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 1px solid var(--cb-border-light);
  background: var(--cb-card);
  color: var(--cb-text-dim);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 0;
  line-height: 1;
}

.cb-info-btn:hover {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
}

.cb-hero-info-btn {
  border-color: rgba(138, 215, 255, 0.3);
}
.cb-hero-info-btn:hover {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
  box-shadow: 0 0 6px rgba(138, 215, 255, 0.2);
}

/* =========================================
   ANIMATIONS
   ========================================= */

/* Screen shake */
@keyframes cb-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 3px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-3px, -4px); }
  80% { transform: translate(3px, 4px); }
}

.combat-overlay.cb-shake,
.combat-fullpage.cb-shake {
  animation: cb-shake 0.3s steps(5);
}

/* Crit flash */
@keyframes cb-flash {
  0% { opacity: 0.5; }
  100% { opacity: 0; }
}

.cb-fx-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 215, 0, 0.12);
  opacity: 0;
  animation: cb-flash 0.3s steps(4);
  pointer-events: none;
  z-index: 9998;
}

/* ---- PROJECTILE: flies left → right ---- */
@keyframes cb-projectile-fly {
  0%   { left: 0;   top: 50%; transform: translate(0, -50%) scale(0.7); opacity: 0.9; }
  60%  { left: 75%;  top: 45%; transform: translate(0, -50%) scale(1);   opacity: 1; }
  100% { left: 92%;  top: 50%; transform: translate(0, -50%) scale(1.2); opacity: 0.6; }
}

.cb-fx-projectile {
  position: absolute;
  width: 48px;
  height: 48px;
  z-index: 20;
  animation: cb-projectile-fly 0.5s ease-in forwards;
}

.cb-fx-projectile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(138, 215, 255, 0.6)) drop-shadow(0 0 16px rgba(138, 215, 255, 0.3));
}

/* Projectile trail */
@keyframes cb-trail-fade {
  0% { opacity: 0.5; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.3); }
}

.cb-fx-trail {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cb-accent);
  box-shadow: 0 0 8px var(--cb-accent);
  animation: cb-trail-fade 0.35s ease-out forwards;
  pointer-events: none;
  z-index: 19;
}

/* ---- IMPACT on right side ---- */
@keyframes cb-impact-burst {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.cb-fx-impact {
  position: absolute;
  width: 60px;
  height: 60px;
  right: 40px;
  top: 50%;
  z-index: 21;
}

.cb-fx-impact::before,
.cb-fx-impact::after {
  content: '';
  position: absolute;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.6);
  animation: cb-impact-burst 0.35s steps(5) forwards;
}

.cb-fx-impact::before {
  top: 50%; left: 0; right: 0;
  height: 4px; margin-top: -2px;
}

.cb-fx-impact::after {
  left: 50%; top: 0; bottom: 0;
  width: 4px; margin-left: -2px;
}

/* ---- DAMAGE NUMBER (flies up from right side) ---- */
@keyframes cb-dmg-pop {
  0%   { transform: translateY(0) scale(0.5); opacity: 0; }
  15%  { transform: translateY(-5px) scale(1.3); opacity: 1; }
  30%  { transform: translateY(-12px) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(0.8); opacity: 0; }
}

.cb-fx-dmg {
  position: absolute;
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  color: var(--cb-enemy-hp);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 2px 0 0 #000, 0 2px 0 #000;
  animation: cb-dmg-pop 1.2s steps(14) forwards;
  pointer-events: none;
  z-index: 25;
  right: 60px;
  top: 35%;
}

.cb-fx-dmg.miss {
  color: var(--cb-text-dim);
  font-size: 14px;
}

.cb-fx-dmg.crit-dmg {
  font-size: 28px;
  color: var(--cb-crit);
  text-shadow: 2px 2px 0 #000, 0 0 14px rgba(255, 215, 0, 0.6);
}

/* ---- SKILL ICON DISPLAY (in projectile now) ---- */
@keyframes cb-skill-icon-show {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  30% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  50% { transform: scale(1) rotate(0deg); opacity: 1; }
  80% { transform: scale(1) rotate(0deg); opacity: 0.8; }
  100% { transform: scale(0.8) rotate(0deg); opacity: 0; }
}

.cb-fx-skill-icon {
  position: absolute;
  width: 72px;
  height: 72px;
  border: 2px solid var(--cb-accent);
  box-shadow: 0 0 20px rgba(138, 215, 255, 0.4), 0 0 40px rgba(138, 215, 255, 0.15);
  image-rendering: pixelated;
  animation: cb-skill-icon-show 0.55s steps(8) forwards;
  z-index: 15;
  left: 50%;
  top: 50%;
  transform-origin: center;
  margin-left: -36px;
  margin-top: -36px;
}

.cb-fx-skill-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cb-fx-skill-name {
  position: absolute;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--cb-accent);
  text-shadow: 0 0 10px rgba(138, 215, 255, 0.6), 2px 2px 0 #000;
  white-space: nowrap;
  left: 50%;
  top: calc(50% + 50px);
  transform: translateX(-50%);
  animation: cb-skill-icon-show 0.55s steps(8) forwards;
  z-index: 15;
}

/* ---- legacy effect classes (still used for some types) ---- */

.cb-fx-slash {
  position: absolute;
  width: 160px; height: 4px;
  background: #fff;
  box-shadow: 0 -5px 0 0 rgba(255,255,255,0.2), 0 5px 0 0 rgba(255,255,255,0.2),
    0 0 14px rgba(255,255,255,0.6), 0 0 28px rgba(138,215,255,0.3);
  animation: cb-slash-sweep 0.35s steps(7) forwards;
  left: 50%; top: 50%;
}

@keyframes cb-slash-sweep {
  0% { transform: translate(-50%, -50%) rotate(-45deg) scaleX(0); opacity: 1; }
  50% { transform: translate(-50%, -50%) rotate(-45deg) scaleX(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-45deg) scaleX(1); opacity: 0; }
}

.cb-fx-strike {
  position: absolute;
  width: 60px; height: 60px;
  animation: cb-strike-burst 0.4s steps(6) forwards;
}

@keyframes cb-strike-burst {
  0% { transform: scale(0); opacity: 1; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.cb-fx-strike::before,
.cb-fx-strike::after {
  content: ''; position: absolute;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.5);
}
.cb-fx-strike::before { top: 50%; left: 0; right: 0; height: 4px; margin-top: -2px; }
.cb-fx-strike::after { left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; }

.cb-fx-rush {
  position: absolute;
  width: 100%; height: 120px;
  left: 0; top: calc(50% - 60px);
}

@keyframes cb-rush-line {
  0% { transform: translateX(-120%); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(300%); opacity: 0; }
}

.cb-fx-rush span {
  position: absolute; left: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--cb-accent), transparent);
  animation: cb-rush-line 0.45s steps(8) forwards;
}

.cb-fx-magic {
  position: absolute;
  width: 140px; height: 140px;
  left: calc(50% - 70px); top: calc(50% - 70px);
}

@keyframes cb-sparkle {
  0% { opacity: 0; transform: scale(0) rotate(0deg); }
  40% { opacity: 1; transform: scale(1) rotate(90deg); }
  100% { opacity: 0; transform: scale(0.5) rotate(180deg); }
}

.cb-fx-magic span {
  position: absolute;
  width: 5px; height: 5px;
  background: var(--cb-mana);
  box-shadow: 0 0 8px var(--cb-mana), -2px 0 0 var(--cb-accent), 2px 0 0 var(--cb-accent),
    0 -2px 0 var(--cb-accent), 0 2px 0 var(--cb-accent);
  animation: cb-sparkle 0.55s steps(5) forwards;
}

.cb-fx-fire {
  position: absolute;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffa500 0%, #ff4500 40%, transparent 70%);
  box-shadow: 0 0 35px rgba(255, 100, 0, 0.5), 0 0 70px rgba(255, 50, 0, 0.2);
  animation: cb-fire-burst 0.5s steps(6) forwards;
}

@keyframes cb-fire-burst {
  0% { transform: scale(0); opacity: 0.8; }
  30% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.cb-fx-ice { position: absolute; width: 80px; height: 80px; }

.cb-fx-ice span {
  position: absolute;
  width: 4px; height: 16px;
  background: #aaddff;
  box-shadow: 0 0 8px #88ccff;
  transform-origin: center center;
  animation: cb-ice-shatter 0.45s steps(5) forwards;
}

@keyframes cb-ice-shatter {
  0% { transform: scale(0); opacity: 0.8; }
  40% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.cb-fx-heal {
  position: absolute;
  width: 120px; height: 120px;
  left: calc(50% - 60px); top: calc(50% - 60px);
}

@keyframes cb-heal-rise {
  0% { transform: translateY(30px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(-60px); opacity: 0; }
}

.cb-fx-heal span {
  position: absolute;
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--cb-hp);
  text-shadow: 0 0 10px rgba(60, 181, 74, 0.5);
  animation: cb-heal-rise 0.7s steps(8) forwards;
}

.cb-fx-block {
  position: absolute;
  width: 55px; height: 65px;
  border: 4px solid var(--cb-accent);
  border-radius: 0 0 27px 27px;
  box-shadow: 0 0 16px rgba(138, 215, 255, 0.4), inset 0 0 16px rgba(138, 215, 255, 0.1);
  animation: cb-block-pulse 0.45s steps(6) forwards;
}

@keyframes cb-block-pulse {
  0% { transform: scale(0.3); opacity: 0; }
  40% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}

.cb-fx-dodge {
  position: absolute;
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  color: var(--cb-text-dim);
  letter-spacing: 4px;
  animation: cb-dodge-dash 0.35s steps(5) forwards;
}

@keyframes cb-dodge-dash {
  0% { transform: translateX(-20px); opacity: 1; }
  100% { transform: translateX(80px); opacity: 0; }
}

/* ---- UNIT HIT FLASH ---- */
@keyframes cb-unit-hit {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(2.5); }
}

.cb-unit.hit-flash {
  animation: cb-unit-hit 0.2s steps(3);
}

/* ---- TARGETED ENEMY SHAKE (player attacks this enemy) ---- */
@keyframes cb-unit-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

.cb-unit.target-shake {
  animation: cb-unit-shake 0.6s ease-out;
}

/* ---- DEFENSE FEEDBACK (block/dodge/brace on hero) ---- */
@keyframes cb-unit-block {
  0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.8); transform: scale(1); }
  30% { box-shadow: 0 0 18px 6px rgba(52, 152, 219, 0.6); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); transform: scale(1); }
}

@keyframes cb-unit-dodge {
  0%, 100% { transform: translateX(0); opacity: 1; }
  25% { transform: translateX(10px); opacity: 0.4; }
  50% { transform: translateX(-8px); opacity: 0.5; }
  75% { transform: translateX(4px); opacity: 0.8; }
}

@keyframes cb-unit-brace {
  0% { box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.8); filter: brightness(1); }
  40% { box-shadow: 0 0 14px 4px rgba(230, 126, 34, 0.5); filter: brightness(1.3); }
  100% { box-shadow: 0 0 0 0 rgba(230, 126, 34, 0); filter: brightness(1); }
}

.cb-unit.defense-block {
  animation: cb-unit-block 0.8s ease-out;
}

.cb-unit.defense-dodge {
  animation: cb-unit-dodge 0.7s ease-out;
}

.cb-unit.defense-brace {
  animation: cb-unit-brace 0.75s ease-out;
}

/* ---- DEFENSE FLOAT ICON (shows above hero) ---- */
@keyframes cb-defense-float {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-30px) scale(1.2); opacity: 0.9; }
  100% { transform: translateY(-50px) scale(0.8); opacity: 0; }
}

.cb-defense-icon {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  pointer-events: none;
  animation: cb-defense-float 1.2s ease-out forwards;
  z-index: 100;
  text-shadow: 0 0 8px rgba(255,255,255,0.6);
}

/* ============================================================
   FLYING ANIMATIONS: skill flies from hero → enemy
   ============================================================ */

/* Skill icon appears on hero */
@keyframes cb-fly-icon-pop {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
}

.cb-fly-icon {
  position: absolute;
  width: 56px;
  height: 56px;
  z-index: 200;
  pointer-events: none;
  animation: cb-fly-icon-pop 0.7s ease-out forwards;
  transform: translate(-50%, -50%);
}

.cb-fly-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 10px rgba(138, 215, 255, 0.7));
}

/* Skill name text near hero */
@keyframes cb-fly-name-show {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
  30% { opacity: 1; transform: translate(-50%, -5px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
}

.cb-fly-name {
  position: absolute;
  z-index: 201;
  pointer-events: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--cb-accent, #8ad7ff);
  text-shadow: 0 0 8px rgba(138, 215, 255, 0.6), 2px 2px 0 #000;
  text-align: center;
  white-space: nowrap;
  animation: cb-fly-name-show 1.1s ease-out forwards;
  transform: translate(-50%, 0);
}

/* Projectile flying hero → enemy */
@keyframes cb-fly-proj {
  0% {
    left: var(--from-x);
    top: var(--from-y);
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 1;
  }
  80% {
    left: var(--to-x);
    top: var(--to-y);
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  100% {
    left: var(--to-x);
    top: var(--to-y);
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0.5;
  }
}

.cb-fly-projectile {
  position: absolute;
  width: 40px;
  height: 40px;
  z-index: 200;
  pointer-events: none;
  animation: cb-fly-proj 0.85s ease-in forwards;
}

.cb-fly-projectile img {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 12px rgba(255, 200, 60, 0.8)) drop-shadow(0 0 24px rgba(255, 140, 0, 0.4));
}

/* Trail dots */
@keyframes cb-fly-trail-fade {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(0.2); opacity: 0; }
}

.cb-fly-trail {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cb-accent, #8ad7ff);
  box-shadow: 0 0 6px rgba(138, 215, 255, 0.6);
  z-index: 199;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: cb-fly-trail-fade 0.6s ease-out forwards;
}

/* Impact burst on enemy */
@keyframes cb-fly-impact-burst {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.cb-fly-impact {
  position: absolute;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.7) 0%, rgba(138,215,255,0.3) 50%, transparent 70%);
  z-index: 200;
  pointer-events: none;
  animation: cb-fly-impact-burst 0.7s ease-out forwards;
}

.cb-fly-impact.impact-fire {
  background: radial-gradient(circle, rgba(255,120,0,0.8) 0%, rgba(255,60,0,0.3) 50%, transparent 70%);
}

.cb-fly-impact.impact-ice {
  background: radial-gradient(circle, rgba(100,200,255,0.8) 0%, rgba(50,150,255,0.3) 50%, transparent 70%);
}

.cb-fly-impact.impact-magic {
  background: radial-gradient(circle, rgba(180,100,255,0.8) 0%, rgba(120,50,200,0.3) 50%, transparent 70%);
}

/* ---- Enemy projectile (red tint) ---- */
.cb-fly-projectile.enemy-projectile img {
  filter: drop-shadow(0 0 12px rgba(255, 60, 60, 0.8)) drop-shadow(0 0 24px rgba(200, 0, 0, 0.4));
  border-radius: 50%;
  width: 36px; height: 36px;
}

.cb-fly-trail.enemy-trail {
  background: #ff4444;
  box-shadow: 0 0 6px rgba(255, 60, 60, 0.6);
}

/* ---- Enemy buff burst (red/orange) ---- */
.cb-buff-burst.enemy-buff {
  animation: cb-buff-pop 1.3s ease-out forwards;
}

.cb-buff-particle.enemy-particle {
  background: #ff4444;
  box-shadow: 0 0 8px rgba(255, 60, 60, 0.8);
}

.cb-buff-name.enemy-buff-name {
  color: #ff6b6b;
  text-shadow: 0 0 8px rgba(255, 60, 60, 0.5), 2px 2px 0 #000;
}

/* ============================================================
   BUFF EXPLOSION: center burst for buffs/specials
   ============================================================ */

@keyframes cb-buff-pop {
  0% { transform: scale(0.2); opacity: 0; }
  30% { transform: scale(1.3); opacity: 1; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.5); opacity: 0; }
}

.cb-buff-burst {
  position: absolute;
  left: 50%; top: 50%;
  width: 80px; height: 80px;
  margin-left: -40px; margin-top: -40px;
  z-index: 15;
  animation: cb-buff-pop 1.4s ease-out forwards;
}

.cb-buff-burst img {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.7));
}

@keyframes cb-buff-particle-fly {
  0% { transform: rotate(var(--angle)) translateY(0) scale(1); opacity: 1; }
  100% { transform: rotate(var(--angle)) translateY(-55px) scale(0.3); opacity: 0; }
}

.cb-buff-particle {
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  margin-left: -4px; margin-top: -4px;
  border-radius: 50%;
  background: #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
  animation: cb-buff-particle-fly 1.2s ease-out forwards;
}

@keyframes cb-buff-name-show {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  30% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
  80% { opacity: 1; transform: translate(-50%, -15px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -25px) scale(0.9); }
}

.cb-buff-name {
  position: absolute;
  left: 50%; bottom: 10%;
  z-index: 16;
  pointer-events: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5), 2px 2px 0 #000;
  white-space: nowrap;
  animation: cb-buff-name-show 1.4s ease-out forwards;
}

/* ============================================================
   FLOATING DAMAGE NUMBERS ON UNITS
   ============================================================ */

@keyframes cb-dmg-float-up {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-25px) scale(1.1); opacity: 0.9; }
  100% { transform: translateY(-45px) scale(0.8); opacity: 0; }
}

.cb-dmg-float {
  position: absolute;
  top: 0;
  z-index: 100;
  pointer-events: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  font-weight: bold;
  animation: cb-dmg-float-up 1.6s ease-out forwards;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

.cb-dmg-float.enemy-dmg {
  color: #ff4444;
}

.cb-dmg-float.hero-dmg {
  color: #ff6b6b;
}

.cb-dmg-float.crit-dmg {
  font-size: 18px;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6), 2px 2px 0 #000;
}

.cb-dmg-float.miss {
  color: #999;
  font-size: 11px;
}

/* ---- NEW LOG ENTRY ---- */
@keyframes cb-text-appear {
  0% { opacity: 0; transform: translateX(-6px); }
  100% { opacity: 1; transform: translateX(0); }
}

.cb-log-entry.new-entry {
  animation: cb-text-appear 0.25s steps(3);
}

/* =========================================
   ENEMY INFO MODAL
   ========================================= */

.enemy-info-modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}

.enemy-info-modal {
  background: var(--cb-bg);
  border: 2px solid var(--cb-border-light);
  width: min(900px, 96vw);
  min-height: 420px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  color: var(--cb-text-dim);
  font-family: 'Press Start 2P', monospace;
  font-size: 13px; line-height: 1.9;
  display: flex;
  flex-direction: column;
}

.enemy-info-modal::-webkit-scrollbar { width: 5px; }
.enemy-info-modal::-webkit-scrollbar-thumb { background: var(--cb-border); }

.ei-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none;
  color: var(--cb-text-dim); font-size: 24px;
  cursor: pointer; z-index: 10; padding: 4px;
  font-family: 'Press Start 2P', monospace;
}
.ei-close:hover { color: var(--cb-enemy-hp); }

/* === 50/50 SPLIT LAYOUT === */
.ei-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ei-left {
  width: 50%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 18px 18px;
  border-right: 2px solid var(--cb-border);
  background: rgba(0,0,0,0.25);
  gap: 14px;
  overflow: hidden;
}

.ei-right {
  width: 50%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.ei-right::-webkit-scrollbar { width: 5px; }
.ei-right::-webkit-scrollbar-thumb { background: var(--cb-border); }

.ei-img {
  width: 100%;
  max-width: 280px;
  height: auto;
  min-height: 220px;
  max-height: 320px;
  object-fit: contain;
  border: 2px solid var(--cb-border);
  background: rgba(0,0,0,0.4);
  image-rendering: pixelated;
}

.ei-title-wrap { width: 100%; text-align: center; }
.ei-name { font-size: 16px; color: var(--cb-text); margin-bottom: 10px; line-height: 1.6; }
.ei-meta { font-size: 12px; color: var(--cb-text-dim); letter-spacing: 1px; }

/* Legacy header (hero modal still uses it) */
.ei-header {
  display: flex; gap: 16px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--cb-border);
  align-items: flex-start;
}

.ei-desc {
  padding: 14px 20px; color: #6a7388;
  font-style: italic; border-bottom: 1px solid var(--cb-border);
  font-size: 12px; line-height: 2;
}

.ei-stats {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 14px 20px; border-bottom: 1px solid var(--cb-border);
}

.ei-stat {
  padding: 7px 12px; background: var(--cb-card);
  border: 1px solid var(--cb-border);
  color: var(--cb-text-dim); font-size: 12px;
}

.ei-row {
  display: flex; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--cb-border);
}

.ei-block {
  flex: 1; padding: 10px 12px;
  border: 1px solid var(--cb-border);
  background: var(--cb-card);
  font-size: 12px; color: var(--cb-text-dim); line-height: 2;
}

.ei-section { padding: 14px 20px; border-bottom: 1px solid var(--cb-border); }
.ei-section-title { font-size: 12px; color: var(--cb-accent); letter-spacing: 2px; margin-bottom: 10px; }

.ei-skill { padding: 8px 0; border-bottom: 1px solid rgba(43, 49, 66, 0.3); }
.ei-skill:last-child { border-bottom: none; }
.ei-skill-header { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ei-skill-name { color: var(--cb-text); font-weight: bold; }
.ei-skill-mult { color: var(--cb-hp, #ff4444); font-size: 11px; margin-left: 4px; }
.ei-skill-trigger { display: inline-block; font-size: 10px; color: var(--cb-accent, #8ad7ff); background: rgba(138, 215, 255, 0.1); border: 1px solid rgba(138, 215, 255, 0.2); border-radius: 3px; padding: 1px 6px; margin-top: 4px; }
.ei-skill-desc { font-size: 11px; color: var(--cb-text-dim); margin-top: 4px; padding-left: 4px; line-height: 1.8; }
.ei-val { color: var(--cb-text-dim); font-size: 13px; }
.ei-rewards { padding: 14px 20px; color: var(--cb-crit); font-size: 12px; letter-spacing: 1px; }

/* =========================================
   HERO INFO MODAL (extends enemy-info-modal)
   ========================================= */

.hero-info-modal .ei-header {
  border-bottom: 1px solid var(--cb-accent);
}

.hero-info-modal .ei-left {
  border-right-color: var(--cb-accent);
}

.hi-bars-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--cb-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hi-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hi-bar-label {
  font-size: 11px;
  color: var(--cb-text-dim);
  min-width: 55px;
  letter-spacing: 1px;
}

.hi-bar-row .cb-bar {
  flex: 1;
}

.hi-skill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(43, 49, 66, 0.3);
}
.hi-skill-row:last-child { border-bottom: none; }

.hi-skill-name {
  flex: 1;
  font-size: 11px;
  color: var(--cb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hi-skill-slot {
  font-size: 10px;
  color: var(--cb-text-dim);
  padding: 3px 6px;
  border: 1px solid var(--cb-border);
  background: rgba(0,0,0,0.2);
}

.hi-skill-xp-bar {
  width: 60px;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.hi-skill-uses {
  font-size: 10px;
  color: var(--cb-text-dim);
  min-width: 55px;
  text-align: right;
}

/* =========================================
   ATTACK TYPE TAB STRIP (above attack column)
   ========================================= */

.cb-atktype-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cb-border);
  flex-wrap: wrap;
}

.cb-atktype-tab {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 5px 10px;
  border: 1px solid var(--cb-border);
  background: var(--cb-card);
  color: var(--cb-text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cb-atktype-tab:hover {
  border-color: var(--cb-accent);
  color: var(--cb-text);
}

.cb-atktype-tab.active {
  background: var(--cb-accent);
  color: #0f1115;
  border-color: var(--cb-accent);
  box-shadow: 0 0 8px rgba(138, 215, 255, 0.3);
}

.cb-weapon-dmg {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--cb-crit);
  letter-spacing: 0.5px;
  margin-left: auto;
  white-space: nowrap;
}

/* =========================================
   STATUS EFFECTS — SQUARES
   ========================================= */

.cb-effects-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2px;
  margin: 3px 0;
  min-height: 20px;
}

.cb-effects-buffs,
.cb-effects-debuffs {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.cb-effects-buffs {
  justify-content: flex-start;
}
.cb-effects-debuffs {
  justify-content: flex-end;
}

.cb-effect-sq {
  width: 26px;
  height: 26px;
  border: 2px solid;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}

.cb-effect-sq:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px currentColor;
  z-index: 5;
}

.cb-sq-icon {
  font-size: 14px;
  line-height: 1;
}

.cb-sq-stacks {
  position: absolute;
  top: -4px;
  right: -4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #fff;
  background: #c62828;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1px solid #000;
}

.cb-sq-rounds {
  position: absolute;
  bottom: -4px;
  right: -3px;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--cb-text-dim);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 0 2px;
  line-height: 1;
}

.cb-effect-popup {
  position: absolute;
  background: linear-gradient(180deg, #1e2230 0%, #14161f 100%);
  border: 2px solid var(--cb-accent);
  border-radius: 8px;
  padding: 8px 12px;
  z-index: 100;
  min-width: 140px;
  max-width: 240px;
  box-shadow: 0 0 16px rgba(138, 215, 255, 0.25), 0 4px 12px rgba(0,0,0,0.5);
  animation: cb-popup-in 0.2s ease-out;
}

.cb-effect-popup.popup-debuff {
  border-color: #c62828;
  box-shadow: 0 0 16px rgba(198, 40, 40, 0.25), 0 4px 12px rgba(0,0,0,0.5);
}

.cb-effect-popup.popup-buff {
  border-color: #4caf50;
  box-shadow: 0 0 16px rgba(76, 175, 80, 0.25), 0 4px 12px rgba(0,0,0,0.5);
}

.cb-popup-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  text-shadow: 1px 1px 0 #000;
}

.cb-popup-details {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--cb-accent);
  line-height: 1.7;
  white-space: normal;
  padding: 4px 0;
  border-top: 1px solid rgba(138, 215, 255, 0.1);
  border-bottom: 1px solid rgba(138, 215, 255, 0.1);
}

.popup-debuff .cb-popup-details {
  color: #ff8a80;
}

.cb-popup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
}

.cb-popup-type {
  text-transform: uppercase;
  letter-spacing: 1px;
}

.popup-buff .cb-popup-type { color: #4caf50; }
.popup-debuff .cb-popup-type { color: #c62828; }

.cb-popup-rounds {
  color: var(--cb-text-dim);
}

@keyframes cb-popup-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.cb-effect-sq.is-buff {
  background: rgba(76, 175, 80, 0.12);
}

.cb-effect-sq.is-debuff {
  background: rgba(198, 40, 40, 0.12);
}

/* =========================================
   SECTION LOCK (mutual exclusion)
   ========================================= */

.cb-section-locked {
  opacity: 0.2;
  pointer-events: none;
  filter: grayscale(0.7);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.cb-section-locked .cb-section-label {
  text-decoration: line-through;
  text-decoration-color: rgba(138, 215, 255, 0.3);
}

/* =========================================
   SPECIAL ACTIONS — BUTTON LIST + [i]
   ========================================= */

.cb-section-special {
  border-right: none;
}

.cb-special-label {
  color: #d4a0ff !important;
  text-shadow: 0 0 6px rgba(180, 120, 255, 0.3);
  border-bottom-color: rgba(180, 120, 255, 0.3) !important;
}

/* ---- Action row with [i] button (universal for all skill types) ---- */

.cb-action-btn-row,
.cb-special-btn-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 4px;
}

.cb-action-btn-row > .cb-btn,
.cb-special-btn-row > .cb-btn {
  flex: 1;
  border-right: none;
}

.cb-btn-special.selected {
  background: rgba(180, 120, 255, 0.15);
  color: #d4a0ff;
  border-color: #d4a0ff;
  box-shadow: 0 0 8px rgba(180, 120, 255, 0.25);
}

.cb-btn-cd {
  font-size: 8px;
  color: var(--cb-text-dim);
  flex-shrink: 0;
  opacity: 0.6;
}

.cb-action-i,
.cb-special-i {
  width: 26px;
  min-width: 26px;
  border: 1px solid var(--cb-border);
  background: var(--cb-card);
  color: #8a93a5;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  padding: 0;
}

.cb-action-i:hover,
.cb-special-i:hover {
  border-color: #d4a0ff;
  color: #fff;
  box-shadow: 0 0 8px rgba(180, 120, 255, 0.3);
  background: rgba(180, 120, 255, 0.2);
}

/* =========================================
   DICE ROLL ANIMATION (improved)
   ========================================= */

.cb-dice-anim {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  text-align: center;
  animation: cb-dice-appear 1.5s ease-out forwards;
  pointer-events: none;
}

@keyframes cb-dice-appear {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  20%  { transform: translate(-50%, -50%) scale(0.95); }
  30%  { transform: translate(-50%, -50%) scale(1.02); }
  35%  { transform: translate(-50%, -50%) scale(1); }
  85%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7) translateY(-10px); }
}

.cb-dice-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120px;
  height: 120px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180, 120, 255, 0.35) 0%, transparent 70%);
  animation: cb-glow-pulse 0.9s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes cb-glow-pulse {
  0%   { opacity: 0.5; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
}

.cb-dice-cube {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 0 20px rgba(180, 120, 255, 0.7))
          drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  transition: transform 0.15s ease;
}

.cb-dice-settle {
  animation: cb-dice-land 0.35s ease-out forwards;
}

@keyframes cb-dice-land {
  0%   { transform: scale(1.2) rotate(5deg); }
  50%  { transform: scale(0.9) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.cb-dice-action-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #d4a0ff;
  margin-top: 12px;
  text-shadow: 0 0 12px rgba(180, 120, 255, 0.7), 2px 2px 0 #000;
  white-space: nowrap;
  letter-spacing: 1px;
  animation: cb-name-fade 1.4s ease forwards;
}

@keyframes cb-name-fade {
  0%   { opacity: 0; transform: translateY(6px); }
  20%  { opacity: 1; transform: translateY(0); }
  85%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Dice result overlay (post-resolve) ---- */

.cb-dice-result {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%) translateY(12px) scale(0.8);
  z-index: 30;
  font-family: 'Press Start 2P', monospace;
  pointer-events: none;
  white-space: nowrap;
  padding: 12px 18px;
  background: rgba(10, 10, 20, 0.92);
  border: 2px solid var(--cb-border-light);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  text-align: center;
}

.cb-dice-result.cb-dice-result-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.cb-dice-result.cb-dice-result-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-20px) scale(0.9);
}

.cb-dice-result.dice-success {
  border-color: #4caf50;
  box-shadow: 0 0 18px rgba(76, 175, 80, 0.35), inset 0 0 30px rgba(76, 175, 80, 0.06);
}

.cb-dice-result.dice-fail {
  border-color: #d74a4a;
  box-shadow: 0 0 18px rgba(215, 74, 74, 0.35), inset 0 0 30px rgba(215, 74, 74, 0.06);
}

.cb-dice-result-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.cb-dice-d20 {
  font-size: 22px;
}

.cb-dice-roll {
  font-size: 22px;
  color: var(--cb-crit);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

.cb-dice-mod {
  font-size: 13px;
  color: var(--cb-accent);
}

.cb-dice-dc-row {
  font-size: 9px;
  color: var(--cb-text-dim);
  margin-bottom: 6px;
}

.cb-dice-verdict {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  padding-top: 4px;
  border-top: 1px solid rgba(138, 215, 255, 0.1);
}

.cb-dice-verdict.verdict-ok {
  color: #4caf50;
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}

.cb-dice-verdict.verdict-fail {
  color: #d74a4a;
  text-shadow: 0 0 10px rgba(215, 74, 74, 0.4);
}

.cb-dice-total-num {
  font-size: 11px;
  opacity: 0.7;
}

/* =========================================
   SPECIAL INFO MODAL ([i] button)
   ========================================= */

.cb-special-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cb-popup-in 0.15s ease-out;
}

.cb-special-modal {
  background: var(--cb-bg);
  border: 2px solid #d4a0ff;
  width: 380px;
  max-width: 90vw;
  position: relative;
  color: var(--cb-text-dim);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  line-height: 2;
  box-shadow: 0 0 30px rgba(180, 120, 255, 0.3), 0 0 60px rgba(0, 0, 0, 0.5);
}

.si-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--cb-text-dim);
  font-size: 18px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  padding: 4px;
  z-index: 10;
}

.si-close:hover { color: #d4a0ff; }

.si-title {
  font-size: 13px;
  color: #d4a0ff;
  padding: 14px 16px 8px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(180, 120, 255, 0.3);
  border-bottom: 1px solid var(--cb-border);
}

.si-desc {
  padding: 10px 16px;
  color: var(--cb-text-dim);
  font-size: 9px;
  line-height: 2;
  font-style: italic;
  border-bottom: 1px solid var(--cb-border);
}

.si-stats {
  padding: 10px 16px 14px;
}

.si-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(43, 49, 66, 0.3);
}

.si-row:last-child { border-bottom: none; }

.si-label {
  color: var(--cb-accent);
  font-size: 9px;
  letter-spacing: 1px;
}

.si-val {
  color: var(--cb-text);
  font-size: 9px;
  text-align: right;
}

.si-val.si-effect {
  color: #ff8a80;
}

.si-type {
  font-size: 8px;
  letter-spacing: 2px;
  padding: 10px 16px 0;
  opacity: 0.8;
}

.si-skill-bar {
  padding: 8px 16px 14px;
  border-top: 1px solid var(--cb-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.si-skill-lvl {
  font-size: 8px;
  color: var(--cb-accent);
  white-space: nowrap;
}

.si-xp-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.si-xp-fill {
  height: 100%;
  background: var(--cb-crit);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.si-skill-xp {
  font-size: 7px;
  color: var(--cb-text-dim);
  white-space: nowrap;
}

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 900px) {
  .cb-battlefield { grid-template-columns: 180px 1fr 180px; }
  .cb-unit-img, .cb-unit-placeholder { width: 64px; height: 64px; }
}

@media (max-width: 700px) {
  .cb-battlefield { grid-template-columns: 150px 1fr 150px; }
  .cb-unit { padding: 6px; }
  .cb-unit-img, .cb-unit-placeholder { width: 52px; height: 52px; }
  .cb-unit-name { font-size: 10px; }
  .cb-controls { flex-wrap: wrap; min-height: auto; }
  .cb-section { min-width: 130px; }
}
