/* ── COMBAT SCREEN LAYOUT ──────────────────────────────────────────────────── */
#screen-combat {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* height is already set by position:absolute;inset:0 from .screen */
}

/* ── COMBAT HEADER ─────────────────────────────────────────────────────────── */
#combat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 40px;
}
#combat-header .level-text {
  font-size: 13px;
  color: var(--gold-bright);
  font-weight: bold;
  letter-spacing: 0.06em;
}
#combat-header .round-text {
  font-size: 11px;
  color: var(--text-dim);
}
#combat-header .phase-text {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── SECTION LABELS ─────────────────────────────────────────────────────────── */
.combat-section-label {
  flex-shrink: 0;
  padding: 4px 10px 3px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#heroes-label {
  color: #d47070;
  background: linear-gradient(180deg, #0d0808 0%, transparent 100%);
  border-bottom: 1px solid rgba(180,60,60,0.2);
}
#horde-label {
  color: var(--gold-bright);
  background: var(--bg);
  border-bottom: 1px solid rgba(200,150,26,0.2);
}

/* ── HEROES SECTION (top ~33%) ─────────────────────────────────────────────── */
#heroes-section {
  flex: 0 0 auto;
  min-height: 130px;
  max-height: 240px;
  padding: 8px 8px 4px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  background: linear-gradient(180deg, #0d0808 0%, var(--bg) 100%);
  border-bottom: 1px solid #2a1a1a;
  scrollbar-width: thin;
  scrollbar-color: #3a1a1a #0d0808;
}
#heroes-section::-webkit-scrollbar { height: 3px; }
#heroes-section::-webkit-scrollbar-track { background: #0d0808; }
#heroes-section::-webkit-scrollbar-thumb { background: #3a1a1a; border-radius: 2px; }

.hero-card {
  flex-shrink: 0;
  width: 38vw;
  min-width: 130px;
  max-width: 160px;
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid #3a1a1a;
  padding: 6px;
  cursor: pointer;
  animation: slideUp 0.3s ease;
  transition: border-color 0.2s, box-shadow 0.15s;
  scrollbar-width: thin;
  scrollbar-color: #3a1a1a transparent;
}
.hero-card::-webkit-scrollbar { width: 3px; }
.hero-card::-webkit-scrollbar-track { background: transparent; }
.hero-card::-webkit-scrollbar-thumb { background: #3a1a1a; border-radius: 2px; }
.hero-card:active { opacity: 0.85; }
.hero-card.dead {
  opacity: 0.3;
  filter: grayscale(1);
  cursor: default;
}
.hero-card.targeting-hero { border-color: var(--gold); box-shadow: 0 0 8px rgba(200,150,26,0.5); cursor: pointer; }

/* Top row: portrait + info side by side */
.hero-top-row {
  display: flex;
  gap: 5px;
  align-items: flex-start;
  margin-bottom: 5px;
}

.hero-portrait-wrap {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}
.hero-portrait-wrap .portrait-placeholder {
  font-size: 1.2rem;
  background: linear-gradient(135deg, #2a0a0a, #1a1a2e);
}

.hero-top-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-hp-text {
  font-size: 14px;
  color: #ffffff;
  white-space: nowrap;
}

/* Action rows on hero card */
.hero-actions-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 4px;
}

.hero-action-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 3px;
  border-radius: 3px;
  font-size: 11px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.hero-action-top {
  display: flex;
  align-items: center;
  gap: 3px;
}
.hero-action-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.85) !important;
  opacity: 0.9;
  line-height: 1.3;
  padding-left: 45px; /* align under hero-action-label width */
}
.hero-action-row.red    { color: var(--red-bright); }
.hero-action-row.blue   { color: var(--blue-bright); }
.hero-action-row.purple { color: var(--purple-bright); }

/* Highlighted = currently active intent */
.hero-action-row.active-intent {
  opacity: 1;
  font-weight: bold;
  border-left: 2px solid currentColor;
  padding-left: 4px;
}
.hero-action-row.active-intent.red    { background: var(--red-bg); }
.hero-action-row.active-intent.blue   { background: var(--blue-bg); }
.hero-action-row.active-intent.purple { background: var(--purple-bg); }

/* Intent repeat count badge (×2 etc) */
.intent-count {
  font-size: 9px;
  font-weight: bold;
  color: var(--gold-bright);
  margin-left: 2px;
}

