:root {
  --bg-color: #0b0e14;
  --panel-color: #1a1e26;
  --accent-neon: #00ffff;
  --accent-pink: #ff00ff;
  --accent-red: #ff3333;
  --text-primary: #e0e6ed;
  --text-muted: #94a3b8;
  --shadow-neon: 0 0 10px rgba(0, 255, 255, 0.4);
}

/* Scope layout to the pinball game container instead of global body */
#game {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

#toolbar {
  width: 250px;
  padding: 24px;
  background-color: var(--panel-color);
  border-right: 1px solid #2d313a;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  height: 100vh;
  box-sizing: border-box;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
}

#toolbar h2 {
  font-size: 0.75rem;
  font-weight: 700;
  margin: 20px 0 4px 0;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#toolbar button {
  padding: 12px 16px;
  background-color: #2d313a;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Improve touch responsiveness for toolbar buttons */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255,255,255,0.06);
}

#toolbar button:hover {
  background-color: #383e4a;
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.1);
}

#toolbar button.active {
  background-color: rgba(0, 255, 255, 0.08);
  border-color: var(--accent-neon);
  color: var(--accent-neon);
  box-shadow: var(--shadow-neon);
}

#play-mode-toggle.playing {
  background-color: rgba(0, 255, 255, 0.15);
  border-color: var(--accent-neon);
  color: var(--accent-neon);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

#delete-tool {
  background-color: rgba(255, 51, 51, 0.05);
  border-color: rgba(255, 51, 51, 0.2);
  color: var(--accent-red);
}

#delete-tool:hover {
  background-color: rgba(255, 51, 51, 0.15);
  border-color: var(--accent-red);
  box-shadow: 0 0 15px rgba(255, 51, 51, 0.3);
}

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px;
  gap: 20px;
  overflow: auto;
  align-items: center;
  background: radial-gradient(circle at center, #1a1e26 0%, #0b0e14 100%);
}

#editor-canvas {
  background-color: #05070a;
  border: 1px solid #2d313a;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  max-width: 100%;
  max-height: calc(100vh - 64px);
  height: auto;
  width: auto;
  object-fit: contain;
  image-rendering: crisp-edges;
  /* Improve touch responsiveness on mobile */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.color-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #bbb;
}

.color-picker-item input {
  background: none;
  border: none;
  padding: 0;
  width: 30px;
  height: 20px;
  cursor: pointer;
}

#level-data {
  width: 100%;
  height: 180px;
  background-color: #1a1a1a;
  color: #0d0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 5px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.7rem;
  resize: vertical;
}

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

.button-grid button {
  padding: 8px 4px;
  font-size: 0.75rem;
  text-align: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-color: #383838;
}

.data-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.data-row button {
  flex: 1;
  padding: 10px 4px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: #444;
  font-weight: 500;
}

.data-row button:hover {
  background-color: #555;
  color: #fff;
  border-color: #888;
}

#toolbar hr {
  border: none;
  border-top: 1px solid #444;
  margin: 15px 0;
}

/* ─── Collapsible section toggle ───────────────────── */
.section-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: #272b34;
  border: 1px solid #2d313a;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.section-toggle:hover { background: #2e3340; color: var(--text-primary); }
.section-toggle.open { color: var(--accent-neon); border-color: rgba(0,255,255,0.2); }

#colors-arrow { font-size: 0.7rem; transition: transform 0.2s; }
.section-toggle.open #colors-arrow { transform: rotate(90deg); }

.section-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 4px 4px;
}
.section-panel.open { display: flex; }

.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #aaa;
}
.panel-row label { flex: 1; }

.panel-row input[type="color"] {
  width: 28px;
  height: 22px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
}

.color-pair {
  display: flex;
  gap: 5px;
}

.panel-text-input {
  background: #111;
  border: 1px solid #333;
  border-radius: 5px;
  color: #ccc;
  font-size: 0.72rem;
  padding: 3px 6px;
  width: 110px;
  min-width: 0;
  box-sizing: border-box;
}

.panel-range {
  width: 110px;
  accent-color: var(--accent-neon);
}