/* ============ Reset & base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  font-family: 'Frank Ruhl Libre', Georgia, serif;
  color: #f5e9d2;
  background: #0a0a14;
  /* Mobile: prevent rubber-band, double-tap zoom delay, and selection on chrome */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: relative; touch-action: pan-x pan-y; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; touch-action: manipulation; }

/* Adaptive sizing variables — JS reads these to compute lane geometry */
:root {
  --portrait-size: 64px;
  --lane-height: 110px;
  --topbar-height: 64px;
  --minimap-height: 32px;
  --figure-width: 110px;
  --figure-label-size: 11px;
  --figure-years-size: 9px;
  --search-width: 280px;
}
@media (max-width: 720px) {
  :root {
    --portrait-size: 48px;
    --lane-height: 86px;
    --topbar-height: 56px;
    --minimap-height: 28px;
    --figure-width: 88px;
    --figure-label-size: 10px;
    --figure-years-size: 8px;
    --search-width: 100%;
  }
}

/* ============ Era background (morphs as you scroll) ============ */
#era-background {
  position: fixed; inset: 0;
  z-index: 0;
  transition: background 1.5s ease;
  background: radial-gradient(ellipse at center, #1a3a1a 0%, #06080d 100%);
}
#era-overlay {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.03) 0%, transparent 50%);
  mix-blend-mode: screen;
}

/* Era-specific themes */
.era-antediluvian #era-background { background: radial-gradient(ellipse at center, #1f3326 0%, #08120a 100%); }
.era-noahide      #era-background { background: linear-gradient(135deg, #2a2438 0%, #0d0a18 100%); }
.era-patriarchal  #era-background { background: linear-gradient(135deg, #6b4a25 0%, #1f1408 100%); }
.era-egypt        #era-background { background: linear-gradient(135deg, #c69749 0%, #3d2810 100%); }
.era-wilderness   #era-background { background: linear-gradient(180deg, #d4a661 0%, #6b4a25 60%, #2a1d0e 100%); }
.era-judges       #era-background { background: linear-gradient(135deg, #5a4423 0%, #1f1610 100%); }
.era-kingdom      #era-background { background: linear-gradient(135deg, #3d1f5a 0%, #c8a045 100%); }
.era-divided      #era-background { background: linear-gradient(135deg, #2a1832 0%, #4a2030 100%); }
.era-exile        #era-background { background: linear-gradient(135deg, #0a1530 0%, #1d0d2a 100%); }
.era-second_temple #era-background { background: linear-gradient(135deg, #5a4520 0%, #d4b870 100%); }
.era-mishnaic     #era-background { background: linear-gradient(135deg, #3d2818 0%, #6b4d30 100%); }
.era-talmudic     #era-background { background: linear-gradient(135deg, #4a3520 0%, #2a1f10 100%); }
.era-geonic       #era-background { background: linear-gradient(135deg, #1a3550 0%, #0a1828 100%); }
.era-rishonim     #era-background { background: linear-gradient(135deg, #3a1a4a 0%, #1a0828 100%); }
.era-acharonim    #era-background { background: linear-gradient(135deg, #4a2818 0%, #1a0c08 100%); }
.era-chassidic    #era-background { background: linear-gradient(135deg, #5a3010 0%, #2a1808 100%); }
.era-modern       #era-background { background: linear-gradient(135deg, #0a3050 0%, #f0f0f0 100%); }
.era-modern #era-overlay { background: linear-gradient(180deg, transparent 0%, rgba(0,80,160,0.15) 100%); }

