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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── Sim place button (top-right, below build toggle) ────────────────────── */
#sim-place {
  position: fixed;
  top: 54px;
  right: 16px;
  padding: 8px 16px;
  background: rgba(14, 11, 8, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.48);
  font: 500 12px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
  z-index: 10;
}

#sim-place:hover {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(22, 16, 10, 0.88);
}

#sim-place.active {
  color: hsl(160, 70%, 52%);
  background: rgba(10, 20, 14, 0.92);
}

/* ── Build mode toggle (top-right) ───────────────────────────────────────── */
#build-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 8px 16px;
  background: rgba(14, 11, 8, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.48);
  font: 500 12px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
  z-index: 10;
}

#build-toggle:hover {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(22, 16, 10, 0.88);
}

#build-toggle.active {
  color: hsl(40, 88%, 62%);
  background: rgba(20, 14, 8, 0.92);
}

/* ── Toolbar (bottom-center) ─────────────────────────────────────────────── */
#build-toolbar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(10, 8, 6, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s;
  z-index: 10;
}

#build-toolbar.visible {
  opacity: 1;
  pointer-events: auto;
}

.tool-btn {
  min-width: 64px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.48);
  font: 500 12px/1 system-ui, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, color 0.12s;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.82);
}

.tool-btn.active {
  background: rgba(255, 182, 36, 0.14);
  color: hsl(40, 88%, 62%);
}

/* ── Object picker panel (above toolbar in Furnish mode) ─────────────────── */
#obj-picker {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(10, 8, 6, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s;
  z-index: 9;
}

#obj-picker::-webkit-scrollbar { display: none; }

#obj-picker.visible {
  opacity: 1;
  pointer-events: auto;
}

.obj-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  flex-shrink: 0;
}

.obj-item:hover {
  background: rgba(255, 255, 255, 0.09);
}

.obj-item.active {
  background: rgba(255, 182, 36, 0.14);
  outline: 1px solid rgba(255, 182, 36, 0.35);
}

.obj-item img {
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
}

.obj-item span {
  color: rgba(255, 255, 255, 0.48);
  font: 500 10px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.obj-item.active span {
  color: hsl(40, 88%, 62%);
}

/* ── Speed controls (top-right, below sim-place) ─────────────────────────── */
#speed-controls {
  position: fixed;
  top: 92px;
  right: 16px;
  display: flex;
  gap: 4px;
  padding: 5px 7px;
  background: rgba(10, 8, 6, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 10px;
  z-index: 10;
}

.speed-btn {
  min-width: 36px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.42);
  font: 600 11px/1 system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, color 0.12s;
}

.speed-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
}

.speed-btn.active {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
}

/* ── Need HUD (bottom-left) ──────────────────────────────────────────────── */
#hud-panel {
  position: fixed;
  bottom: 24px;
  left: 16px;
  width: 204px;
  padding: 10px 12px 10px;
  background: rgba(10, 8, 6, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

#hud-panel.visible {
  opacity: 1;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-label {
  width: 54px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.42);
  font: 500 10px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
}

.hud-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.hud-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.35s ease;
  min-width: 0;
}

/* Mood row */
.hud-mood-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.hud-mood {
  display: block;
  border-radius: 50%;
  flex-shrink: 0;
}

.hud-mood-label {
  color: rgba(255, 255, 255, 0.38);
  font: 500 10px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
