:root {
  --bg: #ece7de;
  --bg-2: #f4f0ea;
  --ink: #2a2836;
  --ink-dim: #7a7884;
  --line: #c8c4bc;
  --hp: #c43c3c;
  --hp-dim: rgba(196,60,60,0.3);
  --gold: #b8892a;
  --party: #3a8a4a;
  --foe: #c05a2a;
  --crit: #b8892a;
  --threat: rgba(230,180,50,0.85);
  --outgoing: rgba(230,180,50,0.85);
  --heal-preview: rgba(58,138,74,0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  height: 100%;
  overflow: hidden;
  overflow-y: auto;
  user-select: none;
  -webkit-user-select: none;
}
body {
  background:
    radial-gradient(circle at 20% 0%, #e2ddd6 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, #e6e0d8 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 1px, transparent 1px, transparent 3px);
  z-index: 1000;
}

/* LAYOUT */
.arena {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: 14px;
  gap: 10px;
}
.arena.hidden { display: none; }

/* MAP SCREEN */
.map-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
  padding: 14px;
  gap: 16px;
}
.map-screen .header { width: 100%; }
.map-screen.hidden { display: none; }

/* Ember display */
.ember-icon, .pixel-icon {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.shape-glyph {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.foe-glyph {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.player-icon {
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
  color: var(--gold);
}
.waypoint-icon {
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.ember-count {
  color: #b07820;
  text-shadow: none;
}
.ember-gain {
  color: #b07820;
  text-shadow: none;
  animation: ember-pop 0.6s ease-out;
}
@keyframes ember-pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
/* CASHOUT — progressive reveal on reward screen */
.reward-cashout {
  margin-bottom: 12px;
}
.reward-cashout.hidden { display: none; }

.cashout-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ink-dim);
}
.cashout-val { font-size: 16px; }
.cashout-dealt { color: var(--party); }
.cashout-taken { color: var(--foe); }
.cashout-kills { color: var(--crit); }

.cashout-fade {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}
.cashout-fade.cashout-visible {
  opacity: 1;
  transform: translateY(0);
}
.cashout-ember-total.cashout-fade {
  transition: none;
}

.slide-up {
  opacity: 0;
  transform: translateY(50px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.slide-up.slide-visible {
  opacity: 1;
  transform: translateY(0);
}

.cashout-separator {
  width: 60%;
  max-width: 280px;
  height: 1px;
  margin: 16px auto;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.reward-subtitle.upgrade-title {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.cashout-embers {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cashout-ember-line {
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  color: #b07820;
  text-shadow: none;
}
.cashout-ember-total {
  font-family: 'VT323', monospace;
  font-size: 26px;
  letter-spacing: 4px;
  color: #b07820;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(176, 120, 32, 0.2);
}
.cashout-ember-total.cashout-visible {
  animation: ember-total-pop 0.5s ease-out;
}
@keyframes ember-total-pop {
  0% { opacity: 0; transform: translateY(6px) scale(0.8); }
  40% { opacity: 1; transform: translateY(-2px) scale(1.15); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Notch display */
.notch-icon, .mark-icon {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.notch-count {
  color: #5a6070;
  text-shadow: none;
}
.cashout-notch-line {
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 1px;
  color: #5a6070;
  text-shadow: none;
  margin-top: 8px;
  text-align: center;
}

/* Achievement cashout tags on reward screen */
.ach-cashout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}
.ach-tag {
  font-family: 'VT323', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.5);
  color: var(--gold);
}
.ach-tag.clean { color: #2a7a3a; border-color: rgba(42,122,58,0.4); }
.ach-tag.minDmg { color: #2a7a98; border-color: rgba(42,122,152,0.4); }
.ach-tag.maxNet { color: var(--gold); border-color: rgba(184,137,42,0.4); }
.ach-tag.lethal { color: #b83030; border-color: rgba(184,48,48,0.4); }
.ach-tag.sheltered { color: #2a8fa8; border-color: rgba(42,143,168,0.4); }
.ach-tag.calculated { color: #c43070; border-color: rgba(196,48,112,0.4); }
.ach-tag.clutch { color: #7a5aaa; border-color: rgba(122,90,170,0.4); }
.ach-tag.overkill { color: #b83030; border-color: rgba(184,48,48,0.4); }
.ach-tag.sweep { color: var(--gold); border-color: rgba(184,137,42,0.4); }
.ach-tag.reckless { color: #c05a2a; border-color: rgba(192,90,42,0.4); }
.ach-tag.focused { color: #3a5aaa; border-color: rgba(58,90,170,0.4); }

.ember-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
  text-align: center;
}
.ember-reason {
  color: #b07820;
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow: none;
}
.ember-total {
  width: 100%;
  margin-top: 4px;
  color: #b07820;
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.map-stats {
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 2px;
  text-align: center;
  min-height: 14px;
}
.map-party {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
}
.map-ally {
  display: flex;
  gap: 8px;
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 1px;
}
.map-ally .map-ally-hp {
  color: var(--hp);
}
.map-ally.dead {
  opacity: 0.5;
  text-decoration: none;
}
.pd-revive-hint {
  font-size: 11px;
  color: #2a7a3a;
  padding: 2px 0;
  letter-spacing: 0.5px;
}
.pd-ally.dead {
  opacity: 0.6;
}
.party-expand-hint {
  color: var(--ink-dim);
  font-size: 18px;
  margin-left: 6px;
  transition: color 0.15s;
}
.map-party:hover .party-expand-hint { color: var(--ink); }
.map-party { cursor: pointer; transition: opacity 0.15s; align-items: center; }
.map-party:hover { opacity: 0.85; }

/* Party detail panel */
.party-detail {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.party-detail.hidden { display: none; }
.pd-ally {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 14px;
  text-align: left;
}
.pd-header {
  font-family: 'VT323', monospace;
  font-size: 17px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.pd-hp {
  color: var(--hp);
  font-size: 14px;
  margin-left: 4px;
}
.pd-line {
  font-size: 11px;
  color: var(--ink);
  line-height: 1.6;
  letter-spacing: 0.3px;
}
.pd-strike-line { border-left: 2px solid var(--gold); padding-left: 8px; margin-bottom: 3px; }
.pd-alt-line { border-left: 2px solid #4a6490; padding-left: 8px; margin-bottom: 3px; }
.pd-passive { border-left: 2px solid #5a5a6a; padding-left: 8px; color: var(--ink-dim); }
.pd-passive.pd-locked { font-style: italic; opacity: 0.5; }
.pd-evo-badge {
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 1px 5px;
  margin-right: 4px;
}
.pd-evo-badge.pd-strike { background: rgba(184,137,42,0.1); color: var(--gold); border: 1px solid var(--gold); }
.pd-evo-badge.pd-alt { background: rgba(74,100,144,0.1); color: #4a6490; border: 1px solid #4a6490; }
.pd-boosted { color: var(--gold); }
.pd-relics {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(184, 137, 42, 0.15);
}
.pd-relics-header {
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
.pd-relic {
  font-size: 11px;
  line-height: 1.4;
  padding: 1px 0;
}
.pd-relic-name {
  color: var(--gold);
  font-family: 'VT323', monospace;
  letter-spacing: 1px;
}
.pd-relic-desc {
  color: var(--ink-dim);
}

.dungeon-grid {
  display: grid;
  gap: 0;
  width: fit-content;
}
.map-cell {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-family: 'VT323', monospace;
  font-size: 32px;
  border: 1px solid rgba(58, 53, 80, 0.2);
  transition: background 0.1s, border-color 0.15s;
}
.map-cell.map-empty {
  color: var(--line);
  background: rgba(255,255,255,0.25);
  cursor: default;
}
.map-cell.map-wall {
  color: #a09a90;
  background: #d0cbc2;
  cursor: default;
}
.map-cell.map-adjacent {
  border-color: rgba(184, 137, 42, 0.3);
  cursor: pointer;
}
.map-cell.map-adjacent:hover {
  background: rgba(184, 137, 42, 0.08);
  border-color: var(--gold);
}
.map-cell.map-player {
  color: var(--gold);
  font-size: 36px;
  background: rgba(255,255,255,0.7);
  border: 2px solid var(--gold);
  border-radius: 4px;
  animation: player-pulse 2s ease-in-out infinite;
}
@keyframes player-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(184,137,42,0.3); border-color: rgba(184,137,42,0.5); }
  50% { box-shadow: 0 0 20px rgba(184,137,42,0.6); border-color: rgba(184,137,42,1); }
}
.map-cell.map-enemy {
  flex-direction: column;
  line-height: 1;
  gap: 0;
}
.map-enemy-glyph {
  font-size: inherit;
}
.map-enemy-glyph.mixed {
  font-size: 20px;
  letter-spacing: 2px;
}
.map-reward-icon {
  font-size: 14px;
  opacity: 0.7;
}
.map-reward-icon .ember-icon {
  color: #b07820;
}
.map-cell.map-campfire {
  color: #b07820;
  animation: campfire-glow 2s ease-in-out infinite;
}
@keyframes campfire-glow {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}
.map-cell.map-secret {
  color: var(--gold);
  animation: secret-pulse 1.5s ease-in-out infinite;
  background: rgba(184, 137, 42, 0.06);
}
@keyframes secret-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.map-cell.map-stairs {
  color: var(--gold);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  gap: 16px;
  flex-shrink: 0;
}
.title {
  font-family: 'VT323', monospace;
  font-size: 26px;
  letter-spacing: 4px;
  color: var(--gold);
}
.title::before { content: "▌ "; color: var(--ink-dim); }
.hint {
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  margin-top: 2px;
}
.header-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.reset-btn, .undo-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 6px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
}
.reset-btn:hover, .undo-btn:hover { color: var(--ink); border-color: var(--ink); }
.reset-btn.confirm-active { color: #b83030; border-color: #b83030; }
.undo-btn { border-color: var(--gold); color: var(--gold); }
.undo-btn:hover { background: rgba(184,137,42,0.1); }
.undo-btn.hidden { display: none; }

/* BATTLEFIELD */
.battlefield {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 10px 0;
  position: relative;
}

/* SVG target lines */
.target-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.foe-row, .ally-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex-shrink: 0;
}

.intent-row {
  flex: 1;
  min-height: 24px;
}

/* UNIT CARDS */
.unit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.4s;
  overflow: visible;
  min-width: 0;
}
.unit.dead {
  opacity: 0.15;
  filter: grayscale(1);
  pointer-events: none;
}

/* Foe cards — clickable targets */
.unit.foe-unit {
  cursor: pointer;
}
.unit.foe-unit:hover:not(.dead) {
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.unit.foe-unit.targeted {
  border-color: var(--outgoing);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Ally cards */
/* Shape-colored left accent on ally cards */
.unit.ally-unit { border-left: 3px solid var(--line); }
.unit.ally-unit.circle { border-left-color: #2a8fa8; }
.unit.ally-unit.triangle { border-left-color: #c43070; }
.unit.ally-unit.square { border-left-color: #3a5aaa; }

.unit.ally-unit.assigning {
  border-color: var(--gold);
  box-shadow: 0 2px 12px rgba(184,137,42,0.2);
  animation: pulse-border 1.2s ease-in-out infinite;
}
.unit.ally-unit.assigned {
  border-color: var(--party);
  opacity: 0.7;
}
.unit.ally-unit[style*="cursor: pointer"] {
  border-color: #2a8fa8;
  box-shadow: 0 2px 8px rgba(42,143,168,0.15);
}
.unit.ally-unit[style*="cursor: pointer"]:hover {
  border-color: #2a8fa8;
  box-shadow: 0 2px 12px rgba(42,143,168,0.25);
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 2px 8px rgba(184,137,42,0.15); }
  50% { box-shadow: 0 2px 16px rgba(184,137,42,0.3); }
}

.unit-top {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sprite {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-family: 'VT323', monospace;
  font-size: 24px;
  background: rgba(255,255,255,0.4);
  border: 2px solid currentColor;
  border-radius: 3px;
  flex-shrink: 0;
}
.unit-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex: 1;
}
/* SKILL BUTTONS */
.skill-row {
  display: flex;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
}
.skill-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 5px 4px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 0.1s;
}
.skill-btn:hover {
  border-color: var(--gold);
  color: var(--ink);
  background: rgba(184,137,42,0.1);
}
.skill-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(184,137,42,0.15);
}

.skill-desc {
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.5px;
  line-height: 1.4;
}
.skill-desc .val-up {
  color: var(--party);
  font-weight: 700;
}

.unit-dmg {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 1px;
}

.passive-label {
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
.passive-label.active {
  color: var(--gold);
  opacity: 1;
}

/* Foe ability labels */
.ability-label {
  font-family: 'VT323', monospace;
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
.ability-label.active {
  opacity: 1;
}
.ability-label.active.rally {
  color: var(--gold);
}
.ability-label.active.heal {
  color: var(--party);
}
.ability-label.active.cleave {
  color: var(--foe);
}
.ability-label.active.regen {
  color: var(--party);
}
.ability-label.active.rally-buff {
  color: var(--gold);
  font-weight: 700;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
.ability-label.active.shield {
  color: #4a7a9a;
}
.ability-label.active.crippled {
  color: #a05050;
  text-decoration: line-through;
}
.ability-label.active.shield-buff {
  color: #4a7a9a;
  font-weight: 700;
}
.ability-label.active.retaliate {
  color: #7a4aa0;
}
.ability-label.active.spore-burst {
  color: #5a8030;
}
.ability-label.active.lurker-unsuppressed {
  color: #b83030;
  font-weight: 700;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
.ability-label.active.lurker-suppressed {
  color: var(--party);
}
.ability-label.flatten-fail {
  color: #c05a2a;
  font-weight: 700;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
.lurker-unsuppressed-dmg {
  color: #b83030;
  font-weight: 700;
}
.bar-shield {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(74,122,154,0.4);
  border-radius: 2px;
  z-index: 2;
  pointer-events: none;
}
.rally-buff-dmg {
  color: #c43c3c;
  font-weight: 700;
}

/* Heal preview on foe HP bar */
.bar-preview-heal {
  position: absolute; top: 0; bottom: 0;
  background: var(--heal-preview);
  z-index: 1;
  animation: threat-pulse 0.8s ease-in-out infinite;
}

/* Guarded indicator on protected ally */
.guarded-label {
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: #2a7a98;
  height: 15px;
  line-height: 15px;
  overflow: hidden;
}
.guarded-label.hidden-reserve {
  color: transparent;
  text-shadow: none;
}
.unit.ally-unit.guarded {
  border-color: rgba(42,127,152,0.4);
  box-shadow: inset 0 0 6px rgba(42,127,152,0.08);
}
.unit.ally-unit.bubbled {
  border-color: rgba(42,143,168,0.5);
  box-shadow: inset 0 0 8px rgba(42,143,168,0.1);
  position: relative;
}
.unit.ally-unit.bubbled::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse at center, rgba(42,143,168,0.06) 0%, transparent 70%);
  pointer-events: none;
  animation: bubble-pulse 2s ease-in-out infinite;
}
@keyframes bubble-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
@keyframes bubble-absorb {
  0% { box-shadow: inset 0 0 8px rgba(42,143,168,0.1); }
  30% { box-shadow: inset 0 0 14px rgba(42,143,168,0.25), 0 0 12px rgba(42,143,168,0.2); }
  100% { box-shadow: inset 0 0 8px rgba(42,143,168,0.1); }
}
.bubble-absorb-flash {
  animation: bubble-absorb 0.5s ease-out !important;
}

/* HP BARS */
.bars { display: flex; flex-direction: column; gap: 3px; }
.bar {
  height: 16px;
  background: #6a6870;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0;
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(.6,.2,.3,1);
}
.bar.hp .bar-fill { background: var(--hp); }

/* Damage burn bar — sits behind bar-fill, shows where HP was, burns away slowly */
.bar-damage-burn {
  position: absolute; top: 0; bottom: 0;
  z-index: 0;
  transform-origin: left;
  animation: damage-burn 1.4s cubic-bezier(.02,.02,.2,1) forwards;
}
.bar-damage-burn.burn-normal {
  background: linear-gradient(90deg, rgba(255,200,100,0.9), rgba(255,140,60,0.95));
}
.bar-damage-burn.burn-kill {
  background: linear-gradient(90deg, rgba(255,220,140,1), rgba(255,160,60,1));
  animation-duration: 1.7s;
}
@keyframes damage-burn {
  0% { transform: scaleX(1); opacity: 0.6; filter: brightness(0.8); }
  100% { transform: scaleX(0); opacity: 1; filter: brightness(1.8); }
}
.bar-label {
  position: absolute; inset: 0;
  font-size: 10px; line-height: 16px;
  text-align: center; letter-spacing: 1px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  color: #fff;
  z-index: 2;
}

/* Preview segments on bars */
.bar-preview-threat {
  position: absolute; top: 0; bottom: 0;
  background: var(--threat);
  z-index: 1;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
.bar-preview-heal {
  position: absolute; top: 0; bottom: 0;
  background: rgba(58,138,74,0.35);
  z-index: 1;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
.bar-preview-outgoing {
  position: absolute; top: 0; bottom: 0;
  background: var(--outgoing);
  z-index: 1;
  animation: threat-pulse 0.8s ease-in-out infinite;
}
@keyframes threat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* FOE TARGET LABEL (on foe cards) */
.foe-target {
  font-family: 'VT323', monospace;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--foe);
  padding: 3px 6px;
  background: rgba(192,90,42,0.06);
  border: 1px solid rgba(192,90,42,0.2);
  border-radius: 2px;
  text-align: center;
}
.foe-target .target-dmg {
  color: var(--hp);
  font-weight: 700;
  margin-left: 2px;
}
.foe-target.cancelled {
  opacity: 0.3;
  text-decoration: line-through;
}

/* ALLY THREAT LABELS (on ally cards) */
.ally-threats {
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--foe);
  padding: 3px 6px;
  background: rgba(196,60,60,0.05);
  border: 1px solid rgba(196,60,60,0.15);
  border-radius: 2px;
  text-align: center;
}
.threat-source {
  color: var(--foe);
}
.threat-source.cancelled {
  opacity: 0.3;
  text-decoration: line-through;
}

/* COMBAT ANIMATIONS */
@keyframes strike-up {
  0% { transform: translateY(0) scale(1); }
  20% { transform: translateY(4px) scale(1.04); }
  45% { transform: translateY(-36px) scale(1.08); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
  60% { transform: translateY(-30px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes strike-down {
  0% { transform: translateY(0) scale(1); }
  20% { transform: translateY(-4px) scale(1.04); }
  45% { transform: translateY(36px) scale(1.08); box-shadow: 0 -8px 20px rgba(0,0,0,0.15); }
  60% { transform: translateY(30px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  10% { transform: translateX(-8px) rotate(-1deg); }
  25% { transform: translateX(7px) rotate(0.8deg); }
  40% { transform: translateX(-6px) rotate(-0.6deg); }
  55% { transform: translateX(5px) rotate(0.4deg); }
  70% { transform: translateX(-3px); }
  85% { transform: translateX(2px); }
}
@keyframes shake-hard {
  0%,100% { transform: translateX(0); }
  8% { transform: translate(-10px, 2px) rotate(-2deg); }
  20% { transform: translate(9px, -2px) rotate(1.5deg); }
  32% { transform: translate(-8px, 1px) rotate(-1.2deg); }
  44% { transform: translate(6px, -1px) rotate(0.8deg); }
  56% { transform: translate(-4px, 1px) rotate(-0.5deg); }
  70% { transform: translate(3px, 0px); }
  85% { transform: translate(-1px, 0px); }
}
@keyframes flash-hit {
  0% { background: rgba(255,255,255,0.5); }
  15% { background: rgba(196,60,60,0.35); }
  40% { background: rgba(196,60,60,0.15); }
  100% { background: rgba(255,255,255,0.5); }
}
@keyframes flash-kill {
  0% { background: rgba(255,255,255,0.5); }
  12% { background: rgba(196,60,60,0.5); filter: brightness(1.1); }
  30% { background: rgba(196,60,60,0.3); }
  100% { background: rgba(255,255,255,0.5); filter: brightness(1); }
}
@keyframes defend-brace {
  0% { border-color: var(--line); box-shadow: none; transform: scale(1); }
  15% { transform: scale(1.04); }
  25%,65% { border-color: #2a8fa8; box-shadow: inset 0 0 8px rgba(42,143,168,0.15), 0 0 12px rgba(42,143,168,0.15); transform: scale(1.02); }
  100% { border-color: var(--line); box-shadow: none; transform: scale(1); }
}
@keyframes unit-die {
  0% { transform: scale(1); opacity: 1; filter: brightness(2) saturate(0.5); }
  25% { transform: scale(1.06); opacity: 0.9; filter: brightness(1.5) saturate(0.3); }
  100% { transform: scale(0.7) translateY(8px); opacity: 0; filter: brightness(0.5) saturate(0) blur(2px); }
}
@keyframes battlefield-shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-3px, 2px); }
  30% { transform: translate(3px, -1px); }
  45% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, 0px); }
}
/* Turn banner */
.turn-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(236,231,222,0.9) 0%, transparent 70%);
  animation: banner-cycle 1.4s ease-out forwards;
}
.turn-banner-text {
  font-family: 'VT323', monospace;
  font-size: 52px;
  letter-spacing: 10px;
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
/* Intent message — shown after lines draw on first turn */
.intent-message {
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--ink);
  pointer-events: none;
  z-index: 100;
  padding: 6px 12px;
  background: linear-gradient(90deg, transparent 0%, rgba(236,231,222,0.9) 20%, rgba(236,231,222,0.9) 80%, transparent 100%);
  animation: intent-msg 1.6s ease-out forwards;
}
@keyframes intent-msg {
  0% { opacity: 0; transform: translateY(4px); }
  15% { opacity: 1; transform: translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* Play rating — FLAWLESS / OPTIMAL */
.play-rating {
  position: absolute;
  left: 0; right: 0;
  top: 42%;
  text-align: center;
  font-family: 'VT323', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 100;
  animation: play-rating-anim 1.4s ease-out forwards;
}
.play-rating-text {
  font-size: 36px;
  letter-spacing: 8px;
  color: inherit;
  text-shadow: inherit;
}
.play-rating-sub {
  font-size: 16px;
  letter-spacing: 3px;
  color: inherit;
  opacity: 0.85;
  text-shadow: inherit;
}
.play-rating {
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.play-rating.flawless { color: #2a7a3a; }
.play-rating.sweep { color: var(--gold); }
.play-rating.reckless { color: #c05a2a; }
.play-rating.clean { color: #2a7a3a; }
.play-rating.minDmg { color: #2a7a98; }
.play-rating.maxNet { color: var(--gold); }
.play-rating.lethal { color: #b83030; }
.play-rating.sheltered { color: #2a8fa8; }
.play-rating.calculated { color: #c43070; }
.play-rating.clutch { color: #7a5aaa; }
.play-rating.focused { color: #3a5aaa; }
.play-rating.overkill { color: #b83030; }
/* Multi-achievement pop — each tag is its own pill */
.play-rating.ach-multi {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  color: inherit;
  text-shadow: none;
}
.ach-pop-tag {
  font-family: 'VT323', monospace;
  font-size: 22px;
  letter-spacing: 3px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.8);
}
.ach-pop-tag.clean { color: #2a7a3a; border-color: rgba(42,122,58,0.5); }
.ach-pop-tag.minDmg { color: #2a7a98; border-color: rgba(42,122,152,0.5); }
.ach-pop-tag.maxNet { color: var(--gold); border-color: rgba(184,137,42,0.5); }
.ach-pop-tag.lethal { color: #b83030; border-color: rgba(184,48,48,0.5); }
.ach-pop-tag.sheltered { color: #2a8fa8; border-color: rgba(42,143,168,0.5); }
.ach-pop-tag.calculated { color: #c43070; border-color: rgba(196,48,112,0.5); }
.ach-pop-tag.clutch { color: #7a5aaa; border-color: rgba(122,90,170,0.5); }
.ach-pop-tag.overkill { color: #b83030; border-color: rgba(184,48,48,0.5); }
.ach-pop-tag.sweep { color: var(--gold); border-color: rgba(184,137,42,0.5); }
.ach-pop-tag.reckless { color: #c05a2a; border-color: rgba(192,90,42,0.5); }
.ach-pop-tag.focused { color: #3a5aaa; border-color: rgba(58,90,170,0.5); }

@keyframes play-rating-anim {
  0% { opacity: 0; transform: translateY(8px) scale(0.8); }
  10% { opacity: 1; transform: translateY(-2px) scale(1.15); }
  22% { transform: translateY(0) scale(1); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4px) scale(1); }
}

@keyframes banner-cycle {
  0% { opacity: 0; }
  10% { opacity: 1; }
  60% { opacity: 1; }
  100% { opacity: 0; }
}

.unit.shake { animation: shake 0.35s cubic-bezier(.36,.07,.19,.97); }
.unit.shake-hard { animation: shake-hard 0.45s cubic-bezier(.36,.07,.19,.97); }
.unit.flash { animation: flash-hit 0.35s; }
.unit.flash-kill { animation: flash-kill 0.4s; }
.unit.dying { animation: unit-die 0.5s ease-in forwards; pointer-events: none; }
/* Strike flash line — fades out after holding */
.strike-flash-line {
  animation: strike-flash-fade ease-out forwards;
  animation-fill-mode: forwards;
}
@keyframes strike-flash-fade {
  0% { stroke-opacity: 1; stroke-width: 3; }
  100% { stroke-opacity: 0; stroke-width: 1; }
}

.battlefield.screen-shake { animation: battlefield-shake 0.3s cubic-bezier(.36,.07,.19,.97); }

/* KILLED overlay */
.unit.will-die::after {
  content: 'KILLED';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: 'VT323', monospace;
  font-size: 28px; letter-spacing: 6px;
  color: var(--hp);
  background: rgba(255,255,255,0.7);
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  animation: threat-pulse 0.7s ease-in-out infinite;
}

/* DAMAGE POPS */
.pop {
  position: absolute;
  font-family: 'VT323', monospace;
  font-size: 28px; font-weight: 700;
  pointer-events: none;
  animation: popup 1s ease-out forwards;
  z-index: 50;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.8), 0 0 4px rgba(0,0,0,0.15);
  left: 50%;
}
.pop.dmg { color: var(--hp); }
.pop.heal { color: var(--party); }
.pop.crit { color: var(--crit); }
.pop.foe-hit { color: var(--foe); }
.pop.kill-pop {
  color: var(--crit);
  font-size: 36px;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.8), 0 0 4px rgba(0,0,0,0.15);
  animation: popup-kill 1.2s ease-out forwards;
}
@keyframes popup {
  0% { transform: translate(-50%, 4px) scale(0); opacity: 0; }
  8% { transform: translate(-50%, -4px) scale(1.5); opacity: 1; }
  20% { transform: translate(-50%, -10px) scale(1); }
  60% { transform: translate(-50%, -30px) scale(1); opacity: 0.9; }
  100% { transform: translate(-50%, -56px); opacity: 0; }
}
@keyframes popup-kill {
  0% { transform: translate(-50%, 4px) scale(0); opacity: 0; }
  6% { transform: translate(-50%, -4px) scale(1.8); opacity: 1; }
  16% { transform: translate(-50%, -12px) scale(1.1); }
  50% { transform: translate(-50%, -30px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -70px) scale(0.85); opacity: 0; }
}

/* COMBAT STATS BAR */
.combat-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 4px 12px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.combat-stats.hidden { display: none; }
.cs-dealt .cs-val { color: var(--party); }
.cs-taken .cs-val { color: var(--foe); }
.cs-taken .cs-val.cs-zero { color: var(--party); }
.cs-kills .cs-val { color: var(--crit); }
.cs-val {
  font-size: 16px;
  transition: color 0.15s;
}

/* LOG */
.log {
  display: none; /* Log removed — reclaiming space for shapes UI */
}
.log-entry { margin-bottom: 2px; }
.log-entry::before { content: "› "; color: var(--gold); }
.log-entry.hit { color: var(--ink); }
.log-entry.kill { color: var(--crit); font-weight: 700; }
.log-entry.heal { color: var(--party); }
.log-entry.foe-hit { color: var(--foe); }

/* REWARD SCREEN */
.reward-screen {
  position: fixed; inset: 0;
  background: rgba(236,231,222,0.95);
  display: flex; justify-content: center; align-items: flex-start;
  z-index: 500;
  backdrop-filter: blur(4px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 0;
}
.reward-screen.hidden { display: none; }
.reward-inner {
  text-align: center;
  padding: 48px 32px 32px;
  max-width: 520px;
  margin: 0 auto;
  width: 90vw;
}
.reward-header {
  position: sticky;
  top: -1px;
  z-index: 10;
  background: var(--bg);
  padding: 8px 0 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.reward-title {
  font-family: 'VT323', monospace;
  font-size: 42px; letter-spacing: 6px;
  color: var(--gold);
  margin-bottom: 8px;
}
.reward-subtitle {
  font-size: 12px; color: var(--ink-dim);
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.reward-party {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding-bottom: 10px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--ink-dim);
}
.reward-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.reward-card {
  flex: 1;
  min-width: 0;
  max-width: 220px;
  padding: 16px;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
}
.reward-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.reward-card-name {
  font-family: 'VT323', monospace;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 8px;
}
.reward-card-desc {
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.5px;
  line-height: 1.5;
}
.reward-card-target {
  font-size: 10px;
  color: var(--ink-dim);
  margin-top: 8px;
  letter-spacing: 1px;
}
.reward-card-selected {
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(184,137,42,0.15);
}
.reward-card-dimmed {
  opacity: 0.25;
  transform: scale(0.96);
  transition: opacity 0.3s, transform 0.3s;
}
.reward-continue {
  max-width: 180px;
  border-color: var(--gold);
}

/* Ally selection for choose-who upgrades */
.reward-allies {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}
.reward-allies.hidden { display: none; }
.reward-ally-card {
  padding: 14px 20px;
  background: var(--bg-2);
  border: 2px solid var(--line);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
}
.reward-ally-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.reward-ally-card.dead {
  opacity: 0.3;
  pointer-events: none;
}
.reward-ally-card.reward-chosen {
  border-color: var(--gold);
  animation: reward-pop 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes reward-pop {
  0% { transform: scale(1); box-shadow: none; }
  40% { transform: scale(1.08); box-shadow: 0 4px 16px rgba(184,137,42,0.2); }
  100% { transform: scale(1.04); box-shadow: 0 2px 12px rgba(184,137,42,0.15); }
}
span.stat-changed {
  color: var(--party);
  font-weight: 700;
}
.reward-ally-stat.stat-changed {
  color: var(--gold);
  font-size: 16px;
  font-weight: 700;
  animation: stat-bump 0.6s ease-out;
}
@keyframes stat-bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.reward-ally-name {
  font-family: 'VT323', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  margin-bottom: 4px;
}
.reward-ally-stat {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 1px;
}

/* CAMPFIRE LAYOUT */
.campfire-top-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
  margin-bottom: 12px;
}
.campfire-action {
  flex: 0 1 140px;
  max-width: 140px;
}

/* CAMPFIRE SECTION HEADERS */
.campfire-section-header {
  font-family: 'VT323', monospace;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--ink-dim);
  text-align: center;
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  width: 100%;
}

/* UPGRADE GRID (campfire) */
.upgrade-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.upgrade-card {
  flex: 0 1 140px;
  max-width: 160px;
}
.upgrade-card.upgrade-selecting {
  flex: 0 1 280px;
  max-width: 300px;
}
.upgrade-ally-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.upgrade-ally-btn {
  flex: 1;
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 4px;
  font-family: 'VT323', monospace;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s;
}
.upgrade-ally-btn:hover {
  border-color: var(--gold);
  background: rgba(184,137,42,0.08);
}
.upgrade-ally-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}
.upgrade-ally-stat {
  font-size: 10px;
  color: var(--ink-dim);
}
.upgrade-ally-cost {
  font-size: 10px;
  color: #b07820;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.upgrade-ally-cost .ember-icon {
  width: 8px;
  height: 11px;
}
.upgrade-cancel {
  text-align: center;
  font-size: 10px;
  color: var(--ink-dim);
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: 1px;
}
.upgrade-cancel:hover {
  color: var(--ink);
}

/* RELIC SHOP */
.relic-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.relic-card {
  flex: 0 1 180px;
  max-width: 200px;
  position: relative;
}
.relic-card-category {
  font-family: 'VT323', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.relic-damage { color: #b04030; }
.relic-survival { color: #2a7a3a; }
.relic-tactical { color: #3060a0; }
.relic-cost {
  font-family: 'VT323', monospace;
  font-size: 12px;
  color: #5a6070;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.relic-cost .notch-icon {
  width: 6px;
  height: 11px;
}
.relic-owned {
  opacity: 0.7;
  border-color: var(--gold);
  background: rgba(184, 137, 42, 0.06);
}
.relic-owned .reward-card-name {
  color: var(--gold);
}
.relic-owned-header {
  width: 100%;
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  text-align: center;
  margin-top: 8px;
  margin-bottom: -4px;
}
.relic-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.relic-reroll-btn {
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: #b07820;
  background: rgba(176,120,32,0.06);
  border: 1px solid rgba(176,120,32,0.3);
  padding: 2px 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.relic-reroll-btn:hover {
  border-color: #b07820;
  background: rgba(176,120,32,0.12);
}
.relic-reroll-btn .ember-icon {
  width: 8px;
  height: 11px;
}
.relic-reroll-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}
.relic-reroll-btn.used {
  opacity: 0.4;
  pointer-events: none;
  border-style: dashed;
  color: var(--ink-dim);
}
.relic-cap-note {
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--ink-dim);
  text-align: center;
  padding: 8px;
  width: 100%;
}

/* FILTER TABS */
.evo-filter-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  width: 100%;
  margin-bottom: 12px;
}
.evo-filter-tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 4px 10px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.evo-filter-tab:hover { color: var(--ink); border-color: var(--ink); }
.evo-filter-tab.active { color: var(--gold); border-color: var(--gold); }

/* EVOLUTION CARDS */
.evo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.evo-card {
  position: relative;
  flex: 0 1 170px;
  max-width: 170px;
  padding: 12px;
}
.evo-card.evo-strike { border-color: rgba(184,137,42,0.4); }
.evo-card.evo-strike:hover { border-color: var(--gold); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.evo-card.evo-alt { border-color: rgba(74,100,140,0.4); }
.evo-card.evo-alt:hover { border-color: #4a6490; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.evo-card.evo-path { border-color: var(--line); }
.evo-card.evo-path:not(.disabled):hover { border-color: var(--ink); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.evo-passive-desc {
  font-size: 11px;
  color: var(--gold);
  margin-top: 6px;
  font-style: italic;
  opacity: 0.85;
}

/* Evolution list layout — full-width rows grouped by shape */
.evo-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  text-align: left;
}
.evo-group-header {
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 10px 8px 4px;
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
  opacity: 0.9;
}
.evo-group-header:first-child { margin-top: 0; }
.evo-row {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s, opacity 0.15s;
}
.evo-row:not(.disabled):hover {
  background: rgba(184,137,42,0.06);
}
.evo-row.disabled {
  opacity: 0.4;
}
.evo-row.taken {
  opacity: 0.35;
}
.evo-row.taken .evo-row-name {
  text-decoration: line-through;
  text-decoration-color: rgba(184,137,42,0.5);
}
.evo-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.evo-row-name {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 1px;
}
.evo-row-desc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
  line-height: 1.4;
}
.evo-row-passive {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--gold);
  margin-top: 3px;
  font-style: italic;
  opacity: 0.85;
}
.evo-card.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}
.evo-card.taken {
  opacity: 0.35;
  border-color: var(--gold) !important;
  background: rgba(184,137,42,0.05);
}
.evo-card.taken .reward-card-name {
  text-decoration: line-through;
  text-decoration-color: rgba(184,137,42,0.5);
}
@keyframes evo-purchase-flash {
  0% { box-shadow: none; transform: scale(1); }
  30% { box-shadow: 0 4px 20px rgba(184,137,42,0.3); transform: scale(1.05); border-color: var(--gold); }
  100% { box-shadow: none; transform: scale(0.95); opacity: 0.35; }
}
.evo-purchased-flash {
  animation: evo-purchase-flash 0.6s ease-out forwards;
  pointer-events: none;
}
.evo-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}
.evo-ally-tag {
  font-family: 'VT323', monospace;
  font-size: 16px;
}
.evo-slot-label {
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.evo-strike .evo-slot-label { color: var(--gold); }
.evo-alt .evo-slot-label { color: #4a6490; }
.evo-cost {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: #b07820;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.evo-status {
  display: block;
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  margin-top: 6px;
}
.evo-status.taken { color: var(--gold); letter-spacing: 2px; }
.evo-status.locked { color: var(--ink-dim); }
.evo-status.expensive { color: #c05a2a; }

/* END SCREEN */
.endscreen {
  position: fixed; inset: 0;
  background: rgba(236,231,222,0.92);
  display: grid; place-items: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.endscreen.hidden { display: none; }
.endscreen-inner {
  text-align: center;
  padding: 40px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--bg-2);
  max-width: 420px;
}
.endscreen h1 {
  font-family: 'VT323', monospace;
  font-size: 48px; letter-spacing: 8px;
  margin-bottom: 12px;
}
.endscreen.win h1 { color: var(--gold); }
.endscreen.lose h1 { color: var(--hp); }
.endscreen p {
  font-size: 12px; color: var(--ink-dim);
  margin-bottom: 24px; letter-spacing: 1px; line-height: 1.6;
}
.commit-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 14px 24px;
  font-family: 'VT323', monospace;
  font-size: 22px; letter-spacing: 4px;
  cursor: pointer;
}
.commit-btn:hover {
  background: var(--ink);
  transform: translateY(-1px);
}

/* Color classes */
.knight { color: #5a5e6a; }
.mage   { color: #7a4aa0; }
.cleric { color: #6a6458; }
.thief  { color: #3a7a3a; }
.circle   { color: #2a8fa8; }
.triangle { color: #c43070; }
.square   { color: #3a5aaa; }
.goblin   { color: #5a7a30; }
.slime    { color: #2a7a98; }
.ogre     { color: #b05a2a; }
.wisp     { color: #a08020; }
.sentinel { color: #4a7a9a; }
.wraith   { color: #7a4aa0; }
.fungus   { color: #5a8030; }
.lurker   { color: #a08020; }

/* Tap-preview highlight (mobile) */
.unit.tap-preview {
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(184,137,42,0.15);
}
.tap-confirm-hint {
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
  padding: 3px 0;
  animation: pulse-border 1.2s ease-in-out infinite;
}

/* Multi-target selection markers */
.multi-target-locked {
  border-color: var(--gold) !important;
  box-shadow: 0 2px 8px rgba(184,137,42,0.15);
}
.multi-target-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  background: var(--gold);
  color: var(--bg);
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 1px 6px;
  z-index: 2;
  font-weight: bold;
}
.multi-target-prompt {
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--gold);
  opacity: 0.7;
  padding: 2px 0;
}

/* Blast preview on skill button */
.skill-btn.confirming {
  background: rgba(184,137,42,0.15);
  border-color: var(--gold);
  color: var(--gold);
  animation: pulse-border 1.2s ease-in-out infinite;
}

@media (max-width: 720px) {
  .map-screen { padding: 8px; gap: 10px; }
  .map-cell { width: 48px; height: 48px; font-size: 24px; }
  .map-cell.map-player { font-size: 28px; }
  .map-enemy-glyph.mixed { font-size: 15px; letter-spacing: 1px; }
  .map-reward-icon { font-size: 11px; }
  .map-ally { font-size: 13px; }
  .map-party { gap: 10px; }
  .reward-inner { padding: 20px; }
  .reward-title { font-size: 32px; letter-spacing: 4px; }
  .reward-options { gap: 8px; }
  .reward-card:not(.evo-card):not(.campfire-action) { max-width: 46%; }
  .reward-card-name { font-size: 18px; }
  .evo-card { flex: 0 1 calc(50% - 6px); max-width: calc(50% - 6px); }
  .reward-allies { flex-wrap: wrap; }
  .arena { padding: 4px 8px 48px; gap: 4px; height: 100dvh; }
  .header { flex-wrap: wrap; gap: 4px; padding-bottom: 3px; }
  .title { font-size: 18px; letter-spacing: 2px; }
  .hint { font-size: 9px; }
  .battlefield { padding: 4px 0; }
  .foe-row, .ally-row { gap: 6px; }
  .intent-row { min-height: 4px; }
  .unit { padding: 6px; gap: 4px; border-width: 1px; }
  .unit-top { gap: 4px; }
  .sprite { width: 30px; height: 30px; font-size: 17px; }
  .unit-name { font-size: 9px; }
  .unit-dmg { font-size: 8px; }
  .ability-label { font-size: 8px; }
  .bar { height: 14px; }
  .bar-label { font-size: 8px; line-height: 14px; }
  .foe-target { font-size: 12px; padding: 2px 4px; }
  .ally-threats { font-size: 11px; padding: 2px 4px; }
  .skill-row { gap: 1px; flex-direction: column; overflow: visible; }
  .skill-btn { font-size: 13px; padding: 3px 8px; min-height: 24px; text-align: left; overflow: visible; text-overflow: unset; white-space: normal; }
  .skill-desc { font-size: 8px; margin-top: 1px; }
  .combat-stats { gap: 16px; font-size: 12px; padding: 3px 8px; }
  .cs-val { font-size: 14px; }
  .log { height: 36px; font-size: 9px; padding: 3px 8px; }
  .pop { font-size: 22px; }
  .play-rating { font-size: 28px; letter-spacing: 5px; }
  .turn-banner-text { font-size: 38px; letter-spacing: 6px; }
  .intent-message { font-size: 16px; letter-spacing: 2px; }
  .unit.will-die::after { font-size: 18px; letter-spacing: 3px; }
  .header-btns {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    display: flex;
    gap: 0;
    z-index: 200;
    background: var(--bg-2);
    border-top: 1px solid var(--line);
    padding: 0;
  }
  .reset-btn, .undo-btn {
    flex: 1;
    padding: 14px 10px;
    font-size: 11px;
    border: none;
    border-radius: 0;
    min-height: 44px;
  }
  .reset-btn { border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
}

@media (max-width: 400px) {
  .title { font-size: 15px; letter-spacing: 1px; }
  .sprite { width: 26px; height: 26px; font-size: 14px; }
  .unit-name { font-size: 8px; }
  .foe-target { font-size: 11px; }
  .skill-btn { font-size: 12px; }
}

/* ============================================================
   PASS BUTTON
   ============================================================ */
.pass-btn {
  flex: 0.6;
  color: var(--ink-dim);
  border-color: var(--line);
}
.pass-btn:hover {
  border-color: var(--ink-dim);
  color: var(--ink);
  background: rgba(138,130,112,0.08);
}
.pass-btn.active {
  border-color: var(--ink-dim);
  color: var(--ink);
  background: rgba(138,130,112,0.15);
}

/* ============================================================
   BOUNTY REVEAL (animated overlay at fight start)
   ============================================================ */
.bounty-reveal {
  position: absolute;
  left: 0; right: 0;
  top: 38%;
  text-align: center;
  font-family: 'VT323', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  padding: 12px 24px;
  background: radial-gradient(ellipse at center, rgba(236,231,222,0.9) 0%, transparent 75%);
}
.bounty-reveal-visible {
  opacity: 1;
  transform: scale(1);
}
.bounty-reveal-exit {
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.35s ease-in;
}
.bounty-reveal-label {
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--ink-dim);
}
.bounty-reveal-text {
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--gold);
}
.bounty-reveal-reward {
  font-size: 16px;
  color: #b07820;
  display: flex;
  align-items: center;
  gap: 4px;
}
.bounty-reveal-reward .ember-icon {
}

/* Tier-based bounty reveal colors */
.bounty-reveal.tier-2 .bounty-reveal-text {
  color: #2a7a98;
}
.bounty-reveal.tier-3 .bounty-reveal-text {
  color: #7a5aaa;
}

/* ============================================================
   BOUNTY TRACKER (persistent bar during combat)
   ============================================================ */
.bounty-tracker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-family: 'VT323', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(184,137,42,0.04);
  margin: 4px 0;
}
.bounty-tag {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  flex-shrink: 0;
}
.bounty-text {
  color: var(--gold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bounty-status {
  font-size: 11px;
  color: var(--ink-dim);
  flex-shrink: 0;
}
.bounty-reward {
  display: flex;
  align-items: center;
  gap: 2px;
  color: #b07820;
  flex-shrink: 0;
  font-size: 12px;
}
.bounty-reward .ember-icon {
  width: 10px;
  height: 13px;
}

/* Tier colors for tracker */
.bounty-tracker.tier-2 .bounty-text {
  color: #2a7a98;
}
.bounty-tracker.tier-2 {
  background: rgba(42,122,152,0.04);
}
.bounty-tracker.tier-3 .bounty-text {
  color: #7a5aaa;
}
.bounty-tracker.tier-3 {
  background: rgba(122,90,170,0.04);
}

/* Bounty states */
.bounty-tracker.bounty-failed {
  opacity: 0.4;
  border-color: var(--line);
  background: none;
}
.bounty-tracker.bounty-failed .bounty-text {
  text-decoration: line-through;
  color: var(--ink-dim);
}
.bounty-tracker.bounty-failed .bounty-status {
  color: #c43c3c;
}
.bounty-tracker.bounty-failed .bounty-reward {
  text-decoration: line-through;
  opacity: 0.5;
}
.bounty-tracker.bounty-complete .bounty-status {
  color: var(--party);
}
.bounty-tracker.bounty-warn {
  border-color: rgba(192,90,42,0.3);
  background: rgba(192,90,42,0.04);
}
.bounty-tracker.bounty-warn .bounty-status {
  color: #c05a2a;
}

/* ============================================================
   BOUNTY CASHOUT (reward screen)
   ============================================================ */
.cashout-bounty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-family: 'VT323', monospace;
  font-size: 14px;
}
.bounty-cashout-tag {
  font-size: 11px;
  letter-spacing: 2px;
  padding: 2px 6px;
  border: 1px solid;
}
.bounty-cashout-tag.bounty-complete {
  color: var(--party);
  border-color: rgba(58,138,74,0.4);
}
.bounty-cashout-tag.bounty-failed {
  color: #c43c3c;
  border-color: rgba(196,60,60,0.3);
}
.bounty-cashout-text {
  color: var(--ink);
  flex: 1;
}
.bounty-cashout-reward {
  color: #b07820;
  display: flex;
  align-items: center;
  gap: 3px;
}
.bounty-cashout-reward .ember-icon {
}
