/* Achilles Tactics ("TFT × Super Auto Pets Pantheon Auto-Battler") — Stylesheet (`public/css/tactics.css`) */
:root {
  --bg: #050811;
  --card: #0c1324;
  --card-elev: #111b33;
  --border-gold: rgba(212, 175, 55, 0.45);
  --border-subtle: rgba(148, 163, 184, 0.18);
  --gold: #d4af37;
  --gold-bright: #fde047;
  --emerald: #10b981;
  --sky: #38bdf8;
  --crimson: #ef4444;
  --amethyst: #a855f7;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --font-serif: "Playfair Display", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  background: radial-gradient(circle at 50% 0%, #101c38 0%, var(--bg) 70%);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Top Navigation Header */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(12, 19, 36, 0.94);
  border-bottom: 1px solid var(--border-gold);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.mode-switch {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px;
  gap: 3px;
}

.mode-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.18s ease;
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.28), rgba(212, 175, 55, 0.1));
  color: var(--gold-bright);
  border: 1px solid var(--border-gold);
}

.regime-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--sky);
  font-size: 0.7rem;
  font-weight: 600;
}

.regime-pill:hover {
  background: rgba(56, 189, 248, 0.22);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card-elev);
  color: var(--text);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  transition: all 0.16s ease;
}

.nav-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.nav-btn.gold-cta {
  background: linear-gradient(135deg, #d4af37, #b48618);
  color: #050811;
  border-color: var(--gold-bright);
  font-weight: 700;
}

.oracle-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: var(--emerald);
}

/* Main 3-Column Auto-Battler Workspace */
.tactics-workspace {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr) 245px;
  gap: 8px;
  max-width: 1580px;
  margin: 5px auto;
  padding: 0 10px 10px;
}

@media (max-width: 1020px) {
  .tactics-workspace {
    grid-template-columns: 1fr;
  }
}

/* Left Rail: 9 Desk Synergy Trait Tracker */
.rail-panel {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 5px;
}

.panel-title {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.trait-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trait-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(17, 27, 51, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  transition: all 0.18s ease;
}

.trait-row.tier-bronze {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.14);
}

.trait-row.tier-silver {
  border-color: #94a3b8;
  background: rgba(148, 163, 184, 0.18);
}

.trait-row.tier-gold {
  border-color: var(--gold-bright);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.26), rgba(168, 85, 247, 0.14));
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.25);
}

.trait-hex {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%);
  background: #1e293b;
  font-size: 1rem;
  flex-shrink: 0;
}

