/* ============================================================
   MigrationScope - Stylesheet
   See Where We All Came From
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */

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

:root {
  --primary: #8B5E3C;
  --ocean: #1e6091;
  --land: #d4a574;
  --fertile: #2d6a4f;
  --split: #e76f51;
  --bg-dark: #0d1117;
  --bg-panel: #161b22;
  --bg-card: #1c2333;
  --bg-hover: #222d3d;
  --text-light: #f0ece6;
  --text-muted: #8b949e;
  --text-dark: #1a1a2e;
  --border: #30363d;
  --radius: 8px;
  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
  height: 100dvh;
  height: 100vh; /* fallback for older browsers */
  width: 100vw;
}

@supports (height: 100dvh) {
  body { height: 100dvh; }
  .app-layout { height: 100dvh; }
}

h1, h2, h3, h4, h5 {
  font-family: 'Merriweather', Georgia, serif;
  font-weight: 700;
}

a { color: var(--ocean); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */

.app-layout {
  display: grid;
  grid-template-rows: 48px 1fr auto;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main"
    "timeline timeline";
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

/* ============================================================
   HEADER
   ============================================================ */

.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

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

.header-brand h1 {
  font-size: 1.1rem;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.header-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-center {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.header-center #currentGroupName {
  font-weight: 600;
  color: var(--text-light);
  font-size: 1rem;
}

/* Comparison Mode */
.btn-compare {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn-compare:hover {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}
.btn-exit-compare {
  background: linear-gradient(135deg, #e76f51, #b45309);
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn-exit-compare:hover {
  background: linear-gradient(135deg, #f97316, #e76f51);
}
.card-compare {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  cursor: pointer;
}
.compare-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #06b6d4;
  cursor: pointer;
}
.browser-card { position: relative; }
.browser-card.compare-selected {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}
.comparison-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
}

.btn-play-all {
  background: linear-gradient(135deg, #1e6091, #2d6a4f);
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn-play-all:hover {
  background: linear-gradient(135deg, #2878ab, #3d8a6f);
  box-shadow: 0 0 12px rgba(30, 96, 145, 0.4);
}
.btn-play-all.active {
  background: linear-gradient(135deg, #e76f51, #b45309);
  box-shadow: 0 0 12px rgba(231, 111, 81, 0.4);
}

.btn-browse {
  background: var(--primary);
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-browse:hover {
  background: #a0714e;
}

.btn-sidebar-toggle {
  display: none;
  background: var(--bg-card);
  color: var(--text-light);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 1.1rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Group Info Card */
.info-header {
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.info-header h2 {
  font-size: 1rem;
  line-height: 1.3;
  flex: 1;
}

.era-badge {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.info-item {
  background: var(--bg-card);
  padding: 6px 8px;
  border-radius: 4px;
}

.info-item.full-width {
  grid-column: 1 / -1;
}

.info-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.info-value {
  display: block;
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 500;
}

.group-summary {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 8px 10px;
  border-radius: 4px;
  border-left: 3px solid var(--primary);
}

/* Phases */
.phase-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

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

.phase-item.active {
  border-color: var(--primary);
  background: rgba(139, 94, 60, 0.1);
}

.phase-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.phase-number {
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.phase-title strong {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

.phase-dates {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.phase-narrative {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: none;
}

.phase-item.active .phase-narrative {
  display: block;
}

.phase-splits {
  margin-top: 6px;
}

.split-event {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--split);
  padding: 3px 0;
}

.split-icon {
  font-size: 0.9rem;
}

/* Detailed Movements */
.phase-details {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}
.details-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
}
.details-toggle:hover { color: var(--text-light); }
.details-arrow {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  display: inline-block;
}
.phase-details.expanded .details-arrow {
  transform: rotate(90deg);
}
.details-list {
  display: none;
  padding: 4px 0 0 12px;
}
.phase-details.expanded .details-list {
  display: block;
}
.detail-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.detail-type-badge {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.detail-type-campaign   { background: rgba(239,68,68,0.2); color: #ef4444; }
.detail-type-trade      { background: rgba(234,179,8,0.2); color: #eab308; }
.detail-type-expedition { background: rgba(6,182,212,0.2); color: #06b6d4; }
.detail-type-raid       { background: rgba(249,115,22,0.2); color: #f97316; }
.detail-type-colony     { background: rgba(34,197,94,0.2); color: #22c55e; }
.detail-type-exodus     { background: rgba(148,163,184,0.2); color: #94a3b8; }
.detail-label { line-height: 1.3; }

/* Key Facts */
#keyFacts {
  list-style: none;
  padding: 0;
}

#keyFacts li {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: 4px;
  margin-bottom: 4px;
  line-height: 1.4;
  position: relative;
  padding-left: 18px;
}

#keyFacts li::before {
  content: "\2022";
  color: var(--primary);
  font-size: 1rem;
  position: absolute;
  left: 6px;
  top: 5px;
}

/* ============================================================
   MAIN MAP AREA
   ============================================================ */

.app-main {
  grid-area: main;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  overflow: hidden;
  position: relative;
}

.map-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
}

#mapCanvas {
  border-radius: var(--radius);
  box-shadow:
    0 0 40px rgba(30, 96, 145, 0.15),
    0 0 80px rgba(30, 96, 145, 0.05),
    inset 0 0 1px rgba(30, 96, 145, 0.3);
}

.zoom-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-light);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(4px);
}

.zoom-btn:hover {
  background: rgba(30, 40, 55, 0.9);
  border-color: var(--primary);
}

.zoom-btn-text {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.zoom-btn.active {
  background: rgba(30, 96, 145, 0.4);
  border-color: rgba(30, 96, 145, 0.7);
  color: #fff;
}

/* ============================================================
   TIMELINE BAR
   ============================================================ */

.app-timeline {
  grid-area: timeline;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  z-index: 100;
  min-height: 52px;
  flex-shrink: 0;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-control {
  background: var(--bg-card);
  color: var(--text-light);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-control:hover {
  background: var(--bg-hover);
}

.btn-control .icon {
  font-size: 0.7rem;
}

.timeline-scrubber-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-scrubber-container input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  outline: none;
}

.timeline-scrubber-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--text-light);
  box-shadow: 0 0 6px rgba(139, 94, 60, 0.5);
}

.timeline-scrubber-container input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--text-light);
  box-shadow: 0 0 6px rgba(139, 94, 60, 0.5);
}

.timeline-date {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 80px;
  text-align: center;
  font-family: 'Merriweather', serif;
}

.timeline-era {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 200px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-speed {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.timeline-speed select {
  background: var(--bg-card);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
}

.timeline-speed label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.progress-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

/* ============================================================
   GROUP BROWSER OVERLAY
   ============================================================ */

.group-browser {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.group-browser.open {
  opacity: 1;
  visibility: visible;
}

.browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.browser-header h2 {
  font-size: 1.2rem;
  color: var(--primary);
}

.browser-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#browserCount {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-close-browser {
  background: var(--bg-card);
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-close-browser:hover {
  background: var(--bg-hover);
}

.browser-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.browser-search {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--text-light);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  width: 260px;
  outline: none;
}

.browser-search:focus {
  border-color: var(--primary);
}

.browser-search::placeholder {
  color: var(--text-muted);
}

.era-filter-btn {
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--transition);
}

.era-filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-light);
}

.era-filter-btn.active {
  background: var(--primary);
  color: #fff;
}

.browser-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  align-content: start;
}

.browser-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.browser-card:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.browser-card.active {
  border-color: var(--primary);
  background: rgba(139, 94, 60, 0.1);
}

.browser-card.locked {
  opacity: 0.6;
}
.browser-card.locked:hover {
  opacity: 0.8;
}

.card-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  box-shadow: 0 0 8px rgba(255,255,255,0.2);
}

.card-content h3 {
  font-size: 0.9rem;
  margin-bottom: 4px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.card-era {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  color: #fff;
}

.card-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-route {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.card-language {
  font-size: 0.68rem;
  color: var(--ocean);
}

.lock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(139, 94, 60, 0.8);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 0.9rem;
}

/* ============================================================
   UPGRADE OVERLAY
   ============================================================ */

.upgrade-overlay {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 24px;
  z-index: 2000;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.upgrade-overlay.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.upgrade-overlay h3 {
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 1rem;
}

.upgrade-overlay p {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.btn-upgrade {
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "timeline";
  }

  .app-sidebar {
    position: fixed;
    left: -320px;
    top: 48px;
    bottom: 64px;
    width: 300px;
    z-index: 200;
    transition: left 0.3s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .app-sidebar.mobile-open {
    left: 0;
  }

  .btn-sidebar-toggle {
    display: block;
  }

  .header-center {
    display: none;
  }

  .timeline-era {
    display: none;
  }

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

  /* Browser overlay mobile fixes */
  .browser-header {
    padding: 12px 14px;
  }

  .browser-header h2 {
    font-size: 1rem;
  }

  .browser-filters {
    padding: 10px 14px;
    gap: 6px;
  }

  .browser-search {
    width: 100%;
    margin-bottom: 4px;
  }

  .browser-grid {
    padding: 12px 14px;
  }

  .era-filter-btn {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .patriarch-btn {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .filter-row {
    gap: 3px;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 8px;
  }

  .header-brand h1 {
    font-size: 0.9rem;
  }

  .app-timeline {
    padding: 6px 8px;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 44px;
  }

  .timeline-controls {
    gap: 3px;
    order: 1;
  }

  .timeline-scrubber-container {
    order: 2;
    width: 100%;
    gap: 6px;
  }

  .btn-control {
    padding: 8px 10px;
    font-size: 0.75rem;
    min-height: 36px;
  }

  .timeline-date {
    font-size: 0.75rem;
    min-width: 55px;
  }

  .timeline-speed {
    display: none;
  }

  .progress-label {
    display: none;
  }

  .timeline-era {
    display: none;
  }

  .timeline-date {
    font-size: 0.75rem;
    min-width: 60px;
  }

  /* Larger touch targets for scrubber on mobile */
  .timeline-scrubber-container input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .timeline-scrubber-container input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  .timeline-scrubber-container input[type="range"] {
    height: 8px;
  }

  .timeline-scrubber-container {
    gap: 6px;
  }

  /* Sidebar full width on very small screens */
  .app-sidebar {
    width: 85vw;
    max-width: 320px;
  }

  /* Browser card compact on mobile */
  .browser-card {
    padding: 10px;
    gap: 8px;
  }

  .card-content h3 {
    font-size: 0.82rem;
  }

  /* Upgrade overlay */
  .upgrade-overlay {
    left: 10px;
    right: 10px;
    bottom: 70px;
  }
}

/* Tiny screens (iPhone SE, etc.) */
@media (max-width: 380px) {
  .header-brand .brand-icon {
    display: none;
  }

  .header-brand h1 {
    font-size: 0.8rem;
  }

  .btn-play-all {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  .btn-browse {
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  .era-filter-btn {
    padding: 3px 6px;
    font-size: 0.6rem;
  }

  .patriarch-btn {
    padding: 3px 6px;
    font-size: 0.6rem;
  }
}

/* ============================================================
   LANDING PAGE RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .landing-hero {
    padding: 60px 16px 32px;
  }

  .hero-content h2 {
    font-size: 2rem;
  }

  .hero-content p {
    font-size: 0.95rem;
  }

  .hero-stats {
    gap: 20px;
    flex-wrap: wrap;
  }

  .hero-stat .stat-number {
    font-size: 1.5rem;
  }

  .landing-features,
  .landing-featured,
  .landing-pricing {
    padding: 48px 16px;
  }

  .landing-features .section-title,
  .section-title {
    font-size: 1.5rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .featured-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .landing-nav {
    padding: 0 12px;
  }
}

@media (max-width: 480px) {
  .hero-content h2 {
    font-size: 1.6rem;
  }

  .hero-content .tagline {
    font-size: 0.75rem;
    letter-spacing: 2px;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .hero-buttons a {
    width: 100%;
    max-width: 280px;
    text-align: center;
  }

  .hero-stats {
    gap: 16px;
  }

  .hero-stat .stat-number {
    font-size: 1.3rem;
  }

  .hero-stat .stat-label {
    font-size: 0.65rem;
  }

  .btn-cta, .btn-cta-outline {
    padding: 10px 20px;
    font-size: 0.85rem;
  }

  .feature-card {
    padding: 18px;
  }

  .pricing-card {
    padding: 24px 18px;
  }

  .pricing-price {
    font-size: 2rem;
  }
}

/* ============================================================
   LANDING PAGE STYLES
   ============================================================ */

/* These styles are only used in index.html */

.landing-body {
  overflow-y: auto;
  height: auto;
}

.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-nav .nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-nav .nav-brand h1 {
  font-size: 1.3rem;
  color: var(--primary);
}

.landing-nav .nav-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.btn-cta {
  background: var(--primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
  display: inline-block;
}

.btn-cta:hover {
  background: #a0714e;
  text-decoration: none;
}

.btn-cta-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  display: inline-block;
}

.btn-cta-outline:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* Hero */
.landing-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 40px;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(30, 96, 145, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 40%, rgba(139, 94, 60, 0.1) 0%, transparent 60%),
    var(--bg-dark);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 700px;
}

.hero-content .tagline {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--primary);
  margin-bottom: 16px;
  font-weight: 600;
}

.hero-content h2 {
  font-size: 3rem;
  line-height: 1.2;
  color: var(--text-light);
  margin-bottom: 20px;
}

.hero-content h2 span {
  color: var(--primary);
}

.hero-content p {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-stats {
  display: flex;
  gap: 40px;
  margin-top: 48px;
  justify-content: center;
}

.hero-stat {
  text-align: center;
}

.hero-stat .stat-number {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  font-family: 'Merriweather', serif;
}

.hero-stat .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Features */
.landing-features {
  padding: 80px 24px;
  background: var(--bg-panel);
}

.landing-features .section-title {
  text-align: center;
  font-size: 2rem;
  color: var(--text-light);
  margin-bottom: 12px;
}

.landing-features .section-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 48px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: all var(--transition);
}

.feature-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

.feature-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Featured Migrations */
.landing-featured {
  padding: 80px 24px;
  background: var(--bg-dark);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.featured-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.featured-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.featured-card h3 {
  font-size: 1.05rem;
  color: var(--text-light);
  margin-bottom: 6px;
}

.featured-card .featured-date {
  font-size: 0.75rem;
  color: var(--primary);
  margin-bottom: 8px;
  font-weight: 600;
}

.featured-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Pricing */
.landing-pricing {
  padding: 80px 24px;
  background: var(--bg-panel);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 700px;
  margin: 0 auto;
}

.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
}

.pricing-card.featured {
  border-color: var(--primary);
  position: relative;
}

.pricing-card.featured::before {
  content: 'MOST POPULAR';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 10px;
  letter-spacing: 1px;
}

.pricing-card h3 {
  font-size: 1.3rem;
  margin-bottom: 6px;
  color: var(--text-light);
}

.pricing-price {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--primary);
  font-family: 'Merriweather', serif;
  margin-bottom: 4px;
}

.pricing-price span {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
}

.pricing-features {
  list-style: none;
  padding: 16px 0;
  text-align: left;
}

.pricing-features li {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 6px 0;
  padding-left: 20px;
  position: relative;
}

.pricing-features li::before {
  content: "\2713";
  color: var(--fertile);
  position: absolute;
  left: 0;
  font-weight: 700;
}

/* Footer */
.landing-footer {
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
}

.footer-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  font-family: 'Merriweather', serif;
}

.footer-links {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 12px;
}

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

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

/* Hero animation lines */
.hero-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.hero-line {
  position: absolute;
  height: 2px;
  border-radius: 1px;
  opacity: 0.15;
  animation: migrateLine 8s ease-in-out infinite;
}

@keyframes migrateLine {
  0% { transform: translateX(-100%); opacity: 0; }
  20% { opacity: 0.15; }
  80% { opacity: 0.15; }
  100% { transform: translateX(200%); opacity: 0; }
}

.hero-line:nth-child(1) { top: 25%; width: 200px; background: var(--ocean); animation-delay: 0s; left: 10%; }
.hero-line:nth-child(2) { top: 40%; width: 300px; background: var(--primary); animation-delay: 2s; left: 30%; }
.hero-line:nth-child(3) { top: 55%; width: 250px; background: var(--split); animation-delay: 4s; left: 20%; }
.hero-line:nth-child(4) { top: 70%; width: 180px; background: var(--fertile); animation-delay: 6s; left: 50%; }
.hero-line:nth-child(5) { top: 35%; width: 350px; background: var(--ocean); animation-delay: 1s; left: 40%; }
.hero-line:nth-child(6) { top: 60%; width: 220px; background: var(--primary); animation-delay: 3s; left: 60%; }

/* ============================================================
   TABLE OF NATIONS LINEAGE & PATRIARCH FILTERS
   ============================================================ */

.lineage-tree {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
}

.lineage-node {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(139, 94, 60, 0.15);
  border: 1px solid rgba(139, 94, 60, 0.25);
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

.lineage-node.current {
  background: rgba(139, 94, 60, 0.3);
  border-color: var(--primary);
  color: var(--text-light);
  font-weight: 600;
}

.lineage-arrow {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin: 0 2px;
  opacity: 0.5;
}

.haplogroup-info {
  padding-top: 6px;
}

.haplogroup-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

.haplogroup-label strong {
  color: var(--text-light);
}

/* Patriarch filter row */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.patriarch-filters {
  margin-top: 2px;
}

.patriarch-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}

.patriarch-btn:hover {
  background: rgba(139, 94, 60, 0.15);
  color: var(--text-light);
}

.patriarch-btn.active {
  background: var(--primary);
  color: var(--text-light);
  border-color: var(--primary);
}

/* ============================================================
   ACCOUNT BUTTON & AUTH MODAL
   ============================================================ */

.btn-account {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}
.btn-account:hover { border-color: var(--primary); color: var(--primary); }
.btn-account.logged-in { border-color: var(--fertile); color: var(--fertile); }
.btn-account.explorer { border-color: var(--primary); color: var(--primary); background: rgba(139,94,60,0.15); }

/* Auth Modal */
.auth-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-modal-backdrop.open { display: flex; }

.auth-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
}
.auth-close:hover { color: var(--text-light); }

.auth-modal h2 {
  font-size: 1.4rem;
  color: var(--text-light);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

.auth-error {
  display: none;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  color: #fca5a5;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.auth-error.visible { display: block; }

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.auth-field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-light);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition);
}
.auth-field input:focus { border-color: var(--primary); }
.auth-field input::placeholder { color: var(--text-muted); opacity: 0.5; }

.btn-auth-submit {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  margin-top: 4px;
  transition: background var(--transition);
}
.btn-auth-submit:hover { background: #a0714e; }
.btn-auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.auth-switch a { color: var(--primary); font-weight: 600; }

/* Account Menu */
.account-menu {
  display: none;
  position: fixed;
  top: 52px;
  right: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 220px;
  z-index: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.account-menu.open { display: block; }

.account-email {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}

.account-plan {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.account-plan.explorer { color: var(--primary); }

.btn-account-action {
  width: 100%;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background var(--transition);
}
.btn-account-action:hover { background: #a0714e; }

.btn-account-signout {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  border-radius: 6px;
  transition: all var(--transition);
}
.btn-account-signout:hover { border-color: #dc2626; color: #fca5a5; }

/* Mobile auth improvements */
@media (max-width: 600px) {
  .auth-modal { padding: 24px 20px; }
  .auth-modal h2 { font-size: 1.2rem; }
  .btn-account { width: 28px; height: 28px; font-size: 12px; }
  .account-menu { right: 8px; min-width: 200px; }
}

@media (max-width: 380px) {
  .auth-modal { padding: 20px 16px; max-width: 95vw; }
}
