/* ============================================
   ASHEN THRONE - Dark Steel UI Theme
   ============================================ */

:root {
  /* ---- Backgrounds ---- */
  --bg-dark: #0a0a14;
  --bg-darker: #060610;
  --bg-panel: #111827;
  --bg-panel-hover: #1a2235;
  --bg-slot: #0d1520;
  --bg-slot-hover: #152030;
  --bg-input: #0d0d18;
  --bg-overlay: rgba(6, 6, 14, 0.95);

  /* ---- Borders ---- */
  --border-steel: #2a3040;
  --border-subtle: #1a2030;
  --border-glow: #4fc3f7;
  --border-gold: #ffd700;

  /* ---- Text ---- */
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-dim: #555;
  --text-bright: #fff;

  /* ---- Accent Colors ---- */
  --accent-cyan: #4fc3f7;
  --accent-orange: #ff9800;
  --accent-green: #66bb6a;
  --accent-red: #ef5350;
  --accent-purple: #e040fb;
  --accent-gold: #ffd700;
  --accent-blue: #42a5f5;

  /* ---- Class Colors (Kinetic/Electric/Psionic) ---- */
  --class-kinetic: #ef5350;
  --class-electric: #ff9800;
  --class-psionic: #26c6da;

  /* ---- Tier Colors ---- */
  --tier-1: #888;
  --tier-2: #4fc3f7;
  --tier-3: #ffd700;

  /* ---- Rarity Colors ---- */
  --rarity-common: #888;
  --rarity-rare: #42a5f5;
  --rarity-epic: #e040fb;
  --rarity-legendary: #ffd700;

  /* ---- Skill Type Colors ---- */
  --skill-power: #e040fb;
  --skill-skill: #ffd54f;
  --skill-strike: #ef5350;

  /* ---- Site Type Colors ---- */
  --site-generator: #ffd54f;
  --site-fabrication: #9e9e9e;
  --site-hydroponic: #66bb6a;
  --site-archive: #42a5f5;
  --site-signal: #e040fb;
  --site-catalyst: #ffd700;

  /* ---- Spacing ---- */
  --space-xs: 2px;
  --space-sm: 4px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;
  --space-2xl: 24px;

  /* ---- Typography ---- */
  --font-mono: monospace;
  --font-xs: 9px;
  --font-sm: 10px;
  --font-md: 11px;
  --font-lg: 12px;
  --font-xl: 14px;
  --font-2xl: 16px;
  --font-3xl: 20px;
  --font-heading: 13px;

  /* ---- Border Radius ---- */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-pill: 12px;
  --radius-full: 50%;
}

/* ============================================
   Panel Components
   ============================================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-steel);
  border-radius: 6px;
  padding: 16px;
  background-image: url('assets/icons/chrome_panel.jpg');
  background-size: 256px 256px;
  background-repeat: repeat;
  background-blend-mode: overlay;
}

.panel-header {
  font-size: 13px;
  font-family: monospace;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-steel);
}

.panel-glow {
  border-color: var(--border-glow);
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.15);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border-steel);
  border-radius: 4px;
  background: var(--bg-panel);
  background-image: url('assets/icons/chrome_panel.jpg');
  background-size: 128px 128px;
  background-repeat: repeat;
  background-blend-mode: overlay;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 3px rgba(0,0,0,0.4);
}

.btn:hover {
  background-color: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 6px rgba(79,195,247,0.15);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  font-weight: bold;
}
.btn-primary:hover { background: #81d4fa; }

.btn-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}
.btn-danger:hover { background: rgba(239, 83, 80, 0.15); }

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* Button variants */
.btn-success { background: var(--accent-green); color: #000; border-color: var(--accent-green); font-weight: bold; }
.btn-success:hover { background: #81c784; }
.btn-warning { background: var(--accent-orange); color: #000; border-color: var(--accent-orange); font-weight: bold; }
.btn-warning:hover { background: #ffb74d; }
.btn-gold { background: var(--accent-gold); color: #000; border-color: var(--accent-gold); font-weight: bold; }
.btn-gold:hover { background: #ffeb3b; }
.btn-ghost { background: transparent; border-color: var(--border-steel); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-panel); color: var(--text-primary); }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 20px; font-size: var(--font-xl); }
.btn-disabled, .btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ============================================
   Cards (items, units, commanders)
   ============================================ */
.ds-card {
  display: flex; align-items: center; gap: var(--space-lg);
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-dark);
  border: 1px solid var(--border-steel);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s;
}
.ds-card:hover { border-color: var(--accent-cyan); }
.ds-card-icon {
  width: 36px; height: 36px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ds-card-body { flex: 1; min-width: 0; }
.ds-card-title { font-family: var(--font-mono); font-size: var(--font-lg); color: var(--text-primary); font-weight: bold; }
.ds-card-subtitle { font-family: var(--font-mono); font-size: var(--font-sm); color: var(--text-secondary); margin-top: var(--space-xs); }
.ds-card-count {
  font-family: var(--font-mono); font-size: var(--font-2xl); font-weight: bold;
  min-width: 30px; text-align: right; flex-shrink: 0;
}

/* ============================================
   Badges (class, tier, rarity, status)
   ============================================ */
.badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--font-xs); letter-spacing: 0.5px;
  text-transform: uppercase; font-weight: bold;
}
.badge-kinetic { background: rgba(239,83,80,0.15); color: var(--class-kinetic); border: 1px solid rgba(239,83,80,0.3); }
.badge-electric { background: rgba(255,152,0,0.15); color: var(--class-electric); border: 1px solid rgba(255,152,0,0.3); }
.badge-psionic { background: rgba(38,198,218,0.15); color: var(--class-psionic); border: 1px solid rgba(38,198,218,0.3); }
.badge-t1 { background: rgba(136,136,136,0.15); color: var(--tier-1); }
.badge-t2 { background: rgba(79,195,247,0.15); color: var(--tier-2); }
.badge-t3 { background: rgba(255,215,0,0.15); color: var(--tier-3); }
.badge-common { color: var(--rarity-common); }
.badge-rare { color: var(--rarity-rare); }
.badge-epic { color: var(--rarity-epic); }
.badge-legendary { color: var(--rarity-legendary); }
.badge-equipped { background: rgba(79,195,247,0.15); color: var(--accent-cyan); border: 1px solid rgba(79,195,247,0.3); }
.badge-power { background: rgba(255,152,0,0.1); color: var(--skill-power); }
.badge-skill { background: rgba(255,213,79,0.1); color: var(--skill-skill); }
.badge-strike { background: rgba(239,83,80,0.1); color: var(--skill-strike); }

/* ============================================
   Stat Rows
   ============================================ */
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-sm) 0;
  font-family: var(--font-mono); font-size: var(--font-md);
}
.stat-label { color: var(--text-secondary); }
.stat-value { color: var(--text-primary); font-weight: bold; }
.stat-value.positive { color: var(--accent-green); }
.stat-value.negative { color: var(--accent-red); }
.stat-value.gold { color: var(--accent-gold); }
.stat-clickable { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.stat-clickable:hover { color: var(--accent-cyan); }

/* ============================================
   Tab Bar
   ============================================ */
.tab-bar { display: flex; border-bottom: 1px solid var(--border-subtle); }
.tab-item {
  flex: 1; text-align: center; padding: var(--space-md) 0; cursor: pointer;
  font-family: var(--font-mono); font-size: var(--font-sm); letter-spacing: 1px;
  color: var(--text-dim); border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }

/* ============================================
   Filter Pills
   ============================================ */
.filter-bar { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.filter-pill {
  padding: var(--space-sm) var(--space-lg); border-radius: var(--radius-pill);
  cursor: pointer; font-family: var(--font-mono); font-size: var(--font-xs);
  letter-spacing: 1px; border: 1px solid var(--border-subtle);
  color: var(--text-dim); background: transparent;
  transition: all 0.2s;
}
.filter-pill:hover { color: var(--text-secondary); border-color: var(--border-steel); }
.filter-pill.active { background: rgba(79,195,247,0.1); color: var(--accent-cyan); border-color: rgba(79,195,247,0.3); }

/* ============================================
   Progress Bars
   ============================================ */
.progress-bar { height: 6px; background: var(--bg-slot); border-radius: var(--radius-sm); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-sm); transition: width 0.3s; }
.progress-fill.green { background: var(--accent-green); }
.progress-fill.cyan { background: var(--accent-cyan); }
.progress-fill.red { background: var(--accent-red); }
.progress-fill.gold { background: var(--accent-gold); }
.progress-fill.orange { background: var(--accent-orange); }

/* ============================================
   Screen Layout Helpers
   ============================================ */
.screen-header {
  font-family: var(--font-mono); font-size: var(--font-heading);
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;
  padding: var(--space-lg) var(--space-xl); border-bottom: 1px solid var(--border-subtle);
}
.screen-body { padding: var(--space-md) var(--space-sm); overflow-y: auto; }
.screen-section { margin-bottom: var(--space-xl); }
.section-label {
  font-family: var(--font-mono); font-size: var(--font-sm); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: var(--space-sm); padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

/* ============================================
   Dividers
   ============================================ */
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border-steel), transparent); margin: var(--space-lg) 0; }
.divider-subtle { height: 1px; background: var(--border-subtle); margin: var(--space-md) 0; }

