body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
  text-align: center;
  background: #121212;
  color: white;
  transition: background 0.2s, color 0.2s;
}

body.light {
  background: #f0f0f0;
  color: #222;
}

h1 {
  margin: 1rem 0 0.5rem;
}

#canvasWrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 100px;
  height: calc(100vh - 160px);
  overflow: hidden;
}

#canvasContainer {
  overflow: scroll;
  max-width: 100%;
  max-height: 100%;
  border: 2px solid #444;
  cursor: default;
}

#canvasContainer.panning {
  cursor: grab;
}
#canvasContainer.panning:active {
  cursor: grabbing;
}

#canvas {
  --pixel-size: 5px;
  display: grid;
  grid-template-columns: repeat(80, var(--pixel-size));
  grid-template-rows: repeat(40, var(--pixel-size));
  border: 2px solid #333;
  transition: all 0.2s;
}

.pixel {
  width: var(--pixel-size);
  height: var(--pixel-size);
  background: #121212;
  user-select: none;
}

.grid .pixel {
  border: 0.5px solid #a8a8a8;
}

body.light .pixel {
  background: #ffffff;
}
body.light .grid .pixel {
  border: 0.5px solid #ccc;
}

#colorBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1c1c1c;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0.5rem;
  border-top: 1px solid #333;
  gap: 1rem;
  flex-wrap: wrap;
}

body.light #colorBar {
  background: #ddd;
  color: #000;
  border-color: #aaa;
}

#colorPalette {
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid #444;
  cursor: pointer;
  border-radius: 4px;
}
.color-swatch:hover {
  border-color: #fff;
}

#customColorsContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
#customColors {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.custom-color-swatch {
  width: 24px;
  height: 24px;
  border: 2px dashed #666;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  transition: border-color 0.2s;
}
.custom-color-swatch:hover {
  border-color: #fff;
}
body.light .custom-color-swatch {
  border-color: #aaa;
}

.color-action {
  cursor: pointer;
  background: #444;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  user-select: none;
  transition: background 0.2s, color 0.2s;
}
.color-action:hover {
  background: #666;
}
.color-action.active {
  background: #00aa88;
  color: white;
}

body.light .color-action {
  cursor: pointer;
  background: #b8b8b8;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  user-select: none;
  transition: background 0.2s, color 0.2s;
}
body.light .color-action:hover {
  background: #969595;
}
body.light .color-action.active {
  background: #00aa88;
  color: white;
}

#controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
#zoomSlider {
  width: 100px;
}
