:root {
  --bg-main: #181a20;
  --bg-panel: #232634;
  --color-main: #eaeaea;
  --color-accent: #a3a3c2;
  --color-btn: #4a90e2;
  --color-btn-hover: #357ab8;
  --color-border: #35374a;
}

body, html {
  background: var(--bg-main);
  color: var(--color-main);
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  height: 100vh;
  width: 100vw;
}

#editor-layout {
  display: flex;
  height: 100vh;
}

#sidebar {
  background: var(--bg-panel);
  width: 220px;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  border-right: 2px solid var(--color-border);
}

.tab-btn {
  background: none;
  color: var(--color-main);
  border: none;
  padding: 12px 24px;
  text-align: left;
  font-size: 1.1em;
  cursor: pointer;
  transition: background 0.2s;
}

.tab-btn:hover, .tab-btn.active {
  background: var(--color-btn);
  color: #fff;
}

#main-panel {
  flex: 1;
  background: var(--bg-main);
  padding: 24px;
  overflow-y: auto;
}

.editor-tab {
  display: none;
}

.editor-tab.active {
  display: block;
}

#floor-select {
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-main);
}

#creator-map-container {
    display: flex;
    width: 900px;
    height: 600px;
    margin: 0 auto;
    position: relative;
    background: #232634;
    border-radius: 8px;
    box-shadow: 0 2px 16px #000a;
    border: 2px solid #4a90e2;
    overflow: hidden;
}

#creator-tool-sidebar {
    width: 120px;
    min-width: 100px;
    background: #232634;
    border-radius: 8px 0 0 8px;
    box-shadow: 0 2px 8px #0003;
    padding: 12px 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

#creator-map-preview {
    flex: 1;
    height: 100%;
    margin: 0 auto;
    position: relative;
    background: #232634;
    overflow: hidden;
    box-shadow: 0 2px 16px #000a;
    display: flex;
    align-items: center;
    justify-content: center;
}

#creator-map-canvas {
    position: absolute;
    left: 0; top: 0;
    cursor: grab;
    background: transparent;
}

#creator-map-canvas:active {
    cursor: grabbing;
}

.tool-btn {
    background: var(--color-btn, #4a90e2);
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
    text-align: left;
}

.tool-btn:hover, .tool-btn.active {
    background: var(--color-btn-hover, #357abd);
}

#npc-quest-section {
    display: none;
    flex-direction: column;
}

/* --- Tile Maker Layout --- */
#tile-maker-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-top: 16px;
}

#tile-maker-left-panel {
  width: 340px;
  min-width: 260px;
  max-width: 400px;
  background: var(--bg-panel);
  border-radius: 8px;
  box-shadow: 0 2px 8px #0003;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

#tile-maker-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-accent, #2c2f3a);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 0;
  color: var(--color-main);
  border: 1px solid var(--color-border);
  width: 100%;
  box-sizing: border-box;
}

#tile-maker-controls select,
#tile-maker-controls input[type="color"],
#tile-maker-controls input[type="text"],
#tile-maker-controls input[type="range"] {
  margin-top: 4px;
  margin-bottom: 4px;
}

#tile-maker-paletteSwatches {
  margin: 6px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px;
  background: var(--bg-accent, #2c2f3a);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.paletteColor {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  box-shadow: 0 1px 4px #23263466;
}