.trait-row.tier-bronze .trait-hex {
  background: linear-gradient(135deg, #b45309, #78350f);
}

.trait-row.tier-silver .trait-hex {
  background: linear-gradient(135deg, #cbd5e1, #475569);
}

.trait-row.tier-gold .trait-hex {
  background: linear-gradient(135deg, #fde047, #b45309);
}

.trait-info {
  flex: 1;
  min-width: 0;
}

.trait-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trait-bp {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--gold);
}

.trait-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center Arena: HUD + 4x7 Tactical Grid + 8-Slot Bench + 5-Slot Agora Shop */
.center-arena {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px 10px;
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-stat {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.hud-val.gold {
  color: var(--gold-bright);
}

.hud-val.emerald {
  color: var(--emerald);
}

.hud-val.crimson {
  color: var(--crimson);
}

.battle-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-pill {
  background: var(--card-elev);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 3px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.speed-pill.active {
  border-color: var(--sky);
  color: var(--sky);
  background: rgba(56, 189, 248, 0.14);
}

.start-battle-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #04130e;
  border: 1px solid #34d399;
  padding: 5px 13px;
  border-radius: 7px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}

.start-battle-btn:hover {
  filter: brightness(1.08);
}

/* Battlefield Container with 50g Interest Coins on Side Rail */
.battlefield-shell {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  background: radial-gradient(circle at 50% 45%, #162344 0%, #091022 85%);
  border: 1px solid var(--border-gold);
  border-radius: 11px;
  padding: 7px 9px;
  position: relative;
}

.interest-coin-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(5, 8, 17, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 3px;
}

.interest-coin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px dashed rgba(212, 175, 55, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.interest-coin.lit {
  background: radial-gradient(circle at 30% 30%, #fde047, #d4af37 65%, #92400e);
  color: #050811;
  font-weight: 800;
  border: 2px solid #fef08a;
  box-shadow: 0 0 10px rgba(253, 224, 71, 0.65);
  transform: scale(1.05);
}

.board-section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.64rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

/* 4x7 Tactical Grid */
.tactical-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.grid-tile {
  min-height: 41px;
  height: 43px;
  background: rgba(12, 19, 36, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 7px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.grid-tile.enemy-tile {
  background: rgba(45, 14, 28, 0.42);
  border-color: rgba(239, 68, 68, 0.22);
}

.grid-tile.player-tile:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
}

.grid-tile.selected-tile {
  border: 2px solid var(--sky);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

.unit-token {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.unit-stars {
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
}

.unit-stars.stars-1 {
  color: #cbd5e1;
}
.unit-stars.stars-2 {
  color: #38bdf8;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.7);
}
.unit-stars.stars-3 {
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(253, 224, 71, 0.95);
}

.unit-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--gold);
  background: #0f172a;
}

.unit-name-tag {
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

.unit-bars {
  width: 92%;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.hp-bar-track,
.mana-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 2px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: var(--emerald);
  transition: width 0.18s ease;
}

.hp-bar-fill.enemy {
  background: var(--crimson);
}

.mana-bar-fill {
  height: 100%;
  background: var(--sky);
  transition: width 0.18s ease;
}

/* 8-Slot Reserve Bench */
.bench-bar {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 5px 9px;
}

.bench-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-top: 4px;
}

.bench-slot {
  min-height: 44px;
  height: 46px;
  background: var(--card-elev);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.bench-slot.occupied {
  border-style: solid;
  border-color: rgba(212, 175, 55, 0.45);
}

.bench-slot.selected-bench {
  border: 2px solid var(--sky);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

/* 5-Slot Olympus Agora Shop */
.agora-shop {
  background: linear-gradient(180deg, #0f182e 0%, #090f1f 100%);
  border: 1px solid var(--border-gold);
  border-radius: 11px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.odds-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
}

.shop-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shop-action-btn {
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border-gold);
  background: var(--card-elev);
  color: var(--text);
}

.shop-action-btn.reroll-btn {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(212, 175, 55, 0.08));
  color: var(--gold-bright);
}

.shop-action-btn.xp-btn {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(56, 189, 248, 0.08));
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--sky);
}

.shop-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

@media (max-width: 820px) {
  .shop-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .bench-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.shop-card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  position: relative;
}

.shop-card:hover:not(.purchased) {
  transform: translateY(-3px);
  border-color: var(--gold-bright);
}

.shop-card.tier-1 {
  border-top: 3px solid var(--emerald);
}
.shop-card.tier-2 {
  border-top: 3px solid var(--amethyst);
}
.shop-card.tier-3 {
  border-top: 3px solid var(--gold-bright);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.14) 0%, var(--card) 100%);
}

.shop-card.purchased {
  opacity: 0.32;
  pointer-events: none;
}

.merge-alert-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  background: linear-gradient(135deg, #fde047, #d4af37);
  color: #050811;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 17, 0.84);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  max-width: 880px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--gold);
}

.close-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.tab-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--card-elev);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tab-btn.active {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.14);
}

.passport-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.passport-card {
  background: var(--card-elev);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.passport-card.active {
  border-color: var(--border-gold);
}

.genome-bars {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.genome-item {
  background: var(--card-elev);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
}

.toast-banner {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card-elev);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.toast-banner.hidden {
  display: none;
}

/* Full-Viewport HiDPI 2x DPR 60fps Particle & Star-Merge Lightning Canvas */
.tactics-fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 90;
}

/* GTA 6 Council: Live Macro Regime & Ghost Arena Wire */
.macro-wire-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 12px;
  background: rgba(5, 8, 17, 0.95);
  border-bottom: 1px solid rgba(212, 175, 55, 0.28);
  overflow: hidden;
  font-size: 0.65rem;
  max-width: 100vw;
}

.macro-wire-tag {
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
}

.macro-wire-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.macro-wire-track {
  display: inline-block;
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  animation: tacticsWireTicker 48s linear infinite;
}

body.reduced-motion .macro-wire-track {
  animation: none;
}

@keyframes tacticsWireTicker {
  0% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* 4-Studio Council Command Strip */
.council-command-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.15fr) minmax(0, 1.6fr);
  gap: 6px;
  max-width: 1580px;
  margin: 4px auto 0;
  padding: 0 10px;
  align-items: stretch;
}

@media (max-width: 1020px) {
  .council-command-strip {
    grid-template-columns: 1fr;
  }
}

.era-banner-card {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.14), rgba(12, 19, 36, 0.92));
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.era-deity-portrait {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold-bright);
  flex-shrink: 0;
  background: #0f172a;
}

.era-banner-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gold-bright);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.era-wonder-sub {
  font-size: 0.63rem;
  color: var(--sky);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.era-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}

.era-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--emerald));
  transition: width 0.25s ease;
}

