/* --- Sidebar Controls Styles --- */
.controls-sidebar-group {
  margin-bottom: 2rem;
}
.sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-medium);
  border-radius: 10px;
  padding: 1rem 0.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(34,211,238,0.04);
}
.sidebar-controls .flex-wrap-gap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.sidebar-controls .control-group {
  margin-top: 0.5rem;
  margin-bottom: 0;
  width: 100%;
  text-align: center;
}
.sidebar-controls label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.sidebar-controls input[type="range"] {
  width: 90%;
  margin: 0.5rem auto 0 auto;
  display: block;
}
/* --- Controls Bar Styles --- */
#controls-bar, .controls-bar {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 12px rgba(34,211,238,0.05);
  border: 1.5px solid var(--accent-primary);
  background: linear-gradient(90deg, var(--bg-dark) 80%, var(--bg-medium) 100%);
}
#controls-bar .panel-title {
  margin-bottom: 1rem;
  text-align: center;
}
#controls-bar .flex-wrap-gap {
  justify-content: center;
  width: 100%;
  margin-bottom: 1rem;
}
#controls-bar .control-group {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 0.5rem auto;
}

/* --- Achievement System Styles --- */
.achievement-summary {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-medium);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.achievement-progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.achievement-progress-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.achievement-progress-bar-container {
  width: 100%;
  max-width: 300px;
  height: 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.achievement-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 6px;
  transition: width 0.3s ease;
  width: 0%;
}

.achievement-categories {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.achievement-category {
  background: var(--bg-medium);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.achievement-category-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.achievement-category-title i {
  font-size: 1.3rem;
  color: var(--accent-primary);
}

.achievement-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.achievement-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-dark);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.achievement-item:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.1);
}

.achievement-item.unlocked {
  border-color: var(--success-color);
  background: linear-gradient(135deg, var(--bg-dark) 0%, rgba(34, 211, 238, 0.05) 100%);
}

.achievement-item.unlocked::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-top: 15px solid var(--success-color);
}

.achievement-item.unlocked::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 2px;
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
}

.achievement-item.achievement-unlock {
  animation: achievementPulse 1s ease-out;
}

@keyframes achievementPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); border-color: var(--success-color); box-shadow: 0 0 20px rgba(34, 211, 238, 0.5); }
  100% { transform: scale(1); }
}

.achievement-icon {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.achievement-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.25rem;
}

.achievement-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.achievement-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-medium);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.achievement-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Responsive adjustments for achievements */
@media (max-width: 768px) {
  .achievement-list {
    grid-template-columns: 1fr;
  }
  
  .achievement-categories {
    gap: 1.5rem;
  }
  
  .achievement-category {
    padding: 1rem;
  }
  
  .achievement-summary {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
}
:root {
  --bg-dark: #0d1117;
  --bg-medium: #161b22;
  --bg-light: #21262d;
  --border-color: #30363d;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --accent-primary: #22d3ee;
  --accent-secondary: #a78bfa;
  --accent-danger: #f43f5e;
  --accent-success: #4ade80;
  --accent-warning: #facc15;
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-glow-primary: 0 0 15px rgba(34, 211, 238, 0.3), 0 0 5px rgba(34, 211, 238, 0.2);
  --shadow-glow-danger: 0 0 15px rgba(244, 63, 94, 0.4);
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  line-height: 1.6;
}

#app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar toggle button - hidden on desktop */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 2001;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 48px;
  height: 48px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:hover {
  background: var(--bg-light);
  border-color: var(--accent-primary);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

/* --- New Sidebar Styles --- */
#sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-dark);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 1.5rem 1rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header i {
  color: var(--accent-primary);
  width: 32px;
  height: 32px;
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  margin-top: 1.5rem;
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-group {
  margin-bottom: 2rem;
}

.nav-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 0.5rem;
  margin-bottom: 0.75rem;
}

.nav-group ul {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-link:hover {
  background-color: var(--bg-medium);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--accent-primary);
  color: var(--bg-dark);
  font-weight: 600;
  box-shadow: var(--shadow-glow-primary);
}
.nav-link.active i {
  color: var(--bg-dark);
}

.sidebar-footer {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.year-display {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: var(--shadow-glow-primary);
}

/* --- Main Content Area --- */
#main-content {
  flex-grow: 1;
  display: flex;
  gap: 2rem;
  padding: 2rem;
  overflow: hidden;
  background-image: radial-gradient(circle at 1px 1px, var(--border-color) 1px, transparent 0);
  background-size: 2rem 2rem;
}

#gameCanvas {
  display: grid;
  grid-template-columns: repeat(64, 8px);
  grid-template-rows: repeat(64, 8px);
  gap: 1px;
  background: rgba(22, 27, 34, 0.8);
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  align-self: flex-start;
  position: relative;
}

