@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;800&family=Outfit:wght@300;400;600;700;800&display=swap');

/* --- CSS Variables & Design System --- */
:root {
  --bg-main: #060814;
  --bg-panel: rgba(13, 17, 34, 0.65);
  --bg-panel-solid: #0d1122;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 87, 87, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-crimson: #ff2a5f;
  --accent-crimson-glow: rgba(255, 42, 95, 0.4);
  --accent-gold: #d4af37;
  --accent-gold-glow: rgba(212, 175, 55, 0.3);
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
  
  --sidebar-width: 420px;
}

/* --- Base & Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-crimson) var(--bg-main);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

body.map-page {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Webkit Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-crimson);
}

/* --- Header / Navigation Bar --- */
header {
  height: 48px;
  min-height: 48px;
  background-color: rgba(6, 8, 20, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 1001;
}

/* --- Map Subheader (Stats & Controls) --- */
.map-subheader {
  height: 48px;
  min-height: 48px;
  background-color: rgba(13, 17, 34, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
}

.subheader-right {
  display: flex;
  align-items: center;
  gap: 32px;
}

/* --- Glass Select Dropdown --- */
.glass-select {
  background: rgba(6, 8, 20, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.glass-select:hover, .glass-select:focus {
  border-color: rgba(255, 87, 87, 0.4);
  box-shadow: 0 0 15px rgba(255, 42, 95, 0.15);
}

.glass-select option {
  background: #0d1122;
  color: var(--text-primary);
  font-weight: 500;
}

.era-select-container {
  display: block;
}

/* Styled as a pill button dropdown */
.era-dropdown {
  border-radius: 20px !important;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 20px;
  padding-right: 38px;
  background-position: right 14px center;
  background-size: 10px;
  height: 32px;
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  transition: var(--transition-smooth);
  width: auto;
  min-width: 180px;
}

.era-dropdown:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.1rem;
  background: linear-gradient(135deg, #fff 30%, var(--accent-crimson) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.brand span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(255, 42, 95, 0.15);
  border: 1px solid rgba(255, 42, 95, 0.3);
  color: var(--accent-crimson);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* --- Global Navigation Links --- */
.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-left: 24px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--accent-crimson);
  background: rgba(255, 42, 95, 0.05);
  border-color: rgba(255, 42, 95, 0.15);
  text-shadow: 0 0 10px rgba(255, 42, 95, 0.2);
}

/* --- Dropdown Navigation --- */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-dropdown-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.nav-dropdown:hover .nav-dropdown-btn {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.05);
}

.nav-dropdown.active .nav-dropdown-btn {
  color: var(--accent-crimson);
  background: rgba(255, 42, 95, 0.05);
  border-color: rgba(255, 42, 95, 0.15);
  text-shadow: 0 0 10px rgba(255, 42, 95, 0.2);
}

.dropdown-chevron {
  width: 0.9em;
  height: 0.9em;
  transition: transform 0.25s ease;
}

.nav-dropdown:hover .dropdown-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(13, 17, 34, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  min-width: 180px;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 8px 0;
  z-index: 1000;
}

.nav-dropdown-content::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent rgba(255, 255, 255, 0.08) transparent;
}

/* Invisible bridge to prevent dropdown from disappearing during mouse movement */
.nav-dropdown-content::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  height: 12px;
  background: transparent;
}

.nav-dropdown:hover .nav-dropdown-content {
  display: block;
}

.nav-dropdown-content a {
  color: var(--text-secondary);
  padding: 8px 16px;
  text-decoration: none;
  display: block;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
  white-space: nowrap;
  text-align: left;
}

.nav-dropdown-content a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-dropdown-content a.active {
  color: var(--accent-crimson);
  background: rgba(255, 42, 95, 0.05);
}

.global-stats {
  display: flex;
  gap: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-crimson);
  text-shadow: 0 0 10px var(--accent-crimson-glow);
}

