html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #0b1117;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
}
#map {
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #18222c 0%, #0b1117 75%);
}
.leaflet-container { background: #0b1117; }

.map-title {
  position: fixed;
  z-index: 1000;
  top: 18px;
  left: 20px;
  color: #f0e2be;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
  pointer-events: none;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .72;
}
.title {
  margin-top: 4px;
  font-size: clamp(27px, 3vw, 43px);
}

.control-panel {
  position: fixed;
  z-index: 1000;
  left: 20px;
  top: 98px;
  width: 190px;
  padding: 13px 15px;
  color: #eadfca;
  background: rgba(13,18,22,.87);
  border: 1px solid rgba(213,183,116,.34);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  backdrop-filter: blur(7px);
  font: 13px/1.7 system-ui, sans-serif;
}
.control-panel label {
  display: block;
  cursor: pointer;
}
.control-panel input {
  margin-right: 8px;
  accent-color: #b89b59;
}
.panel-title {
  font: 700 16px/1.2 Georgia, "Times New Roman", serif;
  margin-bottom: 6px;
}
.panel-title.small { font-size: 14px; }
.panel-divider {
  height: 1px;
  margin: 9px 0;
  background: rgba(213,183,116,.2);
}
.legend-swatch {
  display: inline-block;
  width: 13px;
  height: 9px;
  margin-right: 7px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 2px;
  vertical-align: middle;
}
.legend-swatch.neutral { background: rgba(100,110,110,.35); }
.legend-swatch.peace { background: rgba(113,129,119,.55); }
.legend-swatch.held { background: rgba(181,151,77,.45); }
.legend-swatch.contested { background: rgba(135,56,43,.5); }

.help-card {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  padding: 10px 14px;
  color: #e8dcc0;
  background: rgba(15,20,24,.84);
  border: 1px solid rgba(214,188,128,.35);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  font: 13px/1.3 system-ui, sans-serif;
}

.crest-marker {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #d8bc79;
  box-shadow: 0 0 0 3px rgba(40,27,10,.55), 0 8px 16px rgba(0,0,0,.6);
  background: #1b1f23;
}
.crest-marker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.leaflet-tooltip {
  background: rgba(15,19,22,.96);
  color: #f1e4c6;
  border: 1px solid rgba(214,188,128,.42);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.46);
  padding: 0;
}
.region-tip, .fief-tip {
  padding: 10px 12px;
  min-width: 220px;
}
.tip-title {
  font: 700 17px/1.15 Georgia, "Times New Roman", serif;
  margin-bottom: 5px;
}
.tip-meta {
  font: 11px/1.3 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .7;
}
.tip-body {
  margin-top: 7px;
  font: 13px/1.4 system-ui, sans-serif;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #171b1e;
  color: #efe1bd;
}
.leaflet-popup-content-wrapper {
  border: 1px solid rgba(214,188,128,.4);
  border-radius: 10px;
  box-shadow: 0 14px 35px rgba(0,0,0,.45);
}
.leaflet-popup-content {
  margin: 15px 17px;
  min-width: 285px;
  max-width: 420px;
}
.popup-title {
  font: 700 22px/1.1 Georgia, "Times New Roman", serif;
  margin-bottom: 5px;
}
.popup-subtitle {
  font: 11px/1.35 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .72;
}
.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 13px;
}
.popup-box {
  padding: 8px 9px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 6px;
}
.popup-label {
  font: 700 10px/1.3 system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #c7ae71;
  margin-bottom: 3px;
}
.popup-value {
  font: 13px/1.35 system-ui, sans-serif;
}
.popup-section {
  margin-top: 12px;
  font: 14px/1.45 system-ui, sans-serif;
}
.region-fief-list {
  margin: 6px 0 0;
  padding-left: 18px;
}
.region-fief-list li { margin: 3px 0; }

