html, body { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #87ceeb; font-family: sans-serif; }

#info {
  position: absolute; top: 10px; left: 10px; color: #fff;
  text-shadow: 1px 1px 2px #000; z-index: 10; pointer-events: none;
  font-size: 14px; line-height: 1.5;
}

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 20px; height: 20px;
  margin: -10px 0 0 -10px; pointer-events: none; z-index: 10;
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: #fff; box-shadow: 0 0 2px #000;
}
#crosshair::before { top: 9px; left: 0; width: 20px; height: 2px; }
#crosshair::after  { left: 9px; top: 0; width: 2px; height: 20px; }

#hotbar {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; z-index: 10; padding: 4px;
  background: rgba(0,0,0,0.4); border-radius: 4px;
}
.slot {
  position: relative;
  width: 44px; height: 44px; border: 2px solid #555;
  background-color: #222;
  background-repeat: no-repeat; background-position: center; background-size: 76%;
  image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; text-align: center; line-height: 1.1;
}
.slot.active { border-color: #fff; }
.slot .count, #cursorStack .count {
  position: absolute; right: 3px; bottom: 1px; font-size: 10px;
  color: #ffe9a8; text-shadow: 1px 1px 1px #000;
}
.slot .num {
  position: absolute; left: 3px; top: 2px; font-size: 9px;
  color: #ccc; text-shadow: 1px 1px 1px #000;
}

/* 血條 / 飢餓條（半格用 .top 疊在 .off 上顯示） */
#hud {
  position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 28px; z-index: 10; pointer-events: none;
  font-size: 15px; letter-spacing: 1px; text-shadow: 1px 1px 2px #000;
}
#hearts { color: #e0332e; }
#hungerbar { color: #fff; }
#hud .off { opacity: 0.25; filter: grayscale(1); }
#hud .ico { position: relative; display: inline-block; }
#hud .ico .top { position: absolute; left: 0; top: 0; width: 50%; overflow: hidden; }

/* 挖掘進度條 */
#minebar {
  position: absolute; top: calc(50% + 20px); left: 50%; width: 60px; height: 6px;
  margin-left: -30px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.4);
  display: none; z-index: 10; pointer-events: none;
}
#minebar div { height: 100%; width: 0%; background: #eee; }

/* 受傷紅光 */
#hurt {
  position: absolute; inset: 0; pointer-events: none; z-index: 15;
  background: radial-gradient(ellipse at center, rgba(255,0,0,0) 40%, rgba(190,0,0,0.55) 100%);
  opacity: 0;
}

/* 背包 / 合成面板 */
#invPanel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(22, 22, 28, 0.94); border: 2px solid #666; border-radius: 6px;
  padding: 14px 18px; z-index: 25; color: #fff;
}
#invPanel.hidden { display: none; }
#invPanel h2 { margin: 0 0 6px; font-size: 16px; }
.inv-section { font-size: 12px; color: #9ab; margin: 10px 0 4px; }
#invGrid, #invHotbarRow {
  display: grid; grid-template-columns: repeat(9, 40px); gap: 3px;
}
#invHotbarRow { margin-top: 10px; }
.slot.inv-slot { width: 40px; height: 40px; font-size: 10px; cursor: pointer; white-space: pre-line; }
.slot.inv-slot:hover { border-color: #aaa; }
#craftArea { display: flex; align-items: center; gap: 14px; }
#craftGrid { display: grid; gap: 3px; }
#craftArrow { font-size: 22px; color: #9ab; }
.slot.inv-slot.result { border-color: #444; }
.slot.inv-slot.result.has { border-color: #3a6; background: #1d2b22; }
#craftSection.hidden, #furnaceSection.hidden { display: none; }

/* 熔爐介面 */
#furnaceArea { display: flex; align-items: center; gap: 16px; }
#furnaceCol { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#fBurn, #fCook {
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3);
}
#fBurn { width: 8px; height: 22px; display: flex; align-items: flex-end; }
#fBurn div { width: 100%; height: 0%; background: #ff9a2a; }
#fCook { width: 70px; height: 8px; }
#fCook div { width: 0%; height: 100%; background: #eee; }
#fMid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#fArrow { font-size: 20px; color: #9ab; }

/* 開始選單的刪除存檔小連結 */
#resetSave {
  margin-top: 18px; font-size: 12px; color: #b66;
  text-decoration: underline; cursor: pointer;
}
#resetSave:hover { color: #e88; }

/* 觸控模式（平板/手機） */
body.touch { touch-action: none; -webkit-user-select: none; user-select: none; }
canvas { touch-action: none; display: block; }
.touch #info { display: none; } /* 鍵盤說明在平板上沒意義 */
#touchUI { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
#touchUI.hidden { display: none; }
#joy {
  position: absolute; left: 26px; bottom: 96px;
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.3);
  pointer-events: auto; touch-action: none;
}
#joyStick {
  position: absolute; left: 50%; top: 50%;
  width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255,255,255,0.4);
}
#touchButtons {
  position: absolute; right: 22px; bottom: 92px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  pointer-events: none;
}
.tbtn {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(0,0,0,0.4); border: 2px solid rgba(255,255,255,0.4);
  color: #fff; font-size: 15px; text-shadow: 1px 1px 2px #000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; touch-action: none; cursor: pointer;
}
.tbtn:active { background: rgba(255,255,255,0.3); }
.tbtn.hidden { display: none; }
#touchTop {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 10px; pointer-events: none;
}
.tbtn.small { width: 48px; height: 48px; font-size: 13px; border-radius: 10px; }
.inv-hint { font-size: 11px; color: #889; margin: 10px 0 0; }
#cursorStack {
  position: fixed; z-index: 30; pointer-events: none;
  width: 36px; height: 36px;
  background-color: rgba(0, 0, 0, 0.6); border: 1px solid #888; border-radius: 3px;
  background-repeat: no-repeat; background-position: center; background-size: 82%;
  image-rendering: pixelated;
  color: #fff; font-size: 11px;
}
#cursorStack.hidden { display: none; }

/* 開始 / 死亡選單 */
#overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.6); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  z-index: 20; cursor: pointer; text-align: center; padding: 20px;
}
#overlay h1 { margin: 0 0 10px; }
#overlay.hidden { display: none; }