/* Per-intent target shown inside each action row */
.hero-action-target {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  padding-top: 2px;
  padding-left: 45px;
  letter-spacing: 0.3px;
}

.hero-action-label {
  font-size: 10px;
  opacity: 0.65;
  flex-shrink: 0;
  width: 42px;
  font-style: italic;
}
.hero-action-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-action-val {
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0;
  min-width: 18px;
  text-align: right;
}

/* ── BATTLE LOG ─────────────────────────────────────────────────────────────── */
#combat-log {
  flex-shrink: 0;
  height: 44px;
  overflow: hidden;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
}
#combat-log .log-line {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#combat-log .log-line:last-child { color: var(--text); }

/* ── HORDE SECTION (middle ~40%) ───────────────────────────────────────────── */
#horde-section {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: linear-gradient(180deg, var(--bg) 0%, #0d0d14 100%);
}

.horde-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 5px 7px;
  min-height: 58px;
  flex-shrink: 0;
}
.horde-row.lortar-row { border-color: rgba(200,150,26,0.3); }
.horde-row.dead { opacity: 0.35; }

/* Small portrait in horde row */
.horde-portrait-wrap {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.horde-portrait-wrap .portrait-placeholder {
  font-size: 1rem;
  background: var(--surface2);
}

/* Unit info column */
.horde-info {
  flex: 0 0 80px;
  min-width: 0;
}
.horde-name {
  font-size: 13px;
  font-weight: bold;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.horde-hp-text {
  font-size: 15px;
  color: #ffffff;
  margin-bottom: 2px;
}
.horde-status-row {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

/* Action slots */
.action-slots {
  flex: 1;
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

/* Column wrapper: label + viewport */
.action-slot-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 90px;
}

.action-slot-label {
  font-size: 8px;
  color: var(--text-dark);
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.action-slot-label.rolling {
  color: var(--gold-bright);
  animation: rolling-pulse 0.6s ease-in-out infinite;
}

/* Viewport clips the slot machine animation */
.action-slot-viewport {
  overflow: hidden;
  border-radius: var(--radius);
  display: flex;       /* so action-card flex:1 fills full width */
}
.action-slot-viewport .action-card {
  flex: 1;
  max-width: none;     /* override global max-width so card fills column */
}

/* ── Slot machine animation ── */
@keyframes slot-reel-land {
  0%   { transform: translateY(-120%); filter: blur(3px); opacity: 0; }
  45%  { transform: translateY(8px);   filter: blur(0);   opacity: 1; }
  65%  { transform: translateY(-4px); }
  82%  { transform: translateY(2px); }
  92%  { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

.slot-spin-1 {
  animation: slot-reel-land 0.48s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.slot-spin-2 {
  animation: slot-reel-land 0.48s cubic-bezier(0.22, 0.61, 0.36, 1) 0.16s both;
}

/* ── Rolling placeholder (shown during 3s spin) ── */
@keyframes reel-scroll {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-300%); }
}
@keyframes rolling-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.rolling-placeholder {
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: default;
  overflow: hidden;
}
.rolling-reel {
  width: 100%;
  height: 20px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.08) 0px,
    rgba(255,255,255,0.08) 4px,
    transparent 4px,
    transparent 8px
  );
  animation: reel-scroll 0.18s linear infinite;
  border-radius: 2px;
}
.rolling-label {
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  animation: rolling-pulse 0.6s ease-in-out infinite;
  text-align: center;
}

/* ── Target indicator on horde rows ── */
.horde-row.being-targeted {
  border-color: rgba(231, 76, 60, 0.55);
  box-shadow: inset 2px 0 0 var(--red-bright);
}

.target-indicator {
  font-size: 13px;
  color: var(--red-bright);
  letter-spacing: 0.04em;
  font-weight: bold;
  margin-top: 2px;
  animation: pulse 1s infinite;
}

.action-card {
  flex: 1;
  min-width: 0;
  max-width: 100px;
  min-height: 60px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface2);
  padding: 4px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.action-card:active { transform: scale(0.95); }
.action-card.selected {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.8);
  border-width: 3px;
}
.action-card.selected.card-red {
  background: #5a0a08 !important;
  border-color: #ff3a2a !important;
  box-shadow: 0 6px 20px rgba(255,58,42,0.7), 0 0 12px rgba(255,58,42,0.4) inset;
}
.action-card.selected.card-blue {
  background: #0a2a4a !important;
  border-color: #3ab0ff !important;
  box-shadow: 0 6px 20px rgba(58,176,255,0.7), 0 0 12px rgba(58,176,255,0.4) inset;
}
.action-card.selected.card-purple {
  background: #2a0a4a !important;
  border-color: #c060ff !important;
  box-shadow: 0 6px 20px rgba(192,96,255,0.7), 0 0 12px rgba(192,96,255,0.4) inset;
}
.action-card.disabled { pointer-events: none; opacity: 0.4; }
.action-card.rerollable {
  border-color: var(--gold) !important;
  animation: pulse 0.8s infinite;
  cursor: pointer;
}
.action-card.targeting-source {
  border-color: var(--gold) !important;
  box-shadow: 0 0 8px rgba(200,150,26,0.7);
}

.action-card-name {
  font-size: 12px;
  font-weight: bold;
  color: var(--text);
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.action-card-effect {
  font-size: 13px;
  font-weight: normal;
  color: inherit;
  line-height: 1.3;
}
.action-card-val {
  font-size: 13px;
  font-weight: bold;
  text-align: right;
  margin-top: auto;
}

/* Loot badge on card */
.loot-badge {
  position: absolute;
  top: 2px; right: 2px;
  font-size: 8px;
  color: var(--gold-bright);
  opacity: 0.7;
}

/* ── COMBAT CONTROLS (bottom) ──────────────────────────────────────────────── */
#combat-controls {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* AP display */
#ap-display {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ap-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  min-width: 20px;
}
.ap-pips {
  display: flex;
  gap: 4px;
  flex: 1;
}
.ap-pip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid;
  transition: background 0.2s, border-color 0.2s;
}
.ap-pip.filled {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 0 4px rgba(243,156,18,0.5);
}
.ap-pip.empty {
  background: transparent;
  border-color: var(--grey);
}

.combat-btns {
  display: flex;
  gap: 8px;
}

#end-turn-btn {
  flex: 1;
  font-size: 15px;
  letter-spacing: 0.1em;
}