/* ============ Top bar ============ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  background: linear-gradient(180deg, rgba(8,8,16,0.92) 0%, rgba(8,8,16,0.78) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212, 184, 112, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
@media (max-width: 720px) {
  .topbar { padding: 0 10px; gap: 8px; }
}

.brand { display: flex; align-items: center; gap: 10px; font-family: 'Cinzel', serif; font-weight: 700; font-size: 18px; letter-spacing: 1px; color: #f5d889; min-width: 0; flex-shrink: 0; }
.brand-icon { font-size: 24px; color: #d4b870; text-shadow: 0 0 12px rgba(212, 184, 112, 0.6); }
.brand-text { white-space: nowrap; }
@media (max-width: 720px) { .brand-text { display: none; } .brand-icon { font-size: 22px; } }

.era-display {
  flex: 1;
  text-align: center;
  font-family: 'Cinzel', serif;
  min-width: 0;
}
.era-name { font-size: 16px; font-weight: 500; color: #f5d889; letter-spacing: 2px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.era-years { font-size: 11px; color: rgba(245, 233, 210, 0.6); margin-top: 2px; letter-spacing: 1px; }
@media (max-width: 720px) {
  .era-name { font-size: 12px; letter-spacing: 1px; }
  .era-years { font-size: 9px; letter-spacing: 0.5px; margin-top: 1px; }
}

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
@media (max-width: 720px) { .topbar-right { gap: 6px; } }

/* ============ Search ============ */
.search { position: relative; }
.search input {
  width: var(--search-width);
  min-width: 200px;
  padding: 9px 14px;
  border-radius: 22px;
  border: 1px solid rgba(212, 184, 112, 0.35);
  background: rgba(20, 18, 28, 0.6);
  color: #f5e9d2;
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  outline: none;
  transition: all 0.2s;
}
.search input:focus { border-color: #d4b870; background: rgba(30, 26, 40, 0.85); box-shadow: 0 0 0 3px rgba(212, 184, 112, 0.15); }
.search input::placeholder { color: rgba(245, 233, 210, 0.45); }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 20px);
  max-height: min(420px, 60vh);
  overflow-y: auto;
  background: rgba(15, 14, 22, 0.97);
  border: 1px solid rgba(212, 184, 112, 0.3);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
  display: none;
  z-index: 200;
  -webkit-overflow-scrolling: touch;
}
.search-results.open { display: block; }

