* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'Segoe UI', system-ui, sans-serif; user-select: none; }

#game { display: block; width: 100vw; height: 100vh; cursor: pointer; }

/* Crosshair */
#crosshair {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; pointer-events: none; z-index: 10;
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: #fff;
}
#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%); }
#crosshair.hidden { display: none; }

/* Hotbar */
#hotbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 5px; z-index: 10;
  background: rgba(0,0,0,0.35); border: 2px solid rgba(0,0,0,0.5); border-radius: 4px;
}
.slot {
  width: 50px; height: 50px; position: relative; cursor: pointer;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(120,120,120,0.6);
  display: flex; align-items: center; justify-content: center; border-radius: 2px;
}
.slot.active { border-color: #fff; background: rgba(255,255,255,0.2); transform: scale(1.06); }
.slot img {
  width: 40px; height: 40px; image-rendering: pixelated;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}
.slot .num {
  position: absolute; top: 1px; left: 3px; font-size: 11px; color: #fff;
  text-shadow: 1px 1px 1px #000; font-weight: bold;
}

#blockName {
  position: fixed; left: 50%; bottom: 82px; transform: translateX(-50%);
  color: #fff; text-shadow: 2px 2px 2px #000; font-size: 16px; z-index: 10;
  opacity: 0; pointer-events: none;
}
#blockName.show { animation: fade 2s ease forwards; }
@keyframes fade { 0%,60% { opacity: 1; } 100% { opacity: 0; } }

/* HUD */
#hud {
  position: fixed; top: 8px; left: 8px; z-index: 10;
  color: #fff; text-shadow: 1px 1px 2px #000; font-size: 13px; line-height: 1.5;
  font-family: 'Consolas', monospace;
}
#hud .row { background: rgba(0,0,0,0.25); padding: 1px 6px; border-radius: 3px; display: inline-block; }

/* Hint overlay */
#hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 20; color: #fff; text-align: center; pointer-events: none;
  background: rgba(0,0,0,0.6); padding: 28px 40px; border-radius: 10px;
  text-shadow: 1px 1px 2px #000; max-width: 90vw;
}
#hint h1 { font-size: 30px; margin-bottom: 14px; letter-spacing: 1px; }
#hint p { font-size: 15px; margin: 5px 0; opacity: 0.92; }
#hint .big { font-size: 18px; margin-top: 16px; color: #ffe27a; }
#hint.hidden { display: none; }
#hint .keys { display: grid; grid-template-columns: auto auto; gap: 4px 18px; margin: 14px auto; text-align: left; width: fit-content; }
#hint kbd {
  background: #222; border: 1px solid #555; border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 7px; font-family: monospace; font-size: 13px;
}

.slot .hcount {
  position: absolute; bottom: 0px; right: 3px; font-size: 13px; color: #fff;
  text-shadow: 1px 1px 1px #000, 1px 1px 0 #000; font-weight: bold;
}

#loading {
  position: fixed; inset: 0; background: #111; color: #fff; z-index: 50;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
#loading.hidden { display: none; }

/* Survival bars */
#bars {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  width: 380px; display: flex; flex-direction: column; gap: 2px; z-index: 10;
  pointer-events: none;
}
.bar { display: flex; gap: 1px; }
#hunger { justify-content: flex-end; }
.heart, .food { font-size: 16px; line-height: 1; filter: drop-shadow(1px 1px 1px #000); }
.heart { color: #ff3b3b; }

/* Damage flash */
#damageFlash {
  position: fixed; inset: 0; background: rgba(180,0,0,0); z-index: 9;
  pointer-events: none;
}
#damageFlash.show { animation: dmg 0.4s ease; }
@keyframes dmg { 0% { background: rgba(180,0,0,0.45); } 100% { background: rgba(180,0,0,0); } }

/* Inventory / furnace screens */
.screen {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 30; background: rgba(30,30,35,0.96); border: 3px solid #1a1a1a;
  border-radius: 8px; padding: 16px 18px; color: #eee;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6); min-width: 360px;
}
.screen.hidden { display: none; }
.inv-title { font-size: 18px; font-weight: bold; margin-bottom: 10px; text-shadow: 1px 1px 0 #000; }
.inv-hint { font-size: 11px; opacity: 0.6; margin-top: 10px; }

.islot {
  width: 44px; height: 44px; background: #8b8b8b; border: 2px solid #373737;
  border-top-color: #fff; border-left-color: #fff; position: relative;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.islot:hover { background: #c0c0c0; }
.islot img { width: 36px; height: 36px; image-rendering: pixelated; pointer-events: none; }
.islot .count {
  position: absolute; bottom: -1px; right: 2px; font-size: 13px; font-weight: bold;
  color: #fff; text-shadow: 1px 1px 0 #000; pointer-events: none;
}
.islot.output { background: #6b6b6b; width: 52px; height: 52px; }
.islot.output img { width: 42px; height: 42px; }

.inv-grid { display: grid; gap: 2px; margin: 4px 0; }
.inv-grid.storage { grid-template-columns: repeat(9, 44px); }
.inv-grid.hotbarRow { grid-template-columns: repeat(9, 44px); margin-top: 10px; }

.craft-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.craft-grid { display: grid; grid-template-columns: repeat(2, 44px); gap: 2px; }
.craft-grid.table { grid-template-columns: repeat(3, 44px); }
.craft-arrow, .smelt-arrow { font-size: 26px; color: #888; }

/* Furnace */
.furnace-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.furnace-left { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flame { font-size: 18px; opacity: 0.2; }
.flame::before { content: '🔥'; }

/* Floating cursor item */
#cursorItem {
  position: fixed; z-index: 40; pointer-events: none; width: 44px; height: 44px;
  transform: translate(-50%, -50%);
}
#cursorItem img { width: 36px; height: 36px; image-rendering: pixelated; }
#cursorItem .count { position: absolute; bottom: 0; right: 4px; font-size: 13px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000; }

/* Death overlay */
#death {
  position: fixed; inset: 0; z-index: 45; background: rgba(80,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
}
#death.hidden { display: none; }
.death-box { text-align: center; color: #fff; text-shadow: 2px 2px 3px #000; }
.death-box h1 { font-size: 48px; color: #ff5a5a; margin-bottom: 16px; }
.death-box .big { font-size: 20px; margin-top: 18px; }
.death-box kbd { background: #222; border: 1px solid #555; border-radius: 4px; padding: 2px 9px; }
