:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #090d14;
  color: #e9edf3;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body { display: flex; flex-direction: column; }

.toolbar {
  min-height: 66px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #111824;
  border-bottom: 1px solid #273242;
  z-index: 500;
}

.toolbar h1 { margin: 0; font-size: 17px; }
.toolbar p { margin: 2px 0 0; color: #9eabbc; font-size: 12px; }
.toolbar-actions { display: flex; gap: 8px; }

button {
  border: 1px solid #6b8fc4;
  border-radius: 6px;
  padding: 8px 12px;
  background: #35629e;
  color: white;
  font: inherit;
  cursor: pointer;
}

button:hover { filter: brightness(1.15); }
button.secondary { background: #202b3b; border-color: #435168; }

main { flex: 1; min-height: 0; position: relative; }
#map { position: absolute; inset: 0; background: #05070a; }

.hex-cell { fill: rgb(5 10 18 / 5%); stroke: #cf9b64; stroke-width: 1.5; }
.hex-label {
  color: #f2d4b4;
  text-shadow: 0 1px 3px #000, 1px 0 3px #000, 0 -1px 3px #000;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.poi-image-icon img {
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px #000);
}

.faction-territory { cursor: pointer; }
.faction-legend {
  position: absolute;
  z-index: 450;
  right: 12px;
  bottom: 28px;
  width: min(265px, calc(100% - 24px));
  max-height: calc(100% - 210px);
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid #435168;
  border-radius: 7px;
  background: rgb(14 20 29 / 94%);
  box-shadow: 0 4px 18px rgb(0 0 0 / 30%);
}
.faction-legend summary { cursor: pointer; font-weight: 650; }
.faction-legend ul { list-style: none; padding: 0; margin: 12px 0; }
.faction-legend li { display: flex; align-items: flex-start; gap: 9px; margin: 10px 0; font-size: 13px; }
.faction-swatch { flex: 0 0 12px; height: 12px; border-radius: 3px; margin-top: 3px; }
.faction-legend small { display: block; margin-top: 2px; color: #aeb9c8; }
.faction-legend p { margin: 8px 0 0; font-size: 11px; line-height: 1.45; color: #aeb9c8; }
.faction-tooltip { background: #111824; border-color: #435168; color: #e9edf3; }
.faction-popup { color: #18212d; }

.poi-popup { min-width: 220px; color: #18212d; }
.poi-popup strong { display: block; margin-bottom: 5px; font-size: 15px; }
.poi-popup p { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.poi-popup-actions { display: flex; gap: 6px; }
.poi-popup button { padding: 5px 8px; font-size: 12px; }
.poi-popup button.delete { background: #9d3c3c; border-color: #842f2f; }

#status {
  position: absolute;
  z-index: 450;
  left: 12px;
  bottom: 12px;
  max-width: min(80vw, 520px);
  padding: 6px 9px;
  border-radius: 5px;
  background: rgb(14 20 29 / 88%);
  color: #ccd5e1;
  font-size: 12px;
  pointer-events: none;
}

.leaflet-control-layers { background: #111824; color: #e9edf3; border-color: #435168; }
.leaflet-control-layers-separator { border-top-color: #435168; }
.leaflet-control-attribution { background: rgb(14 20 29 / 78%) !important; color: #bdc8d6 !important; }
.leaflet-control-attribution a { color: #a9c7ef !important; }

@media (max-width: 600px) {
  .toolbar { align-items: flex-start; }
  .toolbar-actions { flex-direction: column; }
  .faction-legend { bottom: 68px; max-height: calc(100% - 250px); }
}
