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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #1a1a1a;
  font-family: "Segoe UI", "Microsoft YaHei", monospace, sans-serif;
  color: #fff;
  user-select: none;
  image-rendering: pixelated;
}

#game { display: block; width: 100%; height: 100%; cursor: none; }

#overlay, #pause {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 16, 16, 0.72);
}
#overlay {
  background:
    linear-gradient(180deg, rgba(120,180,255,0.25), rgba(40,90,40,0.35)),
    #3d6b2f;
}
#overlay.hidden, #pause.hidden, #inventory-screen.hidden,
#furnace-screen.hidden, #hud.hidden { display: none !important; }

.mc-panel {
  width: min(460px, 92vw);
  padding: 28px 24px 22px;
  background: #c6c6c6;
  border: 4px solid #fff;
  border-bottom-color: #555; border-right-color: #555;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #373737, 0 8px 0 rgba(0,0,0,0.35);
  text-align: center; color: #3f3f3f;
}
.mc-panel h1, .mc-panel h2 {
  font-size: 2rem; color: #3f3f3f; text-shadow: 2px 2px 0 #fff;
  margin-bottom: 6px; letter-spacing: 2px;
}
.subtitle { color: #555; margin-bottom: 16px; font-size: 0.9rem; }
.controls {
  list-style: none; text-align: left; margin: 0 auto 18px;
  padding: 10px 12px; background: #8b8b8b;
  border: 2px solid #373737; border-top-color: #fff; border-left-color: #fff;
  font-size: 0.8rem; line-height: 1.75; color: #222;
}
kbd, .mouse {
  display: inline-block; min-width: 1.3em; padding: 0 5px;
  background: #d0d0d0; border: 2px solid #373737;
  border-top-color: #fff; border-left-color: #fff;
  font-size: 0.8em; color: #111; text-align: center;
}
#start-btn, .mc-btn {
  display: block; width: 100%; margin: 8px 0; padding: 12px;
  background: #727272; color: #fff;
  border: 3px solid #fff; border-bottom-color: #373737; border-right-color: #373737;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  text-shadow: 2px 2px 0 #3f3f3f; font-family: inherit;
}
#start-btn:hover, .mc-btn:hover { background: #8b8b8b; }
.hint { margin-top: 12px; font-size: 0.75rem; color: #555; }

#hud { pointer-events: none; }
#crosshair {
  position: fixed; left: 50%; top: 50%; width: 16px; height: 16px;
  transform: translate(-50%, -50%); z-index: 12;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.55);
}
#crosshair::before { left: 50%; top: 2px; bottom: 2px; width: 2px; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 2px; right: 2px; height: 2px; transform: translateY(-50%); }

#water-overlay {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(30, 80, 160, 0.35);
  pointer-events: none;
}

#debug {
  position: fixed; top: 8px; left: 10px; z-index: 12;
  font-size: 12px; line-height: 1.45; font-family: Consolas, monospace;
  text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; color: #ddd;
}

