/**
 * QAZAQ KHANATE 1490: AGE OF STEPPES
 * UI Style in the authentic Age of History 2 grand strategy aesthetic
 */

:root {
  --bg-dark: #070a12;
  --bg-slate: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.94);
  --bg-modal: rgba(7, 10, 18, 0.96);
  --gold: #d4af37;
  --gold-bright: #fbbf24;
  --gold-dark: #854d0e;
  --bronze: #92400e;
  --border-gold: #b45309;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --red-war: #dc2626;
  --green-peace: #10b981;
  --blue-nomad: #0284c7;
  --font-main: 'Cinzel', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, serif, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* --- AGE OF HISTORY 2 TOP HUD BAR --- */
#aoh-top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 80%, #090d16 100%);
  border-bottom: 2px solid var(--border-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

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

/* Country Pill */
.hud-country-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 5px 12px;
  box-shadow: inset 0 0 8px rgba(212, 175, 55, 0.2);
}

.hud-flag {
  font-size: 22px;
}

.hud-country-meta {
  display: flex;
  flex-direction: column;
}

.hud-country-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
}

.hud-country-leader {
  font-size: 10px;
  color: var(--text-muted);
}

/* Resource Capsule */
.hud-capsule {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.hud-icon {
  font-size: 14px;
}

.text-green { color: #34d399; }
.text-red { color: #f87171; }

/* HUD Action Buttons */
.hud-btn {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  color: var(--gold-bright);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.hud-btn:hover {
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

/* End Turn Button (Iconic AoH2 Giant Flag/Gong Button) */
#btn-end-turn {
  background: linear-gradient(180deg, #b45309 0%, #78350f 100%);
  color: #fff;
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: all 0.15s ease;
}

#btn-end-turn:hover {
  background: linear-gradient(180deg, #d97706 0%, #92400e 100%);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.7);
}

/* --- STRATEGY MAP CANVAS --- */
#map-viewport {
  position: absolute;
  top: 60px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 60px);
  overflow: hidden;
  background-color: var(--bg-dark);
}

#game-map-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Chronicle Live Log (Bottom Left) */
#hud-chronicle-log {
  position: absolute;
  bottom: 16px;
  left: 16px;
  max-width: 420px;
  background: rgba(7, 10, 18, 0.85);
  border: 1px solid #334155;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: #cbd5e1;
  pointer-events: none;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.news-line {
  margin-bottom: 4px;
}

.news-line:last-child {
  margin-bottom: 0;
}

/* --- PROVINCE DETAILS DOCK (Age of History 2 Side/Bottom Sheet) --- */
#province-details-dock {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 380px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.96) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85);
  padding: 16px;
  z-index: 90;
  backdrop-filter: blur(6px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#province-details-dock.hidden {
  display: none;
}

.dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.dock-header h3 {
  font-size: 16px;
  color: var(--gold-bright);
}

.dock-owner {
  font-size: 12px;
  color: #94a3b8;
}

.dock-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.dock-stat-item {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 6px;
  text-align: center;
}

.dock-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dock-stat-val {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 2px;
}

/* Regional Buildings & Localized Buffs */
.dock-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.buildings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.building-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 10px;
}

.building-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.building-icon {
  font-size: 18px;
}

.building-name {
  font-size: 12px;
  font-weight: 600;
}

.building-buff {
  font-size: 10px;
  color: #34d399;
}

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

.aoh-btn {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--border-gold);
  color: var(--gold-bright);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  flex: 1;
}

.aoh-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border-color: var(--gold);
}

.aoh-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #475569;
}

.aoh-btn-sm {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--border-gold);
  color: #f8fafc;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.aoh-btn-sm:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold-bright);
}

/* --- TACTICAL BATTLEFIELD ARENA (Automatic combat screen) --- */
#tactical-battle-arena {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #1e293b 0%, #070a12 90%);
  z-index: 500;
  display: flex;
  flex-direction: column;
}

#tactical-battle-arena.hidden {
  display: none;
}

.battle-hud-top {
  height: 65px;
  background: linear-gradient(180deg, #0f172a 0%, #020617 100%);
  border-bottom: 2px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.battle-faction {
  display: flex;
  align-items: center;
  gap: 12px;
}

.faction-flag {
  font-size: 26px;
}

.faction-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-bright);
}

.battle-title-center {
  font-size: 16px;
  font-weight: 800;
  color: #f8fafc;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.battle-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #111827;
}