.stat-val.gold {
  color: var(--accent-gold);
  text-shadow: 0 0 10px var(--accent-gold-glow);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

/* --- Main Layout --- */
.app-container {
  flex-grow: 1;
  position: relative;
  display: flex;
  height: calc(100vh - 96px);
}

/* Map Container styling */
#map {
  flex-grow: 1;
  height: 100%;
  width: 100%;
  background: var(--bg-main);
  z-index: 1;
}

/* Customizing Leaflet Elements */
.leaflet-bar {
  border: 1px solid var(--border-color) !important;
  box-shadow: none !important;
}
.leaflet-bar a {
  background-color: var(--bg-panel-solid) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  transition: var(--transition-fast);
}
.leaflet-bar a:hover {
  background-color: var(--accent-crimson) !important;
  color: #fff !important;
}
.leaflet-control-attribution {
  background: rgba(6, 8, 20, 0.75) !important;
  backdrop-filter: blur(4px);
  color: var(--text-muted) !important;
  font-size: 0.65rem !important;
  border-top-left-radius: 4px;
}
.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* Custom Marker styles */
.war-marker-active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-crimson);
  border: 2px solid #fff;
  box-shadow: 0 0 15px var(--accent-crimson);
  position: relative;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.marker-pin::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border: 2px solid var(--accent-crimson);
  border-radius: 50%;
  animation: pulse-ring 1.8s cubic-bezier(0.215, 0.610, 0.355, 1) infinite;
  opacity: 0;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.marker-pin:hover {
  transform: scale(1.2);
  box-shadow: 0 0 25px var(--accent-crimson);
  background: #fff;
  border-color: var(--accent-crimson);
}

/* --- Floating Glass Sidebar --- */
.sidebar-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 120px;
  width: var(--sidebar-width);
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: rgba(6, 8, 20, 0.6);
  border: 1px solid var(--border-color);
  padding: 12px 16px 12px 40px;
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-crimson);
  box-shadow: 0 0 10px rgba(255, 42, 95, 0.2);
  background: rgba(6, 8, 20, 0.8);
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-box .search-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Sidebar Scrollable Body */
.sidebar-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Wars List (active conflicts in selected year) */
.wars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.war-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.war-card:hover {
  background: rgba(255, 42, 95, 0.05);
  border-color: var(--accent-crimson);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 42, 95, 0.1);
}

.war-card.selected {
  background: rgba(255, 42, 95, 0.08);
  border-color: var(--accent-crimson);
  box-shadow: 0 4px 15px rgba(255, 42, 95, 0.15);
}

.war-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.war-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.war-card-years {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-crimson);
  white-space: nowrap;
  background: rgba(255, 42, 95, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.war-card-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.no-wars-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.no-wars-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.no-wars-icon svg {
  width: 100%;
  height: 100%;
}

.header-section-svg {
  width: 1.1em;
  height: 1.1em;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent-gold);
  flex-shrink: 0;
}

/* Selected War Details View */
.war-detail-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-back-list {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  transition: var(--transition-fast);
}

.btn-back-list:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.detail-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.meta-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.meta-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.meta-value.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-crimson);
}

.detail-summary {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.belligerents-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  position: relative;
}

.belligerents-panel::after {
  content: 'VS';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent-gold);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.belligerent-column {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.belligerent-column.side-a {
  border-left: 2px solid var(--accent-blue);
}

.belligerent-column.side-b {
  border-right: 2px solid var(--accent-crimson);
  text-align: right;
  align-items: flex-end;
}

.belligerent-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.belligerent-list {
  list-style: none;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-events {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  padding-left: 16px;
  margin-top: 10px;
}

.timeline-events::after {
  content: '';
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 4px;
  width: 1px;
  background: var(--border-color);
}

.event-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-dot {
  position: absolute;
  left: -16px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 2px solid var(--bg-panel-solid);
  z-index: 2;
}

.event-year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.event-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.event-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 8px;
  transition: var(--transition-fast);
}

.wiki-link:hover {
  text-decoration: underline;
  color: #60a5fa;
}

/* --- Bottom Control Panel --- */
.timeline-controls {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  height: 80px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Play/Pause Button */
.btn-play-pause {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  background: var(--accent-crimson);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--accent-crimson-glow);
  transition: var(--transition-smooth);
  padding-left: 3px; /* Visually center the play triangle glyph */
}

.btn-play-pause.playing {
  padding-left: 0; /* Reset for symmetric pause bars */
}

.btn-play-pause:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px var(--accent-crimson);
  background: #fff;
  color: var(--accent-crimson);
}