/* Mobile: search collapses to an icon, expands to fullscreen overlay when active */
@media (max-width: 720px) {
  .search {
    position: static;
  }
  .search input {
    display: none;
    position: fixed;
    top: 6px;
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0;
    z-index: 250;
    padding: 11px 16px 11px 42px;
    font-size: 16px;
    background: rgba(15, 14, 22, 0.98);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  }
  .search.open input { display: block; }
  .search-trigger {
    display: flex;
    width: 38px; height: 38px;
    border-radius: 50%;
    align-items: center; justify-content: center;
    background: rgba(20, 18, 28, 0.6);
    border: 1px solid rgba(212, 184, 112, 0.3);
    color: #f5d889;
    font-size: 16px;
    flex-shrink: 0;
  }
  .search-results {
    position: fixed;
    top: 56px;
    left: 8px; right: 8px;
    width: auto;
    max-width: none;
    max-height: 60vh;
    z-index: 240;
    display: none;
  }
  .search.open .search-results.open { display: block; }
}
@media (min-width: 721px) {
  .search-trigger { display: none; }  /* hidden on desktop */
  .search input { display: block; }   /* always visible on desktop */
}
.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(212, 184, 112, 0.08);
  transition: background 0.15s;
}
.search-result:hover, .search-result.active { background: rgba(212, 184, 112, 0.12); }
.search-result-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(212, 184, 112, 0.3); flex-shrink: 0; background: #2a2438; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #d4b870; font-size: 14px; }
.search-result-info { min-width: 0; flex: 1; }
.search-result-name { font-weight: 600; color: #f5e9d2; font-size: 14px; }
.search-result-meta { font-size: 11px; color: rgba(245, 233, 210, 0.55); margin-top: 2px; }

/* ============ Controls ============ */
.controls { display: flex; gap: 6px; }
.controls button {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(20, 18, 28, 0.6);
  border: 1px solid rgba(212, 184, 112, 0.3);
  color: #f5d889;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.controls button:hover { background: rgba(212, 184, 112, 0.18); border-color: #d4b870; transform: translateY(-1px); }
.controls button.active { background: rgba(212, 184, 112, 0.3); }
@media (max-width: 720px) {
  .controls { gap: 4px; }
  .controls button { width: 36px; height: 36px; font-size: 16px; }
  /* Hide zoom buttons on phones — pinch-to-zoom is the natural gesture */
  .controls #zoom-in, .controls #zoom-out { display: none; }
}

/* ============ Mini-map (sub-header strip — never overlaps figures) ============ */
.minimap {
  position: fixed;
  top: var(--topbar-height);
  left: 0; right: 0;
  width: 100%;
  height: var(--minimap-height);
  z-index: 90;
  background: rgba(8, 8, 16, 0.85);
  border-bottom: 1px solid rgba(212, 184, 112, 0.3);
  cursor: pointer;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  touch-action: none; /* let our click-to-jump handler work without scroll interference */
}
.minimap-track { position: absolute; inset: 0; display: flex; }
.minimap-era {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: rgba(245, 233, 210, 0.8);
  border-right: 1px solid rgba(0,0,0,0.35);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.minimap-era:hover { color: #fff; background-color: rgba(245,216,137,0.15); }
@media (max-width: 720px) {
  .minimap-era { font-size: 8px; letter-spacing: 0.5px; padding: 0 2px; }
}
.minimap-thumb {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(245, 216, 137, 0.25);
  border: 2px solid #f5d889;
  border-radius: 6px;
  pointer-events: none;
  transition: left 0.05s linear, width 0.05s linear;
  box-shadow: 0 0 12px rgba(245, 216, 137, 0.5);
}

/* ============ Viewport / canvas ============ */
.viewport {
  position: absolute;
  top: calc(var(--topbar-height) + var(--minimap-height));
  left: 0; right: 0; bottom: 0;
  overflow-x: auto;
  overflow-y: auto;
  z-index: 10;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;  /* iOS momentum scroll */
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
}
.viewport::-webkit-scrollbar { width: 10px; height: 10px; }
.viewport::-webkit-scrollbar-track { background: rgba(8,8,16,0.4); }
.viewport::-webkit-scrollbar-thumb { background: rgba(212, 184, 112, 0.4); border-radius: 5px; }
.viewport::-webkit-scrollbar-thumb:hover { background: rgba(212, 184, 112, 0.7); }
.viewport::-webkit-scrollbar-corner { background: rgba(8,8,16,0.6); }

.canvas {
  position: relative;
  /* width AND height are set in JS — height grows with lane count so vertical scroll exposes all figures */
}

/* Era band labels (large background letters) */
.era-bands { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.era-band {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 180px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.04);
  letter-spacing: 12px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  border-right: 1px dashed rgba(212, 184, 112, 0.08);
}

/* Century guide lines */
.centuries { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.century-line {
  position: absolute;
  top: 0; bottom: 60px;
  width: 1px;
  background: rgba(212, 184, 112, 0.07);
}
.century-line.major { background: rgba(212, 184, 112, 0.18); }
.century-line .label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 10px;
  color: rgba(245, 233, 210, 0.45);
  font-family: 'Cinzel', serif;
  white-space: nowrap;
}

/* Time axis at the bottom */
.time-axis {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60px;
  background: linear-gradient(180deg, transparent, rgba(8, 8, 16, 0.85));
  pointer-events: none;
  z-index: 5;
}

/* ============ Family-tree connection lines (SVG overlay behind figures) ============ */
.family-lines {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
  /* width/height set in JS to match canvas */
}
.family-lines.hidden { display: none; }
.family-line {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
}
.family-line.parent  { stroke: rgba(212, 184, 112, 0.32); }
.family-line.spouse  { stroke: rgba(232, 180, 212, 0.45); stroke-dasharray: 6, 3; }
.family-line.sibling { stroke: rgba(134, 239, 172, 0.18); stroke-dasharray: 2, 4; }
/* Highlight on figure hover via JS-toggled class */
.family-line.highlight { stroke-width: 3; opacity: 1; filter: drop-shadow(0 0 6px currentColor); }

/* ============ Figures ============ */
.figures-layer { position: absolute; inset: 0; padding-top: 150px; padding-bottom: 80px; z-index: 4; }

.figure {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  z-index: 4;
}
.figure:hover { z-index: 50; transform: translateY(-4px); }

.figure-lifeline {
  position: absolute;
  height: 4px;
  background: linear-gradient(90deg, rgba(212, 184, 112, 0.55), rgba(212, 184, 112, 0.85), rgba(212, 184, 112, 0.55));
  border-radius: 2px;
  top: calc(var(--portrait-size) / 2);
  left: 0;
  z-index: 1;
  box-shadow: 0 0 6px rgba(212, 184, 112, 0.3);
}
.figure:hover .figure-lifeline { background: linear-gradient(90deg, #f5d889, #fff5cc, #f5d889); box-shadow: 0 0 12px rgba(245, 216, 137, 0.7); }

.figure-portrait {
  width: var(--portrait-size); height: var(--portrait-size);
  border-radius: 50%;
  background: #2a2438;
  border: 3px solid #d4b870;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: calc(var(--portrait-size) * 0.34);
  color: #f5d889;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6), 0 0 0 2px rgba(8, 8, 16, 0.8);
  position: relative;
  z-index: 5;
  transition: all 0.2s;
}
.figure:hover .figure-portrait, .figure:active .figure-portrait {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.7), 0 0 0 2px rgba(8, 8, 16, 0.8), 0 0 24px rgba(245, 216, 137, 0.6);
  border-color: #f5d889;
}
.figure-portrait img { width: 100%; height: 100%; object-fit: cover; }

.figure-label {
  margin-top: 6px;
  padding: 3px 9px;
  background: rgba(8, 8, 16, 0.85);
  border-radius: 12px;
  font-size: var(--figure-label-size);
  font-weight: 600;
  color: #f5e9d2;
  white-space: nowrap;
  border: 1px solid rgba(212, 184, 112, 0.3);
  z-index: 5;
}
.figure:hover .figure-label, .figure:active .figure-label { background: rgba(212, 184, 112, 0.95); color: #1a0e02; border-color: #f5d889; }

.figure-years {
  margin-top: 2px;
  font-size: var(--figure-years-size);
  color: rgba(245, 233, 210, 0.55);
  font-family: 'Cormorant Garamond', serif;
  z-index: 5;
}
@media (max-width: 720px) {
  /* Hide year labels on mobile to reduce visual noise — already in tooltip/modal */
  .figure-years { display: none; }
}

/* Category color coding on the portrait ring */
.figure[data-category="patriarch"]    .figure-portrait { border-color: #d4b870; }
.figure[data-category="matriarch"]    .figure-portrait { border-color: #e8b4d4; }
.figure[data-category="prophet"]      .figure-portrait { border-color: #87ceeb; }
.figure[data-category="king"]         .figure-portrait { border-color: #c084fc; }
.figure[data-category="judge"]        .figure-portrait { border-color: #f59e0b; }
.figure[data-category="priest"]       .figure-portrait { border-color: #fef3c7; }
.figure[data-category="sage"]         .figure-portrait { border-color: #86efac; }
.figure[data-category="rabbi"]        .figure-portrait { border-color: #93c5fd; }
.figure[data-category="rebbe"]        .figure-portrait { border-color: #fbbf24; }
.figure[data-category="kabbalist"]    .figure-portrait { border-color: #c4b5fd; }
.figure[data-category="villain"]      .figure-portrait { border-color: #ef4444; }
.figure[data-category="convert"]      .figure-portrait { border-color: #fda4af; }

/* Highlight when searched */
.figure.highlight {
  animation: highlight-pulse 2s ease-in-out 3;
}
.figure.highlight .figure-portrait {
  box-shadow: 0 0 0 3px #fff, 0 0 36px 8px #f5d889;
}
@keyframes highlight-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-12px) scale(1.15); }
}

/* ============ Events: top strip with cards + descending guide lines ============ */
.events-layer { position: absolute; inset: 0; padding-bottom: 60px; z-index: 6; pointer-events: none; }

/* Vertical guide line drops from the events strip down past the figures */
.event-line {
  position: absolute;
  top: 130px;        /* below the events strip */
  bottom: 60px;      /* above the time axis */
  width: 1px;
  background: linear-gradient(180deg, rgba(245, 216, 137, 0.55) 0%, rgba(245, 216, 137, 0.18) 60%, rgba(245, 216, 137, 0.06) 100%);
  pointer-events: none;
  z-index: 2;
}

/* Clickable event card pinned to the top strip */
.event-card {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  background: linear-gradient(180deg, #fef0b3 0%, #f5d889 100%);
  color: #1a0e02;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-radius: 14px;
  border: 1px solid #b8923a;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  z-index: 7;
  transition: transform 0.15s, box-shadow 0.15s;
  height: 24px;
  line-height: 16px;
}
.event-card:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 18px rgba(245, 216, 137, 0.55), inset 0 1px 0 rgba(255,255,255,0.6);
  z-index: 60;
}
.event-star { font-size: 11px; }
.event-card-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.event-card-year { font-size: 9px; opacity: 0.7; font-weight: 500; letter-spacing: 0; }
.event-card:hover .event-card-year { opacity: 1; }

/* Tiny golden bead at the top of the descending line, just below the card */
.event-card::after {
  content: '';
  position: absolute;
  bottom: -7px; left: 50%;
  transform: translateX(-50%);
  width: 8px; height: 8px;
  background: #f5d889;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(245, 216, 137, 0.9);
}
@media (max-width: 720px) {
  .event-card { font-size: 9px; padding: 3px 7px 3px 5px; height: 22px; line-height: 14px; gap: 4px; }
  .event-card-year { font-size: 8px; }
  .event-line { top: 100px; }
}

/* ============ Tooltip ============ */
.tooltip {
  position: fixed;
  z-index: 300;
  max-width: 320px;
  background: rgba(15, 14, 22, 0.97);
  border: 1px solid rgba(212, 184, 112, 0.5);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #f5e9d2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tooltip.show { opacity: 1; }
.tooltip-name { font-family: 'Cinzel', serif; font-weight: 700; font-size: 16px; color: #f5d889; margin-bottom: 2px; }
.tooltip-hebrew { font-family: 'Frank Ruhl Libre', serif; font-size: 18px; color: #d4b870; margin-bottom: 6px; direction: rtl; text-align: right; }
.tooltip-meta { font-size: 11px; color: rgba(245, 233, 210, 0.65); margin-bottom: 8px; font-style: italic; }
.tooltip-bio { color: rgba(245, 233, 210, 0.92); }
.tooltip-cta { margin-top: 8px; font-size: 11px; color: #f5d889; font-style: italic; }

/* ============ Modal ============ */
.modal { position: fixed; inset: 0; z-index: 400; display: none; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #1a1828 0%, #0f0e16 100%);
  border: 1px solid rgba(212, 184, 112, 0.4);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 720px) {
  .modal-content { padding: 22px 18px; max-height: 92vh; border-radius: 14px; width: calc(100vw - 16px); }
  .modal-portrait { width: 100px; height: 100px; font-size: 36px; margin-bottom: 14px; }
  .modal-name { font-size: 22px; }
  .modal-hebrew { font-size: 22px; }
  .modal-bio { font-size: 15px; line-height: 1.55; }
  .modal-divider { margin: 14px 0; }
  .modal-close { width: 40px; height: 40px; top: 8px; right: 10px; font-size: 24px; }
  .family-heading { font-size: 12px; }
  .family-pill { font-size: 13px; padding: 7px 14px; } /* bigger touch targets on mobile */
  .family-group-label { font-size: 11px; }
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(212, 184, 112, 0.15);
  color: #f5d889;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(212, 184, 112, 0.35); }

.modal-body { color: #f5e9d2; }
.modal-portrait {
  width: 140px; height: 140px;
  border-radius: 50%;
  margin: 0 auto 20px;
  border: 4px solid #d4b870;
  overflow: hidden;
  background: #2a2438;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 50px;
  font-weight: bold;
  color: #f5d889;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 28px rgba(212, 184, 112, 0.3);
}
.modal-portrait img { width: 100%; height: 100%; object-fit: cover; }
.modal-name { text-align: center; font-family: 'Cinzel', serif; font-size: 28px; color: #f5d889; font-weight: 700; letter-spacing: 1px; }
.modal-hebrew { text-align: center; font-family: 'Frank Ruhl Libre', serif; font-size: 26px; color: #d4b870; margin-top: 4px; direction: rtl; }
.modal-meta { text-align: center; font-size: 13px; color: rgba(245, 233, 210, 0.7); margin-top: 8px; font-style: italic; letter-spacing: 0.5px; }
.modal-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(212, 184, 112, 0.5), transparent); margin: 20px 0; }
.modal-bio { font-family: 'Cormorant Garamond', serif; font-size: 17px; line-height: 1.7; color: rgba(245, 233, 210, 0.95); }
.modal-bio p { margin-bottom: 12px; }
.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.modal-tag { padding: 4px 10px; background: rgba(212, 184, 112, 0.15); border: 1px solid rgba(212, 184, 112, 0.3); border-radius: 12px; font-size: 11px; color: #f5d889; letter-spacing: 0.5px; }

/* ============ Family pills ============ */
.family-section { margin-top: 8px; }
.family-heading {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #f5d889;
  margin-bottom: 14px;
  text-align: center;
  opacity: 0.85;
}
.family-group { margin-bottom: 12px; }
.family-group-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(245, 233, 210, 0.6);
  margin-bottom: 6px;
  font-family: 'Cinzel', serif;
  font-weight: 500;
}
.family-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.family-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(245, 233, 210, 0.06);
  border: 1px solid rgba(245, 233, 210, 0.18);
  color: rgba(245, 233, 210, 0.75);
  transition: all 0.15s;
  user-select: none;
}
.family-pill.clickable {
  background: rgba(212, 184, 112, 0.16);
  border-color: rgba(212, 184, 112, 0.55);
  color: #f5d889;
  cursor: pointer;
}
.family-pill.clickable:hover {
  background: rgba(245, 216, 137, 0.95);
  color: #1a0e02;
  border-color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 216, 137, 0.4);
}

/* Help */
.help-content h2 { font-family: 'Cinzel', serif; color: #f5d889; margin-bottom: 12px; font-size: 26px; letter-spacing: 1px; }
.help-content p { margin-bottom: 12px; line-height: 1.6; color: rgba(245, 233, 210, 0.9); }
.help-content ul { list-style: none; margin: 16px 0; }
.help-content li { padding: 8px 0; border-bottom: 1px solid rgba(212, 184, 112, 0.12); color: rgba(245, 233, 210, 0.92); }
.help-content li b { color: #f5d889; }
.help-footnote { font-size: 12px; color: rgba(245, 233, 210, 0.55); font-style: italic; margin-top: 16px; }
.primary-btn {
  display: block;
  margin: 20px auto 0;
  padding: 12px 32px;
  background: linear-gradient(180deg, #f5d889, #d4b870);
  color: #1a0e02;
  font-weight: 700;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  border-radius: 24px;
  font-size: 14px;
  transition: transform 0.15s, box-shadow 0.2s;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(245, 216, 137, 0.4); }

/* Loader */
.loader { position: fixed; inset: 0; background: #06080d; z-index: 1000; display: flex; align-items: center; justify-content: center; transition: opacity 0.6s; }
.loader.hidden { opacity: 0; pointer-events: none; }
.loader-inner { text-align: center; }
.loader-star { font-size: 80px; color: #d4b870; text-shadow: 0 0 30px rgba(245, 216, 137, 0.6); animation: spin 4s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.loader-text { margin-top: 20px; font-family: 'Cinzel', serif; color: #f5d889; letter-spacing: 2px; font-size: 13px; }

/* (Mobile rules now distributed throughout the file using CSS variables + targeted @media blocks) */
