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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: #fff;
  user-select: none;
}

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

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  pointer-events: none;
  z-index: 5;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 0 1px rgba(0,0,0,0.8);
}
#crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
#crosshair::after { top: 8px; left: 0; width: 18px; height: 2px; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  display: none;
}
body.playing #hud { display: block; }
body.playing #crosshair { display: block; }
#crosshair { display: none; }

#break-progress {
  position: fixed;
  top: calc(50% + 22px);
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.6);
}
#break-progress.hidden { display: none; }
#break-progress-fill { height: 100%; width: 0; background: #e8e8e8; }

#toast {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,12,16,0.85);
  border: 1px solid #666;
  padding: 10px 16px;
  font-size: 14px;
  text-shadow: 1px 1px 0 #000;
  max-width: 480px;
  text-align: center;
  z-index: 30; /* above menu screens so connection errors show on the menu */
  pointer-events: none;
}
#toast.hidden { display: none; }

#mp-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #444;
  margin-top: 14px;
  padding-top: 14px;
}
#mp-section button { background: #3a4f6f; border-color: #29394f; }
#mp-section button:hover { background: #4a648a; }
#mp-section button:disabled { opacity: 0.6; cursor: default; }

#debug-overlay {
  position: fixed;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.5);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
  font-family: 'Consolas', monospace;
}
#debug-overlay.hidden { display: none; }

#vitals {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.bar { display: flex; gap: 2px; }
.bar .icon { width: 16px; height: 16px; font-size: 15px; text-align: center; line-height: 16px;
  filter: drop-shadow(1px 1px 0 #000); }
#health-bar .icon.full { color: #d43a3a; }
#health-bar .icon.empty { color: #4a1414; }
#hunger-bar .icon.full { color: #c98a3e; }
#hunger-bar .icon.empty { color: #4a3818; }

#hotbar {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  pointer-events: auto;
}
.hotbar-slot {
  width: 48px;
  height: 48px;
  background: rgba(20,20,20,0.65);
  border: 2px solid #555;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hotbar-slot.selected { border-color: #fff; background: rgba(255,255,255,0.2); }
.hotbar-slot canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.hotbar-slot .count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

.screen {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 10;
  pointer-events: auto;
}
.screen.hidden { display: none; }
.screen h1 { font-size: 42px; letter-spacing: 2px; text-shadow: 3px 3px 0 #000; }
#death-screen h1 { color: #c92b2b; }

#menu-buttons { display: flex; flex-direction: column; gap: 10px; width: 240px; }
#menu-buttons label { font-size: 12px; color: #aaa; }
#menu-buttons input {
  padding: 8px;
  font-size: 14px;
  background: #222;
  border: 1px solid #555;
  color: #fff;
}
#menu-buttons button {
  padding: 10px;
  font-size: 15px;
  background: #3a5f3a;
  border: 2px solid #294a29;
  color: #fff;
  cursor: pointer;
}
#menu-buttons button:hover { background: #4a7a4a; }
#menu-buttons button.hidden { display: none; }

#inventory-screen.screen { background: rgba(10,12,16,0.85); }

.item-glyph {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
}

.inventory-panel {
  background: rgba(20,22,28,0.95);
  border: 2px solid #444;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.inventory-panel h2 { font-size: 20px; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 48px);
  gap: 4px;
}
.inv-grid.hotbar-row { border-top: 2px solid #444; padding-top: 12px; }

.inv-slot {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.06);
  border: 2px solid #555;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.inv-slot:hover { border-color: #888; }
.inv-slot.held { border-color: #fff; background: rgba(255,255,255,0.2); }
.inv-slot canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.inv-slot .count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

.inv-hint { font-size: 12px; color: #999; max-width: 420px; text-align: center; }

.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  width: 380px;
}
.recipe-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid #444;
  cursor: pointer;
}
.recipe-row:hover { background: rgba(255,255,255,0.14); }
.recipe-row.disabled { opacity: 0.45; cursor: default; }
.recipe-row.disabled:hover { background: rgba(255,255,255,0.06); }
.recipe-result-icon { width: 32px; height: 32px; flex-shrink: 0; }
.recipe-info { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.recipe-name { font-size: 13px; font-weight: bold; }
.recipe-costs { display: flex; gap: 10px; font-size: 11px; }
.recipe-costs .ok { color: #7fd47f; }
.recipe-costs .short { color: #d47f7f; }
