/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: #1a1a2e; color: #e2e8f0; user-select: none; }

/* ===== UI Layer ===== */
#game-ui { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; }
#game-canvas { flex: 1; position: relative; overflow: hidden; }
#game-canvas canvas { display: block; }

/* ===== Top Bar ===== */
#top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; background: linear-gradient(135deg, #16213e, #0f3460);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 100; min-height: 48px; gap: 12px;
}
.stat-group { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.stat-icon { font-size: 1rem; }
.stat .label { color: #94a3b8; font-weight: 400; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.06); color: #e2e8f0; font-size: 1rem;
  cursor: pointer; transition: background 0.2s; display: flex;
  align-items: center; justify-content: center;
}
.top-btn:hover { background: rgba(255,255,255,0.12); }
.fill-btn { width: auto; padding: 0 12px; font-size: 1.1rem; }

/* ===== Bottom Toolbar ===== */
#bottom-bar {
  padding: 8px 12px; background: linear-gradient(135deg, #16213e, #0f3460);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 100; overflow-x: auto;
}
.tool-group { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 14px; border-radius: 10px; border: 2px solid transparent;
  background: rgba(255,255,255,0.04); color: #94a3b8; cursor: pointer;
  transition: all 0.2s; min-width: 56px;
}
.tool-btn:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.tool-btn.active {
  background: rgba(37,99,235,0.2); border-color: #2563eb; color: #60a5fa;
}
.tool-btn.danger.active { background: rgba(239,68,68,0.2); border-color: #ef4444; color: #f87171; }
.tool-icon { font-size: 1.3rem; line-height: 1; }
.tool-label { font-size: 0.65rem; font-weight: 500; white-space: nowrap; }
.tool-divider { width: 1px; height: 36px; background: rgba(255,255,255,0.1); margin: 0 4px; }

/* ===== Modal ===== */
#modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
#modal-overlay.hidden { display: none; }
.modal {
  background: #1e293b; border-radius: 16px; max-width: 520px; width: 90%;
  max-height: 80vh; display: flex; flex-direction: column;
  border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: slideUp 0.25s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: #64748b; font-size: 1.2rem; cursor: pointer; padding: 4px; }
.modal-close:hover { color: #e2e8f0; }
.modal-body { padding: 20px; overflow-y: auto; font-size: 0.9rem; line-height: 1.6; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* ===== Toast ===== */
#toast-container {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 10000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: 12px; background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3); animation: toastIn 0.3s ease;
  pointer-events: auto; text-align: center;
}
.toast.success { border-color: #22c55e; }
.toast.warning { border-color: #eab308; }
.toast.info { border-color: #3b82f6; }

/* ===== Menu Panel ===== */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-item {
  padding: 16px; border-radius: 12px; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer;
  text-align: center; transition: all 0.2s;
}
.menu-item:hover { background: rgba(255,255,255,0.08); }
.menu-item .icon { font-size: 2rem; margin-bottom: 8px; }
.menu-item .name { font-size: 0.85rem; font-weight: 500; }

/* ===== List items (inventory, staff, etc) ===== */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 6px; transition: background 0.2s;
}
.list-item:hover { background: rgba(255,255,255,0.06); }
.list-item .info { flex: 1; }
.list-item .name { font-weight: 500; font-size: 0.9rem; }
.list-item .desc { font-size: 0.78rem; color: #94a3b8; margin-top: 2px; }
.list-item .actions { display: flex; gap: 6px; }
.btn-sm {
  padding: 4px 12px; border-radius: 6px; border: none;
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
  background: rgba(255,255,255,0.08); color: #e2e8f0; transition: background 0.2s;
}
.btn-sm:hover { background: rgba(255,255,255,0.14); }
.btn-sm.primary { background: #2563eb; color: #fff; }
.btn-sm.primary:hover { background: #1d4ed8; }
.btn-sm.danger { background: rgba(239,68,68,0.2); color: #f87171; }
.btn-sm.danger:hover { background: rgba(239,68,68,0.3); }

/* ===== Object info panel (follows selected object) ===== */
#info-panel {
  position: absolute; z-index: 50;
  background: #1e293b; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 12px 16px; min-width: 160px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4); display: none;
  pointer-events: none;
}
#info-panel.show { display: block; }
#info-panel .title { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
#info-panel .detail { font-size: 0.75rem; color: #94a3b8; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .tool-label { display: none; }
  .tool-btn { min-width: 44px; padding: 6px 10px; }
  .stat-group { gap: 10px; }
  .stat { font-size: 0.75rem; }
  #top-bar { padding: 6px 12px; }
  #bottom-bar { padding: 6px 8px; }
}
