@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@500;600;700;800;900&family=EB+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Playfair+Display:ital,wght@0,600;0,700;1,400;1,600&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --font-title: 'Cinzel Decorative', 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-serif: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-body: 'EB Garamond', 'Plus Jakarta Sans', serif;
  --color-gold: #d4af37;
  --color-gold-bright: #fbbf24;
  --color-gold-deep: #996515;
  --color-wood-dark: #1a120b;
  --color-wood-panel: #271a10;
  --color-parchment: #f4efe4;
  --border-gold: 1px solid rgba(212, 175, 55, 0.45);
  --ui-scale: 1;
  --top-bar-h: 58px;
  --dock-w: 320px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0704;
  font-family: var(--font-body);
  color: #f5eedc;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 1;
}

/* Renaissance Commander's Campaign Desk Panel */
.glass-panel, .campaign-desk {
  background: linear-gradient(180deg, rgba(34, 23, 16, 0.94) 0%, rgba(20, 13, 9, 0.98) 100%);
  border: 1px solid #b8862d;
  border-bottom: 2px solid #78521a;
  border-radius: 8px;
  box-shadow: 0 14px 35px -5px rgba(0, 0, 0, 0.85),
              inset 0 1px 0 rgba(255, 235, 170, 0.22),
              inset 0 0 16px rgba(0, 0, 0, 0.5);
}

/* Top Navigation Bar: 3-Wing Strategic Command Desk */
.top-bar {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  height: var(--top-bar-h, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 80;
  gap: 10px;
  box-sizing: border-box;
}

/* Left Wing: Sovereign Monogram & Crown */
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.game-monogram-seal {
  font-size: 1.25rem;
  color: #fbbf24;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.game-title {
  font-family: var(--font-title);
  font-size: 1.18rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  background: linear-gradient(180deg, #fffbeb 0%, #fcd34d 40%, #d97706 80%, #78350f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.9));
  white-space: nowrap;
  flex-shrink: 0;
}

.sovereign-banner-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, rgba(80, 52, 28, 0.7) 0%, rgba(38, 24, 12, 0.9) 100%);
  border: 1.5px solid #d4af37;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 700;
  color: #fef08a;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 235, 170, 0.25);
  white-space: nowrap;
  flex-shrink: 0;
}

.sovereign-banner-pill:hover {
  background: linear-gradient(180deg, rgba(120, 75, 35, 0.85) 0%, rgba(60, 36, 16, 0.95) 100%);
  border-color: #fef08a;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
  transform: translateY(-1px);
}

.btn-return-menu {
  background: linear-gradient(180deg, rgba(50, 34, 22, 0.8) 0%, rgba(26, 17, 11, 0.95) 100%);
  border: 1px solid #8c6a23;
  color: #e5d8c3;
  font-family: var(--font-serif);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-return-menu:hover {
  background: rgba(80, 55, 30, 0.9);
  border-color: #d4af37;
  color: #fef08a;
}

/* Center Wing: Imperial Treasury & Epoch Cartouche */
.top-bar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.imperial-treasury-pill {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(22, 14, 8, 0.94) 0%, rgba(12, 8, 4, 0.98) 100%);
  border: 1.5px solid #8c6a23;
  border-radius: 6px;
  padding: 3px 8px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
  gap: 4px;
  white-space: nowrap;
}

.treasury-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  cursor: default;
  border-radius: 3px;
  transition: background 0.15s;
}

.treasury-item:hover {
  background: rgba(212, 175, 55, 0.12);
}