.cell { 
  width: 8px;
  height: 8px;
  background-color: var(--bg-light);
  border-radius: 2px;
  transition: none !important;
}
.cell:hover {
  transform: scale(1.5);
  z-index: 100;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

#panel-container {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 1rem;
}
#panel-container::-webkit-scrollbar {
  width: 6px;
}
#panel-container::-webkit-scrollbar-track {
  background: transparent;
}
#panel-container::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.view-panel {
  display: none;
}
.view-panel.active {
  display: block;
  animation: fadeInUp 0.5s ease;
}

.panel {
  background: rgba(22, 27, 34, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: relative;
  margin-bottom: 2rem;
}
.panel:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.1);
}
.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.panel-title i {
  color: var(--accent-primary);
  width: 24px;
  height: 24px;
}

/* --- Existing styles from original file (mostly unchanged) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-medium);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-secondary);
}
.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 0.25rem;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.control-button {
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  background-color: var(--bg-light);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.control-button:hover:not(:disabled) {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-dark);
  box-shadow: var(--shadow-glow-primary);
  transform: translateY(-2px);
}
.control-button.danger:hover:not(:disabled) {
  background-color: var(--accent-danger);
  border-color: var(--accent-danger);
  box-shadow: var(--shadow-glow-danger);
}
.control-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.control-group {
  margin-top: 1.5rem;
}
.control-group label {
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  text-transform: uppercase;
}
.control-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
  transition: opacity .2s;
}
.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 0 5px rgba(34, 211, 238, 0.5);
}
.control-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-medium);
  color: var(--text-primary);
}
.flex-wrap-gap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.scenario-button {
  background: transparent;
  color: var(--accent-secondary);
  border: 1px solid var(--accent-secondary);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.3s ease;
}
.scenario-button:hover {
  background-color: var(--accent-secondary);
  color: var(--bg-dark);
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.4);
}
.event-log {
  background: var(--bg-dark);
  color: var(--text-secondary);
  padding: 1rem;
  border-radius: 8px;
  height: 250px;
  overflow-y: auto;
  font-family: "Fira Code", "Monaco", monospace;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
}
.event-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
}
.event-item:last-child {
  border-bottom: none;
}
.dynamic-factors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.factor-control {
  background: var(--bg-medium);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.factor-value {
  font-weight: 700;
  color: var(--accent-primary);
  float: right;
  font-size: 1rem;
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.color-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}
.cell-details {
  font-family: "Fira Code", "Monaco", monospace;
  line-height: 1.8;
  background: var(--bg-medium);
  color: var(--text-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  min-height: 200px;
}
.cell-details strong {
  color: var(--text-primary);
}
.active-events-list {
  color: var(--accent-warning);
  font-weight: 500;
}

/* Cell states and colors */
.under-5 {
  background-color: #fde68a;
}
.age-5-9 {
  background-color: #fcd34d;
}
.age-10-14 {
  background-color: #fbbf24;
}
.age-15-19 {
  background-color: #f59e0b;
}
.age-20-24 {
  background-color: #d97706;
}
.age-25-29 {
  background-color: #b45309;
}
.age-30-34 {
  background-color: #bfdbfe;
}
.age-35-39 {
  background-color: #93c5fd;
}
.age-40-44 {
  background-color: #60a5fa;
}
.age-45-49 {
  background-color: #3b82f6;
}
.age-50-54 {
  background-color: #2563eb;
}
.age-55-59 {
  background-color: #1d4ed8;
}
.age-60-64 {
  background-color: #a7f3d0;
}
.age-65-69 {
  background-color: #6ee7b7;
}
.age-70-74 {
  background-color: #34d399;
}
.age-75-79 {
  background-color: #10b981;
}
.age-80-84 {
  background-color: #059669;
}
.age-85-plus {
  background-color: #047857;
}
.female {
  background-color: #f9a8d4 !important;
}
.male {
  background-color: #93c5fd !important;
}
.healthy {
  border: 1px solid var(--accent-success);
}
.sick {
  border: 1px solid var(--accent-warning);
}
.critical {
  border: 1px solid var(--accent-danger);
  animation: pulse-danger 1s infinite;
}
.poor {
  opacity: 0.6;
}
.middle-class {
  opacity: 0.85;
}
.wealthy {
  opacity: 1;
  box-shadow: 0 0 8px gold;
}
.no-education {
  filter: saturate(0.5);
}
.tertiary-education {
  filter: brightness(1.2);
}
.student {
  background-color: #c4b5fd !important;
}
.employed {
  background-color: #86efac !important;
}
.unemployed {
  background-color: #fca5a5 !important;
}
.retired {
  background-color: #9ca3af !important;
}
.very-happy {
  background-color: #6ee7b7 !important;
}
.happy {
  background-color: #a7f3d0 !important;
}
.neutral {
  background-color: #e5e7eb !important;
}
.sad {
  background-color: #9ca3af !important;
}
.very-dense {
  background-color: #ef4444 !important;
}
.medium-dense {
  background-color: #f97316 !important;
}
.low-dense {
  background-color: #84cc16 !important;
}
.sparse {
  background-color: #22c55e !important;
}
.cell.selected {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
  z-index: 1000;
  box-shadow: var(--shadow-glow-primary);
}

