:root {
  --bg: #0f161d;
  --panel: #121a23;
  --accent: #42d6c7;
  --accent-soft: rgba(66,214,199,0.18);
  --text: #e5f7ff;
  --muted: #94a8bd;
  --danger: #ff8677;
  --radius: 6px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
#topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #0b1015;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.btn {
  background: rgba(66,214,199,0.12);
  border: 1px solid rgba(66,214,199,0.18);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 10px;
  cursor: pointer;
  font-weight: 500;
}
.btn.primary {
  background: var(--accent);
  color: #001b12;
  border-color: rgba(0,0,0,0);
}
#statusBar {
  min-width: 220px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
#layout {
  display: grid;
  /* nur noch 2 Spalten: links (Tiles) + Mitte (Map) */
  grid-template-columns: 480px 1fr;
  height: calc(100vh - 42px);
}
#left {
  background: var(--panel);
  padding: 10px;
  overflow-y: auto;
}
#main {
  position: relative;
  background: #05090e;
}
#left h2 {
  margin-top: 0;
  font-size: 14px;
}

/* Map-Liste ------------------------------------------------- */
#mapList {
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#mapList li {
  background: #0a1017;
  border: 1px solid rgba(255,255,255,0.015);
  border-radius: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  cursor: pointer;
}
#mapList li.active {
  outline: 2px solid var(--accent);
}
#mapList canvas {
  width: 46px;
  height: 46px;
  background: #394451;
  border-radius: 3px;
}

/* Tilepalette ----------------------------------------------- */
#tilePalette {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  max-height: 640px;
  overflow-y: auto;
}
.tile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  margin: 0;
  background: #0c1218;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.02);
  cursor: pointer;
}
.tile-btn img {
  display: block;
  image-rendering: pixelated;
  max-width: 64px;
  max-height: 64px;
}
.tile-btn span {
  display: none;
}
.tile-btn.active {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.tile-btn:hover {
  border-color: var(--accent-soft);
}

/* Canvas & Layerbar ---------------------------------------- */
#layerbar {
  background: #0d131a;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 4px 12px 6px;
  display: flex;
  flex-direction: column;   /* Zeilen untereinander */
  gap: 4px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#canvasWrap {
  position: relative;
  width: 100%;
  height: calc(100% - 36px);
  overflow: auto;
}
#canvasWrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
}

/* Sonstiges ------------------------------------------------ */
.sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.04);
}
#selectedTileBox img {
  width: 64px;
  height: 64px;
  background: #000;
  image-rendering: pixelated;
  margin-bottom: 4px;
}
.debug {
  background: #0a1015;
  border: 1px solid rgba(255,255,255,0.02);
  border-radius: 4px;
  padding: 6px;
  font-size: 11px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}


/* === TEIL 8: Minimap & Selection-Overlay ======================= */

#minimapPanel {
  position: absolute;
  top: 54px; /* unter der Toolbar */
  right: 10px;
  width: 220px;
  background: var(--panel);
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 0 12px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.06);
  z-index: 20;
}

#minimapPanel .panel-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  margin-bottom: 4px;
}

#globalMinimap {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 3px;
  background: #020308;
}

/* Selection-Overlay auf dem Canvas */
#selectionOverlay {
  pointer-events: none; /* wird vom Selection-Tool bei Bedarf aktiviert */
}

.selection-rect {
  outline: 1px dashed rgba(255,255,255,0.7);
}

.canvas-selection-active #selectionOverlay {
  pointer-events: auto;
}

/* Hover/Active-Feedback für Buttons, Tiles & Maps */

.btn,
#mapList li,
.tile-btn {
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, background 0.08s ease-out;
}

.btn:hover,
#mapList li:hover,
.tile-btn:hover {
  box-shadow: 0 0 0 1px rgba(0,255,255,0.4);
  transform: translateY(-1px);
}

.btn:active,
#mapList li:active,
.tile-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 0 6px rgba(0,0,0,0.9);
}

/* Map-Liste optisch anklickbar machen */
#mapList li {
  cursor: pointer;
}

/* Kleinere Scrollbar im Map-List & Tile-Palette-Panel */
#mapList,
#tilePalette {
  scrollbar-width: thin;
}


/* === TEIL 11: Theme-Switcher (A/B/C) ======================= */

body.theme-a {
  /* Standard – nutzt die :root Werte, optional kleine Anpassungen */
}

body.theme-b {
  --bg: #050811;
  --panel: #070c16;
  --accent: #4fd2ff;
  --accent-soft: rgba(79,210,255,0.22);
  --text: #e8f8ff;
  --muted: #8ca0c0;
}

body.theme-c {
  --bg: radial-gradient(circle at top, #1a2330 0%, #050811 55%, #020308 100%);
  --panel: rgba(5, 12, 24, 0.72);
  --accent: #ffb84f;
  --accent-soft: rgba(255,184,79,0.16);
  --text: #fff7e3;
  --muted: #b7aa90;
}

/* Theme-Select im Topbar */
.theme-label {
  font-size: 11px;
  opacity: 0.8;
  margin-right: 4px;
}

.theme-select {
  background: rgba(2,10,20,0.9);
  color: var(--text);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 6px;
  font-size: 11px;
  margin-right: 10px;
}
