/* Sandboxels Clone — lab experiment aesthetic */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Outfit:wght@400;600;700&display=swap');

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Outfit", system-ui, sans-serif;
  color: #e8e6e3;
  background: #0f1114;
  overflow: hidden;
}

#game {
  height: 100%;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: row;
}

/* Main content area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* HUD */
.hud {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 17, 20, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
}

.hud__left, .hud__center, .hud__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.element-name {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}

.brush-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #e8e6e3;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

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

.btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.btn--ghost { background: transparent; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Canvas area */
#canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(30, 35, 42, 0.6) 0%, transparent 70%),
    linear-gradient(180deg, #0f1114 0%, #14171c 100%);
}

#canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 48px rgba(0, 0, 0, 0.4);
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#canvas:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Sidebar */
#sidebar {
  flex-shrink: 0;
  width: 220px;
  min-width: 220px;
  background: rgba(15, 17, 20, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: width 0.2s ease, min-width 0.2s ease;
}

#sidebar.collapsed {
  width: 48px;
  min-width: 48px;
}

#sidebar.collapsed .sidebar-header h2,
#sidebar.collapsed .categories,
#sidebar.collapsed .elements {
  display: none;
}

#sidebar.collapsed .sidebar-header {
  justify-content: center;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cat-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
  padding: 6px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cat-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cat-btn.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #fff;
}

.elements {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-content: start;
}

.elem-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.elem-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.elem-btn {
  aspect-ratio: 1;
  width: 100%;
  max-width: 52px;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

.elem-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.elem-btn--erase {
  background: linear-gradient(135deg, #4a4a4a 0%, #2a2a2a 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.elem-wrap--erase {
  grid-column: 1 / -1;
}

.elem-wrap--erase .elem-btn {
  max-width: none;
  aspect-ratio: auto;
  min-height: 44px;
}

.elem-btn--incinerate {
  background: linear-gradient(135deg, #ff4500 0%, #ff0000 50%, #8b0000 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.elem-wrap--tool {
  grid-column: 1 / -1;
}

.elem-wrap--tool .elem-btn {
  max-width: none;
  aspect-ratio: auto;
  min-height: 44px;
}

.elem-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}

/* Help overlay */
.help {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 15;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.help:hover { opacity: 1; }

.help-content {
  padding: 12px 16px;
  background: rgba(15, 17, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.help-content h3 {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.help-content p {
  margin: 4px 0 0 0;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

@media (max-width: 900px) {
  #sidebar {
    width: 180px;
  }

  .elements {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar {
    transition: none;
  }
}
