/* FableCraft — 全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000;
  font-family: "Microsoft YaHei", "PingFang SC", monospace, sans-serif; }

#game-container { position: relative; width: 100%; height: 100%; }
#game-canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ---------- 准星 ---------- */
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: rgba(255,255,255,.85); font-size: 24px; font-weight: bold;
  text-shadow: 0 0 2px #000; pointer-events: none; z-index: 10;
  mix-blend-mode: difference;
}

/* ---------- HUD ---------- */
#hud { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; pointer-events: none; }
#hotbar {
  display: flex; justify-content: center; margin: 0 auto 8px;
  width: max-content; background: rgba(0,0,0,.35);
  border: 2px solid #222; outline: 2px solid rgba(255,255,255,.25);
  image-rendering: pixelated;
}
.hotbar-slot {
  width: 52px; height: 52px; border: 2px solid #555; position: relative;
  background: rgba(60,60,60,.55);
}
.hotbar-slot.selected { border: 3px solid #fff; margin: -1px; z-index: 1; }
.slot-icon { position: absolute; inset: 6px; background-size: contain;
  background-repeat: no-repeat; background-position: center; image-rendering: pixelated; }
.slot-count {
  position: absolute; right: 2px; bottom: 0; color: #fff; font-size: 15px;
  font-weight: bold; text-shadow: 1px 1px 0 #3f3f3f; pointer-events: none;
}
#held-item-name {
  position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%);
  color: #fff; text-shadow: 1px 1px 0 #000; font-size: 16px;
  opacity: 0; transition: opacity .5s;
}
#status-bars { width: 372px; margin: 0 auto 2px; display: flex; justify-content: space-between; }
.bar-row { display: flex; gap: 1px; }
#hunger-bar { flex-direction: row-reverse; }
.heart, .drumstick { width: 18px; height: 18px; background-size: contain; image-rendering: pixelated; }

#debug-info {
  position: absolute; left: 8px; top: 8px; color: #fff; font-size: 13px;
  text-shadow: 1px 1px 0 #000; z-index: 30; line-height: 1.5;
  background: rgba(0,0,0,.3); padding: 6px 10px; pointer-events: none;
}

#underwater-overlay {
  position: absolute; inset: 0; background: rgba(20, 60, 160, .35);
  pointer-events: none; z-index: 15;
}
#damage-overlay {
  position: absolute; inset: 0; background: rgba(255,0,0,.35);
  pointer-events: none; z-index: 16; opacity: 0; transition: opacity .4s;
}