.fief-popup {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}
.fief-crest {
  width: 74px;
  height: 74px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(214,188,128,.55);
  background: rgba(255,255,255,.04);
}
.fief-crest img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.resource-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(54px, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.resource-grid > div {
  padding: 7px 5px;
  text-align: center;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(214,188,128,.16);
  border-radius: 6px;
}

.resource-grid span {
  display: block;
  margin-bottom: 3px;
  font: 9px/1.2 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .72;
}

.resource-grid strong {
  display: block;
  font: 700 16px/1 Georgia, "Times New Roman", serif;
  color: #f0dca6;
}


.legend-swatch.unclaimed { background: rgba(113,129,119,.62); }
.legend-swatch.claimed { background: rgba(155,132,82,.68); }
.legend-swatch.raid { background: rgba(196,106,50,.72); }
.legend-swatch.trade-war { background: rgba(123,90,166,.72); }
.legend-swatch.war { background: rgba(165,59,53,.78); }


.capital-badge,
.political-membership {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(214,188,128,.18);
  border-radius: 6px;
}

.capital-badge strong,
.political-membership strong {
  color: #d5bc80;
}

.capital-badge.duchy {
  border-color: rgba(190,150,80,.42);
}

.capital-badge.county {
  border-color: rgba(145,165,185,.36);
}


.political-crest-small {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 5px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(214,188,128,.22);
}

.capital-badge-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.capital-badge,
.political-membership {
  align-items: center;
}


.rules-link {
  display: block;
  margin: 7px 0 11px;
  padding: 7px 9px;
  text-align: center;
  color: #f0ddb0;
  text-decoration: none;
  border: 1px solid rgba(214,188,128,.3);
  border-radius: 6px;
  background: rgba(214,188,128,.07);
  font-weight: 600;
}

.rules-link:hover {
  background: rgba(214,188,128,.13);
}

.tip-income {
  margin-top: 7px;
  font: 700 12px/1.35 system-ui, sans-serif;
  color: #d8c48f;
}

.improvement-list {
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.improvement-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px;
  margin-bottom: 5px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(214,188,128,.13);
  border-radius: 5px;
}

.improvement-list span {
  opacity: .62;
  font-size: 11px;
}

.empty-improvements {
  opacity: .6;
  font-style: italic;
}

.income-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 7px;
}

.income-grid > div {
  padding: 7px 4px;
  text-align: center;
  border: 1px solid rgba(214,188,128,.15);
  border-radius: 5px;
  background: rgba(255,255,255,.03);
}

.income-grid span {
  display: block;
  font: 9px/1.2 system-ui, sans-serif;
  text-transform: uppercase;
  opacity: .65;
}

.income-grid strong {
  display: block;
  margin-top: 3px;
  font: 700 16px/1 Georgia, "Times New Roman", serif;
  color: #ecd89c;
}

.income-note {
  margin-top: 6px;
  font-size: 10px;
  opacity: .55;
}


/* Keep large information windows usable near map edges. */
.leaflet-popup-content-wrapper {
  max-height: min(72vh, 560px);
}

.leaflet-popup-content {
  max-height: min(66vh, 510px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.leaflet-popup {
  margin-bottom: 18px;
}


/* Smart popup placement: northern map popups are shifted downward. */
.leaflet-popup-content-wrapper {
  overflow: hidden;
}


.event-callout {
  border: 1px solid rgba(204,150,74,.34);
  background: rgba(157,92,37,.11);
  border-radius: 7px;
  padding: 10px;
}

.event-name {
  margin-top: 3px;
  font: 700 16px/1.25 Georgia, "Times New Roman", serif;
  color: #efd8a0;
}

.event-link-button {
  display: inline-block;
  margin-top: 9px;
  padding: 7px 10px;
  color: #fff1ca !important;
  text-decoration: none;
  background: rgba(166,105,46,.72);
  border: 1px solid rgba(225,184,112,.4);
  border-radius: 5px;
  font: 700 11px/1.2 system-ui, sans-serif;
}

.event-link-button:hover {
  background: rgba(181,120,57,.9);
}


.event-description {
  margin-top: 7px;
  line-height: 1.45;
  font-size: 12px;
  opacity: .82;
  white-space: pre-line;
}


/* V17.2: popup is opened only after northern anchors are moved lower in the viewport. */
.ardesca-smart-popup .leaflet-popup-content-wrapper {
  max-height: calc(100vh - 155px);
}

.ardesca-smart-popup .leaflet-popup-content {
  max-height: calc(100vh - 205px);
  overflow-y: auto;
  overflow-x: hidden;
}