/* Settlement area clustering styles */
.cell.settlement-area {
  box-shadow: inset 0 0 3px rgba(255, 215, 0, 0.3);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.cell.settlement-area.high-density {
  background-color: rgba(255, 215, 0, 0.1);
  box-shadow: inset 0 0 5px rgba(255, 215, 0, 0.4);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

/* Settlement view mode colors */
.settlement-1 {
  background-color: #ff6b6b !important;
}
.settlement-2 {
  background-color: #4ecdc4 !important;
}
.settlement-3 {
  background-color: #45b7d1 !important;
}
.settlement-4 {
  background-color: #96ceb4 !important;
}
.settlement-5 {
  background-color: #ffeaa7 !important;
}
.settlement-6 {
  background-color: #dda0dd !important;
}
.no-settlement {
  background-color: #e5e7eb !important;
  opacity: 0.5;
}

/* Settlement info overlay tooltip */
.settlement-tooltip {
  position: absolute;
  background: var(--bg-dark);
  border: 1px solid var(--accent-primary);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 1000;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.settlement-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.settlement-tooltip-header {
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settlement-tooltip-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 0.8rem;
}

.settlement-tooltip-stat {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.settlement-tooltip-stat strong {
  color: var(--text-primary);
}

.settlement-tooltip-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
}

.settlement-cell-hover {
  position: relative;
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
  animation: settlementPulse 1.5s infinite;
}

@keyframes settlementPulse {
  0%, 100% { outline-color: var(--accent-primary); }
  50% { outline-color: rgba(34, 211, 238, 0.5); }
}

/* Terrain visualization styles */
.terrain-plains {
  background-color: #90EE90 !important;
}
.terrain-hills {
  background-color: #DEB887 !important;
}
.terrain-mountains {
  background-color: #696969 !important;
}
.terrain-forest {
  background-color: #228B22 !important;
}
.terrain-river {
  background-color: #4169E1 !important;
  animation: riverFlow 2s infinite ease-in-out;
}
.terrain-coast {
  background-color: #20B2AA !important;
  animation: waveMotion 3s infinite ease-in-out;
}
.terrain-desert {
  background-color: #F4A460 !important;
}

@keyframes riverFlow {
  0%, 100% { filter: brightness(1.0); }
  50% { filter: brightness(1.2); }
}

@keyframes waveMotion {
  0%, 100% { filter: brightness(1.0) saturate(1.0); }
  50% { filter: brightness(1.1) saturate(1.2); }
}

/* Population indicators on terrain */
.has-population {
  border: 1px solid #000 !important;
  box-shadow: inset 0 0 2px rgba(255, 255, 255, 0.8) !important;
}

.has-population::after {
  content: '•';
  color: #000;
  font-size: 8px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 1px #fff;
}

/* Inter-settlement connection visualization */
.trade-route-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, #22d3ee, transparent, #22d3ee);
  opacity: 0.4;
  z-index: 10;
  pointer-events: none;
  animation: tradeFlow 3s infinite linear;
}

.migration-flow-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, #fbbf24, transparent);
  opacity: 0.6;
  z-index: 10;
  pointer-events: none;
}

@keyframes tradeFlow {
  0% { background-position: 0 0; }
  100% { background-position: 20px 0; }
}

.settlement-connection-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Settlements panel styles */
.settlements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.settlement-card {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settlement-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-primary);
}