#end-turn-btn.resolving {
  background: var(--grey);
  cursor: default;
}

#reroll-cancel-btn {
  display: none;
  min-height: var(--tap-min);
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
}
#reroll-cancel-btn.visible { display: flex; align-items: center; }

/* ── TARGETING OVERLAY MSG ─────────────────────────────────────────────────── */
#targeting-hint {
  display: none;
  position: absolute;
  bottom: 120px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--gold-bright);
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}
#targeting-hint.visible { display: block; }

/* ── RESOLVE OVERLAY ───────────────────────────────────────────────────────── */
#resolve-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 50;
  align-items: center;
  justify-content: center;
}
#resolve-overlay.visible { display: flex; }
.resolve-msg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  font-size: 13px;
  color: var(--text);
  animation: pulse 1s infinite;
}

/* ── UNIT ZOOM POPUP ───────────────────────────────────────────────────────── */
#unit-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

#unit-zoom-box {
  width: 100%;
  max-height: 80%;
  background: var(--surface);
  border-top: 2px solid var(--gold);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideUp 0.2s ease;
}

.zoom-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.zoom-portrait-wrap {
  width: 128px;
  height: 128px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.zoom-unit-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.zoom-unit-name {
  font-size: 20px;
  font-weight: bold;
  color: var(--text);
}

.zoom-unit-hp {
  font-size: 15px;
  color: var(--text-dim);
}

.zoom-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.zoom-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.zoom-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom-action-row {
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.zoom-action-row.red    { background: var(--red-bg);    border-left: 3px solid var(--red-bright); }
.zoom-action-row.blue   { background: var(--blue-bg);   border-left: 3px solid var(--blue-bright); }
.zoom-action-row.purple { background: var(--purple-bg); border-left: 3px solid var(--purple-bright); }

.zoom-action-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-action-label {
  font-size: 12px;
  opacity: 0.6;
  width: 48px;
  flex-shrink: 0;
  font-style: italic;
}

.zoom-action-name {
  flex: 1;
  font-size: 16px;
  font-weight: bold;
  color: var(--text);
}

.zoom-action-val {
  font-size: 18px;
  font-weight: bold;
  color: var(--gold-bright);
  flex-shrink: 0;
}

.zoom-action-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  line-height: 1.5;
  padding-left: 54px;
}

.zoom-close-btn {
  margin-top: 4px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  min-height: var(--tap-min);
}
.zoom-close-btn:active { background: var(--surface2); }
