:root {
  --rom-bg: #0b1220;
  --rom-panel: rgba(15, 22, 38, 0.92);
  --rom-panel-border: rgba(255, 255, 255, 0.06);
  --rom-text: #e5e7eb;
  --rom-muted: #94a3b8;
  --rom-accent: #14b8a6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--rom-bg);
  color: var(--rom-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

#romMap {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.rom-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 32px);
  z-index: 10;
  background: var(--rom-panel);
  border: 1px solid var(--rom-panel-border);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rom-panel.collapsed { display: none; }

.rom-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rom-panel-border);
}

.rom-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
}
.rom-brand { color: var(--rom-accent); letter-spacing: 0.02em; }
.rom-sep { color: var(--rom-muted); }
.rom-sub { color: var(--rom-text); font-size: 12px; }

.rom-collapse, .rom-expand {
  background: rgba(255, 255, 255, 0.06);
  color: var(--rom-text);
  border: 1px solid var(--rom-panel-border);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.rom-expand {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 11;
  background: var(--rom-panel);
  backdrop-filter: blur(8px);
}

.hidden { display: none !important; }

.rom-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rom-panel-border);
  overflow-y: auto;
}
.rom-section:last-child { border-bottom: none; }

.rom-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rom-muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.rom-section h3 em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--rom-muted);
  font-size: 11px;
}

.rom-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 6px;
}
.rom-toggle:hover { background: rgba(255, 255, 255, 0.03); }
.rom-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--rom-accent);
  margin: 0;
}
.rom-label {
  flex: 1;
  font-size: 12.5px;
  color: var(--rom-text);
}
.rom-label em {
  font-style: normal;
  color: var(--rom-muted);
  font-size: 11.5px;
  margin-left: 4px;
}

.rom-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}
.swatch-sat { background: linear-gradient(135deg, #5c7e4f, #2e4a3a 60%, #4a6878); }
.swatch-cty { background: linear-gradient(90deg, #e76f51 0 30%, #efd130 30% 55%, #6a994e 55% 80%, #8aa632 80% 100%); }
.swatch-fields {
  background: transparent;
  border: 2px solid #f8fafc;
  box-sizing: border-box;
}
.swatch-lucas {
  background: radial-gradient(circle at 50% 50%, #e76f51 0 35%, transparent 36%),
              radial-gradient(circle at 70% 30%, #efd130 0 14%, transparent 15%);
  background-color: transparent;
}

.rom-opacity {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
  font-size: 12px;
  color: var(--rom-muted);
}
.rom-opacity input[type="range"] {
  accent-color: var(--rom-accent);
  width: 100%;
}
.rom-opacity span:last-child { color: var(--rom-text); min-width: 36px; text-align: right; }

.rom-legend-list {
  display: grid;
  gap: 4px;
}
.rom-row {
  display: grid;
  grid-template-columns: 14px 1fr 38px;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 12px;
}
.rom-row .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.rom-row .name { color: var(--rom-text); }
.rom-row .bar {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  grid-column: 2 / span 2;
  margin-top: 2px;
}
.rom-row .bar span {
  display: block;
  height: 100%;
  background: currentColor;
  opacity: 0.85;
}
.rom-row.compact {
  grid-template-columns: 14px 1fr auto;
}
.rom-row .count {
  font-variant-numeric: tabular-nums;
  color: var(--rom-muted);
  font-size: 11.5px;
  text-align: right;
}

.rom-row.muted { opacity: 0.45; }
.rom-row.muted .name { color: var(--rom-muted); }

.rom-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--rom-muted);
  line-height: 1.4;
}

.rom-about-list {
  margin: 0;
  padding-left: 18px;
  color: var(--rom-text);
  font-size: 12px;
  line-height: 1.5;
}
.rom-about-list li { margin-bottom: 6px; }
.rom-about-list b { color: var(--rom-text); }

/* MapLibre popup overrides */
.maplibregl-popup {
  font-family: 'Inter', system-ui, sans-serif;
}
.maplibregl-popup-content {
  background: var(--rom-panel);
  color: var(--rom-text);
  border: 1px solid var(--rom-panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.maplibregl-popup-tip { border-top-color: var(--rom-panel); }
.maplibregl-popup-close-button { color: var(--rom-muted); font-size: 16px; padding: 4px 8px; }

.rom-pop-title {
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.rom-pop-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.3);
}
.rom-pop-meta {
  color: var(--rom-muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.rom-pop-meta b { color: var(--rom-text); font-weight: 500; }

/* MapLibre dark controls */
.maplibregl-ctrl-group {
  background: var(--rom-panel) !important;
  border: 1px solid var(--rom-panel-border) !important;
}
.maplibregl-ctrl-group button { filter: invert(0.85) hue-rotate(180deg); }

@media (max-width: 640px) {
  .rom-panel { width: calc(100vw - 24px); right: 12px; top: 12px; }
}