.paletteColor .removeColor {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 13px;
  color: var(--color-danger, #ff5555);
  background: var(--color-main, #eaeaea);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  text-align: center;
  line-height: 14px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  display: none;
}

.paletteColor:hover .removeColor {
  display: block;
}

#tile-maker-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-width: 320px;
}

#tile-maker-canvas {
  border: 4px solid var(--color-border);
  background:
      linear-gradient(45deg, #eaeaea 25%, #d3d3d3 25%, #d3d3d3 75%, #eaeaea 75%),
      linear-gradient(45deg, #eaeaea 25%, #d3d3d3 25%, #d3d3d3 75%, #eaeaea 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  margin: 0 auto;
  image-rendering: pixelated;
  box-shadow: 0 2px 16px #000a;
  display: block;
}

#tile-maker-zoom-controls {
  margin-bottom: 12px;
  background: none;
  color: var(--color-accent);
  font-size: 1em;
  padding: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.npc-quest-section {
    background: none;
}

/* --- Enhanced Inputs & Buttons --- */
input[type="text"],
input[type="number"],
textarea,
select {
  background: #232634;
  color: #eaeaea;
  border: 1.5px solid #4a90e2;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 1em;
  margin-top: 4px;
  margin-bottom: 4px;
  transition: border 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px #0002;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: #357ab8;
  outline: none;
  box-shadow: 0 0 0 2px #4a90e244;
}

label {
  font-weight: 500;
  color: #a3a3c2;
  margin-bottom: 2px;
}

input[type="checkbox"] {
  accent-color: #4a90e2;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: middle;
  cursor: pointer;
}

button,
input[type="button"] {
  background: linear-gradient(90deg, #4a90e2 60%, #357ab8 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 1em;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  margin-bottom: 6px;
  box-shadow: 0 2px 8px #0002;
  transition: background 0.2s, box-shadow 0.2s;
}

button:hover,
input[type="button"]:hover {
  background: linear-gradient(90deg, #357ab8 60%, #4a90e2 100%);
  box-shadow: 0 4px 16px #4a90e244;
}

.saved-npc-row button {
  padding: 6px 14px;
  font-size: 0.95em;
  margin-left: 4px;
  margin-right: 4px;
}

.reward-row input[type="text"],
.reward-row input[type="number"] {
  padding: 6px 8px;
  font-size: 0.95em;
  border-radius: 5px;
}

.reward-row button {
  padding: 6px 10px;
  font-size: 0.95em;
  background: #ff5555;
  color: #fff;
  border-radius: 5px;
  border: none;
  margin-left: 8px;
  transition: background 0.2s;
}

.reward-row button:hover {
  background: #d32f2f;
}

/* Make checkboxes and labels align nicely */
label > input[type="checkbox"] {
  margin-right: 8px;
  margin-bottom: 0;
  vertical-align: middle;
}

#te-tool-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #232634;
  border-radius: 12px;
  padding: 6px 4px;
  box-shadow: 0 2px 8px #0002;
  align-items: center;
}

.te-tool-btn, #te-flip-h, #te-flip-v {
  background: #35374a;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1.5em;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px #0001;
}

.te-tool-btn.active, .te-tool-btn:hover, #te-flip-h:hover, #te-flip-v:hover {
  background: #4a90e2;
  color: #fff;
  box-shadow: 0 2px 8px #4a90e233;
}

#te-tool-panel button:focus {
  outline: 2px solid #ffd700;
}

#te-tool-panel span {
  pointer-events: none;
}

#te-undo, #te-redo {
  background: #35374a;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1.4em;
  width: 40px;
  height: 40px;
  margin: 12px;
  display: flex;  
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

#te-undo:hover, #te-redo:hover {
  background: #4a90e2;
  color: #fff;
}

/* Top controls bar styling */
#te-top-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #232634;
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px #0002;
  max-width: 540px; /* Limit width so it doesn't span the whole page */
}

/* Style for all buttons in top controls */
#te-top-controls button,
#te-top-controls input[type="file"] {
  background: #35374a;
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 0.95em;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px #0001;
}

#te-top-controls button:hover,
#te-top-controls input[type="file"]:hover {
  background: #4a90e2;
  color: #fff;
  box-shadow: 0 2px 8px #4a90e233;
}

#te-top-controls label {
  color: #eaeaea;
  font-size: 0.95em;
  margin-right: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

#te-top-controls input[type="color"],
#te-top-controls input[type="number"] {
  border-radius: 5px;
  border: 1px solid #35374a;
  background: #232634;
  color: #fff;
  padding: 1px 4px;
  font-size: 0.95em;
  height: 28px;
  width: 44px;
}

#te-top-controls input[type="checkbox"] {
  accent-color: #4a90e2;
  width: 16px;
  height: 16px;
}

#te-top-controls span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Map Creator */
#map-creator-layout {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  align-items: stretch;
}
#mc-left {
  width: 250px;
  min-width: 200px;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 2px 8px #0003;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#mc-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0; /* Remove gap so topbar and canvas are flush */
  min-width: 0;
}

#mc-topbar-wrap {
  width: 100%;
  flex-shrink: 0;
  margin-bottom: 8px;
}

#mc-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px;
}

#mc-canvas-wrap {
  width: 650px;     
  height: 650px;   
  min-width: 650px;
  min-height: 650px;
  max-width: 650px;
  max-height: 650px;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mc-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  image-rendering: pixelated;
}

#mc-tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
#mc-tools button {
  background: #35374a;
  border: none;
  color: #fff;
  border-radius: 8px;
  height: 36px;
  cursor: pointer;
}
#mc-tools button.active,
#mc-tools button:hover {
  background: #4a90e2;
}

#mc-layers .mc-layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #2b2f3d;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px;
}
#mc-layers .mc-layer-row input[type="text"] {
  flex: 1;
  min-width: 40px;
}
#mc-layers .mc-layer-row button {
  height: 28px;
  padding: 0 4px;
}

#mc-palette {
  background: #2b2f3d;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}
.mc-pal-item {
  border: 2px solid var(--color-border);
  border-radius: 6px;
  background: #232634;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.mc-pal-item.selected {
  border-color: #4a90e2;
  box-shadow: 0 2px 8px #4a90e244;
}

#mc-asset-props {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #2b2f3d;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px;
}

#mc-topbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#mc-topbar input[type="number"],
#mc-left input[type="number"],
#mc-left input[type="text"] {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: #232634;
  color: #fff;
}

#mc-topbar button, #mc-left button {
  height: 32px;
  background: #35374a;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0 10px;
  cursor: pointer;
}
#mc-topbar button:hover, #mc-left button:hover {
  background: #4a90e2;
}