/* ============================================
   Inputs
   ============================================ */
.ds-input {
  width: 100%; padding: var(--space-md) var(--space-lg);
  background: var(--bg-input); border: 1px solid var(--border-steel);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: var(--font-mono); font-size: var(--font-md); outline: none;
}
.ds-input:focus { border-color: var(--accent-cyan); }
.ds-select {
  padding: var(--space-sm); background: var(--bg-input); border: 1px solid var(--border-steel);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-mono); font-size: var(--font-md);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-dim { color: var(--text-dim); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-bright { color: var(--text-bright); }
.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-md { font-size: var(--font-md); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-bold { font-weight: bold; }
.text-uppercase { text-transform: uppercase; letter-spacing: 1px; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-1 { flex: 1; min-width: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
.no-select { user-select: none; }

/* ============================================
   Formation Grid
   ============================================ */
.formation-grid {
  display: grid;
  gap: 6px;
}

.formation-grid-3x2 {
  grid-template-columns: repeat(3, 1fr);
}

.formation-slot {
  background: var(--bg-slot);
  border: 1px solid var(--border-steel);
  border-radius: 4px;
  padding: 8px;
  min-height: 70px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.formation-slot:hover {
  background: var(--bg-slot-hover);
  border-color: var(--accent-cyan);
}

.formation-slot.has-unit {
  border-color: var(--border-steel);
}


.formation-slot .slot-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  position: absolute;
  top: 3px;
  right: 5px;
}

.formation-slot .unit-img {
  width: 48px;
  height: 64px;
  border-radius: 3px;
  object-fit: cover;
  margin-bottom: 4px;
  background: var(--bg-panel);
}

.formation-slot .unit-name {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-primary);
  font-weight: bold;
}

.formation-slot .unit-class-tag {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: monospace;
  margin-bottom: 2px;
}


.formation-slot .unit-count {
  font-family: monospace;
  font-size: 13px;
  color: #fff;
}

.formation-slot .unit-empty {
  color: var(--text-dim);
  font-size: 11px;
  font-family: monospace;
}

/* HP Bar inside slots */
.hp-bar {
  width: 100%;
  height: 4px;
  background: #1a1a2a;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

.hp-bar-fill.hp-high { background: var(--accent-green); }
.hp-bar-fill.hp-mid { background: var(--accent-gold); }
.hp-bar-fill.hp-low { background: var(--accent-red); }

/* ============================================
   Unit List (Army screen left side)
   ============================================ */
.unit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.1s;
}

.unit-row:hover { background: var(--bg-panel-hover); }

.unit-row .unit-icon {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--bg-slot);
  border: 1px solid var(--border-steel);
}

.unit-row .unit-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.unit-row .unit-info .name {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-primary);
}

.unit-row .unit-info .meta {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
}

.unit-row .unit-count {
  font-family: monospace;
  font-size: 14px;
  color: #fff;
  min-width: 40px;
  text-align: right;
}

/* ============================================
   Resource Bar (HUD top)
   ============================================ */
.resource-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  height: 44px;
  background: var(--bg-dark);
  background-image: linear-gradient(rgba(6,6,14,0.65), rgba(6,6,14,0.65)), url('assets/icons/chrome_bar.jpg');
  background-size: auto 100%, auto 100%;
  background-repeat: repeat-x;
  border-bottom: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), inset 0 -1px 0 rgba(79,195,247,0.15);
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.resource-item .res-icon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: contain;
}

.resource-item .res-icon-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-family: monospace;
  font-weight: bold;
}

.resource-item .res-value {
  font-family: monospace;
  font-size: 13px;
  color: #fff;
}

.resource-item .res-cap {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
}

/* ============================================
   Nav Bar (bottom)
   ============================================ */
.nav-bar {
  display: flex;
  height: 40px;
  background: var(--bg-dark);
  background-image: linear-gradient(rgba(6,6,14,0.65), rgba(6,6,14,0.65)), url('assets/icons/chrome_bar.jpg');
  background-size: auto 100%, auto 100%;
  background-repeat: repeat-x;
  border-top: none;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(79,195,247,0.15);
  transform: scaleY(-1);
}

.nav-bar > * {
  transform: scaleY(-1);
}

.nav-group {
  display: flex;
  flex-shrink: 0;
}

.nav-btn {
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 11px;
  color: #b0b0b0;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  background: none;
}

.nav-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-btn.active {
  color: var(--accent-cyan);
  background: rgba(79, 195, 247, 0.1);
  box-shadow: inset 0 2px 0 var(--accent-cyan), 0 0 8px rgba(79,195,247,0.1);
}

/* ============================================
   Map HUD — Top bar (coords, zone, shield)
   ============================================ */
.hud-top-content {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
  height: 100%;
}

#hud-top-map {
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
}

.map-hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-hud-label {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.map-hud-value {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-secondary);
}

.map-hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 9px;
  font-family: monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.map-hud-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Alert preview — top bar center, 2-line display like chat preview */
#hud-alert-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 10px;
  cursor: pointer;
  overflow: hidden;
  min-width: 0;
  border-left: 1px solid rgba(255,255,255,0.06);
  border-right: 1px solid rgba(255,255,255,0.06);
}
#hud-alert-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
  margin-left: 10px;
}
.hud-alert-line {
  font-family: monospace;
  font-size: 9px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.hud-alert-type { color: #ef5350; font-weight: bold; margin-right: 4px; }
.hud-alert-type--info { color: #4fc3f7; }
.hud-alert-type--success { color: #66bb6a; }
.hud-alert-type--warning { color: #ff9800; }
.hud-alert-dot {
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  animation: alertPulse 0.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes alertPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px 1px currentColor; }
  50% { opacity: 0.3; box-shadow: 0 0 8px 3px currentColor; }
}

/* ============================================
   Bottom Bar — Chat preview (left) + nav buttons (right)
   ============================================ */
#map-chat-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 10px;
  cursor: pointer;
  border-right: 1px solid rgba(79,195,247,0.15);
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,0.35);
}

#map-chat-preview:hover {
  background: rgba(0,0,0,0.45);
}

#map-chat-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.map-chat-line {
  font-family: monospace;
  font-size: 9px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.map-chat-sender {
  color: var(--accent-cyan);
  margin-right: 4px;
}



/* ============================================
   Settings Modal
   ============================================ */
.settings-section {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 0 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.settings-label {
  font-family: monospace;
  font-size: 11px;
  color: #ccc;
}

.settings-desc {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 1px;
}

.settings-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  cursor: pointer;
  background: #2a2a3a;
  border-radius: 10px;
  transition: background 0.2s;
}

.settings-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: #888;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.settings-toggle input:checked + .settings-toggle-slider {
  background: rgba(79,195,247,0.3);
}

.settings-toggle input:checked + .settings-toggle-slider::before {
  transform: translateX(16px);
  background: var(--accent-cyan);
}

.settings-slider {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #2a2a3a;
  border-radius: 2px;
  outline: none;
  flex-shrink: 0;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
}

.settings-select {
  background: #1a1a2a;
  border: 1px solid #2a3a50;
  border-radius: 4px;
  color: #ccc;
  font-family: monospace;
  font-size: 11px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
}

.settings-select:focus {
  border-color: var(--accent-cyan);
}

/* ============================================
   Battle History List
   ============================================ */
.battle-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border-steel);
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.battle-list-item:hover { background: var(--bg-panel-hover); }
.battle-list-item.selected { border-color: var(--accent-cyan); background: rgba(79, 195, 247, 0.05); }

.battle-result-badge {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-weight: bold;
  font-size: 14px;
}

.battle-result-badge.win { background: rgba(102, 187, 106, 0.2); color: var(--accent-green); }
.battle-result-badge.loss { background: rgba(239, 83, 80, 0.2); color: var(--accent-red); }

/* ============================================
   Commander Card
   ============================================ */
.commander-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-slot);
  border: 1px solid var(--accent-purple);
  border-radius: 6px;
}

.commander-card .cmd-portrait {
  width: 100px;
  height: 125px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-panel);
  border: 2px solid var(--accent-purple);
  box-shadow: 0 0 10px rgba(171, 71, 188, 0.3);
}

.commander-card .cmd-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.commander-card .cmd-name {
  font-family: monospace;
  font-size: 14px;
  color: var(--accent-purple);
  text-transform: uppercase;
}

.commander-card .cmd-level {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-secondary);
}

.commander-card .cmd-skill {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 6px;
  background: rgba(171, 71, 188, 0.1);
  border-radius: 3px;
  display: inline-block;
}

/* ============================================
   Modals (override existing)
   ============================================ */
.modal-box {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-glow) !important;
  box-shadow: 0 0 20px rgba(79, 195, 247, 0.1);
}

.modal-box h2 {
  color: var(--accent-cyan) !important;
  font-family: monospace;
}

.modal-box input, .modal-box select {
  background: var(--bg-slot) !important;
  border: 1px solid var(--border-steel) !important;
  color: var(--text-primary) !important;
  font-family: monospace;
}

