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

:root {
  --bg:       #060412;
  --panel:    #0d0a1e;
  --border:   #2a1f4a;
  --accent:   #a855f7;
  --accent2:  #7c3aed;
  --text:     #e2d9f3;
  --text-dim: #7a6a9a;
  --danger:   #dc2626;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

body { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  width: 185px;
  min-width: 185px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 10px;
  overflow-y: auto;
  z-index: 10;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.back-link {
  display: inline-block;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  margin-bottom: 4px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ── Object buttons ──────────────────────────────── */
.obj-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.obj-btn {
  background: #140e28;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background 0.15s, border-color 0.15s;
}
.obj-btn:hover  { background: #1e1438; border-color: var(--accent); }
.obj-btn.active { background: #2a1850; border-color: var(--accent); color: var(--accent); }
.obj-icon  { font-size: 20px; line-height: 1; }
.obj-label { font-size: 10px; }

/* 5th button spans both columns */
.obj-grid .obj-btn:nth-child(5) { grid-column: 1 / -1; flex-direction: row; gap: 8px; justify-content: center; }

/* ── Zoom buttons ─────────────────────────────────── */
.zoom-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.zoom-btn {
  background: #140e28;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.15s, border-color 0.15s;
}
.zoom-btn:hover  { background: #1e1438; border-color: var(--accent); }
.zoom-btn.active { background: #2a1850; border-color: var(--accent); color: var(--accent); }

/* Spawn point tool button — full width, styled like action-btn but with obj-btn look */
.spawn-tool-btn {
  width: 100%;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
  padding: 7px 10px;
}
.spawn-tool-btn.active { border-color: #d946ef; color: #d946ef; background: #2a0a38; }

/* ── Action buttons ──────────────────────────────── */
.action-btn {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: #140e28;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.action-btn:hover        { background: #1e1438; border-color: var(--accent); }
.action-btn.primary      { background: var(--accent2); border-color: var(--accent); color: #fff; text-align: center; }
.action-btn.primary:hover{ background: var(--accent); }
.action-btn.danger       { border-color: #7f1d1d; color: #fca5a5; }
.action-btn.danger:hover { background: #3b0909; border-color: var(--danger); }
.action-btn.toggle.active{ background: #3b0764; border-color: var(--accent); color: var(--accent); }

/* ── Hint ─────────────────────────────────────────── */
.hint {
  background: #0d0822;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
}
.hint b { color: var(--text); }

/* ── Stats ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.stat-item {
  background: #0d0822;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 3px;
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}
.stat-item strong {
  display: block;
  font-size: 15px;
  color: var(--accent);
}

/* ── Game canvas area ─────────────────────────────── */
#game-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

#game-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

body.delete-mode #game-wrap { cursor: not-allowed; }

/* ── Mobile ───────────────────────────────────────── */
@media (max-width: 600px) {
  body { flex-direction: column; }

  #sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    max-height: 64px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 6px 8px;
    gap: 6px;
  }

  .logo, .back-link, .section-label, .hint, .stats-grid { display: none; }

  .obj-grid {
    display: flex;
    flex-direction: row;
    gap: 5px;
  }
  .obj-grid .obj-btn:nth-child(5) {
    grid-column: auto;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
  }

  .obj-btn  { padding: 5px 7px; }
  .obj-label { display: none; }

  .action-btn { width: auto; white-space: nowrap; padding: 5px 10px; }
}