.settlement-card h4 {
  margin: 0 0 0.75rem 0;
  color: var(--accent-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.settlement-stats {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settlement-stats div {
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
}

.settlement-stats strong {
  color: var(--text-primary);
}

.settlement-location {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

/* Chart Styles */
.chart-container {
  width: 100%;
  height: 280px;
  background: var(--bg-medium);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  position: relative;
}
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bg-dark);
  border-radius: 8px;
}
.chart-filter-btn {
  padding: 0.4rem 0.8rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}
.chart-filter-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}
.chart-filter-btn.active {
  background: var(--accent-primary);
  color: var(--bg-dark);
  border-color: var(--accent-primary);
  font-weight: 600;
}
.chart-export-btn {
  padding: 0.4rem 0.8rem;
  background: var(--accent-success);
  color: var(--bg-dark);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.chart-export-btn:hover {
  filter: brightness(1.2);
}
.chart-export-btn i {
  width: 16px;
  height: 16px;
}
.chart-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.chart-tab {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  margin-bottom: -1px;
}
.chart-tab:hover {
  color: var(--text-primary);
}
.chart-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}
.chart-container.hidden {
  display: none;
}

/* Overlays and Animations */
.disaster-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.disaster-overlay.active {
  opacity: 0.4;
}
.disaster-pandemic {
  background: radial-gradient(circle, rgba(74, 222, 128, 0.3) 0%, transparent 70%);
}
.disaster-war {
  background: radial-gradient(circle, rgba(244, 63, 94, 0.4) 0%, transparent 70%);
}
.disaster-natural {
  background: radial-gradient(circle, rgba(250, 204, 21, 0.3) 0%, transparent 70%);
}
.quick-stats-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(13, 17, 23, 0.9);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  min-width: 200px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.quick-stats-overlay.visible {
  opacity: 1;
}
.quick-stats-overlay h4 {
  margin: 0 0 0.5rem 0;
  color: var(--accent-primary);
  font-weight: 600;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes pulse-danger {
  0%,
  100% {
    border-color: var(--accent-danger);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
  }
  50% {
    border-color: #fff;
    box-shadow: 0 0 16px rgba(244, 63, 94, 1);
  }
}
@keyframes birthPulse {
  0% {
    transform: scale(1);
    background: var(--accent-success);
  }
  50% {
    transform: scale(1.5);
    background: #86efac;
  }
  100% {
    transform: scale(1);
  }
}
@keyframes deathFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: scale(0.5);
  }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.birth-animation {
  animation: birthPulse 1s ease-in-out;
}
.death-animation {
  animation: deathFade 1s ease-in-out forwards;
}

/* Responsive Design */
@media (max-width: 1400px) {
  #main-content {
    flex-direction: column;
  }
  #gameCanvas {
    align-self: stretch;
    height: auto;
    aspect-ratio: 4 / 3;
    max-height: 60vh;
  }
  #panel-container {
    padding-right: 0;
  }
}

@media (max-width: 1024px) {
  #sidebar {
    position: fixed;
    left: calc(var(--sidebar-width) * -1);
    height: 100vh;
    top: 0;
    z-index: 2500;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }
  #sidebar.open {
    left: 0;
  }
  .sidebar-toggle {
    display: flex;
  }
  #main-content {
    width: 100%;
  }
}
@media (max-width: 768px) {
  #main-content {
    padding: 1rem;
    gap: 1rem;
  }
  #gameCanvas {
    grid-template-columns: repeat(40, minmax(0, 1fr));
    grid-template-rows: repeat(40, minmax(0, 1fr));
    height: 45vh !important;
    max-width: 100%;
    aspect-ratio: unset !important;
    max-height: none !important;
  }
  .cell {
    width: auto;
    height: auto;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  /* Mobile sidebar toggle - position below grid */
  .sidebar-toggle {
    position: fixed !important;
    top: auto !important;
    bottom: 2rem !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 3000 !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: var(--accent-primary) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
  }
  
  .sidebar-toggle:hover {
    background: var(--accent-primary) !important;
    transform: translateX(-50%) scale(1.1) !important;
  }
  
  /* Mobile sidebar backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2400;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  
  .sidebar-backdrop.active {
    display: block;
  }
  
  /* Better touch targets for mobile */
  .control-button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  
  .nav-link {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }
  
  /* Improve panel padding on mobile */
  .panel {
    padding: 1rem;
    border-radius: 8px;
  }
  
  .modal-content {
    margin: 1rem;
    padding: 1.5rem;
    border-radius: 12px;
  }
}

/* Population Explorer Styles */
.explorer-controls {
  margin-bottom: 1.5rem;
}