.modal-box input:focus, .modal-box select:focus {
  border-color: var(--accent-cyan) !important;
  outline: none;
}

/* ============================================
   Screen Layouts
   ============================================ */
.screen-overlay {
  position: fixed;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 40px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-dark);
  background-image: url('assets/icons/chrome_panel.jpg');
  background-size: 512px 512px;
  background-repeat: repeat;
  background-blend-mode: overlay;
  z-index: 10;
}

.screen-overlay.hidden { display: none; }
.screen-overlay.no-top-bar { top: 0 !important; bottom: 0 !important; padding: 8px !important; }
#command-overlay.no-top-bar { padding: 4px !important; }
.screen-overlay.fullscreen { top: 0 !important; bottom: 0 !important; height: 100vh !important; padding: 0 !important; }

.screen-header {
  font-family: monospace;
  font-size: 18px;
  color: var(--accent-cyan);
  text-align: center;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.two-col-wide-right {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
}

/* ============================================
   Counter Triangle Indicator
   ============================================ */
.counter-badge {
  font-size: 9px;
  font-family: monospace;
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: bold;
}

.counter-badge.strong { background: rgba(102, 187, 106, 0.2); color: var(--accent-green); }
.counter-badge.weak { background: rgba(239, 83, 80, 0.2); color: var(--accent-red); }
.counter-badge.neutral { background: rgba(136, 136, 136, 0.1); color: var(--text-dim); }

/* ============================================
   Crawler Base Layout - Full Bleed
   ============================================ */
/* ============================================
   Base Screen — Full-bleed hull + floating panels
   ============================================ */

.base-fullbleed {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #04040c;
}

/* Hull image fills the screen, object-position biased toward center-top
   so the crawler body is always visible */
.base-hull-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  pointer-events: none;
  user-select: none;
}

/* Dark vignette — bottom and top edges fade to bg so chrome bars read cleanly */
.base-hull-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(4,4,12,0.55) 0%, transparent 18%),
    linear-gradient(to top,    rgba(4,4,12,0.65) 0%, transparent 20%);
}

/* ---- Building rails (left / bottom / right) ---- */
.base-rail {
  position: absolute;
  display: flex;
  z-index: 10;
  gap: 6px;
  pointer-events: none;
}
.base-rail > * { pointer-events: auto; }

.base-rail--left {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
}

.base-rail--right {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
}

.base-rail--bottom {
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: row;
}