.btn-play-pause:active {
  transform: scale(0.95);
}

/* Big Year Display */
.year-display-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 140px;
}

.current-year-text {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.current-year-text span.era-tag {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-crimson);
}

/* Slider Track Wrapper */
.slider-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

/* Conflict markers container & dots along the slider track */
.slider-conflict-markers {
  position: absolute;
  top: 3px; /* Align with the vertical center of the 6px slider track */
  left: 0;
  width: 100%;
  height: 0;
  pointer-events: none;
  z-index: 3; /* Render above the range slider track */
}

.conflict-slider-dot {
  position: absolute;
  top: -3px; /* Center a 6px dot vertically on the track */
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-crimson);
  opacity: 0.65;
  box-shadow: 0 0 4px var(--accent-crimson-glow);
  transform: translateX(-50%);
  cursor: pointer;
  pointer-events: auto; /* Enable clicking and hover tooltips */
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  z-index: 4;
}

.conflict-slider-dot:hover {
  transform: translateX(-50%) scale(1.4);
  opacity: 1;
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold-glow);
}

/* Custom Styled Input Range */
.history-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  position: relative;
  z-index: 2;
  cursor: pointer;
}

/* Active Fill effect (handled by JS via gradient) */
.history-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
}

.history-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-crimson);
  border: 3px solid #fff;
  box-shadow: 0 0 10px var(--accent-crimson);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-top: -7px; /* Align vertical center for webkit */
}

.history-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 15px var(--accent-crimson);
}

.history-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-crimson);
  border: 3px solid #fff;
  box-shadow: 0 0 10px var(--accent-crimson);
  cursor: pointer;
  transition: var(--transition-fast);
}

.history-slider::-moz-range-thumb:hover {
  transform: scale(1.25);
}

/* Slider Ticks/Labels */
.slider-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  position: relative;
  z-index: 1;
}

.slider-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.tick-mark {
  width: 2px;
  height: 6px;
  background: var(--border-color);
  margin-bottom: 4px;
  transition: var(--transition-fast);
}

.slider-tick:hover .tick-mark,
.slider-tick.active .tick-mark {
  background: var(--accent-crimson);
  height: 10px;
  box-shadow: 0 0 5px var(--accent-crimson);
}

.tick-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  font-weight: 600;
  transition: var(--transition-fast);
}

.slider-tick:hover .tick-label,
.slider-tick.active .tick-label {
  color: #fff;
}

/* --- Era Selector Pills (above slider) --- */
.era-pills {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-era {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-era:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-era.active {
  background: rgba(255, 42, 95, 0.15);
  color: #fff;
  border-color: var(--accent-crimson);
  box-shadow: 0 0 10px rgba(255, 42, 95, 0.25);
}

/* --- Search Overlay Panel (if needed, but search inside sidebar is better) --- */

/* Responsive Design */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 360px;
  }
  
  .timeline-controls {
    flex-wrap: wrap;
    height: auto;
    padding: 16px;
    gap: 16px;
    bottom: 15px;
    left: 15px;
    right: 15px;
  }
  
  .sidebar-panel {
    width: var(--sidebar-width);
    left: 15px;
    top: 15px;
    bottom: 175px;
  }
  
  .era-pills {
    width: 100%;
    order: -1;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-left: 0;
  }
  
  .btn-era {
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  body {
    overflow: auto;
  }
  
  .map-subheader {
    height: auto;
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 12px;
  }

  .subheader-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .era-pills {
    display: none !important;
  }

  .era-select-container {
    display: block;
    width: 100%;
  }

  .era-dropdown {
    width: 100%;
    height: 38px;
    font-size: 0.8rem;
    padding: 6px 16px;
    padding-right: 38px;
  }

  .global-stats {
    justify-content: space-between;
    gap: 12px;
  }

  .stat-item {
    align-items: center;
  }
  
  .app-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  
  #map {
    height: 50vh;
    min-height: 400px;
  }
  
  .sidebar-panel {
    position: static;
    width: 100%;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    background: var(--bg-panel-solid);
  }
  
  .timeline-controls {
    position: static;
    width: 100%;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    background: var(--bg-panel-solid);
    padding: 20px;
  }
}