.search-box {
  display: flex;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.search-box input {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.search-box button {
  padding: 0.5rem 0.75rem;
  background: var(--accent-primary);
  border: none;
  border-radius: 6px;
  color: var(--bg-dark);
  cursor: pointer;
  transition: background 0.2s;
}

.search-box button:hover {
  background: #19bdd9;
}

.filter-section h4 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group select {
  padding: 0.4rem;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.filter-group select[multiple] {
  height: 80px;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.explorer-results {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.results-header span {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.results-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-medium);
}

.no-results {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

.result-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.result-item:hover {
  background: var(--bg-light);
}

.result-item:last-child {
  border-bottom: none;
}

.result-main {
  flex: 1;
}

.result-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.result-details {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-tag {
  background: var(--bg-light);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
}

.result-location {
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 500;
}

.result-item.highlighted {
  background: rgba(34, 211, 238, 0.1);
  animation: focusPulse 1s ease-in-out 3 forwards;
}

/* Grid cell highlighting styles */
.cell.search-highlight {
  box-shadow: 0 0 0 2px var(--accent-primary), inset 0 0 10px rgba(34, 211, 238, 0.3);
  z-index: 10;
  position: relative;
  animation: highlightPulse 2s ease-in-out infinite;
}

.cell.focused {
  box-shadow: 0 0 0 3px var(--accent-warning), inset 0 0 15px rgba(250, 204, 21, 0.4);
  z-index: 15;
  position: relative;
  animation: focusPulse 1s ease-in-out 3 forwards;
}

@keyframes highlightPulse {
  0%, 100% { 
    box-shadow: 0 0 0 2px var(--accent-primary), inset 0 0 10px rgba(34, 211, 238, 0.3);
  }
  50% { 
    box-shadow: 0 0 0 2px var(--accent-primary), inset 0 0 20px rgba(34, 211, 238, 0.6);
  }
}

@keyframes focusPulse {
  0%, 100% { 
    box-shadow: 0 0 0 3px var(--accent-warning), inset 0 0 15px rgba(250, 204, 21, 0.4);
  }
  50% { 
    box-shadow: 0 0 0 3px var(--accent-warning), inset 0 0 25px rgba(250, 204, 21, 0.7);
  }
}

/* Saved Queries Styles */
.saved-queries-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.saved-queries-section h4 {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.saved-queries-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.saved-queries-controls select {
  flex: 1;
  padding: 0.4rem;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.quick-segments {
  margin-top: 0.75rem;
}

.segment-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.segment-btn {
  padding: 0.4rem 0.75rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.segment-btn:hover {
  background: var(--accent-primary);
  color: var(--bg-dark);
  border-color: var(--accent-primary);
}

.segment-btn.active {
  background: var(--accent-secondary);
  color: var(--bg-dark);
  border-color: var(--accent-secondary);
}

.results-actions {
  display: flex;
  gap: 0.5rem;
}

/* Segment Comparison Styles */
.segment-comparison {
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-medium);
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.comparison-header h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.comparison-content {
  padding: 1rem;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.comparison-segment {
  padding: 0.75rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.comparison-segment h5 {
  margin: 0 0 0.5rem 0;
  color: var(--accent-primary);
  font-size: 0.9rem;
}

.comparison-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.comparison-stat {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.comparison-stat .value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-medium);
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

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

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.current-filters h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.filter-summary {
  background: var(--bg-light);
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.saved-query-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: var(--bg-light);
}

.query-info h5 {
  margin: 0 0 0.25rem 0;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.query-info p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.query-actions {
  display: flex;
  gap: 0.25rem;
}

.query-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Responsive adjustments for explorer */
@media (max-width: 768px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }
  
  .filter-actions {
    flex-direction: column;
  }
  
  .results-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .saved-queries-controls {
    flex-direction: column;
  }

  .segment-buttons {
    flex-direction: column;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
  }
}

/* Trend Explorer Styles */
.trend-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.trend-controls h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.segment-selector select {
  width: 100%;
  min-height: 80px;
  padding: 0.5rem;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.segment-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metrics-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metrics-selector label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}

.metrics-selector input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

.timeline-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.timeline-slider, .playback-speed {
  margin-bottom: 0.75rem;
}

.timeline-slider label, .playback-speed label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.timeline-slider input, .playback-speed input {
  width: 100%;
  margin: 0.25rem 0;
}

.trend-visualization {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.trend-charts {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-medium);
  padding: 1rem;
}

.trend-stats {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-medium);
  padding: 1rem;
}

.trend-stats h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.current-year-stats {
  font-size: 0.85rem;
}

.segment-stat {
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--bg-light);
  border-radius: 4px;
  border-left: 3px solid var(--accent-primary);
}

.segment-stat h5 {
  margin: 0 0 0.25rem 0;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.segment-stat .stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.segment-stat .stat-item {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.segment-stat .stat-value {
  color: var(--text-primary);
  font-weight: 500;
}

.timeline-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(34, 211, 238, 0.1);
  border: 2px solid var(--accent-primary);
  border-radius: 4px;
  pointer-events: none;
  z-index: 20;
  animation: timelineHighlight 0.5s ease-in-out;
}

@keyframes timelineHighlight {
  0% { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments for trends */
@media (max-width: 768px) {
  .trend-controls {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .trend-visualization {
    grid-template-columns: 1fr;
  }
  
  .segment-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Lifepath Explorer Styles */
.lifepath-modal .modal-content {
  max-width: 95vw;
  max-height: 90vh;
  width: 1200px;
  height: 800px;
}

.lifepath-content {
  display: flex;
  flex-direction: column;
}

.lifepath-body {
  flex: 1;
  overflow: hidden;
  padding: 1rem;
}

.lifepath-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  height: 100%;
}

.lifepath-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.lifepath-breadcrumb span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Family Tree Styles */
.family-tree-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-medium);
  overflow: hidden;
}

.family-tree-container h4 {
  margin: 0;
  padding: 1rem;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.family-tree {
  flex: 1;
  padding: 1rem;
  overflow: auto;
  min-height: 400px;
  position: relative;
}

.tree-controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
}

.person-node {
  display: inline-block;
  padding: 0.75rem;
  margin: 0.25rem;
  background: var(--bg-light);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-width: 120px;
  position: relative;
  max-width: 180px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.person-node:hover {
  background: var(--bg-dark);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.person-node.current {
  border-color: var(--accent-primary);
  background: rgba(34, 211, 238, 0.1);
}

.person-node.deceased {
  opacity: 0.7;
  border-style: dashed;
}

.person-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.person-details {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.person-status {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.status-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.status-icon.alive {
  background: var(--accent-success);
}

.status-icon.deceased {
  background: var(--text-secondary);
}

.generation {
  margin-bottom: 2rem;
  text-align: center;
}

.generation-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.generation-members {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.family-connection {
  position: absolute;
  border-left: 2px solid var(--border-color);
  border-top: 2px solid var(--border-color);
  pointer-events: none;
}

/* Life Timeline Styles */
.life-timeline-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-medium);
  overflow: hidden;
}

.life-timeline-container h4 {
  margin: 0;
  padding: 1rem;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.current-person-info {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-light);
}

.person-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.person-summary .info-item {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.person-summary .info-value {
  color: var(--text-primary);
  font-weight: 500;
}

.life-timeline {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

.timeline-event {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(139, 148, 158, 0.1);
  position: relative;
}

.timeline-event:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.event-year {
  flex-shrink: 0;
  width: 60px;
  font-weight: 600;
  color: var(--accent-primary);
  font-size: 0.9rem;
}

.event-content {
  flex: 1;
  margin-left: 1rem;
}

.event-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

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

.event-marker {
  position: absolute;
  left: 50px;
  top: 0.5rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.timeline-line {
  position: absolute;
  left: 53px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.no-events {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
}

.no-family {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 3rem;
  background: var(--bg-light);
  border-radius: 8px;
  border: 2px dashed var(--border-color);
}

/* Responsive adjustments for lifepath */
@media (max-width: 768px) {
  .lifepath-modal .modal-content {
    width: 95vw;
    height: 90vh;
    margin: 5vh 2.5vw;
  }
  
  .lifepath-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  
  .lifepath-breadcrumb {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .generation-members {
    flex-direction: column;
    align-items: center;
  }
  
  .person-summary {
    grid-template-columns: 1fr;
  }
}

/* Inspector Actions Styles */
.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.inspector-actions .control-button {
  justify-content: flex-start;
  padding: 0.5rem 0.75rem;
}

@media (min-width: 768px) {
  .inspector-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Scenario & Policy System Styles */
.scenario-selector {
  margin-bottom: 2rem;
}

.scenario-selection-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scenario-selection-group select {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.scenario-selection-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

.scenario-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.policy-controls {
  margin-bottom: 2rem;
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.policy-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.policy-control label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.policy-value {
  color: var(--accent-primary);
  font-weight: 600;
}

.policy-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  outline: none;
  cursor: pointer;
}

.policy-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.policy-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow-primary);
}

.policy-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.policy-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.scenario-status {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
}

.status-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.status-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-item span:last-child {
  color: var(--accent-primary);
  font-weight: 600;
}

/* Scenario Comparison Modal */
.scenario-modal .modal-content {
  width: 90vw;
  height: 85vh;
  max-width: 1200px;
}

.scenario-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scenario-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.comparison-controls {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.timeline-controls h4 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.timeline-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.timeline-selector label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.timeline-selector input[type="number"] {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 4px;
  width: 80px;
}

.scenario-selection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.scenario-compare-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.scenario-compare-item label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.scenario-compare-item select {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 4px;
}

.comparison-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.comparison-results {
  animation: fadeIn 0.3s ease-in-out;
}

.results-summary {
  margin-bottom: 2rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.summary-card {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.summary-card h5 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.summary-card .difference {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.summary-card .difference.positive {
  color: var(--accent-success);
}

.summary-card .difference.negative {
  color: var(--accent-danger);
}

.summary-card .difference.neutral {
  color: var(--text-secondary);
}

.comparison-charts {
  margin-bottom: 2rem;
}

.comparison-charts .chart-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.comparison-charts .chart-tab {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.comparison-charts .chart-tab:hover {
  background: var(--bg-medium);
  border-color: var(--accent-primary);
}

.comparison-charts .chart-tab.active {
  background: var(--accent-primary);
  color: var(--bg-dark);
  border-color: var(--accent-primary);
}

.outcome-analysis {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.analysis-item {
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
}

.analysis-item h6 {
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.analysis-item p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Responsive adjustments for scenario system */
@media (max-width: 768px) {
  .scenario-modal .modal-content {
    width: 95vw;
    height: 90vh;
    margin: 5vh 2.5vw;
  }
  
  .policy-grid {
    grid-template-columns: 1fr;
  }
  
  .timeline-selector {
    flex-direction: column;
    align-items: stretch;
  }
  
  .scenario-selection {
    grid-template-columns: 1fr;
  }
  
  .scenario-actions,
  .policy-actions,
  .comparison-actions {
    flex-direction: column;
  }
  
  .status-info {
    grid-template-columns: 1fr;
  }
  
  .summary-cards {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }
}

/* Phase 4: Advanced Civilization Features - Visual Styles */

/* Cultural View Mode Styles */
.culture-agricultural {
  background-color: #8FBC8F !important;
  border: 1px solid #228B22;
}

.culture-merchant {
  background-color: #DAA520 !important;
  border: 1px solid #B8860B;
}

.culture-scholarly {
  background-color: #4682B4 !important;
  border: 1px solid #4169E1;
}

.culture-maritime {
  background-color: #20B2AA !important;
  border: 1px solid #008B8B;
}

.culture-industrial {
  background-color: #708090 !important;
  border: 1px solid #2F4F4F;
}

.culture-nomadic {
  background-color: #CD853F !important;
  border: 1px solid #A0522D;
}

.no-culture {
  background-color: #E6E6FA !important;
  opacity: 0.3;
}

/* Political Systems View Mode Styles */
.politics-tribal {
  background-color: #DEB887 !important;
  border: 1px solid #D2691E;
}

.politics-monarchy {
  background-color: #9370DB !important;
  border: 1px solid #8A2BE2;
}

.politics-republic {
  background-color: #32CD32 !important;
  border: 1px solid #228B22;
}

.politics-oligarchy {
  background-color: #DC143C !important;
  border: 1px solid #B22222;
}

.politics-theocracy {
  background-color: #FFD700 !important;
  border: 1px solid #FFA500;
}

.politics-democracy {
  background-color: #87CEEB !important;
  border: 1px solid #4682B4;
}

.no-politics {
  background-color: #F5F5F5 !important;
  opacity: 0.3;
}

/* Settlement Specialization View Mode Styles */
.spec-farming {
  background-color: #90EE90 !important;
  border: 2px solid #32CD32;
}

.spec-trading {
  background-color: #FFD700 !important;
  border: 2px solid #FFA500;
}

.spec-crafting {
  background-color: #DEB887 !important;
  border: 2px solid #D2691E;
}

.spec-learning {
  background-color: #87CEEB !important;
  border: 2px solid #4682B4;
}

.spec-fishing {
  background-color: #20B2AA !important;
  border: 2px solid #008B8B;
}

.spec-mining {
  background-color: #696969 !important;
  border: 2px solid #2F4F4F;
}

.spec-religious {
  background-color: #DDA0DD !important;
  border: 2px solid #9370DB;
}

/* Urban Hierarchy Styles */
.hierarchy-hamlet {
  background-color: #F0E68C !important;
  border: 1px dotted #DAA520;
}

.hierarchy-village {
  background-color: #98FB98 !important;
  border: 1px solid #32CD32;
}

.hierarchy-town {
  background-color: #87CEEB !important;
  border: 2px solid #4682B4;
}

.hierarchy-city {
  background-color: #DDA0DD !important;
  border: 2px solid #9370DB;
}

.hierarchy-metropolis {
  background-color: #FFD700 !important;
  border: 3px solid #FF8C00;
  box-shadow: 0 0 4px rgba(255, 140, 0, 0.6);
}

.no-specialization {
  background-color: #F8F8FF !important;
  opacity: 0.3;
}

/* Technology and Cultural Advancement Indicators */
.advanced-culture {
  box-shadow: inset 0 0 4px rgba(255, 215, 0, 0.8);
}

.high-tech-settlement {
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 70%);
}

/* Political Stability Indicators */
.stable-government {
  border-style: solid;
}

.unstable-government {
  border-style: dashed;
  animation: politicalUnrest 2s infinite;
}

@keyframes politicalUnrest {
  0%, 100% { border-color: inherit; }
  50% { border-color: #FF4500; }
}

/* Cultural and Trade Connection Lines */
.cultural-connection-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(138, 43, 226, 0.4), transparent);
  opacity: 0.6;
  z-index: 15;
  pointer-events: none;
  animation: culturalFlow 4s infinite linear;
}

@keyframes culturalFlow {
  0% { background-position: 0 0; }
  100% { background-position: 30px 0; }
}

.technology-spread-indicator {
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 3px;
  background-color: #00FFFF;
  border-radius: 50%;
  animation: techPulse 1.5s infinite;
}

@keyframes techPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.5); }
}

/* Phase 4 Panel Styles */
.culture-content, .politics-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.culture-section, .tech-section, .culture-history-section,
.governance-section, .political-events-section, .stability-section {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.culture-grid, .tech-grid, .governance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
  margin-top: 10px;
}

.culture-card, .tech-card, .governance-card {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.culture-card:hover, .tech-card:hover, .governance-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.culture-card h5, .tech-card h5, .governance-card h5 {
  margin: 0 0 8px 0;
  font-size: 1.1em;
  font-weight: 600;
}

.culture-card p, .tech-card p, .governance-card p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.culture-stats, .tech-stats, .governance-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.culture-stats div, .tech-stats div, .governance-stats div {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.history-list, .events-list {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.history-item, .event-item {
  display: grid;
  grid-template-columns: 60px 120px 1fr;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85em;
}

.history-item:last-child, .event-item:last-child {
  border-bottom: none;
}

.history-year, .event-year {
  font-weight: 600;
  color: var(--accent);
}

.history-settlement, .event-settlement {
  color: var(--text-secondary);
  font-weight: 500;
}

.history-change, .event-description {
  color: var(--text-primary);
}

.event-item.reform {
  background: rgba(34, 197, 94, 0.1);
  border-left: 3px solid #22c55e;
}

.event-item.unrest {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
}

.stability-summary {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.stability-metric {
  margin-bottom: 15px;
}

.stability-metric h5 {
  margin: 0 0 8px 0;
  font-size: 1em;
  color: var(--text-primary);
}

.stability-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 5px;
}

.stability-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
  transition: width 0.3s ease;
}

.stability-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stability-stats div {
  font-size: 0.85em;
  color: var(--text-secondary);
}

/* Utility classes for inline styles */
.mb-1 {
  margin-bottom: 1rem;
}

.chart-height-400 {
  height: 400px;
}

.chart-height-350 {
  height: 350px;
}

/* Social Network Styles */
.social-network-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg-medium);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.network-view-controls h4,
.network-filters h4 {
  font-size: 0.9em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.network-visualization {
  position: relative;
  margin-bottom: 1rem;
}

.network-canvas-container {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 2px solid var(--border-color);
  overflow: hidden;
}

#socialNetworkCanvas {
  display: block;
  cursor: crosshair;
}

.network-controls-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.network-controls-overlay .control-button {
  padding: 8px;
  min-width: auto;
  width: 36px;
  height: 36px;
  font-size: 0.8em;
}

.selected-node-info {
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.node-info h5 {
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}

.node-info p {
  margin: 0.25rem 0;
  font-size: 0.9em;
}

.network-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.influence-rankings,
.community-analysis {
  margin-top: 1.5rem;
}

.influence-list,
.community-stats {
  max-height: 200px;
  overflow-y: auto;
}

.influencer-item,
.community-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.influencer-item:hover,
.community-item:hover {
  background: var(--bg-medium);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.influencer-info,
.community-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.influencer-info strong,
.community-info strong {
  color: var(--text-primary);
}

.influencer-info span,
.community-info span {
  color: var(--accent-primary);
  font-weight: 500;
  font-size: 0.9em;
}

.influencer-details,
.community-details {
  color: var(--text-secondary);
  font-size: 0.8em;
}

.filter-group {
  margin-bottom: 0.75rem;
}

.filter-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group input[type="range"] {
  width: 100%;
  margin-bottom: 0.25rem;
}

.filter-group span {
  font-size: 0.8em;
  color: var(--accent-primary);
  font-weight: 600;
}

/* Network node highlighting */
.network-node-highlighted {
  filter: drop-shadow(0 0 8px var(--accent-primary));
}

/* Responsive design for social network */
@media (max-width: 768px) {
  .social-network-controls {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .network-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }
  
  #socialNetworkCanvas {
    width: 100%;
    height: 350px;
  }
  
  .network-controls-overlay {
    top: 5px;
    right: 5px;
    gap: 3px;
  }
  
  .network-controls-overlay .control-button {
    width: 32px;
    height: 32px;
    padding: 6px;
  }
}

@media (max-width: 768px) {
  .culture-grid, .tech-grid, .governance-grid {
    grid-template-columns: 1fr;
  }
  
  .history-item, .event-item {
    grid-template-columns: 50px 100px 1fr;
    gap: 8px;
    font-size: 0.8em;
  }
}

/* Touch interaction improvements */
* {
  -webkit-tap-highlight-color: transparent;
}

button, .control-button, .nav-link, .cell {
  touch-action: manipulation;
}

/* Utility classes for responsive design */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
  .show-desktop { display: block !important; }
}

/* Responsive text utilities */
.text-responsive {
  font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.title-responsive {
  font-size: clamp(1.25rem, 4vw, 2rem);
}

/* Spacing utilities */
.p-mobile { padding: 0.5rem; }
.px-mobile { padding-left: 0.5rem; padding-right: 0.5rem; }
.py-mobile { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.m-mobile { margin: 0.5rem; }
.mx-mobile { margin-left: 0.5rem; margin-right: 0.5rem; }
.my-mobile { margin-top: 0.5rem; margin-bottom: 0.5rem; }
