/* HP bars — shared by party, enemies, focused enemy */
.hp-bar-outer {
  height: 20px;
  background: #0d1015;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.hp-bar-outer.big { height: 26px; }
.hp-bar-outer.small { height: 10px; }
.hp-bar-outer.tiny { height: 6px; border-radius: 3px; }
.hp-bar-inner {
  height: 100%;
  background: linear-gradient(180deg, #f55 0%, #c33 50%, #a22 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: width 100ms linear;
}
.hp-bar-inner.party {
  background: linear-gradient(180deg, #5c5 0%, #3a3 50%, #2a2 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Unified arena — two grids share one battlefield background with a subtle
   vignette so the panel feels like a scene, not just a container. */
#arena {
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.35) 100%),
    linear-gradient(135deg, #1a1d24 0%, #22262d 50%, #221a22 100%);
  border: var(--panel-border);
  border-radius: var(--panel-radius);
  padding: var(--sp-4);
  position: relative;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}
.battle-col {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.col-label {
  font-size: var(--text-xs); color: var(--text-2); margin-bottom: var(--sp-2);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: var(--weight-bold);
  text-align: center;
}
/* Attack-lines SVG overlay covers the whole arena so lines can cross between grids */
#attack-lines {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}
.attack-line {
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  animation: attack-line-fade 380ms ease-out forwards;
}
.attack-line.hero  { stroke: #f5d020; filter: drop-shadow(0 0 6px rgba(245, 208, 32, 0.8)); }
.attack-line.enemy { stroke: #ff6060; filter: drop-shadow(0 0 6px rgba(255, 96, 96, 0.8)); }
.attack-line.crit  { stroke-width: 5; stroke: #ffdd00; filter: drop-shadow(0 0 10px rgba(255, 221, 0, 0.9)); }
.attack-line.weak  { stroke-width: 4; stroke: #ee44ee; filter: drop-shadow(0 0 8px rgba(232, 62, 232, 0.9)); }
@keyframes attack-line-fade {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}
/* Party column */
.grid-cell.downed {
  opacity: 0.4;
  border-color: #6a2a2a;
}
.cell-hp-wrap {
  width: 90%; margin-top: 0.25rem;
  pointer-events: none; user-select: none;
}
.cell-hp-wrap .hp-bar-outer {
  width: 100%;
}

/* Upgrade indicator lives on the cell border/glow — zero extra pixels used.
   Order matters: downed dim should win over these, so we keep .downed later. */
.grid-cell.upgrade-1  { border-color: #888; }
.grid-cell.upgrade-5  { border-color: #d4a017; box-shadow: 0 0 6px rgba(212, 160, 23, 0.55); }
.grid-cell.upgrade-10 { border-color: #d47017; box-shadow: 0 0 8px rgba(212, 112, 23, 0.6); }
.grid-cell.upgrade-50 {
  border-color: #e83ee8; box-shadow: 0 0 10px rgba(232, 62, 232, 0.7);
  animation: upgrade-pulse 1.6s ease-in-out infinite;
}
@keyframes upgrade-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(232, 62, 232, 0.5); }
  50%      { box-shadow: 0 0 16px rgba(232, 62, 232, 0.85); }
}

/* Empty cells now visible by default via .is-empty; while dragging, they
   subtly signal as drop targets. */
#grid.is-dragging .grid-cell.is-empty {
  border-color: var(--accent-gold);
  background: rgba(255, 215, 0, 0.04);
}
#grid.is-dragging .grid-cell.is-empty .cell-empty-glyph {
  color: var(--accent-gold);
  animation: empty-slot-pulse 1.2s ease-in-out infinite;
}
@keyframes empty-slot-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.75; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* Grid — labels + 3x3 cells, rotated 90° CW (Back | Mid | Front left→right) */
.grid-labels {
  display: grid; grid-template-columns: repeat(3, 1fr);
  font-size: var(--text-xs); color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: var(--sp-2); text-align: center;
  font-weight: var(--weight-medium);
}
#grid {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: var(--sp-2); aspect-ratio: 1 / 1; max-width: 100%;
}
.grid-cell {
  background: var(--surface-2);
  border: 2px solid var(--border-hair);
  border-radius: 10px;
  padding: var(--sp-2) var(--sp-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  cursor: pointer; position: relative; min-height: 100px;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast),
              background var(--dur-fast),
              box-shadow var(--dur-fast);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.grid-cell:hover:not(.is-empty) {
  border-color: var(--border-strong);
  background: var(--surface-3);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
}
.grid-cell.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.08);
}
.grid-cell.selected:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 6px 12px rgba(0,0,0,0.3); }
.grid-cell[draggable="true"] { cursor: grab; }
.grid-cell[draggable="true"]:active { cursor: grabbing; }
.grid-cell.dragging { opacity: 0.4; }
.grid-cell.drag-over { background: var(--surface-3); border-color: var(--accent-gold); transform: scale(1.04); }

/* Row-color hints (Back=blue, Mid=tan, Front=red combat-edge) — kept for the
   compass at-a-glance. Applied only to filled cells; empty cells stay neutral. */
.grid-cell:not(.is-empty)[data-row="back"] { border-left-color: #3a5a7a; }
.grid-cell:not(.is-empty)[data-row="mid"] { border-left-color: #7a5a3a; }
.grid-cell:not(.is-empty)[data-row="front"] { border-left-color: #7a4a3a; border-right: 3px solid #d84a2a; }

/* Cell contents shouldn't intercept clicks or trigger their own drag */
.grid-cell svg,
.grid-cell .cell-portrait-wrap,
.grid-cell .cell-name,
.grid-cell .cell-class,
.grid-cell .cell-meta,
.grid-cell .cell-pos,
.grid-cell .cell-empty-frame {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.cell-portrait-wrap {
  margin-top: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.cell-name { font-size: var(--text-sm); font-weight: var(--weight-bold); margin-top: var(--sp-1); text-align: center; color: var(--text-1); line-height: 1.15; }
.cell-meta { font-size: var(--text-xs); color: var(--text-2); }
.cell-pos { position: absolute; top: 6px; right: 8px; font-size: var(--text-xs); color: #7c7; font-weight: var(--weight-bold); }
.cell-pos.weak { color: #c77; }

/* Empty cell: dashed slot silhouette so the 3×3 grid always keeps its
   shape. Reads as a placeholder frame rather than dead space. */
.grid-cell.is-empty {
  background: rgba(255, 255, 255, 0.015);
  border-style: dashed;
  border-color: var(--border-hair);
  cursor: default;
  box-shadow: none;
}
.grid-cell.is-empty:hover { border-color: var(--border-strong); }
.cell-empty-frame {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; opacity: 0.55;
}
.cell-empty-glyph {
  font-size: 32px;
  line-height: 1;
  color: var(--text-2);
  font-weight: var(--weight-normal);
}
.cell-empty-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-2);
}

.grid-hint { text-align: center; font-size: var(--text-xs); color: var(--text-2); margin-top: var(--sp-2); }

/* Enemies column — 4×4 grid */
.enemy-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--sp-2);
  aspect-ratio: 1 / 1;
  max-width: 100%;
}
.enemy-grid-empty {
  text-align: center; padding: 2rem 0;
  grid-column: 1 / -1; grid-row: 1 / -1;
  align-self: center;
  color: var(--text-2);
  font-size: var(--text-md);
}
.enemy-cell {
  background: var(--surface-2);
  border: 2px solid var(--border-hair);
  border-radius: 8px;
  padding: var(--sp-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  position: relative;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast),
              box-shadow var(--dur-fast);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.enemy-cell:hover:not(.is-empty) {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.enemy-cell.is-empty {
  background: rgba(255, 255, 255, 0.015);
  border-color: var(--border-hair);
  border-style: dashed;
  padding: 0;
}
.enemy-empty-frame {
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.02) 0px,
      rgba(255,255,255,0.02) 6px,
      transparent 6px,
      transparent 12px
    );
  border-radius: 6px;
}

/* Portrait frame around the enemy silhouette — a recessed inset area so
   the creature reads as sitting IN a frame rather than floating in a box.
   This is the slot the future real enemy art will drop into. */
.enemy-portrait {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: linear-gradient(180deg, #14171d 0%, #0b0d12 100%);
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  position: relative;
}
/* Subtle top-light on the portrait area — sells the recessed feel */
.enemy-portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
}
.enemy-cell-svg {
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}

/* Boss cells — the whole visual language cranks up. Bigger portrait, red
   inner glow, subtle idle pulse, dramatic label. */
.enemy-cell.boss-cell {
  border-color: #d84a2a;
  border-width: 3px;
  background: linear-gradient(180deg, #3a1a15 0%, #22262d 100%);
  box-shadow:
    inset 0 0 20px rgba(216, 74, 42, 0.25),
    0 0 16px rgba(216, 74, 42, 0.3);
  padding: var(--sp-2);
  gap: var(--sp-2);
  animation: boss-idle-pulse 3s ease-in-out infinite;
}
.enemy-cell.boss-cell .enemy-portrait {
  background: linear-gradient(180deg, #1a0d0a 0%, #0b0605 100%);
  border-color: rgba(0, 0, 0, 0.65);
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.7),
    inset 0 0 24px rgba(216, 74, 42, 0.35);
}
.enemy-cell.boss-cell .enemy-portrait::after {
  background: radial-gradient(ellipse at top, rgba(255, 140, 100, 0.15) 0%, transparent 55%);
}
@keyframes boss-idle-pulse {
  0%, 100% { box-shadow: inset 0 0 18px rgba(216, 74, 42, 0.2),  0 0 12px rgba(216, 74, 42, 0.25); }
  50%      { box-shadow: inset 0 0 26px rgba(216, 74, 42, 0.35), 0 0 24px rgba(216, 74, 42, 0.45); }
}
.enemy-cell-label {
  font-size: var(--text-xs); font-weight: var(--weight-bold); color: #ff8866;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.enemy-cell.boss-cell .enemy-cell-label {
  font-size: var(--text-md);
  color: #ffb090;
  text-shadow: 0 0 8px rgba(255, 100, 60, 0.65);
  letter-spacing: 2px;
}
.enemy-cell-hp { font-size: 10px; color: var(--text-2); text-align: center; }
.enemy-cell.boss-cell .enemy-cell-hp {
  font-size: var(--text-sm);
  color: var(--text-1);
  font-weight: var(--weight-medium);
}
.enemy-cell .hp-bar-outer { width: 100%; height: 8px; }
.enemy-cell.boss-cell .hp-bar-outer { height: 14px; }

/* Weakness indicator — top-left corner chip. Now with a small background
   plate so it reads as a badge, not a floating glyph. */
.enemy-weak-icon {
  position: absolute; top: 5px; left: 5px;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-hair);
  border-radius: 5px;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.7));
}
.enemy-cell { position: relative; }

/* === Combat feedback: cell flashes + floating damage numbers === */

.grid-cell, .enemy-cell { position: relative; }

/* Attacker lean: brief scale + subtle glow */
.grid-cell.attacking,
.enemy-cell.attacking {
  transform: scale(1.06);
  transition: transform 100ms ease-out;
  z-index: 3;
}
.grid-cell.attacking { box-shadow: 0 0 12px rgba(245, 208, 32, 0.55); }
.enemy-cell.attacking { box-shadow: 0 0 12px rgba(255, 96, 96, 0.55); }

/* Target hit: red overlay pulse via ::after so we don't clobber existing backgrounds */
.grid-cell.taking-hit::after,
.enemy-cell.taking-hit::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255, 60, 60, 0.45);
  border-radius: inherit;
  pointer-events: none;
  animation: hit-flash 320ms ease-out;
  z-index: 2;
}
@keyframes hit-flash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Floating damage numbers */
.dmg-num {
  position: absolute;
  left: 50%; top: 45%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: none;
  animation: dmg-rise 900ms ease-out forwards;
  z-index: 10;
  white-space: nowrap;
}
.dmg-num.enemy { color: #ffbbbb; font-size: 0.8rem; }
.dmg-num.crit  { color: #ffdd00; font-size: 1.15rem; text-shadow: 0 0 6px rgba(255, 221, 0, 0.9), 0 1px 2px #000; }
.dmg-num.weak  { color: #ee44ee; text-shadow: 0 0 6px rgba(232, 62, 232, 0.85), 0 1px 2px #000; }
@keyframes dmg-rise {
  0%   { opacity: 0; transform: translate(-50%, 0)      scale(0.75); }
  20%  { opacity: 1; transform: translate(-50%, -40%)   scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -140%)  scale(1); }
}

/* Awakening stars — top of hero cell. Color follows the ascension tier so
   Chase can tell at a glance how deep the class has gone. */
.cell-awakens {
  font-size: 0.6rem;
  letter-spacing: 1px;
  line-height: 1;
  text-align: center;
  min-height: 0.7rem;
  margin-bottom: 0.1rem;
  color: #ffd700;
  text-shadow: 0 0 3px rgba(255, 215, 0, 0.6);
}
.cell-awakens:empty { min-height: 0; margin-bottom: 0; }

/* Tier 1 (1–5 ascensions): bronze */
.cell-awakens.tier-1 { color: #d4914d; text-shadow: 0 0 3px rgba(212, 145, 77, 0.7); }
/* Tier 2 (6–10 ascensions): silver-blue */
.cell-awakens.tier-2 { color: #d0e0f0; text-shadow: 0 0 4px rgba(220, 235, 255, 0.75); }
/* Tier 3 (11–15 ascensions): gold — the max color */
.cell-awakens.tier-3 { color: #ffd700; text-shadow: 0 0 5px rgba(255, 215, 0, 0.85); }

/* DPS — bottom of hero cell */
.cell-dps {
  font-size: 0.68rem;
  font-weight: bold;
  color: #ffd700;
  text-align: center;
  line-height: 1;
  margin-top: 0.2rem;
}

/* Splash hits — thinner attack line, smaller/dimmer damage number so they
   read as secondary to the primary hit. */
.attack-line.splash {
  stroke-width: 1.5;
  opacity: 0.7;
}
.dmg-num.splash {
  font-size: 0.7rem;
  opacity: 0.85;
  color: #dddddd;
  text-shadow: 0 1px 2px #000;
}
/* Splash crits are still bright but a hair smaller than a primary crit */
.dmg-num.splash.crit { font-size: 0.9rem; color: #ffdd00; }
/* Splash weak-type hits (magenta) also get the size discount */
.dmg-num.splash.weak { color: #ee44ee; }

/* Class label under champion name in grid cell */
.cell-class {
  font-size: 0.62rem;
  color: #ffd700;
  line-height: 1;
  margin-top: 0.05rem;
  text-align: center;
}
