/* Voxelcraft HUD. Class names below are a contract for src/game/ui.js:
 * .slot .slot.selected .slot .icon .slot .count .heart .heart.empty
 * .bubble .recipe .recipe.disabled .tag */
:root {
  --ink: #e8e6e1;
  --panel: rgba(18, 20, 24, 0.88);
  --edge: rgba(255, 255, 255, 0.14);
  --accent: #7cb342;
  --slot: 46px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b0d10;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink); -webkit-font-smoothing: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ------------------------------- HUD ---------------------------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px;
  transform: translate(-50%, -50%); opacity: 0.85;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: rgba(255, 255, 255, 0.9);
  mix-blend-mode: difference;
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px 40px rgba(0, 0, 0, 0.45); }
#water-overlay {
  position: absolute; inset: 0; background: rgba(30, 90, 170, 0.35);
  box-shadow: inset 0 0 120px 30px rgba(0, 30, 70, 0.6);
}
#water-overlay.hidden { display: none !important; }

#health, #air { position: absolute; display: flex; gap: 3px; }
#health { left: 14px; bottom: 84px; }
#air { left: 14px; bottom: 112px; }
.heart, .bubble { width: 15px; height: 15px; border-radius: 3px; image-rendering: pixelated; }
.heart { background: #d33; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 4px rgba(0, 0, 0, 0.5); }
.heart.half { background: linear-gradient(90deg, #d33 50%, #3a2226 50%); }
.heart.empty { background: #3a2226; }
.bubble { background: #6fc3ff; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3); }
.bubble.empty { background: rgba(255, 255, 255, 0.12); }

#hotbar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 5px; background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--edge); border-radius: 6px;
}
.slot {
  position: relative; width: var(--slot); height: var(--slot); border-radius: 4px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center;
}
.slot.selected { outline: 2px solid var(--accent); outline-offset: 1px; background: rgba(255, 255, 255, 0.16); }
.slot .icon { width: 74%; height: 74%; border-radius: 3px; image-rendering: pixelated; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); }
.slot .count {
  position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 700;
  color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000;
}
.slot .glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: rgba(0, 0, 0, 0.55); font-weight: 700; }
#held-label {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  font-size: 13px; text-shadow: 1px 1px 0 #000; opacity: 0.9;
}
#debug {
  position: absolute; left: 10px; top: 10px; font-size: 12px; line-height: 1.45;
  white-space: pre; text-shadow: 1px 1px 0 #000; opacity: 0.92;
}
#toast {
  position: absolute; left: 50%; top: 12%; transform: translateX(-50%);
  font-size: 14px; text-shadow: 1px 1px 0 #000; opacity: 0; transition: opacity 0.35s;
  max-width: 70vw; text-align: center;
}
#toast.show { opacity: 1; }
#hint {
  position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%);
  font-size: 12px; opacity: 0.55; text-shadow: 1px 1px 0 #000; white-space: nowrap;
}

/* ------------------------------ panels -------------------------------- */
.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  padding: 22px 26px; z-index: 30; min-width: 420px; max-width: 86vw;
  max-height: 88vh; overflow: auto; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.panel h1 { margin: 0 0 2px; font-size: 30px; letter-spacing: 1px; }
.panel h2 { margin: 0 0 10px; font-size: 20px; }
.panel .sub { margin: 0 0 16px; opacity: 0.6; font-size: 13px; }
.panel .row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.panel .fields { gap: 18px; }
.panel label { font-size: 13px; display: flex; flex-direction: column; gap: 4px; opacity: 0.85; }
.panel button {
  font: inherit; font-size: 14px; padding: 9px 14px; border-radius: 6px; cursor: pointer;
  background: rgba(255, 255, 255, 0.09); color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.panel button:hover { background: rgba(255, 255, 255, 0.18); }
.panel button:disabled { opacity: 0.4; cursor: default; }
.panel select, .panel input[type=text] {
  font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 5px;
  background: rgba(0, 0, 0, 0.4); color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.18);
}
.panel .keys { font-size: 11.5px; opacity: 0.45; line-height: 1.6; margin-top: 14px; }
#menu-note { font-size: 12.5px; opacity: 0.75; min-height: 16px; }
.sep { height: 1px; background: var(--edge); margin: 14px 0; }
.grid { display: flex; flex-wrap: wrap; gap: 6px; }
#craft-list { display: flex; flex-direction: column; gap: 6px; }
.recipe {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); cursor: pointer;
}
.recipe:hover { background: rgba(255, 255, 255, 0.14); }
.recipe.disabled { opacity: 0.38; cursor: default; }
.recipe .icon { width: 26px; height: 26px; border-radius: 3px; flex: 0 0 auto; }
.recipe .txt { font-size: 13px; }
.tag { font-size: 11px; opacity: 0.6; margin-left: auto; }

/* ----------------------------- loading -------------------------------- */
#loading {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: #0b0d10;
}
#loading .bar { width: 320px; height: 10px; border: 1px solid var(--edge); border-radius: 6px; overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.2s; }
#loading p { font-size: 13px; opacity: 0.7; margin: 0; }
@media (max-width: 720px) { .panel { min-width: 0; width: 92vw; } :root { --slot: 38px; } }
