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

html, body {
  height: 100%;
  background: #1a1410;
  color: #f5ecd9;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

#game { position: fixed; inset: 0; }

#canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* ---- Top HUD ---- */
#hud {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.hud-group {
  display: flex; gap: 8px; align-items: center;
  background: rgba(28, 22, 16, 0.82);
  border: 1px solid rgba(255, 220, 150, 0.2);
  padding: 6px 12px; border-radius: 10px;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
.hud-item { font-size: 15px; white-space: nowrap; }
.hud-item b { color: #ffe49a; }

/* ---- Buttons ---- */
.btn {
  font: inherit; color: #f5ecd9; cursor: pointer;
  background: #3a2e22; border: 1px solid #5a4630;
  border-radius: 8px; padding: 6px 10px;
}
.btn:hover { background: #4a3a2a; }
.btn:active { transform: translateY(1px); }

/* ---- Compact hotbar ---- */
#hotbar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  background: rgba(24, 18, 13, 0.82);
  border: 1px solid rgba(255, 220, 150, 0.18);
  padding: 5px; border-radius: 12px;
  max-width: 96vw; flex-wrap: wrap; justify-content: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}

.slot {
  position: relative; width: 50px; height: 50px;
  border-radius: 9px; cursor: pointer;
  background: rgba(58, 46, 34, 0.55);
  border: 1px solid rgba(255, 220, 150, 0.12);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .08s;
}
.slot:hover { background: rgba(90, 70, 48, 0.7); transform: translateY(-2px); }
.slot:active { transform: translateY(0); }
.slot img {
  max-width: 40px; max-height: 40px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
  pointer-events: none;
}
.slot .cost {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 10px; font-weight: 700; color: #ffe49a;
  text-shadow: 0 1px 2px #000; pointer-events: none;
}
.slot .keyhint {
  position: absolute; top: 1px; left: 3px;
  font-size: 9px; color: rgba(255,255,255,0.45); pointer-events: none;
}
.slot.selected {
  background: rgba(120, 95, 55, 0.85);
  border-color: #ffe49a;
  box-shadow: 0 0 0 1px #ffe49a, 0 0 12px rgba(255,220,150,0.4);
}
.slot.tool.selected { border-color: #ff9a9a; box-shadow: 0 0 0 1px #ff9a9a, 0 0 12px rgba(255,150,150,0.4); }
.slot.unaffordable { opacity: 0.4; }

.hotbar-sep { width: 1px; height: 38px; background: rgba(255,220,150,0.15); margin: 0 3px; }

/* Tooltip that follows the hovered slot */
#tooltip {
  position: absolute; z-index: 50;
  background: rgba(20, 15, 10, 0.95);
  border: 1px solid rgba(255,220,150,0.25);
  padding: 5px 9px; border-radius: 7px;
  font-size: 12px; line-height: 1.3; pointer-events: none;
  white-space: nowrap; transform: translate(-50%, -100%);
}
#tooltip .tt-name { color: #ffe49a; font-weight: 600; }
#tooltip .tt-cost { color: #cfe9b0; }
#tooltip.hidden { display: none; }

/* ---- Toasts ---- */
#toasts {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(28, 22, 16, 0.92);
  border: 1px solid rgba(255, 220, 150, 0.3);
  padding: 8px 16px; border-radius: 20px; font-size: 14px;
  animation: pop 0.2s ease;
}
.toast.bad { border-color: rgba(255, 120, 120, 0.6); color: #ffc4c4; }
.toast.good { border-color: rgba(150, 255, 150, 0.5); color: #c8ffc8; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }

/* ---- Help ---- */
#help {
  position: absolute; top: 60px; right: 10px;
  background: rgba(28, 22, 16, 0.85);
  border: 1px solid rgba(255, 220, 150, 0.2);
  padding: 10px 14px; border-radius: 10px;
  font-size: 12px; line-height: 1.6; max-width: 260px;
}
#help b { color: #ffe49a; }
#help.hidden { display: none; }