#bars {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%);
  z-index: 12; display: flex; gap: 48px; align-items: flex-end;
}
#hearts, #food { display: flex; gap: 1px; height: 18px; }
.heart, .drumstick {
  width: 18px; height: 18px; background-size: contain; background-repeat: no-repeat;
  image-rendering: pixelated;
}
.heart.full { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M1 1h2v1h1v1h1V2h1V1h2v1h1v2H7v1H6v1H5v1H4V6H3V5H2V4H1V3H0V2h1z'/%3E%3Cpath fill='%23ff1313' d='M1 2h1v1h1v1h1v1h1V4h1V3h1V2h1v1h1v1H7v1H6v1H5v1H4v1H3V6H2V5H1V4H0V3h1z'/%3E%3C/svg%3E"); }
.heart.empty { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M1 1h2v1h1v1h1V2h1V1h2v1h1v2H7v1H6v1H5v1H4V6H3V5H2V4H1V3H0V2h1z'/%3E%3Cpath fill='%23404040' d='M1 2h1v1h1v1h1v1h1V4h1V3h1V2h1v1h1v1H7v1H6v1H5v1H4v1H3V6H2V5H1V4H0V3h1z'/%3E%3C/svg%3E"); }
.heart.half { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M1 1h2v1h1v1h1V2h1V1h2v1h1v2H7v1H6v1H5v1H4V6H3V5H2V4H1V3H0V2h1z'/%3E%3Cpath fill='%23404040' d='M1 2h1v1h1v1h1v1h1V4h1V3h1V2h1v1h1v1H7v1H6v1H5v1H4v1H3V6H2V5H1V4H0V3h1z'/%3E%3Cpath fill='%23ff1313' d='M1 2h1v1h1v1h1v1h1V4h1V3h1V2H1z'/%3E%3C/svg%3E"); }
.drumstick.full { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M2 0h3v1h1v1h1v3H6v1H5v1H4v1H2V6H1V5H0V2h1V1h1z'/%3E%3Cpath fill='%23A16207' d='M2 1h2v1h1v1h1v2H5v1H4v1H3v1H2V6H1V5H0V3h1V2h1z'/%3E%3Cpath fill='%23F4D03F' d='M3 2h1v1h1v1H4v1H3V4H2V3h1z'/%3E%3C/svg%3E"); }
.drumstick.empty { opacity: 0.35; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M2 0h3v1h1v1h1v3H6v1H5v1H4v1H2V6H1V5H0V2h1V1h1z'/%3E%3Cpath fill='%23555' d='M2 1h2v1h1v1h1v2H5v1H4v1H3v1H2V6H1V5H0V3h1V2h1z'/%3E%3C/svg%3E"); }

#hotbar {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  z-index: 12; display: flex; gap: 0;
}
.slot {
  width: 44px; height: 44px; position: relative;
  background: rgba(0,0,0,0.45);
  border: 2px solid #373737;
  border-top-color: #8b8b8b; border-left-color: #8b8b8b;
  box-shadow: inset 1px 1px 0 #000;
  display: flex; align-items: center; justify-content: center;
  image-rendering: pixelated;
}
.slot.active { outline: 2px solid #fff; outline-offset: -2px; z-index: 1; }
.slot canvas { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.slot .count {
  position: absolute; right: 3px; bottom: 1px;
  font-size: 12px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.slot .dur {
  position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px;
  background: #333; pointer-events: none;
}
.slot .dur > i {
  display: block; height: 100%; background: #0c0;
}
.slot .keynum {
  position: absolute; top: 1px; left: 3px;
  font-size: 9px; color: rgba(255,255,255,0.35);
}

#hand-item {
  position: fixed; right: 8%; bottom: 6%;
  width: 120px; height: 120px; z-index: 11;
  pointer-events: none; transform-origin: 80% 100%; opacity: 0.95;
}
#hand-item canvas {
  width: 100%; height: 100%; image-rendering: pixelated;
  filter: drop-shadow(4px 6px 0 rgba(0,0,0,0.45));
}

#inventory-screen, #furnace-screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); pointer-events: auto;
}
.inv-panel {
  background: #c6c6c6;
  border: 4px solid #fff;
  border-bottom-color: #555; border-right-color: #555;
  padding: 16px 18px 14px;
  box-shadow: inset 2px 2px 0 #fff, 0 10px 0 rgba(0,0,0,0.3);
  color: #3f3f3f; min-width: 360px;
}
.inv-title { font-size: 1.1rem; margin-bottom: 10px; text-shadow: 1px 1px 0 #fff; }
.inv-label { font-size: 0.8rem; margin: 10px 0 4px; color: #555; }
.inv-grid, .hotbar-row, .craft-grid { display: grid; gap: 2px; }
.inv-grid { grid-template-columns: repeat(9, 44px); }
.hotbar-row { grid-template-columns: repeat(9, 44px); }
.craft-grid { grid-template-columns: repeat(2, 44px); grid-template-rows: repeat(2, 44px); }
.craft-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.craft-arrow { font-size: 1.4rem; color: #555; }
.inv-panel .slot { cursor: pointer; pointer-events: auto; }
.inv-panel .slot:hover { background: rgba(255,255,255,0.15); }
.inv-hint { margin-top: 10px; font-size: 0.72rem; color: #555; max-width: 420px; line-height: 1.5; }

.furnace-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 8px;
}
.furnace-col { display: flex; flex-direction: column; gap: 4px; }
.furnace-progress { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#furn-bar {
  width: 80px; height: 10px; background: #555;
  border: 2px solid #373737; border-top-color: #fff; border-left-color: #fff;
}
#furn-bar-fill {
  height: 100%; width: 0%; background: #e06020;
  transition: width 0.1s linear;
}

#cursor-item {
  position: fixed; z-index: 50; pointer-events: none;
  width: 36px; height: 36px; margin: -18px 0 0 -18px; display: none;
}
#cursor-item.show { display: block; }
#cursor-item canvas { width: 32px; height: 32px; image-rendering: pixelated; }
#cursor-item .count {
  position: absolute; right: 0; bottom: 0;
  font-size: 12px; font-weight: 700; color: #fff; text-shadow: 1px 1px 0 #000;
}