/* ---- Building panels ---- */
.bpanel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 58px;
  padding: 7px 8px 6px;
  background: rgba(8, 10, 22, 0.82);
  border: 1px solid color-mix(in srgb, var(--bpc, #4fc3f7) 35%, transparent);
  border-top: 2px solid var(--bpc, #4fc3f7);
  border-radius: 5px;
  cursor: pointer;
  font-family: monospace;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.bpanel:hover {
  background: rgba(14, 18, 36, 0.95);
  border-color: color-mix(in srgb, var(--bpc, #4fc3f7) 65%, transparent);
  transform: translateY(-2px);
}

.bpanel:active {
  transform: translateY(1px);
}

.bpanel--selected {
  background: rgba(14, 18, 36, 0.95);
  border-color: color-mix(in srgb, var(--bpc, #4fc3f7) 80%, transparent);
  box-shadow: 0 2px 16px rgba(0,0,0,0.6), 0 0 12px color-mix(in srgb, var(--bpc,#4fc3f7) 25%, transparent);
}

/* Upgrading: pulse ring on the top border */
.bpanel--upgrading {
  border-top-color: var(--accent-cyan) !important;
  animation: bpanel-pulse 1.6s ease-in-out infinite;
}

@keyframes bpanel-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 -1px 10px rgba(79,195,247,0.15); }
  50%       { box-shadow: 0 2px 16px rgba(0,0,0,0.6), 0 -1px 18px rgba(79,195,247,0.45); }
}

.bpanel--maxed {
  border-top-color: var(--accent-gold) !important;
  opacity: 0.85;
}

.bpanel-icon {
  font-size: 17px;
  line-height: 1;
  filter: drop-shadow(0 1px 4px color-mix(in srgb, var(--bpc,#4fc3f7) 50%, transparent));
}

.bpanel-label {
  font-size: 9px;
  color: #ddd;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.bpanel-sub {
  font-size: 9px;
  color: #666;
  white-space: nowrap;
}

.bpanel-timer {
  color: var(--accent-cyan);
  font-weight: bold;
  font-style: normal;
}

.bpanel-arrow {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 12px;
  opacity: 0.6;
  line-height: 1;
}

/* Elevated container — escapes screen-overlay stacking context during tutorial */
#base-info-elevated {
  position: fixed;
  inset: 0;
  z-index: 102;
  pointer-events: none;
}
#base-info-elevated .base-info-panel {
  position: fixed;
  pointer-events: auto;
}

/* ---- Inline info panel (center) ---- */
.base-info-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  background: rgba(8, 10, 22, 0.92);
  border: 1px solid color-mix(in srgb, var(--bpc, #4fc3f7) 40%, transparent);
  border-top: 2px solid var(--bpc, #4fc3f7);
  border-radius: 6px;
  padding: 10px 12px;
  z-index: 20;
  font-family: monospace;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.7), 0 0 20px color-mix(in srgb, var(--bpc,#4fc3f7) 12%, transparent);
  animation: base-info-in 0.15s ease-out;
}

@keyframes base-info-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.base-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.base-info-icon { font-size: 22px; line-height: 1; }

.base-info-title {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.base-info-level {
  font-size: 9px;
  color: var(--text-dim, #666);
  text-transform: uppercase;
}

.base-info-close {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-dim, #666);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}

.base-info-close:hover {
  color: var(--text-primary, #e0e0e0);
  background: rgba(255,255,255,0.08);
}

.base-info-stats {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 6px;
  margin-bottom: 8px;
}

.base-info-stats .stat-row { padding: 2px 0; font-size: 10px; }

.base-info-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 0;
}

.base-info-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.base-cost-chip {
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary, #aaa);
  white-space: nowrap;
}

.base-cost-chip--short { color: var(--accent-red, #ef5350); }

.base-info-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.base-info-upgrade { flex: 1; }

.base-info-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.base-info-timer {
  font-size: 10px;
  color: var(--accent-cyan, #4fc3f7);
  font-weight: bold;
  text-align: center;
}

.base-info-boost {
  white-space: nowrap;
  font-size: 10px;
  padding: 4px 8px;
}

/* ---- Boost modal ---- */
.base-boost-progress {
  margin-bottom: 10px;
}

.base-boost-modal-timer {
  font-size: 11px;
  color: var(--accent-cyan, #4fc3f7);
  font-weight: bold;
  text-align: center;
  margin-top: 3px;
  font-family: monospace;
}

.base-boost-grades {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.base-boost-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 5px;
  background: rgba(255,255,255,0.03);
  border: 1px solid color-mix(in srgb, var(--gc, #888) 25%, transparent);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: monospace;
}

.base-boost-row:hover {
  background: rgba(255,255,255,0.07);
  border-color: color-mix(in srgb, var(--gc, #888) 55%, transparent);
}

.base-boost-row--dim {
  opacity: 0.45;
  cursor: default;
}

.base-boost-row-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.base-boost-row-count {
  font-size: 10px;
  font-weight: bold;
  min-width: 28px;
}

.base-boost-row-pct {
  font-size: 10px;
  color: var(--text-dim, #666);
  min-width: 30px;
}

.base-boost-row-time {
  font-size: 10px;
  font-weight: bold;
  flex: 1;
  text-align: right;
}

.base-boost-row-btn {
  font-size: 9px;
  padding: 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.base-boost-free-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 5px;
  background: rgba(102,187,106,0.08);
  border: 1px solid rgba(102,187,106,0.3);
  cursor: pointer;
  transition: background 0.12s;
  font-family: monospace;
}

.base-boost-free-row:hover {
  background: rgba(102,187,106,0.15);
}

/* ---- Building Info Tab (shared across nav screens) ---- */
.binfo-tab {
  max-width: 400px;
  margin: 0 auto;
  padding-top: 12px;
  font-family: monospace;
}
.binfo-tab.has-detail {
  max-width: 620px;
  display: flex;
  flex-direction: row;
  gap: 0;
}
.binfo-tab.has-detail .binfo-main {
  flex: 1;
  min-width: 0;
  border-right: 1px solid #1a2030;
  padding-right: 12px;
}
.binfo-tab.has-detail .binfo-detail {
  flex: 0 0 190px;
  padding-left: 12px;
  overflow-y: auto;
  font-family: monospace;
}

.binfo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.binfo-icon { font-size: 28px; line-height: 1; }

.binfo-title {
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.binfo-level {
  font-size: 10px;
  color: var(--text-dim, #666);
  text-transform: uppercase;
}

.binfo-lore {
  font-size: 10px;
  color: var(--text-secondary, #aaa);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid rgba(255,255,255,0.08);
  border-radius: 0 4px 4px 0;
  margin-bottom: 10px;
}

.binfo-bonuses {
  margin-bottom: 10px;
}

.binfo-bonus {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(79,195,247,0.06);
  border: 1px solid rgba(79,195,247,0.15);
  margin-bottom: 4px;
  color: var(--accent-cyan, #4fc3f7);
}

.binfo-bonus--next {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
  color: var(--text-dim, #666);
}

.binfo-bonus-label {
  font-weight: bold;
  margin-right: 4px;
}

.binfo-stats {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 6px;
  margin-bottom: 8px;
}

.binfo-stats .stat-row { padding: 2px 0; font-size: 10px; }

.binfo-upgrade {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
  margin-top: 8px;
}

.binfo-upgrade-label {
  font-size: 11px;
  color: var(--text-primary, #e0e0e0);
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.binfo-costs {
  margin-bottom: 6px;
}

.binfo-costs .stat-row { padding: 2px 0; font-size: 10px; }

/* ============================================
   Profile Screen
   ============================================ */
.profile-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-stat {
  padding: 8px;
  background: rgba(10, 10, 20, 0.5);
  border-radius: 4px;
  text-align: center;
}

.profile-stat-label {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-stat-value {
  font-family: monospace;
  font-size: 16px;
  color: #fff;
  font-weight: bold;
  margin: 2px 0;
}

.profile-stat-sub {
  font-family: monospace;
  font-size: 10px;
  color: #666;
}

/* ============================================
   Research Screen — 2-panel layout
   ============================================ */

/* Layout */
.res-layout {
  display: flex;
  gap: 8px;
  height: calc(100vh - 116px);
  padding-top: 6px;
}
.res-grid-panel { width: 48%; flex-shrink: 0; }
.res-detail-panel { flex: 1; }

/* Left: category labels + cell grid */
.res-cat-label {
  font-family: monospace;
  font-size: 8px;
  letter-spacing: 1px;
  margin: 6px 0 2px;
}
.res-cat-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

/* Grid cells */
.res-cell {
  flex: 1;
  padding: 4px 2px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
  border: 2px solid var(--border-subtle);
  background: rgba(10,10,20,0.6);
  transition: border-color 0.15s, background 0.15s;
}
.res-cell--selected {
  border-color: var(--cat-color, var(--accent-cyan));
  background: color-mix(in srgb, var(--cat-color, var(--accent-cyan)) 8%, transparent);
}
.res-cell-icon { font-size: 16px; }
.res-cell-name {
  font-family: monospace;
  font-size: 7px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.res-cell-level {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-primary);
}
.res-cell--max .res-cell-level { color: var(--accent-green); }
.res-cell--active .res-cell-level { color: var(--accent-gold); }

/* Right: empty state */
.res-empty-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Right: detail panel */
.res-detail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 6px;
}
.res-detail-icon { font-size: 24px; text-align: center; }
.res-detail-name {
  font-family: monospace;
  font-size: 14px;
  text-align: center;
  font-weight: bold;
}
.res-detail-desc {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
}
.res-detail-level {
  font-family: monospace;
  font-size: 16px;
  color: var(--text-primary);
  text-align: center;
}
.res-detail-level--max { color: var(--accent-green); }
.res-detail-action { margin-top: auto; }

/* Cost box */
.res-cost-box {
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}
.res-cost-header {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.res-cost-line {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-primary);
}
.res-cost-line--short { color: var(--accent-red); }
.res-cost-time {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Lore block */
.res-lore {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  font-style: italic;
  border-left: 2px solid var(--text-dim);
  padding-left: 6px;
  line-height: 1.4;
}

/* Timer row */
.res-timer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

/* Timer text (used by both detail panel and grid) */
.research-timer-text {
  font-family: monospace;
  font-size: 11px;
  color: var(--accent-cyan);
}

/* Boost buttons */
.research-boost-btn {
  flex-shrink: 0;
  background: color-mix(in srgb, var(--accent-gold) 13%, transparent);
  color: var(--accent-gold);
  border: 1px solid color-mix(in srgb, var(--accent-gold) 27%, transparent);
  font-size: 11px;
  white-space: nowrap;
}
.research-free-btn {
  background: color-mix(in srgb, var(--accent-green) 13%, transparent);
  color: var(--accent-green);
  border: 1px solid color-mix(in srgb, var(--accent-green) 27%, transparent);
  font-weight: bold;
}

/* Gated / already-researching messages */
.res-gated-msg {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px;
}

/* Boost modal title */
.res-boost-title {
  font-size: 13px;
  color: var(--accent-cyan);
  font-weight: bold;
}

/* ============================================
   Hospital - Cryostasis Cards
   ============================================ */
.hosp-cryo-card {
  background: var(--bg-slot);
  border: 1px solid var(--border-steel);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
}

.hosp-cryo-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.hosp-cryo-actions {
  display: flex;
  gap: 8px;
}

.hosp-cryo-actions .btn {
  flex: 1;
  font-size: 11px;
  padding: 8px;
}

/* ============================================
   Command Center - Formation & Commander
   ============================================ */
.cmd-formation-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cmd-formation-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
}

.cmd-formation-label {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 1px;
}

.cmd-slot {
  padding: 10px;
  background: var(--bg-slot);
  border: 1px solid var(--border-steel);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.cmd-slot:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-slot-hover);
}

.cmd-slot.has-unit {
  border-left-width: 3px;
}

.cmd-slot-name {
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
}

.cmd-slot-count {
  font-family: monospace;
  font-size: 16px;
  color: #fff;
}

.cmd-slot-class {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
}

.cmd-unit-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-steel);
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  font-family: monospace;
  font-size: 12px;
  transition: all 0.15s;
}

.cmd-unit-option:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
}

.cmd-unit-option.selected {
  border-color: var(--accent-cyan);
  background: rgba(79, 195, 247, 0.1);
}

/* ============================================
   Army Screen - Accordion List
   ============================================ */
/* ============================================
   Army Screen
   ============================================ */

.army-list {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 16px;
}

/* Training queue banner */
.army-queue-bar {
  font-family: monospace;
  font-size: 11px;
  color: var(--accent-cyan);
  padding: 8px 12px;
  background: rgba(79, 195, 247, 0.06);
  border: 1px solid rgba(79, 195, 247, 0.18);
  border-radius: 6px;
  margin-bottom: 12px;
  text-align: center;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* Tier header */
.army-tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.army-tier-title {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: bold;
}

.army-tier-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}

.army-tier-chip {
  font-family: monospace;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: bold;
  letter-spacing: 0.3px;
}

.army-tier-lock {
  font-family: monospace;
  font-size: 10px;
  color: var(--accent-red);
  margin-left: 4px;
}

.army-tier-ready {
  font-family: monospace;
  font-size: 10px;
  color: var(--accent-green);
  margin-left: 4px;
}

/* Unit row */
.army-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-steel);
  border-left: 3px solid var(--row-color, var(--border-steel));
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  min-height: 52px;
  overflow: hidden;
}

.army-row:hover { background: var(--bg-panel-hover); }
.army-row:active { transform: scale(0.99); }
.army-row.expanded {
  border-color: var(--row-color, var(--accent-cyan));
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}
.army-row.locked {
  opacity: 0.28;
  cursor: default;
  border-left-color: var(--border-steel);
}
.army-row.locked:hover { background: var(--bg-panel); }

/* Thumbnail */
.army-row-thumb {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-darker);
}

.army-row-thumb img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  display: block;
}

.army-row-thumb--missing {
  background: var(--bg-slot);
}

.army-row-thumb--missing img {
  opacity: 0;
}

/* Row body */
.army-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0;
}

.army-row-name {
  font-family: monospace;
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.army-row-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}

.army-row-carry {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
}

.army-row-count {
  font-family: monospace;
  font-size: 18px;
  font-weight: bold;
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.army-row-count--locked {
  color: var(--text-dim);
  font-size: 16px;
}

.army-row-arrow {
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

/* ---- Expanded detail panel ---- */
.army-detail {
  background: rgba(8, 12, 24, 0.97);
  border: 1px solid var(--border-steel);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 14px;
  margin-bottom: 4px;
}

.army-detail-top {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

/* Portrait container — shows colored fallback letter if art missing */
.army-detail-portrait-wrap {
  width: 90px;
  height: 120px;
  border-radius: 6px;
  border: 2px solid var(--border-steel);
  flex-shrink: 0;
  background: var(--bg-slot);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.army-detail-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}

.army-portrait-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 40px;
  font-weight: bold;
  color: var(--border-steel);
  pointer-events: none;
}

.army-portrait--missing .army-detail-portrait {
  opacity: 0;
}

.army-detail-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.army-detail-name {
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
}

.army-detail-stat-row {
  display: flex;
  gap: 14px;
  margin-top: 2px;
}

.army-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
}

.army-stat-num {
  font-family: monospace;
  font-size: 18px;
  font-weight: bold;
}

.army-stat-label {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.army-detail-counters {
  display: flex;
  gap: 10px;
  font-family: monospace;
  font-size: 11px;
  flex-wrap: wrap;
}

.army-lore-btn {
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  margin-left: 4px;
}

.army-lore-btn:hover { color: var(--accent-cyan); }

/* Training section */
.army-train-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.army-train-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}

.army-train-qty {
  font-family: monospace;
  font-size: 18px;
  color: #fff;
  font-weight: bold;
  min-width: 36px;
  text-align: center;
}

.army-train-costs {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 8px;
  background: rgba(10,10,20,0.4);
}

.army-train-time {
  opacity: 0.7;
}

/* Portrait flip card */
.army-portrait-flip {
  perspective: 800px;
  cursor: pointer;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.army-portrait-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.army-portrait-inner.flipped {
  transform: rotateY(180deg);
}

.army-portrait-front,
.army-portrait-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
}
.army-portrait-back {
  transform: rotateY(180deg);
}

.army-portrait-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

.army-portrait-back {
  transform: rotateY(180deg);
  background: rgba(8, 10, 22, 0.95);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px;
  gap: 8px;
  font-family: monospace;
}

.army-portrait-back .army-back-desc {
  font-size: 11px;
  color: #aaa;
  line-height: 1.5;
}

.army-portrait-back .army-back-lore {
  font-size: 10px;
  color: #777;
  line-height: 1.4;
  font-style: italic;
  border-left: 2px solid #444;
  padding-left: 8px;
}

.army-portrait-back .army-back-counters {
  display: flex;
  gap: 10px;
  font-size: 11px;
}

.army-flip-hint {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-family: monospace;
  font-size: 8px;
  color: #555;
  pointer-events: none;
}

/* Locked/unowned commander card */
.army-cmd-locked {
  filter: grayscale(85%) brightness(0.6);
  transition: filter 0.2s ease;
}
.army-cmd-locked:hover {
  filter: grayscale(60%) brightness(0.75);
}

/* Lock overlay on unowned portrait detail */
.army-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2;
  pointer-events: none;
}
.army-lock-overlay::after {
  content: '🔒';
  font-size: 28px;
  opacity: 0.7;
}

/* LOCKED badge on roster cards */
.army-locked-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #666;
  font-size: 7px;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: monospace;
  letter-spacing: 0.5px;
}

/* "How to obtain" hint */
.army-obtain-hint {
  padding: 8px 10px;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 9px;
  color: var(--accent-cyan, #4fc3f7);
  text-align: center;
}

/* Training progress (active queue) */
.army-train-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.army-train-timer {
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
}

.army-train-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Grid tile training overlay */
.army-tile-training {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 2px 3px;
  background: rgba(0,0,0,0.75);
  font-family: monospace;
  font-size: 8px;
  color: var(--accent-cyan);
  font-weight: bold;
  text-align: center;
  pointer-events: none;
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-steel); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================
   Battle Replay
   ============================================ */
.br-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  background: #0a0a14;
}

.br-battlefield {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  perspective: 500px;
  perspective-origin: 50% 35%;
  background-color: #0a0a14;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.br-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 200px;
}

.br-side-label {
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
}

.br-formation {
  display: flex;
  gap: 4px;
  transform-style: preserve-3d;
}

/* 3D perspective — formations angle toward each other */
.br-side.br-attacker .br-formation {
  transform: rotateY(25deg) rotateX(8deg);
}
.br-side.br-defender .br-formation {
  transform: rotateY(-25deg) rotateX(8deg);
}

.br-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.br-col-label {
  font-family: monospace;
  font-size: 8px;
  color: #555;
  text-align: center;
  letter-spacing: 1px;
}

.br-vs {
  font-family: monospace;
  font-size: 20px;
  color: #333;
  padding: 0 8px;
  align-self: center;
}

/* Portrait-oriented slot cards (80×120, 2:3 ratio) */
.br-slot {
  position: relative;
  width: 80px;
  height: 120px;
  border: 1px solid #2a3040;
  border-radius: 6px;
  background: rgba(10, 10, 20, 0.85);
  overflow: hidden;
  transition: all 0.2s;
}

.br-slot.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
}

.br-slot.destroyed {
  border-color: #3a1a1a;
}
.br-slot.destroyed .br-slot-hud {
  display: none;
}

/* Buff — green pulsing border */
.br-buff-1 { animation: br-buff-border 1.5s ease-in-out infinite; }
.br-buff-2 { animation: br-buff-border 1.0s ease-in-out infinite; border-width: 3px; }
.br-buff-3 { animation: br-buff-border 0.7s ease-in-out infinite; border-width: 4px; }

@keyframes br-buff-border {
  0%, 100% { border-color: rgba(102,187,106,0.5); }
  50% { border-color: rgba(102,187,106,1.0); }
}

/* Debuff — red pulsing border */
.br-debuff-1 { animation: br-debuff-border 1.5s ease-in-out infinite; }
.br-debuff-2 { animation: br-debuff-border 1.0s ease-in-out infinite; border-width: 3px; }
.br-debuff-3 { animation: br-debuff-border 0.7s ease-in-out infinite; border-width: 4px; }

@keyframes br-debuff-border {
  0%, 100% { border-color: rgba(239,83,80,0.5); }
  50% { border-color: rgba(239,83,80,1.0); }
}

/* Both buff + debuff: split green/red border — overrides individual animations */
.br-buff-debuff {
  animation: br-split-border 1.2s ease-in-out infinite !important;
  border-width: 3px !important;
}
@keyframes br-split-border {
  0%, 100% { border-color: rgba(102,187,106,0.5); border-bottom-color: rgba(239,83,80,0.5); border-right-color: rgba(239,83,80,0.5); }
  50% { border-color: rgba(102,187,106,1.0); border-bottom-color: rgba(239,83,80,1.0); border-right-color: rgba(239,83,80,1.0); }
}

.br-destroyed-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 10, 10, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.br-destroyed-text {
  font-family: monospace;
  font-size: 9px;
  color: #5a2a2a;
  letter-spacing: 1px;
  text-align: center;
}

.br-slot-portrait {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.br-slot-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.br-slot-video.hidden {
  display: none;
}

/* Mirror right-side (attacker) troop portraits to face left */
.br-side.br-defender .br-slot-portrait,
.br-side.br-defender .br-slot-video {
  transform: scaleX(-1);
}

/* Commander portrait wrapper — applies same rotation as .br-formation */
.br-cmd-wrap {
  flex-shrink: 0;
  align-self: center;
  transform-style: preserve-3d;
}
/* Left wrapper — skew angles vertical edges, top/bottom stay equal length */
#br-cmd-left-wrap {
  transform: skewX(3deg);
}
/* Right wrapper — mirrored */
#br-cmd-right-wrap {
  transform: skewX(-3deg);
}

/* Commander portrait — flat rectangle inside skewed wrapper */
.br-cmd-portrait {
  position: relative;
  width: 244px;
  height: 366px;
  border: 2px solid #4fc3f755;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(10, 10, 20, 0.85);
}

.br-cmd-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.br-cmd-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.br-cmd-video.hidden { display: none; }

/* Mirror right-side commander to face left */
#br-cmd-right .br-cmd-img,
#br-cmd-right .br-cmd-video {
  transform: scaleX(-1);
}

.br-cmd-name {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 3px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font: bold 8px monospace;
  color: #aaa;
  text-align: center;
  z-index: 2;
}

/* HUD overlay at bottom of slot card */
.br-slot-hud {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 2;
  padding: 3px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  align-items: center;
  gap: 4px;
}

.br-slot-count {
  font-family: monospace;
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

.br-slot-empty {
  font-family: monospace;
  font-size: 10px;
  color: #333;
}

/* Base HP bars */
.br-base-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 0;
}

.br-base-label {
  font-family: monospace;
  font-size: 9px;
  color: #666;
  min-width: 30px;
}

.br-base-track {
  flex: 1;
  height: 8px;
  background: #1a1a2a;
  border-radius: 4px;
  overflow: hidden;
}

.br-base-fill {
  height: 100%;
  background: var(--accent-cyan);
  border-radius: 4px;
  transition: width 0.4s;
}

.br-base-hp {
  font-family: monospace;
  font-size: 10px;
  color: #888;
  min-width: 40px;
  text-align: right;
}

/* Controls */
.br-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(6, 6, 14, 0.95);
  border-top: 1px solid #2a3040;
  flex-wrap: nowrap;
  position: relative;
}

.br-controls .btn {
  padding: 3px 8px;
  font-size: 9px;
  min-height: 0;
}

.br-log-inline {
  flex: 1;
  font-family: monospace;
  font-size: 10px;
  color: #888;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  position: relative;
  min-width: 0;
}

.br-log-inline .br-log-full {
  display: none;
}

.br-log-inline.expanded {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  white-space: normal;
  overflow-y: auto;
  max-height: 120px;
  background: rgba(4, 4, 10, 0.95);
  border: 1px solid #2a3040;
  border-radius: 6px 6px 0 0;
  padding: 6px 8px;
  z-index: 5;
}

.br-log-inline.expanded > #br-log-latest {
  display: none;
}

.br-log-inline.expanded .br-log-full {
  display: block;
  font-size: 9px;
  color: #666;
  line-height: 1.5;
}

.br-round-indicator {
  font-family: monospace;
  font-size: 12px;
  color: #888;
  margin-left: auto;
}

.br-speed-btns {
  display: flex;
  gap: 4px;
}

.br-speed-btns .btn.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}

/* Battle log */
.br-log {
  height: 80px;
  overflow-y: auto;
  padding: 6px 10px;
  background: rgba(4, 4, 10, 0.95);
  border-top: 1px solid #1a2030;
}

/* Projectile streak */
.br-streak {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #ffd54f 30%, #ff6d00 70%, transparent 100%);
  pointer-events: none;
  animation: br-streak-anim 0.35s ease-out forwards;
  z-index: 10;
}

@keyframes br-streak-anim {
  0% { opacity: 0; transform-origin: 0 50%; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
.br-streak-orange { background: linear-gradient(90deg, transparent 0%, #ff9800 30%, #ef5350 70%, transparent 100%); }
.br-streak-purple { background: linear-gradient(90deg, transparent 0%, #4fc3f7 30%, #e040fb 70%, transparent 100%); }
.br-streak-gold { background: linear-gradient(90deg, transparent 0%, #ffd700 30%, #fff 60%, #ffd700 80%, transparent 100%); }

/* Damage popup */
.br-damage-popup {
  position: absolute;
  transform: translateX(-50%);
  font-family: monospace;
  font-weight: bold;
  font-size: 13px;
  color: #ef5350;
  pointer-events: none;
  z-index: 30;
  animation: br-dmg-float 0.5s ease-out forwards;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.6);
}

@keyframes br-dmg-float {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; transform: translateX(-50%) translateY(-20px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-28px); }
}

/* Attack shake */
.br-attack-shake {
  animation: br-shake 0.25s ease-in-out;
}

@keyframes br-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}

/* Buff-scaled shake variants */
.br-attack-shake-1 { animation: br-shake-1 0.25s ease-in-out; }
.br-attack-shake-2 { animation: br-shake-2 0.25s ease-in-out; }
.br-attack-shake-3 { animation: br-shake-3 0.2s ease-in-out; }

@keyframes br-shake-1 {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(6px); }
  75% { transform: translateX(-6px); }
}
@keyframes br-shake-2 {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(8px) scale(1.02); }
  75% { transform: translateX(-8px) scale(1.02); }
}
@keyframes br-shake-3 {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(10px) scale(1.04); }
  40% { transform: translateX(-10px) scale(1.04); }
  60% { transform: translateX(6px) scale(1.02); }
  80% { transform: translateX(-6px) scale(1.02); }
}

/* Screen shake for 3+ buff attacks */
.br-screen-shake { animation: br-screen-rumble 0.3s ease-in-out; }
@keyframes br-screen-rumble {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, 1px); }
  80% { transform: translate(2px, -1px); }
}

/* Hit flash */
.br-hit-flash {
  animation: br-hit 0.35s ease-out;
}

@keyframes br-hit {
  0% { box-shadow: 0 0 0 rgba(239, 83, 80, 0); background: rgba(10,10,20,0.85); }
  30% { box-shadow: 0 0 15px rgba(239, 83, 80, 0.6); background: rgba(60,20,20,0.9); }
  100% { box-shadow: 0 0 0 rgba(239, 83, 80, 0); background: rgba(10,10,20,0.85); }
}

/* Buff-scaled hit flash variants */
.br-hit-flash-orange { animation: br-hit-orange 0.35s ease-out; }
.br-hit-flash-purple { animation: br-hit-purple 0.35s ease-out; }
.br-hit-flash-gold { animation: br-hit-gold 0.4s ease-out; }

@keyframes br-hit-orange {
  0% { box-shadow: 0 0 0 rgba(255,152,0,0); }
  30% { box-shadow: 0 0 18px rgba(255,152,0,0.7); background: rgba(40,25,10,0.9); }
  100% { box-shadow: 0 0 0 rgba(255,152,0,0); background: rgba(10,10,20,0.85); }
}
@keyframes br-hit-purple {
  0% { box-shadow: 0 0 0 rgba(224,64,251,0); }
  30% { box-shadow: 0 0 20px rgba(224,64,251,0.7); background: rgba(30,10,40,0.9); }
  100% { box-shadow: 0 0 0 rgba(224,64,251,0); background: rgba(10,10,20,0.85); }
}
@keyframes br-hit-gold {
  0% { box-shadow: 0 0 0 rgba(255,215,0,0); }
  25% { box-shadow: 0 0 25px rgba(255,215,0,0.8); background: rgba(40,35,10,0.9); }
  50% { box-shadow: 0 0 15px rgba(255,215,0,0.5); }
  100% { box-shadow: 0 0 0 rgba(255,215,0,0); background: rgba(10,10,20,0.85); }
}

/* Base flash */
.br-flash {
  animation: br-base-flash 0.4s ease-out;
}

@keyframes br-base-flash {
  0% { box-shadow: none; }
  30% { box-shadow: 0 0 10px rgba(239, 83, 80, 0.5); }
  100% { box-shadow: none; }
}

/* Commander skill flash */
.br-commander-flash {
  animation: br-cmd-flash 0.5s ease-out;
}

@keyframes br-cmd-flash {
  0% { box-shadow: inset 0 0 0 rgba(171, 71, 188, 0); }
  30% { box-shadow: inset 0 0 40px rgba(171, 71, 188, 0.4); }
  100% { box-shadow: inset 0 0 0 rgba(171, 71, 188, 0); }
}

/* Panel scale-in animation (chat, alerts) */
@keyframes panel-scale-in {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Conduit +100 float-up celebration */
@keyframes conduit-float {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-30px); opacity: 0; }
}

/* Action notification animations */
@keyframes notif-slide-in {
  0% { transform: translateX(100%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes notif-slide-out {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

.notif-loc-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Location title card (Dark Souls style) */
@keyframes lore-location-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* ============================================
   Lore Popup (Elden Ring style)
   ============================================ */
.lore-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: lore-fade-in 0.2s ease-out;
}

.lore-popup.hidden { display: none; }

@keyframes lore-fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.lore-popup-inner {
  background: #0d0d18;
  border: 1px solid #2a3a50;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  max-height: 85vh;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  animation: lore-slide-up 0.25s ease-out;
  display: flex;
  flex-direction: column;
}
/* Wider when two-panel detail is present */
.lore-popup-inner.has-detail { max-width: 600px; }

@keyframes lore-slide-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.lore-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #1a2030;
  flex-shrink: 0;
}

.lore-popup-title {
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
  color: #e0e0e0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lore-popup-close {
  background: none;
  border: none;
  color: #555;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.lore-popup-close:hover { color: #fff; }

/* Body — single column by default, flex row when detail present */
.lore-popup-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.lore-popup-body.has-detail {
  display: flex;
  flex-direction: row;
}
.lore-popup-body.has-detail .lore-popup-text {
  flex: 1;
  min-width: 0;
  border-right: 1px solid #1a2030;
  overflow-y: auto;
}
.lore-popup-body.has-detail .lore-popup-detail {
  flex: 0 0 200px;
  overflow-y: auto;
}

.lore-popup-desc {
  font-family: monospace;
  font-size: 12px;
  color: #ccc;
  padding: 12px 16px;
  line-height: 1.5;
}

.lore-popup-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #2a3a50, transparent);
  margin: 0 16px;
}

.lore-popup-lore {
  font-family: monospace;
  font-size: 11px;
  color: #888;
  font-style: italic;
  padding: 12px 16px 16px;
  line-height: 1.6;
}

/* Detail panel (right column in two-panel mode) */
.lore-popup-detail {
  display: none;
  font-family: monospace;
  font-size: 10px;
  color: #aaa;
  padding: 12px 14px;
  line-height: 1.5;
}

/* ============================================
   Enhanced Battle Replay — Trailing Health Bars + Commander Pop-ins
   ============================================ */

/* Trailing red health bar (green drops instantly, red bleeds down) */
.br-slot-hp-bar {
  height: 3px;
  flex: 1;
  background: #1a1a2a;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.br-slot-hp-trail {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: #ef535088;
  border-radius: 3px;
  transition: width 0.8s ease-out;
  z-index: 1;
}

.br-slot-hp-fill {
  position: relative;
  height: 100%;
  border-radius: 3px;
  transition: width 0.15s ease-out;
  z-index: 2;
}
.br-slot-hp-heal {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: #69f0ae88;
  border-radius: 3px;
  z-index: 1;
  transition: width 0.1s ease-out;
}
.br-slot-hp-heal.fade {
  transition: width 0.6s ease-out, opacity 0.6s ease-out;
  opacity: 0;
}

/* Commander skill pop-in */
.br-commander-popin {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(10, 10, 20, 0.95);
  border-radius: 8px;
  z-index: 30;
  pointer-events: none;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
}

.br-commander-popin.from-left {
  left: -200px;
  animation: br-popin-left 1.5s ease-out forwards;
  border: 1px solid #66bb6a;
}

.br-commander-popin.from-right {
  right: -200px;
  animation: br-popin-right 1.5s ease-out forwards;
  border: 1px solid #ef5350;
}

@keyframes br-popin-left {
  0% { left: -200px; opacity: 0; }
  15% { left: 10px; opacity: 1; }
  75% { left: 10px; opacity: 1; }
  100% { left: -200px; opacity: 0; }
}

@keyframes br-popin-right {
  0% { right: -200px; opacity: 0; }
  15% { right: 10px; opacity: 1; }
  75% { right: 10px; opacity: 1; }
  100% { right: -200px; opacity: 0; }
}

.br-commander-portrait {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}

.br-commander-text {
  font-family: monospace;
}

.br-commander-name {
  font-size: 11px;
  font-weight: bold;
  color: #fff;
}

.br-commander-skill {
  font-size: 10px;
  color: #ffd54f;
  margin-top: 2px;
}

/* Targeting line */
.br-target-line {
  position: absolute;
  height: 2px;
  pointer-events: none;
  z-index: 5;
  animation: br-target-fade 0.5s ease-out forwards;
}

@keyframes br-target-fade {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Collapsed battle log */
.br-log-collapsed {
  height: 24px;
  overflow: hidden;
  padding: 4px 10px;
  background: rgba(4, 4, 10, 0.95);
  border-top: 1px solid #1a2030;
  cursor: pointer;
  transition: height 0.3s;
}

.br-log-collapsed.expanded {
  height: 120px;
  overflow-y: auto;
}

.br-log-toggle {
  font-family: monospace;
  font-size: 9px;
  color: #555;
  text-align: right;
  cursor: pointer;
  user-select: none;
}

/* Round summary */
.br-round-summary {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(6, 6, 14, 0.92);
  border: 1px solid #ffd700;
  border-radius: 8px;
  padding: 12px 24px;
  z-index: 30;
  font-family: monospace;
  text-align: center;
  pointer-events: none;
  animation: br-round-fade 1.5s ease-out forwards;
}

@keyframes br-round-fade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* Victory/defeat splash */
.br-result-splash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 14, 0.85);
  z-index: 40;
  animation: br-splash-in 0.5s ease-out;
}

@keyframes br-splash-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.br-result-text {
  font-family: monospace;
  font-size: 36px;
  font-weight: bold;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.br-result-detail {
  font-family: monospace;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

/* Counter color targeting lines */
.br-target-line.strong { background: linear-gradient(90deg, transparent, #66bb6a88, transparent); }
.br-target-line.weak { background: linear-gradient(90deg, transparent, #ef535088, transparent); }
.br-target-line.neutral { background: linear-gradient(90deg, transparent, #ffffff44, transparent); }

@keyframes flash-red {
  0% { box-shadow: 0 0 0 rgba(239, 83, 80, 0); }
  50% { box-shadow: 0 0 12px rgba(239, 83, 80, 0.6); }
  100% { box-shadow: 0 0 0 rgba(239, 83, 80, 0); }
}

@keyframes flash-green {
  0% { box-shadow: 0 0 0 rgba(102, 187, 106, 0); }
  50% { box-shadow: 0 0 12px rgba(102, 187, 106, 0.6); }
  100% { box-shadow: 0 0 0 rgba(102, 187, 106, 0); }
}

@keyframes damage-float {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

.slot-flash-hit { animation: flash-red 0.4s ease-out; }
.slot-flash-heal { animation: flash-green 0.4s ease-out; }

.damage-popup {
  position: absolute;
  font-family: monospace;
  font-weight: bold;
  font-size: 14px;
  color: var(--accent-red);
  animation: damage-float 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 20;
}

/* ============================================
   TUTORIAL OVERLAY
   ============================================ */

/* ── Formation Grid ── */
.fg-grid { display:flex; flex-direction:column; gap:3px; }
.fg-header { display:flex; gap:3px; }
.fg-col-label { flex:1; text-align:center; color:#555; font-size:9px; font-family:monospace; letter-spacing:1px; }
.fg-row { display:flex; gap:3px; }
.fg-slot { position:relative; width:52px; height:52px; flex:0 0 52px; border:2px solid #2a3040; border-radius:6px; display:flex; align-items:center; justify-content:center; cursor:pointer; background:rgba(10,10,20,0.6); overflow:hidden; }
.fg-slot:hover { background:rgba(20,20,40,0.8); }
.fg-filled { }
.fg-empty { border-style:dashed; border-color:#333; }
.fg-thumb { width:48px; height:48px; object-fit:contain; border-radius:4px; }
.fg-count-overlay { position:absolute; bottom:2px; right:4px; font-family:monospace; font-size:11px; font-weight:bold; color:#fff; text-shadow:0 1px 3px rgba(0,0,0,0.9); }
.fg-abbr { font-family:monospace; font-weight:bold; font-size:12px; }
.fg-count { font-family:monospace; font-size:10px; color:#aaa; }
.fg-cost { font-family:monospace; font-size:8px; color:#ff9800; opacity:0.7; }
.fg-plus { color:#555; font-size:18px; }
.fg-leadership { margin-top:8px; font-family:monospace; font-size:10px; }
.fg-bar { height:4px; background:#1a1a2a; border-radius:2px; margin-top:4px; overflow:hidden; }
.fg-bar-fill { height:100%; border-radius:2px; transition:width 0.2s; }
.fg-picker-grid { display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; }
.fg-picker-cell { padding:10px 6px; border:1px solid #333; border-radius:6px; text-align:center; cursor:pointer; background:rgba(10,10,20,0.8); display:flex; flex-direction:column; align-items:center; gap:2px; }
.fg-picker-cell:hover:not(.fg-disabled) { background:rgba(30,30,60,0.9); }
.fg-disabled { opacity:0.3; cursor:not-allowed; }

.tutorial-locked {
  opacity: 0.3 !important;
  pointer-events: none !important;
  filter: grayscale(1);
}
.tutorial-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(239, 83, 80, 0.15);
  border-radius: inherit;
}

.tutorial-panel {
  position: fixed;
  top: 48px; /* below top HUD */
  right: 0;
  max-height: 50vh;
  width: 260px;
  background: linear-gradient(to left, #0a0e14 0%, #0a0e14ee 80%, #0a0e1400 100%);
  padding: 16px 12px 8px;
  z-index: 105;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.tutorial-panel::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -32px;
  height: 40px;
  background: linear-gradient(to bottom, #0a0e14cc 0%, transparent 100%);
  pointer-events: none;
}
.tutorial-panel.hidden { display: none; }

.tutorial-ada-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tutorial-ada-portrait {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1a2a3a;
  border: 2px solid #4fc3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #4fc3f7;
  font-weight: bold;
  flex-shrink: 0;
}
.tutorial-ada-name {
  color: #4fc3f7;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
}
.tutorial-ada-sub {
  color: #555;
  font-size: 9px;
}
.tutorial-ada-speech {
  color: #ccc;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
}
.tutorial-objective {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tutorial-objective-label {
  color: #ff9800;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.tutorial-objective-text {
  color: #e0e0e0;
  font-size: 13px;
}
.tutorial-action-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  color: #000;
  cursor: pointer;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.tutorial-action-btn:active {
  opacity: 0.8;
}

.tutorial-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1a2a;
}
.tutorial-dot.done { background: #4fc3f7; }
.tutorial-dot.active { background: #4fc3f744; box-shadow: 0 0 6px #4fc3f7; }

.tutorial-result-box {
  border: 1px solid;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  text-align: center;
}
.tutorial-result-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.tutorial-result-lore {
  border-left: 3px solid #555;
  padding: 6px 10px;
  margin-bottom: 8px;
}

/* Highlight animation for interactive tutorial steps */
@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 195, 247, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(79, 195, 247, 0); }
}
.tutorial-highlight {
  animation: tutorial-pulse 1.5s infinite !important;
  outline: 2px solid #4fc3f7 !important;
  outline-offset: 2px;
  position: relative;
  z-index: 10;
}

/* ---- Emergency Power Overlay (Tutorial Step 0) ---- */
.emergency-power-overlay {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.82);
  border: 2px solid rgba(239, 83, 80, 0.4);
  z-index: 100;
  pointer-events: none;
  transition: opacity 1.2s ease-out;
}
.emergency-power-overlay.fade-out { opacity: 0; }

.emergency-power-label {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 101;
  pointer-events: none;
  transition: opacity 1.2s ease-out;
}
.emergency-power-label.fade-out { opacity: 0; }

.emergency-power-icon {
  font-size: 48px;
  color: #ef5350;
  margin-bottom: 8px;
  animation: emergency-blink 2s infinite;
}
.emergency-power-text {
  color: #ef5350;
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 4px;
  text-transform: uppercase;
  animation: emergency-blink 2s infinite;
}
.emergency-power-sub {
  color: rgba(239, 83, 80, 0.4);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 4px;
}

@keyframes emergency-blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ============================================
   CONNECTION STATUS BANNER
   ============================================ */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-xl);
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--accent-orange);
  background: rgba(255, 152, 0, 0.12);
  border-bottom: 1px solid rgba(255, 152, 0, 0.3);
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
.connection-banner.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.connection-banner.failed {
  color: var(--accent-red);
  background: rgba(239, 83, 80, 0.12);
  border-bottom-color: rgba(239, 83, 80, 0.3);
}
.connection-banner .pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-orange);
  animation: connection-pulse 1.5s ease-in-out infinite;
  margin-right: var(--space-sm);
}
.connection-banner.failed .pulse-dot {
  background: var(--accent-red);
  animation: none;
}
@keyframes connection-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ============================================
   ROTATE DEVICE OVERLAY (portrait blocker)
   ============================================ */
#rotate-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #0a0a1a;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
@media (orientation: portrait) {
  #rotate-overlay { display: flex; }
}
@media (orientation: landscape) {
  #rotate-overlay { display: none !important; }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Resource bar: compact */
  .resource-bar { gap: 8px; padding: 0 8px; height: 36px; }
  .resource-item .res-icon, .resource-item .res-icon-placeholder { width: 16px; height: 16px; }
  .resource-item .res-value { font-size: 10px; }
  .resource-item .res-cap { display: none; }
  .resource-bar .res-icon { width: 18px !important; height: 18px !important; }

  /* Nav bar: smaller */
  .nav-bar { height: 36px; }
  .nav-btn { font-size: 8px; gap: 1px; min-height: 36px; }
  .nav-btn img { width: 16px; height: 16px; }

  /* Game area adjusted for smaller chrome */
  .screen-overlay {
    top: 36px !important;
    height: calc(100vh - 72px) !important;
  }

  /* Login box: fit mobile */
  .login-box { width: 90vw; max-width: 360px; padding: 24px; }
  .login-box h1 { font-size: 22px; }

  /* Modal: full width on mobile */
  .modal-box { max-width: 95vw !important; min-width: unset !important; padding: 16px; }

  /* Panels: reduce padding */
  .panel { padding: 8px; }

  /* Two-column layouts: stack on mobile */
  .two-col-wide-right { grid-template-columns: 1fr !important; }

  /* Buttons: bigger touch targets */
  .btn { min-height: 36px; padding: 8px 12px; font-size: 11px; }

  /* Battle replay: scale down */
  .br-slot { width: 60px !important; height: 90px !important; }
  .br-slot-count { font-size: 9px !important; min-width: 20px !important; }
  .br-slot-hud { padding: 1px 2px !important; gap: 2px !important; }
  .br-slot-hp-bar { height: 2px !important; }
  .br-cmd-wrap { width: 100px !important; }
  .br-cmd-portrait { width: 100px !important; height: 150px !important; }

  /* Army screen: adjust grid */
  .army-roster-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)) !important; }

  /* Tabs: scrollable */
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; font-size: 10px; padding: 6px 10px; }

  /* Filter pills: scrollable */
  .filter-pills { overflow-x: auto; flex-wrap: nowrap; gap: 4px; }
  .filter-pill { font-size: 9px; padding: 3px 8px; white-space: nowrap; }
}

@media (max-width: 480px) {
  /* Extra small: hide resource labels, icon-only nav */
  .resource-bar { gap: 4px; }
  .resource-item .res-value { font-size: 9px; }
  .nav-btn span { display: none; }
  .nav-btn img { width: 20px; height: 20px; }
  .nav-bar { height: 32px; }

  .login-box { padding: 16px; }
  .login-box h1 { font-size: 18px; }

  .br-slot { width: 50px !important; height: 75px !important; }
  .br-cmd-wrap { width: 80px !important; }
  .br-cmd-portrait { width: 80px !important; height: 120px !important; }
}

/* Landscape mobile (short height = phone sideways) */
@media (max-height: 450px) {
  .resource-bar { gap: 8px; padding: 0 8px; height: 32px; }
  .resource-item .res-icon { width: 16px !important; height: 16px !important; }
  .resource-item .res-value { font-size: 10px; }
  .resource-item .res-cap { display: none; }
  .nav-bar { height: 32px; }
  .nav-btn { font-size: 8px; min-height: 32px; }
  .screen-overlay { top: 32px !important; height: calc(100vh - 64px) !important; }
  .screen-overlay.no-top-bar { top: 0 !important; bottom: 0 !important; height: auto !important; padding: 6px !important; }
  .screen-overlay.fullscreen { top: 0 !important; bottom: 0 !important; height: 100vh !important; padding: 0 !important; }

  /* Bigger touch targets for all buttons */
  .btn, button { min-height: 32px; }
  .modal-box { max-width: 90vw !important; max-height: 80vh !important; }
  .modal-box button { min-height: 36px; padding: 8px 16px; }

  /* Notification dismiss buttons */
  .notif-action { min-width: 32px; min-height: 32px; font-size: 14px; }

  /* Battle replay — scale to fill mobile landscape viewport */
  /* Battle replay — maximize vertical space on mobile landscape */
  .br-battlefield { overflow-x: auto; overflow-y: hidden; padding: 0 4px !important; align-items: stretch !important; }
  .br-side { max-width: none !important; flex: 1 !important; display: flex !important; flex-direction: column !important; }
  .br-side-label { font-size: 8px !important; flex-shrink: 0 !important; padding-top: 2px !important; }
  .br-formation { flex: 1 !important; display: flex !important; }
  .br-col { flex: 1 !important; display: flex !important; flex-direction: column !important; }
  .br-col-label { display: none !important; }
  .br-slot { width: 65px !important; height: 98px !important; }
  .br-base-bar { padding: 1px 0 !important; }
  .br-base-track { height: 4px !important; }
  .br-base-hp { font-size: 8px !important; }
  .br-base-label { font-size: 8px !important; }
  .br-slot-count { font-size: 8px !important; }
  .br-cmd-portrait { width: auto !important; height: 70vh !important; aspect-ratio: 2/3 !important; }
  .br-cmd-wrap { width: auto !important; }
  .br-cmd-name { font-size: 7px !important; }

  /* Tutorial panel — compact for mobile landscape */
  .tutorial-panel {
    top: 34px;
    width: 220px;
    max-height: calc(100vh - 68px);
    padding: 8px 10px 6px;
    overflow-y: auto;
  }
  .tutorial-panel::after { display: none; }
  .tutorial-ada-row { margin-bottom: 4px; gap: 6px; }
  .tutorial-ada-portrait { width: 24px; height: 24px; font-size: 12px; }
  .tutorial-ada-name { font-size: 9px; }
  .tutorial-ada-sub { display: none; }
  .tutorial-ada-speech { font-size: 11px; line-height: 1.3; padding: 6px 8px; margin-bottom: 6px; }
  .tutorial-objective { margin-bottom: 4px; gap: 6px; }
  .tutorial-objective-label { font-size: 8px; }
  .tutorial-objective-text { font-size: 11px; }
  .tutorial-action-btn { padding: 8px; font-size: 12px; margin-bottom: 4px; }
  .tutorial-progress { gap: 4px; }
  .tutorial-dot { width: 6px; height: 6px; }
  .tutorial-result-box { padding: 6px 8px; margin-bottom: 6px; }
  .tutorial-result-box div { font-size: 10px !important; }
  .tutorial-result-label { font-size: 8px !important; }

  /* Emergency overlay label — move up on mobile */
  .emergency-power-label { top: 22%; }
  .emergency-power-icon { font-size: 32px; margin-bottom: 4px; }
  .emergency-power-text { font-size: 16px; letter-spacing: 3px; }
  .emergency-power-sub { font-size: 9px; }

  /* Lore popup — compact for mobile landscape */
  .lore-popup-inner { max-height: calc(100vh - 16px); max-width: 92vw; }
  .lore-popup-inner.has-detail { max-width: 92vw; }
  .lore-popup-header { padding: 8px 12px 6px; }
  .lore-popup-title { font-size: 13px; }
  .lore-popup-desc { font-size: 11px; padding: 8px 12px; }
  .lore-popup-lore { font-size: 10px; padding: 8px 12px 10px; }
  .lore-popup-detail { font-size: 9px; padding: 8px 10px; }
  .lore-popup-body.has-detail .lore-popup-detail { flex: 0 0 180px; }

  /* Building info 2-panel — compact for mobile landscape */
  .binfo-tab.has-detail .binfo-detail { flex: 0 0 160px; font-size: 9px; padding-left: 8px; }

  /* All building info tabs: horizontal 2-panel layout on landscape */
  .binfo-tab { max-width: 700px; }
  .binfo-main {
    display: flex;
    flex-direction: row;
    gap: 12px;
  }
  .binfo-info {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
  }
  .binfo-upgrade {
    flex: 0 0 200px;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,0.06);
    padding-left: 12px;
    padding-top: 0;
    margin-top: 0;
  }
  .binfo-lore { display: none; }
}

/* ============================================
   TUTORIAL PANEL — DESKTOP OVERRIDE
   Only applies when NOT in mobile landscape
   ============================================ */
@media (min-height: 451px) {
  .tutorial-panel {
    width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(8, 12, 20, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-left: 2px solid rgba(79, 195, 247, 0.15);
    border-bottom: 1px solid rgba(79, 195, 247, 0.08);
    border-radius: 0 0 0 8px;
  }
  .tutorial-panel::after { display: none; }
  .tutorial-ada-speech {
    background: rgba(15, 20, 30, 0.8);
    border-color: #2a3a50;
  }
}
