:root {
  --bg: #1d1f21;
  --panel: #2a2d31;
  --text: #e8e8e8;
  --muted: #a0a4a8;
  --accent: #4f8cff;
  /* overlay colors, also read by app.js */
  --delete: rgba(220, 50, 47, 0.45);
  --unfinished: rgba(140, 40, 40, 0.35);
  --build: rgba(40, 220, 70, 0.5);
  --buffer: rgba(0, 0, 0, 0);
  --protected: rgba(200, 160, 255, 0.45);
  --spawn: rgba(255, 200, 0, 0.65);
  --mark-keep: rgba(0, 230, 255, 0.8);
  --mark-delete: rgba(255, 140, 0, 0.7);
  --mark-warn: rgba(230, 0, 230, 0.8);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, sans-serif; }
body { display: flex; flex-direction: column; }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px;
  background: var(--panel); z-index: 1000; }
header select, header button { font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid #444; border-radius: 4px; padding: 4px 10px; cursor: pointer; }
#modes { display: flex; gap: 4px; }
#modes button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.opacity { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#player { margin-left: auto; color: var(--muted); }

#map { flex: 1; background: #111; }
#map.marking { cursor: crosshair; }
.leaflet-container { background: #111; }

#legend { position: absolute; right: 16px; bottom: 32px; z-index: 1000; background: var(--panel);
  padding: 8px 12px; border-radius: 6px; font-size: 12px; max-width: 260px; }
#legend .sw { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px;
  background: var(--c); border: 1px solid #0006; }
#legend .hint { margin: 6px 0 0; color: var(--muted); }

#status { position: absolute; left: 16px; bottom: 16px; z-index: 1000; background: var(--panel);
  padding: 4px 10px; border-radius: 4px; font-size: 12px; color: var(--muted); }
#message { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2000;
  background: var(--panel); padding: 24px 32px; border-radius: 8px; max-width: calc(100% - 32px); }
#message.toast { top: 64px; transform: translateX(-50%); padding: 8px 16px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid #444; border-radius: 8px;
  max-width: min(420px, calc(100% - 32px)); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
dialog button { font: inherit; padding: 4px 12px; border-radius: 4px; border: 1px solid #555;
  background: var(--bg); color: var(--text); cursor: pointer; }
dialog button.danger { background: #b02a2a; border-color: #b02a2a; }

.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content ul { margin: 4px 0; padding-left: 18px; }

@media (max-width: 640px) {
  #legend { display: none; }
}