#tactical-battle-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Battle Tactical Command Dock */
.battle-command-dock {
  height: 95px;
  background: linear-gradient(180deg, #0f172a 0%, #070a12 100%);
  border-top: 2px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}

.tactical-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tactical-btn {
  background: linear-gradient(180deg, #1e293b 0%, #090d16 100%);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  color: var(--gold-bright);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 105px;
}

.tactical-btn:hover {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.tactical-btn-title {
  font-size: 11px;
  font-weight: 800;
}

.tactical-btn-desc {
  font-size: 8px;
  color: var(--text-muted);
}

#battle-combat-log {
  max-width: 320px;
  font-size: 10px;
  color: #cbd5e1;
  line-height: 1.4;
  height: 70px;
  overflow-y: hidden;
  border-left: 1px solid #334155;
  padding-left: 12px;
}

.log-entry {
  margin-bottom: 2px;
}

/* --- MODALS (Diplomacy, Tech Tree, Nation Picker, Events) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

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

.modal-window {
  background: linear-gradient(180deg, #1e293b 0%, #090d16 100%);
  border: 2px solid var(--border-gold);
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.95);
  width: 100%;
  max-width: 840px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  color: var(--gold-bright);
}

.modal-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Nation Picker Cards */
.nation-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.nation-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.nation-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.25);
}

.nation-card.featured-nation {
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, rgba(2, 132, 199, 0.15) 0%, rgba(15, 23, 42, 0.9) 100%);
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.35);
}

.nation-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nation-flag {
  font-size: 28px;
}

.nation-titles {
  flex: 1;
}

.nation-name {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.nation-leader {
  font-size: 11px;
  color: var(--gold);
}

.nation-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}

.nation-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
  flex: 1;
}

.nation-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: #cbd5e1;
  background: rgba(0,0,0,0.3);
  padding: 6px;
  border-radius: 4px;
}

/* Diplomacy Rows */
.dip-country-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  gap: 12px;
}

.dip-col-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.dip-flag {
  font-size: 24px;
}

.dip-col-info h4 {
  font-size: 13px;
  color: #f8fafc;
}

.dip-col-info small {
  font-size: 10px;
  color: #94a3b8;
}

.dip-col-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 120px;
}

.relation-meter {
  width: 100px;
  height: 8px;
  background: #334155;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-bar {
  height: 100%;
}

.relation-meter span {
  position: absolute;
  top: -14px;
  right: 0;
  font-size: 9px;
  font-weight: 700;
}

.status-war { color: var(--red-war); font-weight: 700; font-size: 10px; }
.status-alliance { color: #34d399; font-weight: 700; font-size: 10px; }
.status-nap { color: var(--gold-bright); font-weight: 700; font-size: 10px; }
.status-trade { color: #38bdf8; font-weight: 700; font-size: 10px; }
.status-truce { color: #cbd5e1; font-weight: 700; font-size: 10px; }
.status-neutral { color: #64748b; font-size: 10px; }

.dip-col-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Tech Tree Cards */
.tech-header-status {
  display: flex;
  justify-content: space-between;
  background: rgba(0,0,0,0.4);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--gold-bright);
}

.tech-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.tech-card.tech-done {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.tech-card.tech-active {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.1);
}

.tech-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.tech-icon { font-size: 20px; }
.tech-titles h4 { font-size: 13px; color: #f8fafc; }
.tech-titles small { font-size: 10px; color: #94a3b8; }
.badge-done { background: #10b981; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 700; margin-left: auto; }
.badge-active { background: var(--gold-dark); color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 700; margin-left: auto; }
.tech-desc { font-size: 11px; color: #94a3b8; margin-bottom: 6px; }
.tech-bonuses { font-size: 10px; color: #34d399; font-weight: 600; margin-bottom: 8px; }

/* Historical Event Modal */
#event-modal .modal-window {
  max-width: 500px;
}

.event-body {
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 18px;
}

.event-options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- RESPONSIVE ADAPTATIONS (Mobile & Tablet) --- */
@media (max-width: 768px) {
  #aoh-top-hud {
    height: auto;
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
  }

  .hud-country-badge {
    padding: 3px 8px;
  }

  .hud-capsule {
    padding: 3px 6px;
    font-size: 11px;
  }

  #btn-end-turn {
    padding: 6px 10px;
    font-size: 11px;
  }

  #province-details-dock {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
    max-height: 50vh;
    overflow-y: auto;
  }

  .battle-command-dock {
    height: auto;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
  }

  .tactical-btn {
    min-width: 80px;
    padding: 6px 8px;
  }

  #battle-combat-log {
    max-width: 100%;
    border-left: none;
    border-top: 1px solid #334155;
    padding-top: 6px;
    padding-left: 0;
    height: 40px;
  }
}

