:root {
  --ink: #172532;
  --ink-soft: #243746;
  --paper: #f4f7f9;
  --ocean: #e6f1f5;
  --border: rgba(23, 37, 50, 0.14);
  --shadow: 0 18px 48px rgba(25, 43, 57, 0.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: "DM Sans", system-ui, sans-serif; color: var(--ink); background: var(--paper); }
button { font: inherit; }
.site-header {
  min-height: 104px;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background: linear-gradient(135deg, #162430 0%, #213645 100%);
}
.brand { display: flex; align-items: center; gap: 16px; }
.crest-holder {
  width: 78px;
  height: 86px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  background: rgba(255, 253, 247, 0.96);
  border: 1px solid rgba(231, 214, 178, 0.8);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18), inset 0 0 0 1px rgba(255,255,255,.5);
}
.family-crest { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand h1 { margin: 0; font: 700 clamp(1.55rem, 2.6vw, 2.45rem)/1 "Playfair Display", serif; letter-spacing: .01em; }
.brand p { margin: 8px 0 0; font-size: .78rem; letter-spacing: .28em; text-transform: uppercase; opacity: .84; }
.tagline { font-family: "Playfair Display", serif; font-style: italic; font-size: 1.08rem; opacity: .9; }
.toolbar {
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--border);
}
.traveler-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.traveler-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 135px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  color: white;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.20);
  transition: transform .15s ease, opacity .15s ease, filter .15s ease;
}
.traveler-toggle:hover { transform: translateY(-1px); }
.traveler-toggle.is-off { opacity: .34; filter: grayscale(.15); }
.traveler-toggle .dot { width: 14px; height: 14px; border-radius: 999px; background: white; box-shadow: 0 0 0 4px rgba(255,255,255,.18); }
.traveler-toggle .name { font-weight: 700; }
.traveler-toggle .count { display: block; font-size: .72rem; opacity: .92; margin-top: 1px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.secondary-btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.secondary-btn.is-active { background: var(--ink); color: white; }

/* Map is deliberately shorter than the original version. */
.map-shell { position: relative; height: min(57.2vh, 616px); min-height: 429px; }
#map { height: 100%; width: 100%; background: var(--ocean); }
.leaflet-container { font: inherit; background: var(--ocean); }
.leaflet-control-attribution { font-size: 10px; }

.country-card {
  position: absolute;
  z-index: 800;
  top: 18px;
  right: 18px;
  width: min(330px, calc(100% - 36px));
  padding: 22px;
  border-radius: 20px;
  background: rgba(255,255,255,.97);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.7);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.country-card.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}
.close-card {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(23,37,50,.06);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  -webkit-tap-highlight-color: transparent;
}
.close-card:hover { background: rgba(23,37,50,.11); }
.country-card-eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .18em; font-weight: 800; opacity: .55; }
.country-card h2 { margin: 6px 34px 6px 0; font-family: "Playfair Display", serif; font-size: 2rem; }
.country-card p { margin: 0 0 16px; color: #52616d; line-height: 1.45; }
.visitor-list { display: grid; gap: 9px; }
.visitor-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 9px; border-top: 1px solid var(--border); }
.visitor-name { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.visitor-dot { width: 12px; height: 12px; border-radius: 50%; }
.visitor-status { font-size: .8rem; color: #62727f; }
.legend {
  position: absolute;
  z-index: 700;
  left: 20px;
  bottom: 20px;
  padding: 15px 17px;
  border-radius: 16px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 12px 30px rgba(25,43,57,.12);
  border: 1px solid rgba(255,255,255,.7);
  font-size: .8rem;
}
.legend h3 { margin: 0 0 10px; font-size: .9rem; }
.legend > div { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.swatch { width: 22px; height: 15px; border-radius: 4px; border: 1px solid rgba(23,37,50,.08); display: inline-block; }
.swatch-unvisited { background: #dfe3e5; }
.swatch-single { background: #D98B5F; }
.swatch-multi { background: linear-gradient(135deg, #D98B5F 0 25%, #9A7BB8 25% 50%, #9B5968 50% 75%, #D99AAF 75%); }
.swatch-all { background: #865d78; }
.stats-bar {
  min-height: 82px;
  padding: 16px 30px;
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) 2fr;
  gap: 20px;
  align-items: center;
  color: white;
  background: linear-gradient(135deg, #162430 0%, #213645 100%);
}
.stats-bar > div { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: .74rem; opacity: .7; text-transform: uppercase; letter-spacing: .1em; }
.stats-bar strong { font-size: 1rem; }
.footer-note { text-align: right; font-family: "Playfair Display", serif; font-style: italic; opacity: .9; }

@media (max-width: 900px) {
  .tagline { display: none; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .footer-note { text-align: left; }
}

@media (max-width: 640px) {
  .site-header { padding: 16px 18px; min-height: 88px; }
  .crest-holder { width: 58px; height: 64px; padding: 4px; border-radius: 10px; }
  .brand p { font-size: .65rem; }
  .toolbar { padding: 10px; }
  .traveler-controls { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .traveler-toggle { min-width: 0; width: 100%; }
  .toolbar-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .secondary-btn { padding: 9px 7px; font-size: .78rem; }

  /* Mobile map remains visible and is no longer buried beneath the details card. */
  .map-shell { height: 52.8vh; min-height: 385px; }
  #map { height: 100%; min-height: 0; }
  .country-card {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: 58vh;
    overflow-y: auto;
    z-index: 1200;
  }
  .country-card.is-hidden { transform: translateY(18px); }
  .legend { display: none; }
  .stats-bar { grid-template-columns: 1fr 1fr; padding: 14px 18px; }
}