/* ---------- 通用弹层 ---------- */
.modal {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
}
.menu-panel {
  background: rgba(30,30,30,.92); border: 2px solid #000;
  outline: 2px solid rgba(255,255,255,.2);
  padding: 28px 36px; text-align: center; min-width: 340px;
}
.menu-panel h2 { color: #fff; margin-bottom: 20px; text-shadow: 2px 2px 0 #3f3f3f; }
.mc-btn {
  display: block; width: 100%; margin: 8px 0; padding: 11px 0;
  background: #6e6e6e; color: #fff; font-size: 16px;
  border: 2px solid #000; box-shadow: inset -2px -3px 0 rgba(0,0,0,.4), inset 2px 2px 0 rgba(255,255,255,.35);
  cursor: pointer; text-shadow: 1px 1px 0 #3f3f3f; font-family: inherit;
}
.mc-btn:hover:not(:disabled) { background: #7f8cff; }
.mc-btn:active:not(:disabled) { box-shadow: inset 2px 3px 0 rgba(0,0,0,.4); }
.mc-btn:disabled { opacity: .45; cursor: not-allowed; }
#save-toast { color: #9f9; height: 20px; margin-top: 8px; font-size: 14px; }

.setting-row { margin: 14px 0; text-align: left; color: #eee; }
.setting-row label { display: block; margin-bottom: 4px; font-size: 14px; }
.setting-row input[type=range] { width: 100%; }

.death-panel { background: rgba(120, 0, 0, .8); }
.death-panel p { color: #fdd; margin-bottom: 16px; }

/* ---------- 主菜单 ---------- */
#main-menu {
  position: absolute; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.title-bg {
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(#6ea8e8 0%, #a8cdf0 45%, #7aa25a 45.2%, #5d7f43 100%);
  filter: brightness(.8);
}
.game-title {
  font-size: 72px; color: #fff; letter-spacing: 4px;
  text-shadow: 4px 4px 0 #3f3f3f, -2px -2px 0 rgba(0,0,0,.3);
  margin-bottom: 4px;
}
.subtitle { color: #ffe14d; font-size: 16px; margin-bottom: 30px;
  text-shadow: 2px 2px 0 #3f3f3f; transform: rotate(-3deg); }
.title-panel { background: rgba(30,30,30,.75); }
.seed-row { margin-top: 12px; color: #ccc; font-size: 13px; text-align: left; }
.seed-row input {
  width: 100%; margin-top: 4px; padding: 8px; background: #111; color: #fff;
  border: 2px solid #555; font-family: inherit;
}
.footer-note { position: absolute; bottom: 14px; color: rgba(255,255,255,.85);
  font-size: 13px; text-shadow: 1px 1px 0 #000; }

/* ---------- 加载画面 ---------- */
#loading-screen {
  position: absolute; inset: 0; z-index: 200; background: #222;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.loading-text { color: #fff; font-size: 20px; margin-bottom: 16px; }
.loading-bar-outer { width: 300px; height: 12px; border: 2px solid #888; }
#loading-bar { height: 100%; width: 0; background: #3c3; transition: width .15s; }

/* ---------- 背包 ---------- */
.inv-panel {
  background: #c6c6c6; border: 3px solid #000;
  box-shadow: inset -4px -4px 0 #555, inset 4px 4px 0 #fff;
  padding: 18px 22px;
}
.inv-section-title { color: #3f3f3f; font-size: 14px; margin: 6px 0 4px; }
#inv-main { display: grid; grid-template-columns: repeat(9, 46px); gap: 3px; margin-bottom: 10px; }
#inv-hotbar { display: grid; grid-template-columns: repeat(9, 46px); gap: 3px; }
.slot {
  width: 46px; height: 46px; background: #8b8b8b; position: relative;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #fff;
  cursor: pointer;
}
.slot:hover { background: #a5a5a5; }
#craft-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
#craft-grid { display: grid; gap: 3px; }
#craft-grid.g2 { grid-template-columns: repeat(2, 46px); }
#craft-grid.g3 { grid-template-columns: repeat(3, 46px); }
.craft-arrow { font-size: 30px; color: #3f3f3f; font-weight: bold; }
#craft-result { width: 54px; height: 54px; }

/* ---------- 熔炉 ---------- */
#furnace-wrap { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.furnace-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#furnace-fire {
  width: 18px; height: 18px; background: #555; position: relative;
  display: flex; align-items: flex-end;
}
#furnace-fire-fill { width: 100%; background: linear-gradient(#ffb84d, #e8762a); height: 0%; }
#furnace-progress {
  width: 60px; height: 14px; background: #8b8b8b;
  box-shadow: inset 1px 1px 0 #373737;
}
#furnace-progress-fill { height: 100%; width: 0%; background: #fff; }
.furnace-out { width: 54px !important; height: 54px !important; }

#cursor-item {
  position: fixed; width: 40px; height: 40px; pointer-events: none; z-index: 300;
  background-size: contain; background-repeat: no-repeat; image-rendering: pixelated;
  display: none;
}
#cursor-item .slot-count { font-size: 14px; }
#tooltip {
  position: fixed; z-index: 310; background: rgba(16,0,16,.94);
  border: 2px solid #25015a; color: #fff; padding: 4px 8px; font-size: 14px;
  pointer-events: none;
}
