:root {
  --ink: #17213d;
  --muted: #60708d;
  --gold: #f7b731;
  --blue: #3867d6;
  --green: #20bf6b;
  --red: #eb3b5a;
  --purple: #8854d0;
  --paper: #ffffff;
  --bg: #f4f7ff;
  --line: #dfe7fb;
  --shadow: 0 18px 45px rgba(22, 33, 62, .14);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef5ff 0, #fff 38%, #f8fbff 100%);
}
button, input, select { font: inherit; }
.hero {
  padding: 22px clamp(16px, 4vw, 60px) 70px;
  color: white;
  background: radial-gradient(circle at 86% 18%, #ffe08a 0 13%, transparent 14%), linear-gradient(135deg, #172554, #3157d5 62%, #54d6ff);
  overflow: hidden;
}
.topbar { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.topbar a {
  color: white;
  text-decoration: none;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 35px; align-items: end; max-width: 1180px; margin: 70px auto 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .15em; font-weight: 900; color: var(--gold); font-size: .8rem; }
.hero h1 { font-size: clamp(2.8rem, 8vw, 6.9rem); line-height: .9; margin: 8px 0 20px; }
.lede { font-size: clamp(1.08rem, 2vw, 1.38rem); max-width: 760px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  background: white;
  color: #1f3a93;
  box-shadow: var(--shadow);
}
.button.primary { background: var(--gold); color: #432800; }
.button.ghost { background: rgba(255,255,255,.12); color: white; box-shadow: none; border: 1px solid rgba(255,255,255,.22); }
.button.slim { align-self: end; padding: 12px 14px; box-shadow: none; background: #ecf2ff; }
.stat-card { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); border-radius: 28px; padding: 26px; backdrop-filter: blur(10px); }
.stat-card span { font-size: 5rem; font-weight: 950; color: var(--gold); line-height: 1; }
.panel { max-width: 1180px; margin: 28px auto; padding: clamp(18px, 4vw, 34px); background: rgba(255,255,255,.92); border: 1px solid #e6ecff; border-radius: 32px; box-shadow: var(--shadow); }
.accent { background: linear-gradient(135deg, #fff8e3, #f0fff7); }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: end; }
.section-heading h2, .compare-panel h2 { font-size: clamp(1.6rem, 4vw, 2.6rem); margin: .2rem 0; }
.result-count { background: #edf3ff; padding: 10px 13px; border-radius: 999px; color: var(--blue); white-space: nowrap; }
.controls { display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr 1fr auto; gap: 12px; margin: 22px 0; }
.controls label { font-weight: 900; color: var(--muted); }
input, select { width: 100%; margin-top: 6px; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; background: white; color: var(--ink); }
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; align-content: start; }
.king-card { position: relative; border: 0; text-align: left; padding: 18px; min-height: 205px; border-radius: 24px; background: linear-gradient(180deg, #fff, #f7f9ff); box-shadow: 0 8px 24px rgba(22,33,62,.1); cursor: pointer; transition: .2s ease; }
.king-card:hover, .king-card.active { transform: translateY(-3px); outline: 3px solid #ffd36b; }
.king-card h3 { margin: 18px 0 4px; font-size: 1.35rem; }
.meta { color: var(--muted); font-weight: 800; font-size: .9rem; }
.avatar { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 16px; background: #eaf0ff; color: var(--blue); font-weight: 950; }
.avatar.large { width: 62px; height: 62px; font-size: 1.8rem; border-radius: 22px; }
.pill { float: right; font-size: .75rem; font-weight: 950; border-radius: 999px; padding: 5px 9px; background: #eaf0ff; color: var(--blue); text-transform: uppercase; letter-spacing: .04em; }
.good { background: #e7fff1; color: #078244; }
.mixed, .contested { background: #fff5d6; color: #9a6400; }
.bad { background: #ffe8ee; color: #c2173c; }
.foreign { background: #efe8ff; color: #6b35c8; }
.detail { position: sticky; top: 15px; align-self: start; background: #18233f; color: white; border-radius: 28px; padding: 26px; min-height: 520px; }
.detail-top { display: flex; gap: 15px; align-items: center; }
.detail h2 { font-size: 2.4rem; margin: .2rem 0; }
.summary { font-size: 1.08rem; line-height: 1.6; }
.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.fact-grid div, .scripture { background: rgba(255,255,255,.1); padding: 12px; border-radius: 16px; }
.fact-grid strong { color: #ffd36b; display: block; }
.fact-grid span { display: block; margin-top: 5px; }
.detail h3 { color: #ffd36b; margin-bottom: 4px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.timeline-scale { display: flex; justify-content: space-between; color: var(--muted); font-weight: 900; border-bottom: 2px dashed #d3dfbd; padding-bottom: 8px; }
.timeline-track { display: grid; gap: 9px; margin-top: 14px; }
.timeline-row { position: relative; display: grid; grid-template-columns: 170px 1fr 130px; align-items: center; gap: 12px; min-height: 34px; border: 0; border-radius: 14px; background: rgba(255,255,255,.62); padding: 6px 10px; text-align: left; cursor: pointer; }
.timeline-row span { font-weight: 900; }
.timeline-row i { position: absolute; left: 190px; right: 130px; height: 18px; border-radius: 999px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.timeline-row small { text-align: right; color: var(--muted); font-weight: 800; }
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; align-items: start; }
.bible-map { width: 100%; border-radius: 28px; background: #7dd3fc; box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); }
.land, .sinai { fill: url(#landGradient); filter: url(#mapShadow); }
.coast-glow { fill: #f8e7b9; opacity: .86; }
.desert { fill: none; stroke: rgba(125, 82, 31, .28); stroke-width: 2; stroke-dasharray: 9 13; }
.river { fill: none; stroke: #38bdf8; stroke-linecap: round; opacity: .8; }
.nile { stroke-width: 12; }
.euphrates, .tigris { stroke-width: 8; }
.water { fill: #1d4ed8; opacity: .86; stroke: #dff8ff; stroke-width: 3; }
.route { fill: none; stroke: rgba(91, 64, 32, .35); stroke-width: 3; stroke-dasharray: 7 8; }
.map-labels text { fill: rgba(23, 33, 61, .55); font-size: 18px; font-weight: 900; font-style: italic; }
.region { cursor: pointer; stroke: #fff; stroke-width: 4; filter: drop-shadow(0 6px 5px rgba(0,0,0,.18)); transition: .2s; }
.region path { opacity: .82; }
.region:hover, .region:focus { opacity: .9; transform: translateY(-3px); outline: none; }
.region:hover path, .region:focus path { opacity: 1; }
.region text { fill: white; font-weight: 950; font-size: 19px; paint-order: stroke; stroke: rgba(23,33,61,.55); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.legend button { display: flex; gap: 8px; align-items: center; width: 100%; margin: 7px 0; border: 0; border-radius: 14px; padding: 10px; text-align: left; background: #eef4ff; font-weight: 900; cursor: pointer; }
.legend span { width: 14px; height: 14px; border-radius: 4px; }
.compare-panel { display: grid; grid-template-columns: .9fr 1.4fr; gap: 22px; align-items: start; }
.compare-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.compare-tray article { min-height: 150px; border-radius: 22px; padding: 16px; background: linear-gradient(180deg, #fff, #f3f7ff); border: 1px solid var(--line); }
.compare-tray strong, .compare-tray span, .compare-tray small { display: block; }
.compare-tray span { color: var(--blue); font-weight: 900; margin: 6px 0; }
.learn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.learn-grid article { background: #f8fbff; border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
dialog { border: 0; border-radius: 24px; padding: 24px; max-width: 470px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20,28,52,.55); }
footer { text-align: center; color: var(--muted); padding: 35px; }
.empty { grid-column: 1 / -1; padding: 22px; background: #fff8e3; border-radius: 18px; font-weight: 900; }
@media (max-width: 950px) {
  .hero-grid, .layout, .map-wrap, .compare-panel, .learn-grid { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr 1fr; }
  .detail { position: relative; min-height: auto; }
  .compare-tray { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .hero { padding-bottom: 38px; }
  .hero-grid { margin-top: 36px; }
  .topbar { justify-content: flex-start; }
  .controls, .fact-grid { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .timeline-row { grid-template-columns: 1fr; padding-bottom: 28px; }
  .timeline-row i { left: 10px !important; right: auto; bottom: 8px; max-width: calc(100% - 20px); }
  .timeline-row small { text-align: left; }
}
.king-popup { width: min(680px, calc(100vw - 28px)); color: white; background: #18233f; }
.king-popup form { position: relative; }
.dialog-close { position: absolute; top: -10px; right: -8px; width: 38px; height: 38px; border: 0; border-radius: 999px; background: #ffd36b; color: #432800; font-size: 1.6rem; font-weight: 950; cursor: pointer; }
.popup-top { padding-right: 38px; }
.popup-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.popup-facts div { background: rgba(255,255,255,.1); padding: 12px; border-radius: 16px; }
.popup-facts strong { display: block; color: #ffd36b; }
.popup-facts span { display: block; margin-top: 5px; }
@media (max-width: 620px) { .popup-facts { grid-template-columns: 1fr; } }
.map-note { margin-top: -8px; color: var(--muted); font-weight: 800; }
.accurate-map-wrap { grid-template-columns: minmax(0, 1fr) 280px; }
.accurate-map { min-height: 560px; border-radius: 28px; overflow: hidden; border: 1px solid var(--line); box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); background: #dbeafe; }
.leaflet-container { font-family: inherit; }
.legend small { display: block; color: var(--muted); font-weight: 700; margin-left: 22px; margin-top: 3px; line-height: 1.25; }
@media (max-width: 620px) { .accurate-map { min-height: 430px; } }