.vault-chest-strip {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.vault-chest-btn {
  flex: 1;
  min-width: 82px;
  background: var(--card-elev);
  border: 1px solid var(--border-gold);
  border-radius: 7px;
  padding: 4px 6px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-size: 0.66rem;
  font-weight: 700;
  transition: all 0.15s ease;
}

.vault-chest-btn small {
  font-size: 0.58rem;
  color: var(--sky);
  font-weight: 600;
}

.vault-chest-btn.ready {
  border-color: var(--emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.22);
}

.vault-chest-btn.claimed {
  opacity: 0.55;
  border-color: var(--border-subtle);
  box-shadow: none;
}

.coach-strip-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(12, 19, 36, 0.94));
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 10px;
  padding: 5px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
}

.coach-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.coach-step-badge {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid var(--emerald);
  color: #a7f3d0;
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.coach-telemetry-pill {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: var(--gold-bright);
  background: rgba(5, 8, 17, 0.72);
  padding: 3px 6px;
  border-radius: 5px;
  border-left: 3px solid var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.codex-entry-card {
  background: var(--card-elev);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Laptop 1280x720 & Short-Height Viewport Ergonomics: Fit Both 4x7 Grids + Bench Above 720px Fold */
@media (max-height: 820px) and (min-width: 769px) {
  .top-nav {
    padding: 3px 10px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .brand-subtitle,
  #audioToggleBtn,
  #motionToggleBtn {
    display: none;
  }
  .brand-logo {
    width: 24px;
    height: 24px;
  }
  .brand-title {
    font-size: 0.86rem;
  }
  .mode-btn,
  .regime-pill,
  .nav-btn,
  .oracle-badge {
    padding: 2px 6px;
    font-size: 0.64rem;
  }
  .macro-wire-bar {
    padding: 1px 10px;
    font-size: 0.6rem;
  }
  .council-command-strip {
    margin: 2px auto 0;
    gap: 4px;
  }
  .era-banner-card,
  .vault-chest-strip,
  .coach-strip-card {
    padding: 3px 7px;
  }
  .era-deity-portrait {
    width: 26px;
    height: 26px;
  }
  .era-banner-title {
    font-size: 0.68rem;
  }
  .era-wonder-sub,
  #coachStepDesc,
  .coach-telemetry-pill {
    display: none;
  }
  .vault-chest-strip > .hud-label {
    display: none;
  }
  .vault-chest-btn {
    padding: 2px 5px;
    font-size: 0.62rem;
  }
  .tactics-workspace {
    margin: 3px auto;
    gap: 6px;
    padding: 0 8px 6px;
  }
  .center-arena {
    gap: 4px;
  }
  .hud-bar {
    padding: 3px 8px;
  }
  .hud-val {
    font-size: 0.75rem;
  }
  .battlefield-shell {
    padding: 4px 7px;
    gap: 6px;
  }
  .tactical-grid {
    gap: 3px;
  }
  .grid-tile {
    min-height: 31px;
    height: 33px;
    padding: 1px;
  }
  .unit-avatar {
    width: 15px;
    height: 15px;
  }
  .unit-name-tag {
    font-size: 0.5rem;
  }
  .bench-bar {
    padding: 3px 7px;
  }
  .bench-slot {
    min-height: 34px;
    height: 36px;
  }
}

/* Mobile 390x844 Ergonomics: Put Center Arena (HUD + 4x7 Battlefield + Bench) Above the Fold */
@media (max-width: 768px) {
  body {
    display: flex;
    flex-direction: column;
  }
  .top-nav {
    order: 1;
    padding: 4px 8px;
    gap: 4px;
  }
  .brand-subtitle,
  #openCodexBtn,
  #audioToggleBtn,
  #motionToggleBtn,
  #strictModeBtn {
    display: none;
  }
  .tactics-workspace {
    order: 2;
    display: flex;
    flex-direction: column;
    padding: 0 6px 8px;
    margin: 4px 0;
    gap: 6px;
  }
  .tactics-workspace > .center-arena {
    order: 1;
  }
  .tactics-workspace > aside.rail-panel:first-of-type {
    order: 2;
  }
  .tactics-workspace > aside.rail-panel:last-of-type {
    order: 3;
  }
  .council-command-strip {
    order: 3;
    padding: 0 6px;
  }
  .macro-wire-bar {
    order: 4;
  }
  .battlefield-shell {
    grid-template-columns: 1fr;
    padding: 6px;
    gap: 5px;
  }
  .interest-coin-pillar {
    flex-direction: row;
    padding: 3px 6px;
    gap: 6px;
  }
  .interest-coin {
    width: 24px;
    height: 24px;
    font-size: 0.56rem;
  }
  .tactical-grid {
    gap: 2.5px;
  }
  .grid-tile {
    min-height: 36px;
    height: 38px;
    padding: 1px;
  }
  .unit-avatar {
    width: 17px;
    height: 17px;
  }
  .unit-name-tag {
    font-size: 0.48rem;
  }
  .bench-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .bench-slot {
    min-height: 38px;
    height: 40px;
  }
  .shop-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .genome-bars {
    grid-template-columns: 1fr;
  }
}