/* --- Advanced Features CSS --- */

/* Header Buttons styling */
.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}



/* --- Casualty Interactive SVG Chart Drawer --- */
.chart-drawer {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: -300px; /* Hidden below viewport */
  height: 240px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  transition: var(--transition-smooth);
}

.chart-drawer.open {
  bottom: 0px;
}

/* Adjust timeline and sidebar if chart is open */
body.chart-open .timeline-controls {
  bottom: 260px;
}
body.chart-open .sidebar-panel {
  bottom: 360px;
}

.chart-toggle-btn {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-bottom: none;
  color: var(--text-primary);
  padding: 6px 16px;
  border-radius: 8px 8px 0 0;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  position: absolute;
  top: -29px;
  left: 40px;
  z-index: 101;
  transition: var(--transition-smooth);
}

.chart-toggle-btn:hover {
  background: var(--bg-panel-solid);
  color: var(--accent-gold);
}

.chart-header {
  height: 38px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-gold);
  letter-spacing: 0.05em;
}

.btn-chart-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.btn-chart-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-crimson);
}

.btn-chart-close svg {
  width: 16px;
  height: 16px;
  display: block;
}

.chart-body {
  flex-grow: 1;
  padding: 10px 15px 5px 15px;
  position: relative;
  overflow: hidden;
}

/* SVG Chart Elements */
.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8px;
  user-select: none;
}

.chart-line {
  fill: none;
  stroke: var(--accent-crimson);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 5px var(--accent-crimson-glow));
}

.chart-area {
  fill: url(#chart-grad);
  opacity: 0.15;
}

.chart-bar-hover-zone {
  fill: transparent;
  cursor: pointer;
}

.chart-bar-hover-zone:hover {
  fill: rgba(255, 42, 95, 0.08);
}

.chart-tracker-line {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 1;
  stroke-dasharray: 2, 2;
  pointer-events: none;
}


/* --- Animated Campaign Paths --- */
.campaign-path-line {
  stroke: var(--accent-gold);
  stroke-dasharray: 6, 6;
  stroke-linecap: round;
  animation: dash-flow 25s linear infinite;
  filter: drop-shadow(0 0 3px var(--accent-gold-glow));
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -1000;
  }
}

/* --- Sidebar Era Graphics --- */
.era-hero-banner {
  height: 140px;
  width: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
  background: #060814;
}

/* --- Heatmap Toggle Button --- */
.btn-heatmap-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-heatmap-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-heatmap-toggle.active {
  background: rgba(251, 191, 36, 0.15); /* amber glow */
  color: #fbbf24;
  border-color: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.25);
}

.battle-marker-icon {
  width: 28px;
  height: 28px;
  cursor: pointer;
  animation: marker-float 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-marker-icon svg {
  width: 100%;
  height: 100%;
  color: var(--accent-gold);
  filter: drop-shadow(0 0 3px #000) drop-shadow(0 0 5px var(--accent-gold));
}

@keyframes marker-float {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.1);
  }
}

