* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a1a2e;
  outline: none;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.6);
}

.editor-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#editor-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: #222;
  border-bottom: 1px solid #444;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  gap: 6px;
}

#editor-toolbar button,
.tool-btn {
  padding: 6px 14px;
  font-family: monospace;
  font-size: 13px;
  background: #333;
  color: #eee;
  border: 1px solid #555;
  cursor: pointer;
}

#editor-toolbar button:hover,
.tool-btn:hover {
  background: #444;
}

#editor-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#editor-toolbar button:disabled:hover {
  background: #333;
}

.tool-btn.active,
.sprite-btn.active {
  background: #2121de;
  border-color: #4444ff;
}

#editor-status {
  margin-left: auto;
  font-family: monospace;
  font-size: 13px;
  color: #aaa;
}

#sprite-editor-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

#sprite-list {
  width: 160px;
  overflow-y: auto;
  background: #1a1a1a;
  border-right: 1px solid #444;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.level-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
}

.level-tab {
  width: 100%;
  padding: 6px 8px;
  text-align: left;
  font-family: monospace;
  font-size: 12px;
  background: #333;
  color: #eee;
  border: 1px solid #555;
  cursor: pointer;
}

.level-tab:hover {
  background: #444;
}

.level-tab.active {
  background: #2121de;
  border-color: #4444ff;
  color: #ffff00;
}

#sprite-groups {
  min-height: 0;
}

.sprite-group {
  margin-bottom: 12px;
}

.sprite-group h3 {
  font-family: monospace;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.sprite-btn {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  padding: 6px 8px;
  text-align: left;
  font-family: monospace;
  font-size: 12px;
  background: #333;
  color: #eee;
  border: 1px solid #555;
  cursor: pointer;
}

.sprite-btn:hover {
  background: #444;
}

#sprite-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#sprite-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid #555;
  cursor: crosshair;
}

#sprite-label {
  font-family: monospace;
  color: #aaa;
  font-size: 13px;
}

#palette-panel {
  width: 160px;
  padding: 12px;
  background: #1a1a1a;
  border-left: 1px solid #444;
}

.editor-subpanel {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.editor-subpanel.hidden {
  display: none;
}

.editor-help {
  font-family: monospace;
  font-size: 10px;
  color: #777;
  line-height: 1.4;
  margin-bottom: 8px;
}

.editor-subpanel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.enemy-body-color-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.enemy-body-color-row input[type='color'] {
  width: 40px;
  height: 28px;
  border: none;
  padding: 0;
  background: none;
  flex-shrink: 0;
}

.enemy-body-color-row code {
  flex: 1;
  font-size: 10px;
  color: #aaa;
}

.enemy-body-color-row button {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.tool-btn.active {
  border-color: #ffff00;
  color: #ffff00;
}

#palette-panel h3 {
  font-family: monospace;
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

#palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.palette-swatch {
  width: 40px;
  height: 40px;
  border: 2px solid #555;
  cursor: pointer;
  padding: 0;
}

.palette-swatch.transparent {
  background: repeating-conic-gradient(#666 0% 25%, #444 0% 50%) 50% / 10px 10px;
  color: #fff;
  font-family: monospace;
}

.palette-swatch.active {
  border-color: #ffff00;
}

#vulnerable-color-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: monospace;
  font-size: 12px;
  color: #aaa;
  margin-bottom: 8px;
}

#power-mode-duration-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: monospace;
  font-size: 12px;
  color: #aaa;
  margin-bottom: 8px;
}

#power-mode-active-duration {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #555;
  background: #222;
  color: #eee;
  font-family: monospace;
  font-size: 12px;
}

#vulnerable-enemy-color {
  width: 100%;
  height: 32px;
  border: none;
  padding: 0;
  background: none;
}

#custom-color-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: monospace;
  font-size: 12px;
  color: #aaa;
  margin-bottom: 12px;
}

#custom-color-label.active {
  color: #ffff00;
}

#custom-color-label.active #custom-color {
  outline: 2px solid #ffff00;
  outline-offset: 2px;
}

#custom-color {
  width: 100%;
  height: 32px;
  border: none;
  padding: 0;
  background: none;
}
