:root {
  --bg: #070b16;
  --bg-2: #0b1020;
  --surface: #111a2e;
  --surface-2: #0f172a;
  --border: #1e2a44;
  --text: #f4f1ea;
  --text-dim: #9fb0c9;
  --gold: #e6b566;
  --gold-soft: #f1cd8e;
  --sky: #8fb8ff;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: #f5f5f5;
}

header {
  padding: 1rem 2rem;
  background: #0b1020;
  border-bottom: 1px solid #222;
}

header h1 {
  margin: 0;
}

header p {
  margin: 0.25rem 0 0;
  color: #aaa;
}

.layout {
  display: flex;
  height: calc(100vh - 64px);
}

#map {
  flex: 2;
  position: relative;
}

.leaflet-container {
  background: #b8d8ea;
}

.leaflet-container.plain2d-mode {
  background: #b8d8ea !important;
}

.river-label {
  color: #11507f;
  font-size: 11px;
  font-style: italic;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 1px 2px #fff;
  pointer-events: none;
}

.river-tip {
  font-style: italic;
}

.side-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-left: 1px solid #222;
}

.slider-container {
  padding: 1rem;
  border-bottom: 1px solid #222;
}

.playback-controls {
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid #222;
  align-items: center;
}

.map-toggles {
  padding: 1rem;
  border-bottom: 1px solid #222;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

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

.map-toggles label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}

.playback-controls button {
  padding: 0.5rem 1rem;
  background: #38bdf8;
  border: none;
  border-radius: 4px;
  color: #020617;
  font-weight: bold;
  cursor: pointer;
  flex: 1;
}

.playback-controls select {
  padding: 0.5rem;
  background: #111827;
  color: #f5f5f5;
  border: 1px solid #374151;
  border-radius: 4px;
  cursor: pointer;
}

.culture-label-wrapper {
  position: relative;
  display: inline-block;
  isolation: auto;
}

.culture-label-wrapper:hover {
  z-index: 10000 !important;
  isolation: isolate;
}

.leaflet-marker-icon.culture-label:has(.culture-label-wrapper:hover) {
  z-index: 10001 !important;
}

.culture-name-text {
  background: rgba(10, 18, 36, 0.88);
  color: #e2f0ff;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  border: 1.5px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 2px 8px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.3);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.culture-label-wrapper:hover .culture-name-text {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.6);
  filter: brightness(1.5);
  text-shadow: 0 0 8px currentColor;
}

.culture-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
  z-index: 10000;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  min-width: 100px;
}

.culture-dropdown.visible {
  display: block;
}

.dropdown-item {
  padding: 8px 14px;
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  pointer-events: auto;
  text-align: center;
  border-bottom: 1px solid #1e293b;
}

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

.dropdown-item:hover {
  background: #1e293b;
  color: #38bdf8;
}

.exit-isolate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b !important;
  padding: 0.5rem 0.75rem !important;
  margin-bottom: 0.5rem !important;
  border-left: 3px solid #38bdf8;
}

.exit-isolate-item span {
  color: #38bdf8;
  font-size: 0.85rem;
  font-weight: 600;
}

.exit-isolate-item button {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.exit-isolate-item button:hover {
  background: #dc2626;
}

.exit-isolate-btn {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  letter-spacing: 0.02em;
}

.exit-isolate-btn:hover {
  background: #dc2626;
}

.exit-isolate-btn.hidden {
  display: none;
}

.culture-search-container {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #222;
  position: relative;
}

.culture-search-container input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}

.culture-search-container input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.culture-search-container input::placeholder {
  color: #6b7280;
}

.culture-search-results {
  position: absolute;
  top: calc(100% - 4px);
  left: 1rem;
  right: 1rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0 0 6px 6px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.culture-search-results.hidden {
  display: none;
}

.culture-search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #111827;
  font-size: 0.85rem;
}

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

.culture-search-result-item:hover {
  background: #374151;
}

.culture-search-result-item .search-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.culture-search-result-item .search-culture-name {
  color: #e5e7eb;
  flex: 1;
}

.culture-search-result-item .search-culture-dates {
  color: #6b7280;
  font-size: 0.75rem;
  white-space: nowrap;
}

.culture-search-no-results {
  padding: 0.75rem;
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
}

.ai-ask-container {
  padding: 0.5rem 1rem 0.75rem;
  border-bottom: 1px solid #222;
}

.ai-ask-input-row {
  display: flex;
  gap: 0.4rem;
}

.ai-ask-input-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}

.ai-ask-input-row input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.ai-ask-input-row input::placeholder {
  color: #6b7280;
}