/* --- Alliance & Conflict Web Visualizer --- */
.alliance-web-container {
  margin-top: 15px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alliance-web-svg {
  width: 100%;
  height: 180px;
  overflow: visible;
}

/* --- Mock Adsense Placements (Global) --- */
.ad-slot-horizontal {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 40px auto;
  background: rgba(13, 17, 34, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  overflow: hidden;
  padding: 10px;
}

.ad-slot-horizontal::before {
  content: 'ADVERTISEMENT';
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.05em;
}

.ad-slot-mock-content {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 4px;
  text-align: center;
}

.ad-slot-mock-content a {
  color: var(--accent-gold);
  text-decoration: underline;
  margin-left: 5px;
}

/* --- Global Button Styles --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-crimson);
  color: #fff;
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: 6px;
  box-shadow: 0 0 20px var(--accent-crimson-glow);
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary:hover {
  background: #ff5757;
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255, 87, 87, 0.6);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-icon {
  width: 1.1em;
  height: 1.1em;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  display: inline-block;
}

/* --- Share Button Styling (Global Standard) --- */
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--accent-crimson);
  background: rgba(255, 42, 95, 0.05);
  color: var(--accent-crimson);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  height: 32px;
}

.btn-share:hover {
  background: var(--accent-crimson);
  color: #fff;
  box-shadow: 0 0 10px var(--accent-crimson-glow);
}

.btn-share span {
  display: inline-block;
}

/* --- Footer Section (Global) --- */
footer {
  border-top: 1px solid var(--border-color);
  padding: 48px 24px;
  background: #03050c;
  color: var(--text-secondary);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-logo {
  display: flex;
  flex-direction: column;
}

.footer-logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}

.footer-link:hover {
  color: var(--accent-crimson);
}

.footer-copyright {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

/* --- Battle Strategy Animator (Sidebar) --- */
.battle-animator-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.battle-animator-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.battle-svg-viewport {
  width: 100%;
  height: 180px;
  background: #020308;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: block;
}

.battle-phase-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  min-height: 54px;
}

.animator-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.phase-nav-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.phase-nav-btn:hover:not(:disabled) {
  background: var(--accent-crimson);
  color: #fff;
  border-color: var(--accent-crimson);
}

.phase-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.phase-indicators {
  display: flex;
  gap: 6px;
}

.phase-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition-fast);
}

.phase-dot.active {
  background: var(--accent-crimson);
  box-shadow: 0 0 6px var(--accent-crimson);
}

/* SVG shapes inside battle strategy map */
.svg-grid-line {
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 1;
}

.svg-unit-rect {
  stroke-width: 1.5;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.svg-unit-rect.side-a {
  fill: rgba(255, 42, 95, 0.22);
  stroke: var(--accent-crimson);
}

.svg-unit-rect.side-b {
  fill: rgba(212, 175, 55, 0.18);
  stroke: var(--accent-gold);
}

.svg-unit-rect.veteran {
  fill: rgba(59, 130, 246, 0.22);
  stroke: var(--accent-blue);
}

.svg-unit-rect.cavalry {
  fill: rgba(245, 158, 11, 0.22);
  stroke: #f59e0b;
}

.svg-unit-rect.artillery {
  fill: rgba(168, 85, 247, 0.22);
  stroke: #a855f7;
}

.svg-unit-rect.fortified {
  fill: rgba(16, 185, 129, 0.2);
  stroke: #10b981;
}

.svg-unit-rect.reinforcements {
  fill: rgba(59, 130, 246, 0.25);
  stroke: var(--accent-blue);
  stroke-dasharray: 2, 2;
}

.svg-unit-rect.retreating {
  fill: rgba(255, 255, 255, 0.08);
  stroke: var(--text-muted);
  stroke-dasharray: 2, 2;
}

.svg-unit-rect.trapped {
  fill: rgba(239, 68, 68, 0.35);
  stroke: #ef4444;
  animation: pulseTrapped 1.5s ease-in-out infinite alternate;
}

.svg-unit-label {
  fill: #ffffff;
  font-family: var(--font-sans);
  font-size: 5px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pulseTrapped {
  from { fill: rgba(239, 68, 68, 0.15); stroke-width: 1.5; }
  to { fill: rgba(239, 68, 68, 0.45); stroke-width: 2.5; }
}