.treasury-item .res-icon {
  font-size: 0.92rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.treasury-item .res-val {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.84rem;
  white-space: nowrap;
}

.treasury-item .res-delta {
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.9;
}

.treasury-divider {
  width: 1px;
  height: 18px;
  background: linear-gradient(180deg, transparent, rgba(212, 175, 55, 0.4), transparent);
  flex-shrink: 0;
}

.btn-epoch {
  background: linear-gradient(180deg, rgba(85, 55, 28, 0.75) 0%, rgba(45, 28, 14, 0.92) 100%);
  border: 1.5px solid #d4af37;
  color: #fef08a;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.74rem;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 240, 180, 0.25);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-epoch:hover {
  background: linear-gradient(180deg, #d4af37 0%, #b45309 100%);
  color: #1a0f04;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

/* Right Wing: Mode Switcher & Chancelleries */
.top-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.mode-tabs {
  display: flex;
  gap: 3px;
  background: rgba(14, 9, 6, 0.9);
  padding: 3px;
  border-radius: 5px;
  border: 1px solid #78521a;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7);
}

.btn-tab {
  background: transparent;
  border: 1px solid transparent;
  color: #cbb89d;
  font-family: var(--font-serif);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.btn-tab:hover {
  color: #fef08a;
  background: rgba(80, 52, 28, 0.45);
  border-color: rgba(212, 175, 55, 0.3);
}

.btn-tab.active {
  background: linear-gradient(180deg, #d4af37 0%, #b45309 85%, #78350f 100%);
  color: #170d04;
  font-weight: 800;
  border: 1px solid #fef08a;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.campaign-hud-group,
.rts-hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-camp-action {
  background: linear-gradient(180deg, rgba(42, 28, 18, 0.8) 0%, rgba(22, 14, 9, 0.95) 100%);
  border: 1px solid #8c6a23;
  color: #e5d8c3;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.74rem;
  padding: 5px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-camp-action:hover {
  background: rgba(70, 48, 28, 0.9);
  border-color: #d4af37;
  color: #fff;
  transform: translateY(-1px);
}

.btn-camp-action.btn-scale-ui {
  border-color: #f59e0b;
  color: #fef08a;
  background: linear-gradient(180deg, rgba(80, 50, 20, 0.85) 0%, rgba(35, 20, 10, 0.95) 100%);
}

/* BOTTOM-RIGHT: Imperial Turn Medallion & Season Astrolabe */
.imperial-turn-seal {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 85;
  display: flex;
  align-items: center;
  pointer-events: auto;
  user-select: none;
}

.turn-seal-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, rgba(28, 18, 11, 0.96) 0%, rgba(14, 9, 5, 0.98) 100%);
  border: 2px solid #d4af37;
  border-radius: 10px;
  padding: 6px 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85),
              0 0 20px rgba(180, 83, 9, 0.3),
              inset 0 1px 0 rgba(255, 235, 170, 0.25),
              inset 0 0 12px rgba(0, 0, 0, 0.6);
  gap: 3px;
}

.turn-season-badge {
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fffbeb;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.turn-counter-badge {
  font-family: var(--font-serif);
  font-size: 0.70rem;
  color: #fbbf24;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  margin-bottom: 3px;
  white-space: nowrap;
}

.btn-end-turn-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #d97706 0%, #b45309 60%, #78350f 100%);
  border: 1.5px solid #fef08a;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.btn-end-turn-seal:hover {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.75), 0 0 15px rgba(254, 240, 138, 0.5);
}

.btn-end-turn-seal:active {
  transform: translateY(1px);
}

.seal-inner-circle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.seal-inner-circle .seal-icon {
  font-size: 1.0rem;
}

.seal-inner-circle .seal-text {
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

/* RTS Top Bar */
.rts-hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scenario-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-select {
  background: linear-gradient(180deg, rgba(32, 22, 14, 0.9) 0%, rgba(18, 12, 8, 0.95) 100%);
  color: #f5eedc;
  border: 1px solid #8c6a23;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: var(--font-serif);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropdown-select:hover {
  border-color: #d4af37;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  background: rgba(14, 9, 6, 0.7);
  border: 1px solid #6b4c20;
  border-radius: 4px;
  padding: 3px 10px;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.stat-label {
  font-family: var(--font-serif);
  font-size: 0.68rem;
  text-transform: uppercase;
  color: #c4b5a0;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.stat-val {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: #fef08a;
}

/* Speed Controls */
.speed-group {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}

.btn-icon.active {
  background: #f59e0b;
  color: #0f172a;
  border-color: #f59e0b;
}

/* Province Inspector (4X Campaign Left Dock) */
.left-dock {
  position: absolute;
  top: calc(var(--top-bar-h, 58px) + 12px);
  left: 14px;
  width: var(--dock-w, 320px);
  max-height: calc(100vh - var(--top-bar-h, 58px) - 24px);
  z-index: 75;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.province-card {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - var(--top-bar-h, 58px) - 26px);
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #8c6a23;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 235, 170, 0.2);
}

.prov-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.prov-flag {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.prov-title-wrap {
  flex: 1;
  min-width: 0;
}

.prov-title-wrap h3 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fffbeb;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prov-region {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  color: #d4c0a5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.btn-prov-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 4px;
  color: #fbbf24;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 7px;
  transition: all 0.2s;
  line-height: 1.1;
  flex-shrink: 0;
}

.btn-prov-close:hover {
  background: #b91c1c;
  color: #fff;
  border-color: #ef4444;
}

/* Province Tab Bar */
.prov-tab-bar {
  display: flex;
  gap: 4px;
  margin: 2px 0 4px 0;
}

.prov-tab-btn {
  flex: 1;
  background: rgba(28, 18, 11, 0.75);
  border: 1px solid #78521a;
  color: #c4b5a0;
  padding: 5px 4px;
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  white-space: nowrap;
}

.prov-tab-btn:hover {
  color: #fef08a;
  border-color: #d4af37;
  background: rgba(60, 40, 20, 0.85);
}

.prov-tab-btn.active {
  background: linear-gradient(180deg, #d4af37 0%, #b45309 100%);
  color: #170d04;
  border-color: #fef08a;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

/* Scrollable Province Body */
.prov-card-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: #d4af37 rgba(26, 17, 11, 0.8);
}

.prov-card-body::-webkit-scrollbar {
  width: 4px;
}
.prov-card-body::-webkit-scrollbar-thumb {
  background: #d4af37;
  border-radius: 2px;
}

.yield-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
}

.yield-box {
  font-family: var(--font-serif);
  font-size: 0.74rem;
  color: #cbd5e1;
}

.buildings-section h4, .recruit-sec h4 {
  font-family: var(--font-serif);
  font-size: 0.74rem;
  font-weight: 700;
  color: #fef08a;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.building-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge-bld {
  background: rgba(45, 30, 18, 0.8);
  border: 1px solid #8c6a23;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 0.66rem;
  font-weight: 600;
  color: #f5eedc;
}

.prov-actions, .recruit-sec {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.btn-action {
  background: linear-gradient(180deg, rgba(38, 25, 16, 0.85) 0%, rgba(20, 13, 8, 0.95) 100%);
  border: 1px solid #78521a;
  color: #e5d8c3;
  padding: 5px 9px;
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.btn-action:hover {
  background: rgba(70, 46, 26, 0.95);
  color: #fef08a;
  border-color: #d4af37;
  transform: translateX(2px);
}

.btn-action.active {
  background: rgba(180, 83, 9, 0.4);
  color: #fef08a;
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
  font-weight: 700;
}

.btn-recruit-prov {
  background: linear-gradient(180deg, rgba(50, 32, 18, 0.85) 0%, rgba(26, 17, 10, 0.95) 100%);
  border-color: #8c6a23;
  color: #fef08a;
}

.btn-recruit-prov:hover {
  background: linear-gradient(180deg, #b45309 0%, #78350f 100%);
  color: #ffffff;
  border-color: #fbbf24;
}

.enemy-prov-notice {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: #f87171;
  font-style: italic;
  padding: 6px 0;
}

/* Selected Unit Panel (RTS) */
.unit-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unit-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-badge {
  font-size: 1.6rem;
}

.unit-titles h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.unit-cat {
  font-size: 0.7rem;
  color: #94a3b8;
}

.unit-bars {
  background: rgba(30, 41, 59, 0.5);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.unit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.no-selection {
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  padding: 14px 0;
}

/* Recruitment Bottom Bar */
.bottom-dock {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  z-index: 10;
}

.recruit-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
}

.recruit-buttons {
  display: flex;
  gap: 8px;
}

.btn-recruit {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-recruit:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: #3b82f6;
  transform: translateY(-2px);
}

.recruit-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.recruit-name {
  font-size: 0.78rem;
  font-weight: 600;
}

.recruit-cost {
  font-size: 0.68rem;
  color: #fbbf24;
  font-weight: 700;
}

/* Battle Chronicle */
.right-dock {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 290px;
  max-height: 190px;
  padding: 12px;
  z-index: 10;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: bottom 0.25s ease;
}

/* In 4X Campaign mode, dock moves above the imperial turn seal */
.mode-campaign .right-dock {
  bottom: 125px;
}

.log-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 6px;
}

#battle-log-entries {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 150px;
}

.log-item {
  font-size: 0.72rem;
  color: #cbd5e1;
  line-height: 1.3;
}

.log-time {
  color: #64748b;
  font-size: 0.65rem;
  margin-right: 4px;
}

/* Modals Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 350;
}

.modal-window {
  width: 90%;
  max-width: 920px;
  max-height: 85vh;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.modal-head h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fbbf24;
}

.btn-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-close:hover {
  color: #fff;
}

/* Pre-Battle Clash Screen (Total War Style) */
.pre-battle-content {
  width: 90%;
  max-width: 960px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.pre-battle-header {
  text-align: center;
}

.pre-battle-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 1px;
}

.battle-sub {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
}

.armies-comparison {
  display: grid;
  grid-template-columns: 1fr 180px 1fr;
  gap: 20px;
  align-items: center;
}

.army-side {
  background: rgba(30, 41, 59, 0.6);
  border-radius: 10px;
  border-top: 4px solid #3b82f6;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flag-icon {
  font-size: 2rem;
}

.side-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.fac-title {
  font-size: 0.75rem;
  color: #94a3b8;
}

.side-troops {
  display: flex;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.6);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.roster-list {
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.balance-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.balance-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
}

.power-bar {
  width: 100%;
  height: 24px;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.power-att, .power-def {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}

.vs-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fbbf24;
}

.pre-battle-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.btn-battle {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.auto-btn {
  background: rgba(51, 65, 85, 0.8);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.auto-btn:hover {
  background: #475569;
  color: #fff;
}

.rts-btn {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  border: 1px solid #f59e0b;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.4);
}

.rts-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(217, 119, 6, 0.6);
}

/* Post-Battle Modal */
.post-battle-content {
  width: 90%;
  max-width: 650px;
  padding: 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.victory-banner h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fbbf24;
}

.debrief-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.debrief-box {
  background: rgba(30, 41, 59, 0.6);
  padding: 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gen-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
}

.troop-count {
  font-size: 0.78rem;
  color: #94a3b8;
}

.btn-return {
  background: #2563eb;
  color: #fff;
  border: 1px solid #60a5fa;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  margin: 0 auto;
}

/* Tech Tree Grid */
.epoch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.epoch-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epoch-current {
  border-color: #fbbf24;
  background: rgba(245, 158, 11, 0.1);
}

.epoch-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.epoch-icon {
  font-size: 1.8rem;
}

.epoch-card-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.epoch-period {
  font-size: 0.7rem;
  color: #94a3b8;
}

.epoch-desc {
  font-size: 0.75rem;
  color: #cbd5e1;
  line-height: 1.3;
}

.epoch-unlocks {
  font-size: 0.72rem;
  color: #93c5fd;
}

.epoch-status {
  padding: 4px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.epoch-status.current {
  background: #f59e0b;
  color: #0f172a;
}

.epoch-status.past {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.btn-advance-epoch {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #0f172a;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
}

/* Diplomacy Grid */
.diplomacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.diplo-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diplo-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diplo-banner {
  font-size: 1.8rem;
}

.diplo-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.diplo-leader {
  font-size: 0.72rem;
  color: #94a3b8;
}

.diplo-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.status-badge {
  border: 1px solid;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 800;
}

.diplo-actions {
  display: flex;
  gap: 6px;
}

.btn-diplo {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

.btn-peace {
  background: #10b981;
  color: #fff;
}

.btn-war {
  background: #ef4444;
  color: #fff;
}

.btn-alliance {
  background: #3b82f6;
  color: #fff;
}

/* Custom Civilization Builder (Empire Earth) */
.civ-modal-content {
  max-width: 860px;
}

.civ-builder-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.civ-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background: rgba(15, 23, 42, 0.55);
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-text {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  color: #f8fafc;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.85rem;
}

.points-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 58, 138, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.4);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #93c5fd;
}

.points-badge {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(15, 23, 42, 0.7);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.talents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.talent-item {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.talent-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.talent-name {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
}

.talent-val-badge {
  background: #f59e0b;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 4px;
}

.talent-slider {
  accent-color: #f59e0b;
  cursor: pointer;
}

.talent-item small {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.2;
}

.civ-footer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ==========================================================================
   BAROQUE MAIN MENU SCREEN (Crónica de Sangre y Pólvora • Historical Soul)
   ========================================================================== */

.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(14, 9, 6, 0.42) 0%, rgba(8, 5, 3, 0.86) 100%),
              url('../assets/menu_bg.jpg') center/cover no-repeat;
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

#menu-fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.menu-decor-border {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: min(740px, calc(100vw - 16px));
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  background: linear-gradient(135deg, rgba(26, 17, 11, 0.94) 0%, rgba(13, 8, 5, 0.98) 100%);
  border: 2px solid #d4af37;
  border-radius: 6px;
  padding: clamp(10px, 1.8vh, 22px) clamp(16px, 3vw, 32px);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.92),
              0 0 40px rgba(180, 83, 9, 0.28),
              inset 0 0 25px rgba(0, 0, 0, 0.8),
              inset 0 0 0 1px rgba(255, 235, 170, 0.2);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #d4af37 rgba(26, 17, 11, 0.8);
}

.menu-decor-border::-webkit-scrollbar {
  width: 5px;
}
.menu-decor-border::-webkit-scrollbar-thumb {
  background: #d4af37;
  border-radius: 3px;
}

/* Ornate Corner Brackets */
.menu-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #fef08a;
  pointer-events: none;
}

.corner-tl { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.corner-tr { top: 6px; right: 6px; border-left: none; border-bottom: none; }
.corner-bl { bottom: 6px; left: 6px; border-right: none; border-top: none; }
.corner-br { bottom: 6px; right: 6px; border-left: none; border-top: none; }

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.menu-header-cartouche {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.menu-crest-frame {
  width: clamp(48px, 6.2vh, 60px);
  height: clamp(48px, 6.2vh, 60px);
  min-width: 48px;
  min-height: 48px;
  max-width: 60px;
  max-height: 60px;
  border-radius: 50%;
  border: 2px solid #d4af37;
  box-shadow: 0 0 18px rgba(212, 175, 55, 0.4), inset 0 0 8px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  margin-bottom: 2px;
  background: #1a120b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-crest-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: contrast(1.1) brightness(1.05);
}

.menu-motto-ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: clamp(0.62rem, 1.1vh, 0.72rem);
  font-weight: 700;
  letter-spacing: 2px;
  color: #fef08a;
  text-transform: uppercase;
  background: linear-gradient(90deg, transparent, rgba(140, 106, 35, 0.35), transparent);
  padding: 2px 16px;
  margin-top: 2px;
  border-top: 1px solid rgba(212, 175, 55, 0.35);
  border-bottom: 1px solid rgba(212, 175, 55, 0.35);
}

.motto-flourish {
  color: #d4af37;
  font-size: 0.75rem;
}

.menu-main-title {
  font-family: var(--font-title);
  font-size: clamp(1.6rem, 3.2vh, 2.3rem);
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(180deg, #fffbeb 0%, #fcd34d 40%, #d97706 75%, #78350f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  margin: 2px 0 0 0;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.95));
}

.menu-sub-title {
  font-family: var(--font-serif);
  font-size: clamp(0.75rem, 1.3vh, 0.95rem);
  font-weight: 700;
  letter-spacing: clamp(2.5px, 0.4vw, 4px);
  color: #fef08a;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  margin-top: 1px;
}

.menu-tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(0.74rem, 1.2vh, 0.88rem);
  color: #d4c0a5;
  margin-top: 2px;
}

.menu-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 82%;
  margin: clamp(6px, 1.1vh, 12px) 0 clamp(8px, 1.3vh, 14px) 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b8862d, transparent);
}

.divider-gem {
  color: #fef08a;
  font-size: 0.8rem;
  filter: drop-shadow(0 0 4px #fbbf24);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1vh, 9px);
  width: 100%;
}

.btn-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: clamp(6px, 1.0vh, 9px) 16px;
  background: linear-gradient(90deg, rgba(38, 26, 17, 0.92) 0%, rgba(20, 13, 8, 0.96) 100%);
  border: 1px solid #78521a;
  border-left: 4px solid #d4af37;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 235, 170, 0.1);
}

.btn-menu:hover {
  background: linear-gradient(90deg, rgba(62, 42, 26, 0.96) 0%, rgba(32, 20, 12, 0.98) 100%);
  border-color: #d4af37;
  border-left-color: #fef08a;
  transform: translateX(4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.85),
              0 0 18px rgba(212, 175, 55, 0.22),
              inset 0 0 12px rgba(212, 175, 55, 0.12);
}

/* 3D Wax Seal Medallions */
.menu-seal {
  width: clamp(32px, 4.4vh, 38px);
  height: clamp(32px, 4.4vh, 38px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7),
              inset 0 2px 2px rgba(255, 255, 255, 0.3),
              inset 0 -2px 3px rgba(0, 0, 0, 0.5);
}

.seal-gold {
  background: radial-gradient(circle, #fcd34d 0%, #b45309 80%, #78350f 100%);
  border: 1.5px solid #fef08a;
}

.seal-ruby {
  background: radial-gradient(circle, #f87171 0%, #b91c1c 80%, #450a0a 100%);
  border: 1.5px solid #fca5a5;
}

.seal-bronze {
  background: radial-gradient(circle, #d97706 0%, #92400e 80%, #451a03 100%);
  border: 1.5px solid #fde68a;
}

.seal-emerald {
  background: radial-gradient(circle, #4ade80 0%, #15803d 80%, #052e16 100%);
  border: 1.5px solid #86efac;
}

.seal-sapphire {
  background: radial-gradient(circle, #60a5fa 0%, #1d4ed8 80%, #172554 100%);
  border: 1.5px solid #93c5fd;
}

.seal-brass {
  background: radial-gradient(circle, #fbbf24 0%, #a16207 80%, #422006 100%);
  border: 1.5px solid #fef08a;
}

.seal-icon {
  font-size: clamp(1.0rem, 1.8vh, 1.2rem);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.btn-menu-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.btn-menu-title {
  font-family: var(--font-serif);
  font-size: clamp(0.88rem, 1.4vh, 1.02rem);
  font-weight: 700;
  color: #f5eedc;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.btn-menu:hover .btn-menu-title {
  color: #fef08a;
}

.btn-menu-desc {
  font-family: var(--font-body);
  font-size: clamp(0.72rem, 1.15vh, 0.82rem);
  color: #bba689;
  line-height: 1.25;
}

.menu-btn-arrow {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: #78521a;
  transition: all 0.2s;
  margin-left: auto;
}

.btn-menu:hover .menu-btn-arrow {
  color: #fef08a;
  transform: translateX(3px);
}

.menu-footer {
  margin-top: clamp(8px, 1.3vh, 14px);
  font-family: var(--font-serif);
  font-size: clamp(0.64rem, 1.05vh, 0.72rem);
  color: #8c7860;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Return to Menu Button in Top Bar */
.btn-return-menu {
  background: linear-gradient(180deg, rgba(62, 42, 26, 0.8) 0%, rgba(35, 23, 14, 0.95) 100%);
  border: 1px solid #c89b3c;
  color: #fef08a;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 235, 170, 0.2);
}

.btn-return-menu:hover {
  background: linear-gradient(180deg, #d4af37 0%, #b45309 100%);
  color: #170d04;
  border-color: #fef08a;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.45);
}

/* ==========================================================================
   HISTORICAL SCENARIOS MODAL
   ========================================================================== */

.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 14px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

.scenario-card-item {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.scenario-card-item:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: #fbbf24;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.scen-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scen-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fbbf24;
}

.scen-card-era {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fef08a;
}

.scen-card-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.35;
  flex-grow: 1;
}

.scen-card-btn {
  align-self: flex-end;
  background: #d97706;
  border: none;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.scen-card-btn:hover {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* ==========================================================================
   CUSTOM BATTLE & ARMY BUILDER MODAL
   ========================================================================== */

.custom-battle-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.cb-controls-bar {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 14px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  align-items: center;
}

.cb-control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cb-control-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
}

.cb-budget-buttons {
  display: flex;
  gap: 6px;
}

.btn-budget-pill {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-budget-pill.active, .btn-budget-pill:hover {
  background: #d97706;
  border-color: #fbbf24;
  color: #fff;
}

.cb-armies-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.cb-army-col {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cb-army-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.cb-army-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.cb-cost-badge {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
}

.cb-roster-list {
  min-height: 120px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cb-roster-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 6px 10px;
}

.cb-roster-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.cb-roster-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-roster-mod {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(30, 41, 59, 0.8);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-roster-mod:hover {
  background: #d97706;
  border-color: #fbbf24;
}

.cb-unit-shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.cb-shop-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.2s;
}

.cb-shop-card:hover {
  border-color: #fbbf24;
  background: rgba(30, 41, 59, 0.8);
}

.cb-shop-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.cb-shop-cost {
  color: #fbbf24;
  font-size: 0.75rem;
}

.cb-shop-desc {
  font-size: 0.68rem;
  color: #94a3b8;
  line-height: 1.2;
}

.cb-env-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cb-launch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.btn-cb-launch {
  background: linear-gradient(135deg, #d97706, #b45309);
  border: 1px solid #fbbf24;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px 28px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(217, 119, 6, 0.4);
  transition: all 0.2s;
}

.btn-cb-launch:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.5);
}

/* ==========================================================================
   BAROQUE TACTICAL COMMAND SUITE & LIVE ANALYTICS DRAWER
   ========================================================================== */

.btn-tactical-toggle {
  background: rgba(217, 119, 6, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-tactical-toggle:hover,
.btn-tactical-toggle.active {
  background: rgba(245, 158, 11, 0.35);
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
  transform: translateY(-1px);
}

.tactical-drawer {
  position: absolute;
  top: 84px;
  left: 16px;
  right: 16px;
  z-index: 45;
  background: rgba(11, 17, 32, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(212, 175, 55, 0.35);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 25px rgba(212, 175, 55, 0.15);
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.tactical-drawer.open {
  max-height: 520px;
  opacity: 1;
  pointer-events: auto;
}

.drawer-inner {
  padding: 18px 24px;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #fbbf24;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.drawer-filigree {
  font-size: 1.2rem;
  color: #d4af37;
}

.btn-drawer-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-drawer-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

.drawer-content-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.drawer-col {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
}

.drawer-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.drawer-btn-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-drawer-action {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.btn-drawer-action:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: #fbbf24;
  transform: translateY(-1px);
}

.btn-drawer-action .b-icon {
  font-size: 1.2rem;
}

.btn-drawer-action strong {
  display: block;
  font-size: 0.85rem;
  color: #f8fafc;
}

.btn-drawer-action small {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
}

.drawer-stat-card {
  background: rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: #cbd5e1;
}

.drawer-stat-row strong {
  font-size: 13px;
}

.btn-center-wagon {
  width: 100%;
}

/* =========================================================
   4X THEATER NAVIGATION & MAPMODES FLOATING BAR (AoH3 Style)
   ========================================================= */
.campaign-theaters-bar {
  position: absolute;
  bottom: 18px;
  top: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(26, 17, 11, 0.94) 0%, rgba(14, 9, 5, 0.98) 100%);
  backdrop-filter: blur(8px);
  border: 1.5px solid #8c6a23;
  border-radius: 20px;
  padding: 4px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 235, 170, 0.2);
}

.theaters-cluster,
.mapmodes-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
}

.theater-label {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  margin-right: 2px;
  white-space: nowrap;
}

.btn-theater-pill,
.btn-mapmode-pill {
  background: rgba(38, 25, 16, 0.85);
  border: 1px solid #78521a;
  color: #e5d8c3;
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn-theater-pill:hover,
.btn-mapmode-pill:hover {
  background: rgba(70, 46, 26, 0.95);
  border-color: #d4af37;
  color: #fef08a;
  transform: translateY(-1px);
}

.btn-theater-pill:active,
.btn-mapmode-pill:active {
  transform: scale(0.96);
}

.btn-mapmode-pill.active {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #fef08a;
  color: #fff;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

/* UI Scale Settings Modal */
.scale-modal-window {
  max-width: 440px;
  width: 90vw;
  background: linear-gradient(135deg, rgba(28, 18, 11, 0.96) 0%, rgba(14, 9, 5, 0.98) 100%);
  border: 2px solid #d4af37;
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.9), 0 0 25px rgba(212,175,55,0.3);
  box-sizing: border-box;
}

.scale-options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 16px 0;
}

.btn-scale-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(38, 25, 16, 0.85);
  border: 1px solid #78521a;
  border-radius: 5px;
  color: #e5d8c3;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-scale-option:hover {
  background: rgba(70, 46, 26, 0.95);
  border-color: #d4af37;
  color: #fef08a;
  transform: translateX(3px);
}

.btn-scale-option.active {
  background: linear-gradient(180deg, #d4af37 0%, #b45309 100%);
  color: #170d04;
  border-color: #fef08a;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

/* =========================================================
   CODEX BELLUM: BAROQUE ENCYCLOPEDIA & MILITARY MANUAL
   ========================================================= */
.codex-window {
  max-width: 1040px;
  width: 90vw;
  height: 85vh;
  background: radial-gradient(circle at top left, #1e1b18, #0d0c0a 80%);
  border: 2px solid #d4af37;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), inset 0 0 20px rgba(212, 175, 55, 0.15);
  display: flex;
  flex-direction: column;
}

.codex-layout {
  display: flex;
  flex-direction: column;
  height: calc(100% - 60px);
  padding: 0 16px 16px 16px;
  gap: 12px;
}

.codex-vol-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 8px;
  overflow-x: auto;
}

.codex-vol-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 26, 20, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.codex-vol-tab:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #fbbf24;
  color: #fff;
}

.codex-vol-tab.active {
  background: linear-gradient(135deg, #78350f, #451a03);
  border-color: #fbbf24;
  color: #fbbf24;
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.25);
}

.codex-main-split {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.codex-chap-nav {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 6px;
}

.codex-chap-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 18, 14, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  transition: all 0.2s;
}

.codex-chap-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: #d4af37;
  color: #fff;
}

.codex-chap-btn.active {
  background: rgba(120, 53, 15, 0.4);
  border-color: #fbbf24;
  color: #fbbf24;
  font-weight: 700;
}

.codex-reading-content {
  flex: 1;
  background: #fdfbf7;
  color: #1c1917;
  border-radius: 8px;
  padding: 24px 32px;
  overflow-y: auto;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.5);
  border: 1px solid #dcd3be;
  font-family: 'Plus Jakarta Sans', serif;
  line-height: 1.65;
}

.codex-parchment-header {
  border-bottom: 2px solid #d4af37;
  padding-bottom: 12px;
  margin-bottom: 16px;
  text-align: center;
}

.codex-vol-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.codex-chap-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  color: #78350f;
  margin: 6px 0;
}

.codex-ornament {
  font-size: 0.75rem;
  color: #b45309;
}

.codex-chap-body h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  color: #451a03;
  margin: 14px 0 6px 0;
}

.codex-chap-body p {
  font-size: 0.92rem;
  color: #292524;
  margin-bottom: 10px;
}

.codex-tip-box {
  background: #fef3c7;
  border-left: 4px solid #d97706;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #78350f;
  margin: 12px 0;
}

.regiment-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f5eedc;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #e7dcba;
  margin: 12px 0;
  font-size: 0.85rem;
  color: #451a03;
}

/* =========================================================
   P2P WEBRTC MULTIPLAYER MODAL
   ========================================================= */
.p2p-textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px;
  color: #38bdf8;
  font-family: monospace;
  font-size: 11px;
  resize: vertical;
  box-sizing: border-box;
}

/* =========================================================
   3D GLOBE PROJECTION & VIEW TOGGLE
   ========================================================= */
#globe-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  display: none;
  background: radial-gradient(circle at center, #0a0f1d 0%, #030712 100%);
  overflow: hidden;
}

.btn-view-toggle {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-view-toggle:hover {
  background: #38bdf8;
  color: #0f172a;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.btn-view-toggle.active {
  background: #0284c7;
  color: #fff;
  border-color: #7dd3fc;
}

/* Top bar quick launch actions */
.btn-quick-launch {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-quick-launch:hover {
  background: rgba(217, 119, 6, 0.25);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* ==========================================================================
   CAMPAIGN SETUP MODAL - CÁMARA DEL CONSEJO DE ESTADO
   ========================================================================== */

#campaign-setup-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 5, 3, 0.9);
  backdrop-filter: blur(10px);
  padding: 16px;
  box-sizing: border-box;
}

.campaign-setup-window {
  width: 100%;
  max-width: 1080px;
  max-height: calc(100vh - 28px);
  background: linear-gradient(135deg, rgba(24, 15, 9, 0.98) 0%, rgba(12, 7, 4, 0.99) 100%);
  border: 2px solid #d4af37;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.95),
              0 0 50px rgba(180, 83, 9, 0.35),
              inset 0 0 30px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.35);
  background: linear-gradient(90deg, rgba(50, 32, 18, 0.6) 0%, rgba(20, 12, 6, 0.8) 100%);
}

.setup-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-header-title h2 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: #fef08a;
  margin: 0;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.setup-header-title span {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: #d4c0a5;
  font-style: italic;
}

.btn-setup-close {
  background: transparent;
  border: 1px solid #8c6a23;
  color: #fef08a;
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-setup-close:hover {
  background: #b91c1c;
  border-color: #ef4444;
  color: #fff;
}

/* Two-column layout */
.setup-body {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 18px;
  padding: 16px 22px;
  overflow-y: auto;
  max-height: calc(100vh - 165px);
  scrollbar-width: thin;
  scrollbar-color: #d4af37 rgba(26, 17, 11, 0.8);
}

.setup-column-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fef08a;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(140, 106, 35, 0.4);
  padding-bottom: 5px;
}

/* Scenario Cards */
.scenario-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-card {
  background: rgba(30, 20, 12, 0.7);
  border: 1px solid #78521a;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.scenario-card:hover {
  background: rgba(55, 36, 20, 0.85);
  border-color: #d4af37;
  transform: translateX(4px);
}

.scenario-card.active {
  background: linear-gradient(135deg, rgba(80, 50, 22, 0.95) 0%, rgba(45, 26, 12, 0.98) 100%);
  border: 2px solid #f59e0b;
  border-left: 5px solid #fbbf24;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.45), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.scenario-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.scenario-card-title {
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: #fffbeb;
  font-weight: 700;
}

.scenario-badge {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(180, 83, 9, 0.35);
  color: #fef08a;
  border: 1px solid #d4af37;
}

.scenario-card-desc {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: #c4b5a0;
  line-height: 1.35;
  margin-top: 4px;
}

.scenario-meta-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.72rem;
  font-family: var(--font-serif);
  color: #fbbf24;
}

/* Faction Grid */
.factions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.btn-faction-pill {
  background: rgba(26, 17, 10, 0.8);
  border: 1px solid #6b4c1b;
  border-radius: 5px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s;
  color: #e5d8c3;
}

.btn-faction-pill:hover {
  background: rgba(60, 40, 20, 0.9);
  border-color: #d4af37;
  transform: translateY(-2px);
}

.btn-faction-pill.active {
  background: linear-gradient(180deg, rgba(80, 50, 22, 0.95) 0%, rgba(45, 28, 12, 0.98) 100%);
  border: 2px solid #f59e0b;
  color: #fef08a;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.btn-faction-pill .f-banner {
  font-size: 1.15rem;
}

.btn-faction-pill .f-name {
  font-size: 0.67rem;
  font-family: var(--font-serif);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 66px;
}

/* Faction Sovereign Dossier */
.sovereign-dossier-card {
  background: linear-gradient(135deg, rgba(28, 18, 11, 0.9) 0%, rgba(16, 10, 6, 0.95) 100%);
  border: 1px solid #8c6a23;
  border-radius: 6px;
  padding: 12px 14px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6);
}

.dossier-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(140, 106, 35, 0.3);
  padding-bottom: 6px;
}

.dossier-crest {
  font-size: 2.0rem;
  width: 44px;
  height: 44px;
  background: rgba(140, 106, 35, 0.2);
  border: 1px solid #d4af37;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.dossier-leader-info h3 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: #fef08a;
  margin: 0;
}

.dossier-leader-info span {
  font-family: var(--font-serif);
  font-size: 0.74rem;
  color: #d4c0a5;
  font-style: italic;
}

.dossier-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.78rem;
  color: #fbbf24;
  margin: 4px 0 8px 0;
  padding-left: 8px;
  border-left: 2px solid #d4af37;
}

.dossier-briefing {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: #c4b5a0;
  line-height: 1.4;
  margin-bottom: 8px;
}

.dossier-section-title {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fef08a;
  letter-spacing: 0.8px;
  margin: 6px 0 3px 0;
}

.dossier-traits-text {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  color: #86efac;
  background: rgba(6, 78, 59, 0.25);
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 5px 8px;
  border-radius: 4px;
}

.dossier-victory-goals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.victory-goal-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.74rem;
  font-family: var(--font-body);
  color: #e5d8c3;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 6px;
  border-radius: 4px;
}

.victory-goal-item strong {
  color: #fbbf24;
  font-family: var(--font-serif);
  min-width: 90px;
}

/* Bottom Action Bar */
.setup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  background: linear-gradient(90deg, rgba(20, 12, 6, 0.95) 0%, rgba(35, 22, 12, 0.9) 100%);
  border-top: 1px solid rgba(212, 175, 55, 0.35);
}

.btn-setup-custom-civ {
  background: rgba(45, 30, 18, 0.8);
  border: 1px solid #d4af37;
  color: #fef08a;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-setup-custom-civ:hover {
  background: #b45309;
  color: #fff;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.btn-setup-launch-main {
  background: linear-gradient(180deg, #d97706 0%, #b45309 60%, #78350f 100%);
  border: 2px solid #fbbf24;
  color: #ffffff;
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 8px 24px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(217, 119, 6, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-setup-launch-main:hover {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.7);
}

/* UI Scale & Desktop Display Density Modal */
.scale-modal-window {
  max-width: 580px;
  width: 90%;
  padding: 16px 20px;
}

.scale-modal-desc {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: #d4c0a5;
  line-height: 1.45;
  margin-bottom: 14px;
}

.scale-options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-scale-option {
  background: linear-gradient(180deg, rgba(38, 25, 16, 0.85) 0%, rgba(20, 13, 8, 0.95) 100%);
  border: 1px solid #78521a;
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.btn-scale-option strong {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  color: #fef08a;
}

.btn-scale-option small {
  font-family: var(--font-body);
  font-size: 0.74rem;
  color: #94a3b8;
}

.btn-scale-option:hover {
  background: linear-gradient(180deg, rgba(80, 52, 28, 0.95) 0%, rgba(45, 28, 14, 1) 100%);
  border-color: #d4af37;
  transform: translateX(4px);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}

.btn-scale-option:active {
  transform: translateX(2px);
}


/* ==========================================================================
   DESKTOP RESOLUTION SCALABILITY BREAKPOINTS
   ========================================================================== */

/* 720p HD / Compact Desktop (769px - 1280px) */
@media (min-width: 769px) and (max-width: 1280px) {
  :root {
    --ui-scale: 0.88;
    --top-bar-h: 50px;
    --dock-w: 290px;
  }
  .game-title { display: none; }
  .game-monogram-seal { display: flex; }
  .btn-menu-label { display: none; }
  .btn-action-text { display: none; }
  .btn-camp-action { padding: 4px 7px; font-size: 0.82rem; }
  .treasury-item { padding: 2px 4px; gap: 3px; }
  .treasury-item .res-delta { font-size: 0.65rem; }
  .treasury-item .res-val { font-size: 0.76rem; }
  .btn-epoch { max-width: 130px; font-size: 0.70rem; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn-tab { padding: 4px 8px; font-size: 0.70rem; }
  .campaign-theaters-bar { bottom: 14px; top: auto; padding: 2px 6px; gap: 3px; transform: translateX(-50%) scale(0.80); transform-origin: bottom center; }
  .btn-theater-pill, .btn-mapmode-pill { padding: 2px 5px; font-size: 0.65rem; }
  .imperial-turn-seal { bottom: 12px; right: 12px; transform: scale(0.85); transform-origin: bottom right; }
  .mode-campaign .right-dock { bottom: 110px; }
}

/* ==========================================================================
   MOBILE & TOUCH DEVICE RESPONSIVE SUITE (Smartphones & Tablets <= 768px)
   ========================================================================== */
.btn-mobile-only {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --ui-scale: 0.82;
    --top-bar-h: auto;
    --dock-w: 100vw;
  }

  /* Top Bar: Mobile 2-Tier Stack */
  .top-bar {
    height: auto !important;
    min-height: 48px;
    padding: 5px 8px !important;
    flex-wrap: wrap !important;
    row-gap: 5px !important;
    background: linear-gradient(180deg, rgba(24, 15, 9, 0.98) 0%, rgba(13, 8, 5, 0.99) 100%) !important;
    border-bottom: 1.5px solid #8c6a23;
  }

  .top-bar-left {
    flex: 1 1 auto;
    gap: 6px;
  }
  .game-title { display: none !important; }
  .game-monogram-seal { display: flex !important; font-size: 1.15rem; }
  .sovereign-banner-pill {
    padding: 3px 8px !important;
    font-size: 0.74rem !important;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .btn-return-menu { display: none !important; }

  .top-bar-right {
    flex: 0 0 auto;
    gap: 4px;
    margin-left: auto;
  }
  .mode-tabs { gap: 2px; }
  .btn-tab { padding: 3px 7px !important; font-size: 0.70rem !important; }

  /* Collapse desktop action buttons on mobile, reveal single mobile menu button */
  .top-bar-right .btn-camp-action:not(.btn-mobile-only) {
    display: none !important;
  }
  .btn-mobile-only {
    display: inline-flex !important;
    padding: 4px 8px !important;
    font-size: 0.74rem !important;
    background: linear-gradient(180deg, #d4af37 0%, #92400e 100%) !important;
    color: #1a0f05 !important;
    font-weight: 700 !important;
    border: 1px solid #fef08a !important;
  }
  .btn-mobile-only .btn-action-text {
    display: inline !important;
  }

  /* Tier 2: Treasury and Epoch */
  .top-bar-center {
    order: 3;
    flex: 1 0 100% !important;
    width: 100% !important;
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
  }
  .campaign-hud-group {
    width: 100% !important;
    justify-content: space-between !important;
    gap: 4px !important;
  }
  .imperial-treasury-pill {
    padding: 2px 6px !important;
    gap: 4px !important;
    flex: 1 !important;
    justify-content: space-around !important;
  }
  .treasury-item {
    padding: 1px 2px !important;
    gap: 2px !important;
  }
  .treasury-item .res-icon { font-size: 0.72rem !important; }
  .treasury-item .res-val { font-size: 0.70rem !important; }
  .treasury-item .res-delta { font-size: 0.58rem !important; }
  .treasury-divider { height: 12px; margin: 0 1px; }
  .btn-epoch {
    max-width: 110px !important;
    font-size: 0.65rem !important;
    padding: 3px 6px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* RTS HUD Mobile */
  .rts-hud-group {
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 3px !important;
    justify-content: center !important;
  }
  .rts-hud-group .stats-group {
    gap: 3px !important;
  }
  .rts-hud-group .stat-box {
    padding: 2px 5px !important;
    font-size: 0.68rem !important;
  }
  .rts-hud-group .stat-label { font-size: 0.60rem !important; }
  .rts-hud-group .stat-val { font-size: 0.70rem !important; }
  .rts-hud-group .scenario-controls select {
    font-size: 0.66rem !important;
    padding: 2px 4px !important;
    max-width: 110px !important;
  }

  /* Theaters Bar: Swipeable Bottom Strip with clear margin from Turn Seal */
  .campaign-theaters-bar {
    position: fixed !important;
    bottom: 8px !important;
    left: 8px !important;
    right: 95px !important;
    top: auto !important;
    width: auto !important;
    max-width: calc(100vw - 105px) !important;
    transform: none !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 3px 8px !important;
    gap: 5px !important;
    border-radius: 12px !important;
    z-index: 60 !important;
  }
  .campaign-theaters-bar::-webkit-scrollbar { display: none; }
  .theaters-cluster, .mapmodes-cluster { flex-shrink: 0 !important; }
  .theater-label { font-size: 0.64rem !important; }
  .btn-theater-pill, .btn-mapmode-pill {
    padding: 3px 6px !important;
    font-size: 0.64rem !important;
    min-height: 26px !important;
  }

  /* Imperial Turn Seal: Compact Bottom-Right */
  .imperial-turn-seal {
    position: fixed !important;
    bottom: 8px !important;
    right: 6px !important;
    transform: scale(0.72) !important;
    transform-origin: bottom right !important;
    z-index: 70 !important;
  }

  /* Hide Chronicle by default on mobile so it doesn't obstruct touch gameplay */
  .mode-campaign .right-dock {
    display: none !important;
  }
  .mode-campaign .right-dock.mobile-open {
    display: flex !important;
    position: fixed !important;
    bottom: 60px !important;
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    max-height: 38vh !important;
    z-index: 120 !important;
  }

  /* Hide decorative compass rose on mobile */
  .compass-rose {
    display: none !important;
  }

  /* Province Inspector: Native Mobile Bottom Sheet */
  #province-inspector-panel {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 65vh !important;
    z-index: 1000 !important;
    margin: 0 !important;
  }
  .province-card {
    border-radius: 18px 18px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    max-height: 65vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.9) !important;
    padding: 10px 12px !important;
  }
  .prov-card-body {
    max-height: calc(65vh - 95px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* RTS Selected Unit Inspector: Mobile Bottom Sheet */
  #selected-unit-panel {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 55vh !important;
    border-radius: 18px 18px 0 0 !important;
    z-index: 1000 !important;
    overflow-y: auto !important;
  }

  /* RTS Bottom Recruitment Dock */
  #rts-recruit-bar {
    position: fixed !important;
    bottom: 8px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    transform: none !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 4px 8px !important;
    gap: 6px !important;
    border-radius: 12px !important;
  }
  .recruit-buttons {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }
  .btn-recruit {
    flex-shrink: 0 !important;
    min-height: 38px !important;
    padding: 4px 8px !important;
    font-size: 0.70rem !important;
  }

  /* Main Menu on Mobile */
  .menu-overlay {
    padding: 6px !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-x: hidden !important;
  }
  .menu-decor-border {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    min-width: 0 !important;
    padding: 10px 8px !important;
    margin: auto !important;
    max-height: calc(100vh - 16px) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .menu-content,
  .menu-header-cartouche,
  .menu-buttons,
  .btn-menu,
  .btn-menu-text,
  .btn-menu-title,
  .btn-menu-desc,
  .menu-footer {
    min-width: 0 !important;
    max-width: 100% !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    box-sizing: border-box !important;
  }
  .menu-crest-frame {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }
  .menu-motto-ribbon {
    font-size: 0.48rem !important;
    letter-spacing: 0.5px !important;
    padding: 2px 4px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .menu-main-title {
    font-size: 1.25rem !important;
    letter-spacing: 1px !important;
  }
  .menu-sub-title {
    font-size: 0.65rem !important;
    letter-spacing: 1px !important;
  }
  .menu-tagline {
    font-size: 0.62rem !important;
    padding: 0 4px !important;
  }
  .menu-buttons {
    gap: 5px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .btn-menu {
    padding: 5px 8px !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .btn-menu-text {
    flex: 1 !important;
    min-width: 0 !important;
  }
  .menu-btn-arrow {
    display: none !important;
  }
  .menu-seal {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
  }
  .seal-icon {
    font-size: 0.95rem !important;
  }
  .btn-menu-title {
    font-size: 0.78rem !important;
    white-space: normal !important;
    line-height: 1.2 !important;
  }
  .btn-menu-desc {
    font-size: 0.62rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2 !important;
  }
  .menu-footer {
    font-size: 0.52rem !important;
    letter-spacing: 0.3px !important;
    line-height: 1.25 !important;
    padding: 0 4px !important;
  }
}

/* 768p WXGA / Laptop Gaming (1281px - 1440px) */
@media (min-width: 1281px) and (max-width: 1440px) {
  :root {
    --ui-scale: 0.94;
    --top-bar-h: 54px;
    --dock-w: 295px;
  }
  .game-title { display: none; }
  .game-monogram-seal { display: flex; }
  .btn-menu-label { display: none; }
  .btn-action-text { display: none; }
  .btn-camp-action { padding: 5px 8px; font-size: 0.85rem; }
  .treasury-item { padding: 2px 5px; gap: 4px; }
  .treasury-item .res-delta { font-size: 0.68rem; }
  .treasury-item .res-val { font-size: 0.80rem; }
  .btn-epoch { max-width: 155px; font-size: 0.72rem; padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .campaign-theaters-bar { bottom: 16px; top: auto; padding: 3px 8px; gap: 4px; transform: translateX(-50%) scale(0.92); transform-origin: bottom center; }
  .btn-theater-pill, .btn-mapmode-pill { padding: 2px 5px; font-size: 0.68rem; }
  .imperial-turn-seal { bottom: 16px; right: 16px; transform: scale(0.92); transform-origin: bottom right; }
  .mode-campaign .right-dock { bottom: 118px; }
}

/* 1080p Full HD Standard Desktop (1441px - 2160px) */
@media (min-width: 1441px) and (max-width: 2160px) {
  :root {
    --ui-scale: 1.0;
    --top-bar-h: 58px;
    --dock-w: 330px;
  }
  .game-title { display: block; }
  .game-monogram-seal { display: none; }
  .btn-action-text { display: inline; }
  .btn-menu-label { display: inline; }
  .campaign-theaters-bar { bottom: 18px; top: auto; transform: translateX(-50%); transform-origin: bottom center; }
  .imperial-turn-seal { bottom: 20px; right: 20px; }
  .mode-campaign .right-dock { bottom: 125px; }
}

/* 1440p / 2K QHD (2161px - 2880px) */
@media (min-width: 2161px) and (max-width: 2880px) {
  :root {
    --ui-scale: 1.15;
    --top-bar-h: 70px;
    --dock-w: 390px;
  }
  .game-title { font-size: 1.45rem; }
  .btn-camp-action { font-size: 0.88rem; padding: 7px 14px; }
  .treasury-item { font-size: 0.98rem; }
  .campaign-theaters-bar { bottom: 24px; top: auto; transform: translateX(-50%) scale(1.15); transform-origin: bottom center; }
  .imperial-turn-seal { bottom: 28px; right: 28px; transform: scale(1.15); transform-origin: bottom right; }
}

/* 4K UHD (>= 2881px) */
@media (min-width: 2881px) {
  :root {
    --ui-scale: 1.35;
    --top-bar-h: 86px;
    --dock-w: 480px;
  }
  .game-title { font-size: 1.8rem; }
  .btn-camp-action { font-size: 1.1rem; padding: 9px 18px; }
  .campaign-theaters-bar { bottom: 32px; top: auto; transform: translateX(-50%) scale(1.35); transform-origin: bottom center; }
  .imperial-turn-seal { bottom: 36px; right: 36px; transform: scale(1.35); transform-origin: bottom right; }
}