.ai-ask-input-row button {
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.ai-ask-input-row button:hover {
  opacity: 0.9;
}

.ai-ask-input-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-ask-response {
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #1e1b4b;
  border: 1px solid #312e81;
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ai-ask-response.hidden {
  display: none;
}

.ai-ask-response .ai-loading {
  color: #8b5cf6;
  font-style: italic;
}

/* ---- AI Visual Assistant: tabs / tree / routes ---- */
.ai-result {
  white-space: normal;
}
.ai-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #312e81;
  padding-bottom: 0.4rem;
}
.ai-tab-btn {
  background: #2e2a5e;
  color: #c4b5fd;
  border: 1px solid #3b3680;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.74rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ai-tab-btn:hover { background: #3b3680; }
.ai-tab-btn.active {
  background: #8b5cf6;
  color: #fff;
  border-color: #8b5cf6;
}
.ai-tab-panel.hidden { display: none; }
.ai-answer-text { margin: 0 0 0.4rem; color: #ddd6fe; }
.ai-disclaimer {
  margin: 0.4rem 0 0;
  padding: 0.4rem 0.55rem;
  background: #3a2a1a;
  border: 1px solid #6b4f2a;
  border-radius: 5px;
  color: #fcd9a8;
  font-size: 0.76rem;
}
.ai-panel-hint {
  margin: 0 0 0.5rem;
  color: #a78bfa;
  font-size: 0.74rem;
  font-style: italic;
}

/* Family tree */
.ai-tree, .ai-tree-children {
  list-style: none;
  margin: 0;
  padding-left: 0.9rem;
}
.ai-tree { padding-left: 0; }
.ai-tree-children {
  border-left: 1px solid #3b3680;
  margin-left: 0.5rem;
}
.ai-tree-node { margin: 0.3rem 0; }
.ai-tree-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  background: #2a2658;
  border: 1px solid #3b3680;
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ai-tree-card:hover {
  background: #3b3680;
  border-color: #8b5cf6;
}
.ai-tree-name { font-weight: 600; color: #ede9fe; font-size: 0.82rem; }
.ai-tree-dates { color: #a5b4fc; font-size: 0.72rem; }
.ai-tree-region { color: #9ca3cf; font-size: 0.72rem; }
.ai-tree-rel {
  color: #c4b5fd;
  font-size: 0.68rem;
  background: #1e1b4b;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

/* Map / routes */
.ai-map-title { margin: 0 0 0.15rem; color: #ede9fe; font-size: 0.92rem; }
.ai-map-range { color: #a5b4fc; font-size: 0.75rem; margin-bottom: 0.3rem; }
.ai-map-summary { margin: 0 0 0.5rem; color: #ddd6fe; }
.ai-map-show-btn {
  background: #e6b566;
  color: #2a1c05;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.6rem;
}
.ai-map-show-btn:hover { background: #f0c87f; }
.ai-map-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.ai-map-btn-row .ai-map-show-btn { margin-bottom: 0; }
.ai-map-play-btn {
  background: #8b5cf6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.ai-map-play-btn:hover { background: #a78bfa; }
.ai-map-play-btn:disabled { opacity: 0.6; cursor: default; }
.ai-anim-caption {
  margin-bottom: 0.6rem;
  padding: 0.4rem 0.55rem;
  background: #1e1b4b;
  border: 1px solid #3b3680;
  border-radius: 5px;
  color: #e6b566;
  font-size: 0.78rem;
}
.ai-list-row { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.ai-list-row:hover { background: #3b3680; border-color: #8b5cf6; }
.ai-route-list { display: flex; flex-direction: column; gap: 0.4rem; }
.ai-route {
  background: #2a2658;
  border: 1px solid #3b3680;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}
.ai-route-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
}
.ai-route-path { font-weight: 600; color: #ede9fe; font-size: 0.8rem; }
.ai-route-meta { color: #9ca3cf; font-size: 0.72rem; margin-top: 0.2rem; }
.ai-route-label { color: #c4b5fd; font-size: 0.74rem; margin-top: 0.15rem; }
.ai-conf {
  font-size: 0.66rem;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  white-space: nowrap;
}
.ai-conf-high { background: #14532d; color: #86efac; }
.ai-conf-medium { background: #4a3a10; color: #fcd34d; }
.ai-conf-low { background: #4a1f1f; color: #fca5a5; }

/* Sources */
.ai-sources-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.ai-sources-key { color: #a5b4fc; font-size: 0.76rem; font-weight: 600; }
.ai-sources-val { color: #ddd6fe; font-size: 0.78rem; }
.ai-evidence-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ai-evidence-tag {
  background: #1e1b4b;
  color: #c4b5fd;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  font-size: 0.68rem;
}
.ai-sources-note { margin: 0.2rem 0 0; color: #b9b2e0; font-size: 0.76rem; }

.panel-block {
  padding: 1rem;
  border-bottom: 1px solid #222;
  overflow-y: auto;
}

#cultureItems {
  list-style: none;
  padding: 0;
  margin: 0;
}

#cultureItems li {
  padding: 0.5rem;
  margin-bottom: 0.25rem;
  background: #111827;
  cursor: pointer;
  border-radius: 4px;
}

#cultureItems li:hover {
  background: #1f2937;
}

.genetic-term {
  color: #facc15;
  text-decoration: none;
  border-bottom: 1px dashed #facc15;
  cursor: pointer;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s;
}

.genetic-term:hover {
  background: rgba(250, 204, 21, 0.15);
  color: #fde047;
  border-bottom-style: solid;
}

.dna-section {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.dna-section h3 {
  color: #34d399;
  border-bottom-color: rgba(16, 185, 129, 0.3);
}

.lineage-section {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.lineage-section h3 {
  color: #a78bfa;
  border-bottom-color: rgba(139, 92, 246, 0.3);
}

.lineage-flow {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.lineage-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lineage-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  min-width: 90px;
  flex-shrink: 0;
}

.lineage-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.lineage-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.3;
}

.lineage-item.clickable {
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.lineage-item.clickable:active {
  transform: scale(0.97);
}

.lineage-predecessor {
  background: rgba(251, 146, 60, 0.07);
  border: 1px solid rgba(251, 146, 60, 0.2);
  color: rgba(253, 186, 116, 0.6);
}

.lineage-predecessor.clickable {
  background: rgba(251, 146, 60, 0.12);
  border: 1px solid rgba(251, 146, 60, 0.3);
  color: #fdba74;
}

.lineage-predecessor.clickable:hover {
  background: rgba(251, 146, 60, 0.25);
  border-color: #fb923c;
}

.lineage-successor {
  background: rgba(56, 189, 248, 0.07);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: rgba(125, 211, 252, 0.6);
}

.lineage-successor.clickable {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
}

.lineage-successor.clickable:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
}

.lineage-arrow {
  color: #475569;
  font-size: 1rem;
}

.lineage-region {
  font-size: 0.75rem;
  color: #64748b;
  font-style: italic;
}

.lineage-relationship {
  font-size: 0.7rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.formation-text {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(139, 92, 246, 0.06);
  border-left: 3px solid rgba(139, 92, 246, 0.4);
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #cbd5e1;
}

.lineage-plus {
  color: #475569;
  font-weight: bold;
  font-size: 0.9rem;
}

/* Overlay Styles */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  background: #0f172a;
  padding: 2.5rem;
  border-radius: 12px;
  border: 1px solid #1e293b;
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #f1f5f9;
}

#overlayBody h2 {
  color: #38bdf8;
  margin-top: 0;
  font-size: 2rem;
  border-bottom: 2px solid #1e293b;
  padding-bottom: 0.5rem;
}

.era-label {
  display: inline-block;
  margin: 0.6rem 0 0.2rem;
  padding: 0.25rem 0.7rem;
  background: #7c2d12;
  color: #fde68a;
  border: 1px solid #b45309;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.detail-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 1.5rem 0;
}

.detail-image {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1e293b;
  background: #020617;
}

.detail-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.2s;
}

.detail-image img:hover {
  opacity: 0.9;
}

/* Image Modal Styles */
.image-modal {
  position: fixed;
  z-index: 3000;
  padding-top: 50px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(2, 6, 23, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.modal-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
  animation: zoom 0.3s;
  cursor: zoom-in;
  transition: transform 0.3s ease;
}

@keyframes zoom {
  from {transform: scale(0.7); opacity: 0;}
  to {transform: scale(1); opacity: 1;}
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #f1f5f9;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
  z-index: 3001;
}

.modal-close:hover {
  color: #38bdf8;
}

#modalCaption {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  color: #cbd5e1;
  padding: 15px 0;
  font-size: 1.2rem;
  font-weight: 500;
}

.image-label {
  background: #1e293b;
  color: #38bdf8;
  padding: 4px 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #334155;
}

.detail-section {
  margin-top: 1.5rem;
}

.detail-section h3 {
  color: #94a3b8;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.detail-section p {
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

.ie-badge {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-left: 4px solid;
}

.ie-yes {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: #3b82f6;
  color: #93c5fd;
}

.ie-no {
  background: rgba(239, 68, 68, 0.15);
  border-left-color: #ef4444;
  color: #fca5a5;
}

.ie-partial {
  background: rgba(234, 179, 8, 0.15);
  border-left-color: #eab308;
  color: #fde68a;
}

.ie-unknown {
  background: rgba(148, 163, 184, 0.15);
  border-left-color: #94a3b8;
  color: #cbd5e1;
}

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

.meta-item strong {
  color: #38bdf8;
  display: block;
  margin-bottom: 0.25rem;
}

.more-info-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #1e293b;
  text-align: center;
}

.more-info-btn {
  padding: 0.75rem 2rem;
  background: #38bdf8;
  color: #020617;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.more-info-btn:hover {
  background: #7dd3fc;
}

footer {
  padding: 0.5rem 1rem;
  background: #020617;
  border-top: 1px solid #222;
  text-align: right;
}

footer a {
  color: #38bdf8;
  text-decoration: none;
}

/* Auth */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.auth-card {
  background: #020617;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid #1f2937;
  width: 320px;
}

.auth-card h1 {
  margin-top: 0;
}

.auth-card label {
  display: block;
  margin-bottom: 1rem;
}

.auth-card input {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border-radius: 4px;
  border: 1px solid #374151;
  background: #020617;
  color: #f9fafb;
}

.auth-card button {
  width: 100%;
  padding: 0.75rem;
  border-radius: 4px;
  border: none;
  background: #38bdf8;
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.error {
  color: #f97373;
  margin-top: 0.5rem;
}

/* Admin */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1.6fr;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 80px);
  box-sizing: border-box;
}

.admin-panel {
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

.admin-panel h2 {
  margin-top: 0;
}

.admin-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

.admin-panel li {
  padding: 0.5rem;
  margin-bottom: 0.25rem;
  background: #0b1120;
  border-radius: 4px;
  cursor: pointer;
}

.admin-panel li:hover {
  background: #111827;
}

.admin-panel button {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  border: none;
  background: #22c55e;
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

#logoutBtn {
  background: #f97316;
  color: #020617;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

#adminEditor {
  flex: 1;
  overflow-y: auto;
}

#adminEditor form label {
  display: block;
  margin-bottom: 0.5rem;
}

#adminEditor form input,
#adminEditor form textarea {
  width: 100%;
  padding: 0.4rem;
  margin-top: 0.25rem;
  border-radius: 4px;
  border: 1px solid #374151;
  background: #020617;
  color: #f9fafb;
}

#adminEditor form textarea {
  min-height: 80px;
}

#adminEditor form button {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: none;
  background: #38bdf8;
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.expansion-section {
  border-top: 1px solid #1e293b;
  padding-top: 1.5rem;
}

.expansion-desc {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 1rem;
}

.expansion-btn-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.expansion-btn {
  padding: 0.75rem 1.25rem;
  background: #f97316;
  color: #020617;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
  flex: 1;
}

.expansion-btn:hover {
  background: #fb923c;
}

.solo-view-btn {
  padding: 0.75rem 1.25rem;
  background: #7c3aed;
  color: #f5f3ff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
  flex: 1;
}

.solo-view-btn:hover {
  background: #6d28d9;
}

.solo-view-desc {
  font-size: 0.78rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

/* ─── Tribe system ─── */

.tribes-btn-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #1e293b;
}

.show-tribes-btn {
  padding: 0.7rem 1.2rem;
  background: #0f766e;
  color: #ccfbf1;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.show-tribes-btn:hover {
  background: #115e59;
}

.tribes-btn-desc {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

/* Tribe HUD banner (below exit-isolate button on map) */
.tribe-hud {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 8, 22, 0.94);
  border: 1px solid #0f766e;
  border-radius: 8px;
  padding: 10px 18px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 1rem;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.30);
  pointer-events: auto;
}

.tribe-hud.hidden {
  display: none;
}

.tribe-hud span {
  color: #94a3b8;
  font-size: 0.88rem;
}

.tribe-hud strong {
  color: #5eead4;
}

.tribe-hud button {
  padding: 5px 14px;
  background: #0f766e;
  color: #ccfbf1;
  border: none;
  border-radius: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.tribe-hud button:hover {
  background: #115e59;
}

/* Tribe labels on map */
.tribe-label {
  background: rgba(5, 8, 22, 0.85);
  border: 1.5px solid currentColor;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  transform: translate(-50%, -50%);
  position: relative;
}

/* Tribe popup styling (inside Leaflet popup) */
.tribe-popup strong {
  font-size: 1rem;
  color: #f8fafc;
  display: block;
  margin-bottom: 4px;
}

.tribe-popup .tribe-capital {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.tribe-popup .tribe-note {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.5;
  font-style: italic;
}

#expansionHUD {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 8, 22, 0.94);
  border: 1px solid #f97316;
  border-radius: 10px;
  padding: 14px 24px;
  z-index: 10001;
  min-width: 360px;
  max-width: 680px;
  width: clamp(360px, 50vw, 680px);
  text-align: center;
  box-shadow: 0 4px 24px rgba(249, 115, 22, 0.25);
  pointer-events: auto;
}

.expansion-hud-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f97316;
  margin-bottom: 4px;
}

.expansion-hud-year {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f5f5f5;
  margin-bottom: 6px;
}

.expansion-hud-status {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.5;
  min-height: 2.5em;
  margin-bottom: 6px;
}

.expansion-hud-narrative {
  font-size: 0.82rem;
  color: #fde68a;
  line-height: 1.6;
  min-height: 3em;
  max-height: 9em;
  overflow-y: auto;
  background: rgba(249, 115, 22, 0.06);
  border-left: 2px solid #f97316;
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  text-align: left;
  opacity: 0;
  transition: none;
}

.expansion-hud-narrative:empty {
  background: none;
  border-left: none;
  padding: 0;
  min-height: 0;
}

@keyframes narrativeFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.narrative-fade-in {
  animation: narrativeFadeIn 0.6s ease forwards;
}

.expansion-hud-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 12em;
  overflow-y: auto;
  text-align: left;
}

.expansion-hud-cards:empty {
  display: none;
}

.rome-event-card {
  background: rgba(124, 45, 18, 0.18);
  border-left: 3px solid #b91c1c;
  border-radius: 5px;
  padding: 8px 11px;
  animation: narrativeFadeIn 0.5s ease forwards;
}

.rome-event-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}

.rome-event-card-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.rome-event-card-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.rome-event-card-text {
  font-size: 0.8rem;
  color: #e7d8c8;
  line-height: 1.55;
}

.expansion-hud-slider {
  margin-bottom: 10px;
}

.expansion-hud-slider input[type="range"] {
  width: 100%;
  accent-color: #b91c1c;
  cursor: pointer;
}

.expansion-hud-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.expansion-hud-stop {
  padding: 6px 20px;
  background: transparent;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.expansion-hud-stop:hover {
  background: #38bdf8;
  color: #020617;
}

.expansion-hud-voice {
  padding: 6px 14px;
  background: transparent;
  color: #a78bfa;
  border: 1px solid #a78bfa;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}

.expansion-hud-voice:hover {
  background: #a78bfa;
  color: #020617;
}

.expansion-hud-close {
  padding: 6px 20px;
  background: transparent;
  color: #f97316;
  border: 1px solid #f97316;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.expansion-hud-close:hover {
  background: #f97316;
  color: #020617;
}

.migration-tooltip {
  background: rgba(15, 23, 42, 0.9);
  color: #f97316;
  border: 1px solid #f97316;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.ice-tooltip {
  background: rgba(180, 220, 245, 0.9);
  color: #1e3a5f;
  border: 1px solid #a8d4f0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ===== ADMIN V2 ===== */

.admin-layout-v2 {
  display: grid;
  grid-template-columns: 260px 400px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.admin-sidebar-v2 {
  background: #020b1a;
  border-right: 1px solid #1f2937;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #1f2937;
}

.stab {
  flex: 1;
  padding: 0.6rem 0.25rem;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.stab.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

.stab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0.5rem;
  gap: 0.4rem;
}

.stab-content.hidden {
  display: none;
}

.sidebar-new-btn {
  width: 100%;
  padding: 0.5rem;
  background: #22c55e;
  color: #020617;
  font-weight: 700;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}

.sidebar-new-btn:hover {
  background: #4ade80;
}

.sidebar-search {
  width: 100%;
  padding: 0.35rem 0.5rem;
  background: #0b1120;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f9fafb;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

.sidebar-item {
  padding: 0.45rem 0.5rem;
  margin-bottom: 2px;
  background: #0b1120;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.sidebar-item:hover {
  background: #111827;
  border-color: #374151;
}

.sidebar-item.active {
  background: #0f2040;
  border-color: #38bdf8;
}

.si-name {
  font-size: 0.82rem;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-sub {
  font-size: 0.7rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.si-actions button {
  flex: 1;
  padding: 2px 6px;
  font-size: 0.72rem;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: #374151;
  color: #f9fafb;
}

.si-actions button:hover { background: #4b5563; }
.btn-danger-sm { background: #7f1d1d !important; color: #fca5a5 !important; }
.btn-danger-sm:hover { background: #991b1b !important; }

/* Editor panel */
.admin-editor-v2 {
  background: #020b1a;
  border-right: 1px solid #1f2937;
  overflow-y: auto;
  padding: 1rem;
}

.admin-editor-inner {
  color: #94a3b8;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.admin-form h3 {
  margin: 0 0 0.5rem 0;
  color: #f1f5f9;
  font-size: 1rem;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
  color: #94a3b8;
}

.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: #0b1120;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f9fafb;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.admin-form textarea {
  min-height: 70px;
  resize: vertical;
  font-family: monospace;
}

.admin-form input[type="range"] {
  padding: 0;
  accent-color: #38bdf8;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-primary {
  padding: 0.5rem 1rem;
  background: #38bdf8;
  color: #020617;
  border: none;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-primary:hover { background: #7dd3fc; }

.btn-secondary {
  padding: 0.4rem 0.8rem;
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #1d4ed8;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-secondary:hover { background: #1e40af; color: #bfdbfe; }

.btn-danger {
  padding: 0.5rem 1rem;
  background: #7f1d1d;
  color: #fca5a5;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-danger:hover { background: #991b1b; }

.boundary-info {
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  background: #0b1120;
  border-radius: 4px;
  border: 1px solid #1f2937;
}

.boundary-ok   { color: #4ade80; }
.boundary-none { color: #64748b; }

.bounds-fieldset {
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 0.5rem;
  margin: 0;
}

.bounds-fieldset legend {
  font-size: 0.75rem;
  color: #64748b;
  padding: 0 0.25rem;
}

.bounds-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 0.4rem;
  align-items: end;
  margin-bottom: 0.4rem;
}

/* Map section */
.admin-map-section {
  display: flex;
  flex-direction: column;
  background: #020b1a;
  overflow: hidden;
}

.admin-map-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #020617;
  border-bottom: 1px solid #1f2937;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.map-tool-btn {
  padding: 0.35rem 0.7rem;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #374151;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.map-tool-btn:hover {
  background: #334155;
  color: #f1f5f9;
}

.map-tool-status {
  font-size: 0.75rem;
  color: #64748b;
  flex: 1;
  min-width: 120px;
}

#adminMap {
  flex: 1;
  width: 100%;
}

/* Toast */
#adminToast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #22c55e;
  color: #020617;
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  z-index: 99999;
  pointer-events: none;
}

#adminToast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
/* Top navigation (Map / Languages) — absolutely positioned so it does not
   change the header height the map layout depends on. */
header {
  position: relative;
}

.top-nav {
  position: absolute;
  top: 1rem;
  right: 5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  max-width: 80%;
}

.top-nav a {
  color: #c4b5fd;
  text-decoration: none;
  font-size: 1.8rem;
  font-weight: 600;
  padding: 0.7rem 1.6rem;
  border: 1px solid #2a2350;
  border-radius: 6px;
  background: #161033;
}

.top-nav a:hover {
  background: #241a4d;
  color: #fff;
}

.top-nav a.active {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

@media (max-width: 600px) {
  .top-nav {
    top: 0.75rem;
    right: 2.5rem;
    gap: 0.4rem;
  }
  .top-nav a {
    font-size: 1.56rem;
    padding: 0.6rem 1.1rem;
  }
}

/* ===== Rebrand: Your Human Story ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
  padding: 0 1.5rem;
  background: rgba(7, 11, 22, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.site-nav .brand-mark { font-size: 1.4rem; }
.site-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.site-nav .nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.site-nav .nav-links a:hover,
.site-nav .nav-links a.active { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.site-nav .nav-soon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #5d6b85;
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  cursor: default;
}
.site-nav .nav-soon em,
.btn .soon {
  font-style: normal;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1a1304;
  background: var(--gold);
  padding: 0.12rem 0.36rem;
  border-radius: 5px;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

/* Hero */
header.hero {
  position: relative;
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(230, 181, 102, 0.16), transparent 60%),
    radial-gradient(900px 520px at 82% 115%, rgba(143, 184, 255, 0.12), transparent 60%),
    linear-gradient(180deg, #070b16 0%, #0a1122 100%);
  overflow: hidden;
}
.hero-inner { position: relative; max-width: 840px; }
.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 0.78rem;
  color: var(--gold-soft);
  margin: 0 0 1.3rem;
  font-weight: 600;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  line-height: 1.02;
  margin: 0;
  color: var(--text);
}
.hero-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.3rem, 3vw, 2.1rem);
  color: var(--gold);
  margin: 0.7rem 0 0;
}
.hero-sub {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: var(--text-dim);
  max-width: 640px;
  margin: 1.5rem auto 0;
  line-height: 1.65;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 2.3rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.85rem 1.6rem;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #1a1304;
  box-shadow: 0 8px 24px rgba(230, 181, 102, 0.25);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(230, 181, 102, 0.42); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.13); }
.btn-ghost.is-soon { color: #6b7a96; border-color: var(--border); cursor: default; }
.hero-scroll {
  position: absolute;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 1.5rem;
  text-decoration: none;
  animation: yhs-bob 1.8s ease-in-out infinite;
}
@keyframes yhs-bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(7px); }
}

#explore { scroll-margin-top: 64px; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .site-nav .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem 1rem;
  }
  .site-nav.open .nav-links { display: flex; }
  .site-nav .nav-links a,
  .site-nav .nav-soon { width: 100%; }

  /* Stack the map and the controls panel vertically on phones/tablets.
     Without this the flex row crams the map into an unusable sliver. */
  .layout {
    flex-direction: column;
    height: auto;
  }
  #map {
    flex: none;
    width: 100%;
    height: 70vh;
    min-height: 360px;
  }
  .side-panel {
    flex: none;
    width: 100%;
    border-left: none;
    border-top: 1px solid #222;
  }
}

/* ============================================================
   AI Museum Guide: info card, story player, showcase
   ============================================================ */

/* ---- Info card ---- */
.ai-card { display: flex; flex-direction: column; gap: 0.55rem; }
.ai-card-head { display: flex; align-items: center; gap: 0.5rem; }
.ai-card-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(255,255,255,0.06); }
.ai-card-title { margin: 0; font-family: var(--font-display); font-size: 1.35rem; color: var(--text); line-height: 1.15; }
.ai-card-status { font-size: 0.85rem; color: var(--gold-soft); font-style: italic; margin-top: -0.2rem; }
.ai-card-range { margin: 0.1rem 0; }
.ai-card-range-pill {
  display: inline-block; background: rgba(230,181,102,0.14); color: var(--gold-soft);
  border: 1px solid rgba(230,181,102,0.4); border-radius: 999px;
  padding: 0.2rem 0.7rem; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em;
}
.ai-card-summary { margin: 0.2rem 0; color: #dfe6f2; line-height: 1.55; font-size: 0.93rem; }

.ai-card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.1rem; }
.ai-card-btn {
  background: var(--gold); color: #1a1206; border: none; border-radius: 8px;
  padding: 0.45rem 0.8rem; font-size: 0.85rem; font-weight: 700; cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.ai-card-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ai-card-btn.ghost { background: transparent; color: var(--gold-soft); border: 1px solid rgba(230,181,102,0.5); }
.ai-card-btn.story { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }
.ai-card-btn.big { font-size: 0.95rem; padding: 0.6rem 1.1rem; margin-bottom: 0.6rem; }

.ai-card-section { border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,0.02); overflow: hidden; }
.ai-card-section + .ai-card-section { margin-top: 0.1rem; }
.ai-card-section-head {
  display: flex; align-items: center; gap: 0.45rem; cursor: pointer; list-style: none;
  padding: 0.55rem 0.7rem; font-weight: 600; font-size: 0.9rem; color: var(--text);
  user-select: none;
}
.ai-card-section-head::-webkit-details-marker { display: none; }
.ai-card-section-head::after { content: '▸'; margin-left: auto; color: var(--text-dim); transition: transform 0.15s ease; }
.ai-card-section[open] .ai-card-section-head::after { transform: rotate(90deg); }
.ai-card-section-icon { font-size: 1rem; }
.ai-card-section-body { padding: 0 0.7rem 0.6rem; display: flex; flex-direction: column; gap: 0.35rem; }
.ai-card-row { display: flex; gap: 0.5rem; font-size: 0.88rem; line-height: 1.4; }
.ai-card-row-label { flex: 0 0 33%; color: var(--text-dim); font-weight: 600; }
.ai-card-row-val { color: #e6ecf6; }

.ai-card-event {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.25rem 0; font-size: 0.88rem;
  border-radius: 6px;
}
.ai-card-event:hover { background: rgba(230,181,102,0.08); }
.ai-card-event-year {
  flex: 0 0 auto; border: 1px solid var(--gold); color: var(--gold-soft);
  border-radius: 6px; padding: 0.1rem 0.45rem; font-size: 0.78rem; font-weight: 700;
}
.ai-card-event-title { color: #e6ecf6; }

.ai-card-related { margin-top: 0.3rem; }
.ai-card-related-label { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ai-card-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ai-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer;
  background: rgba(255,255,255,0.04); border: 1px solid var(--chip-color, #555);
  border-left-width: 3px; border-radius: 8px; padding: 0.3rem 0.6rem;
  color: var(--text); font-size: 0.82rem; transition: background 0.12s ease, transform 0.12s ease;
}
.ai-chip:hover { background: rgba(255,255,255,0.09); transform: translateY(-1px); }
.ai-chip.disabled { cursor: default; opacity: 0.55; }
.ai-chip.disabled:hover { background: rgba(255,255,255,0.04); transform: none; }
.ai-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.ai-chip-name { font-weight: 600; }
.ai-chip-rel { color: var(--text-dim); font-size: 0.74rem; }

/* ---- Story tab panel ---- */
.ai-story-panel { display: flex; flex-direction: column; }
.ai-story-title { margin: 0 0 0.2rem; font-family: var(--font-display); font-size: 1.2rem; color: var(--text); }
.ai-story-sub { margin: 0 0 0.6rem; color: var(--text-dim); font-size: 0.86rem; }
.ai-story-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.ai-story-li { display: flex; gap: 0.6rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; transition: background 0.12s ease; }
.ai-story-li:hover { background: rgba(124,58,237,0.1); border-color: rgba(168,85,247,0.5); }
.ai-story-li-year { flex: 0 0 auto; color: #c4b5fd; font-weight: 700; font-size: 0.8rem; padding-top: 0.1rem; }
.ai-story-li-title { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.ai-story-li-desc { color: var(--text-dim); font-size: 0.83rem; line-height: 1.45; margin-top: 0.15rem; }

/* ---- Homepage showcase ---- */
.showcase { background: linear-gradient(180deg, var(--bg-2), var(--bg)); padding: 3.5rem 1.25rem 3rem; border-top: 1px solid var(--border); }
.showcase-inner { max-width: 1040px; margin: 0 auto; text-align: center; }
.showcase-eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.78rem; color: var(--gold); font-weight: 700; margin: 0 0 0.3rem; }
.showcase-title { font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 0 0 0.4rem; color: var(--text); }
.showcase-sub { color: var(--text-dim); max-width: 620px; margin: 0 auto 2rem; line-height: 1.6; }
.showcase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.showcase-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.3rem 1.2rem; cursor: pointer; color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.showcase-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 14px 36px rgba(0,0,0,0.45); }
.showcase-card-icon { font-size: 2rem; }
.showcase-card-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.showcase-card-desc { color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; flex: 1; }
.showcase-card-go { color: var(--gold-soft); font-weight: 700; font-size: 0.88rem; margin-top: 0.3rem; }

@media (max-width: 640px) {
  .ai-card-row-label { flex: 0 0 40%; }
  .showcase { padding: 2.5rem 1rem; }
}

/* ============================================================================
   ROME CINEMATIC EXPERIENCE — documentary narration panel
   ========================================================================== */
.showcase-card.is-feature {
  border-color: rgba(230, 181, 102, 0.55);
  box-shadow: 0 0 0 1px rgba(230, 181, 102, 0.18), 0 18px 40px rgba(0, 0, 0, 0.45);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(230, 181, 102, 0.12), transparent 55%),
    var(--surface, #111a2e);
}
.showcase-card.is-feature .showcase-card-go { color: var(--gold, #e6b566); }

/* --- Compact documentary overlay: small, semi-transparent, draggable -------- */
.rome-cine {
  position: fixed;
  left: 18px;
  bottom: 18px;
  right: auto;
  top: auto;
  width: min(250px, calc(100vw - 24px));
  z-index: 4000;
  background: linear-gradient(180deg, rgba(14, 10, 7, 0.55), rgba(20, 13, 8, 0.62));
  border: 1px solid rgba(230, 181, 102, 0.38);
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5);
  color: #f4ecdd;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  animation: romeCineRise 0.4s cubic-bezier(0.2, 0.8, 0.25, 1);
  transition: opacity 0.6s ease;
}
/* Auto-fades after a few idle seconds so it never blocks the documentary; any
   hover/touch snaps it back to full opacity (see armRomeCineFade in script.js). */
.rome-cine.faded { opacity: 0.28; }
.rome-cine.faded:hover { opacity: 1; }
@keyframes romeCineRise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.55rem 0.5rem 0.85rem;
  cursor: grab;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid rgba(230, 181, 102, 0.16);
  touch-action: none;
  user-select: none;
}
.rc-head:active { cursor: grabbing; }
.rc-head-title {
  font-family: var(--font-display, Georgia, serif);
  font-size: 0.74rem;
  font-weight: 700;
  color: #e6b566;
  letter-spacing: 0.02em;
}
.rc-head-btns { display: flex; gap: 4px; }
.rc-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(230, 181, 102, 0.28);
  background: rgba(0, 0, 0, 0.3);
  color: #e6b566;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.rc-icon:hover { background: rgba(230, 181, 102, 0.18); }

.rome-cine.min .rc-body { display: none; }
.rome-cine.min { width: min(200px, calc(100vw - 24px)); }
.rome-cine.min .rc-head { border-bottom: none; }

.rc-body { padding: 0.55rem 0.62rem 0.6rem; }
.rc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.rc-date {
  font-family: var(--font-display, Georgia, serif);
  font-size: 0.82rem;
  font-weight: 700;
  color: #e6b566;
  background: rgba(230, 181, 102, 0.12);
  border: 1px solid rgba(230, 181, 102, 0.3);
  border-radius: 999px;
  padding: 0.06rem 0.5rem;
}
.rc-chapter { font-size: 0.62rem; letter-spacing: 0.1em; color: #b9a888; }
.rc-titlerow { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.22rem; }
.rc-bigicon { font-size: 1.05rem; line-height: 1; flex: 0 0 auto; }
.rc-title {
  font-family: var(--font-display, Georgia, serif);
  font-size: 0.92rem;
  line-height: 1.15;
  margin: 0;
  color: #fbf3e4;
}
.rc-text {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #e3d8c5;
  max-height: 19vh;
  overflow-y: auto;
}
.rc-more {
  background: none;
  border: none;
  color: #e6b566;
  font-size: 0.8rem;
  padding: 0;
  cursor: pointer;
  margin-bottom: 0.55rem;
}
.rc-more:hover { text-decoration: underline; }
/* ---- Shared story-player progress dots (Yamnaya / Hittite / AI stories) ---- */
.rc-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 0.6rem; }
.rc-seg {
  flex: 1 1 0;
  min-width: 5px;
  height: 4px;
  border-radius: 2px;
  background: rgba(230, 181, 102, 0.18);
  cursor: pointer;
  transition: background 0.2s;
}
.rc-seg:hover { background: rgba(230, 181, 102, 0.45); }
.rc-seg.on { background: #e6b566; }

/* ---- Documentary timeline bar: milestone ticks, current auto-highlighted ---- */
.rc-timeline {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  margin-bottom: 0.6rem;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(230, 181, 102, 0.18);
}
.rc-timeline::-webkit-scrollbar { display: none; }
.rc-tick {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.rc-tick-bar {
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: rgba(230, 181, 102, 0.22);
  transition: background 0.2s, height 0.2s, box-shadow 0.2s;
}
.rc-tick.major .rc-tick-bar { height: 12px; width: 5px; background: rgba(230, 181, 102, 0.4); }
.rc-tick.past .rc-tick-bar { background: rgba(230, 181, 102, 0.55); }
.rc-tick:hover .rc-tick-bar { background: rgba(230, 181, 102, 0.7); }
.rc-tick.on .rc-tick-bar {
  height: 16px;
  width: 5px;
  background: #e6b566;
  box-shadow: 0 0 7px rgba(230, 181, 102, 0.85);
}
.rc-tick-year {
  font-size: 0.5rem;
  line-height: 1;
  color: #b9a888;
  white-space: nowrap;
}
.rc-tick.on .rc-tick-year { color: #fbf3e4; font-weight: 700; }
.rc-actions { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.rc-actions2 { display: flex; gap: 0.4rem; }
.rc-btn {
  border-radius: 8px;
  border: 1px solid rgba(230, 181, 102, 0.45);
  background: rgba(255, 255, 255, 0.05);
  color: #e6b566;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.36rem 0.45rem;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, opacity 0.15s;
}
.rc-btn:hover { background: rgba(230, 181, 102, 0.16); }
.rc-btn.primary {
  flex: 1;
  background: linear-gradient(180deg, #e6b566, #c9933f);
  color: #2a1a08;
  font-weight: 700;
}
.rc-btn.primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, #e6b566, #c9933f); }
.rc-btn.ghost { flex: 0 0 auto; }
.rc-btn.small { flex: 1; font-size: 0.78rem; padding: 0.42rem 0.4rem; }
.rc-btn.small.on { background: rgba(230, 181, 102, 0.22); color: #fbf3e4; }
.rc-btn:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 640px) {
  .rome-cine { left: 8px; right: 8px; bottom: 8px; width: min(250px, calc(100vw - 16px)); }
  .rc-title { font-size: 0.92rem; }
  .rc-text { font-size: 0.76rem; max-height: 19vh; }
}

/* ---- Rome territory prominence: stronger border + warm glow ---- */
.rome-direct-path {
  filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6))
          drop-shadow(0 0 2px rgba(139, 0, 0, 0.85));
}
/* Brief gold "acquisition" pulse when a new chapter settles (pulseRomeTerritory). */
.rome-direct-path.rome-acquire { animation: romeAcquire 1.3s ease-out; }
@keyframes romeAcquire {
  0%   { filter: drop-shadow(0 0 3px rgba(212, 175, 55, 0.4)); }
  35%  { filter: drop-shadow(0 0 16px rgba(240, 205, 90, 0.95)) drop-shadow(0 0 6px rgba(240, 205, 90, 0.8)); }
  100% { filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6)) drop-shadow(0 0 2px rgba(139, 0, 0, 0.85)); }
}

/* ---- Rome map labels: semi-transparent + shorter (truncate, never sprawl) ---- */
.rome-event-text, .rome-client-text, .rome-breakaway-text, .rome-arrow-text {
  opacity: 0.8;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.35s ease;
}

/* ---- Map event emoji icon (dropped at conquest/invasion targets) ---- */
.rome-evt-emoji {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.9));
  animation: romeEvtPop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  pointer-events: none;
}
@keyframes romeEvtPop {
  0%   { transform: scale(0.2); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- AI explainer panel + audio settings ---- */
.rc-ai {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(230, 181, 102, 0.10);
  border: 1px solid rgba(230, 181, 102, 0.3);
  max-height: 26vh;
  overflow-y: auto;
}
.rc-ai-title { font-size: 0.72rem; font-weight: 700; color: #e6b566; margin-bottom: 0.25rem; }
.rc-ai-body { font-size: 0.78rem; line-height: 1.45; color: #f0e6d4; }
.rc-ai-load { font-style: italic; opacity: 0.8; }
.rc-actions3 { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.rc-actions3 .rc-btn.tiny { flex: 1; }
.rc-settings {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(230, 181, 102, 0.18);
}
.rc-btn.tiny { flex: 0 0 auto; font-size: 0.68rem; padding: 0.3rem 0.42rem; }
.rc-btn.tiny.on { background: rgba(230, 181, 102, 0.22); color: #fbf3e4; }
.rc-vol { display: flex; align-items: center; gap: 0.25rem; font-size: 0.7rem; color: #cbb890; margin-left: auto; }
.rc-vol input[type="range"] { width: 64px; accent-color: #e6b566; }
/* While borders are morphing, fade map labels so the eye follows the movement.
   Restored automatically when the scene settles/pauses (class removed). */
body.rome-animating .rome-event-text,
body.rome-animating .rome-client-text,
body.rome-animating .rome-breakaway-text,
body.rome-animating .rome-arrow-text {
  opacity: 0.16 !important;
}

/* ---- Animated event layer: destination flash ---- */
.event-flash-wrap { background: transparent; border: none; }
.event-flash {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
  animation: eventFlashPulse 1.1s ease-out infinite;
}
@keyframes eventFlashPulse {
  0%   { transform: scale(0.4); opacity: 0.9; }
  70%  { opacity: 0.25; }
  100% { transform: scale(2.6); opacity: 0; }
}
