/* ============ 方界 MineWeb — UI 样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Minecraft", "PingFang SC", "Microsoft YaHei", monospace, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }

#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
}

.hidden { display: none !important; }

/* 合成面板（I4） */
.inv-craft-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin: 8px 0;
}
.craft-grid { display: grid; gap: 4px; }
.craft-grid.g2 { grid-template-columns: repeat(2, 44px); }
.craft-grid.g3 { grid-template-columns: repeat(3, 44px); }
.craft-arrow { font-size: 20px; color: #ddd; }
.panel-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

/* ---------- 加载界面 ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60, 90, 160, 0.35), transparent 60%),
    linear-gradient(180deg, #1a1c2c 0%, #101321 100%);
  z-index: 100;
  transition: opacity 0.6s ease;
}
.screen.fade-out { opacity: 0; pointer-events: none; }

.loading-inner { text-align: center; }

.game-title {
  font-size: 56px;
  font-weight: 900;
  color: #e8e6df;
  letter-spacing: 4px;
  text-shadow: 3px 3px 0 #3a3a3a, 6px 6px 12px rgba(0,0,0,0.6);
  margin-bottom: 8px;
}
.game-title span {
  display: block;
  font-size: 18px;
  color: #8fa8d8;
  letter-spacing: 10px;
  font-weight: 400;
  text-shadow: 2px 2px 0 #222;
  margin-top: 4px;
}

.loading-bar {
  width: 340px; height: 18px;
  margin: 34px auto 10px;
  background: #2b2b33;
  border: 2px solid #0e0f16;
  box-shadow: inset 0 0 0 2px #4a4a55, 0 4px 10px rgba(0,0,0,0.5);
}
#loading-fill {
  width: 0%; height: 100%;
  background: linear-gradient(180deg, #7ed957 0%, #4ea832 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.35);
  transition: width 0.2s ease;
}
#loading-text {
  color: #b8c0d8;
  font-size: 14px;
  letter-spacing: 2px;
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 50; }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 22px;
  font-weight: 300;
  text-shadow: 0 0 2px rgba(0,0,0,0.8);
  mix-blend-mode: difference;
}

#debug-info {
  position: absolute; left: 10px; top: 10px;
  color: #e0e0e0;
  font-size: 12px;
  line-height: 1.7;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.75);
  white-space: pre;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,0.28) 100%);
}

/* ---------- 快捷栏（I1 简易版，I3 精修） ---------- */
#hotbar {
  position: absolute; left: 50%; bottom: 14px;
  transform: translateX(-50%);
  display: flex; gap: 0;
  background: rgba(0,0,0,0.42);
  border: 2px solid rgba(255,255,255,0.22);
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
}
.hotbar-slot {
  width: 46px; height: 46px;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.hotbar-slot.selected {
  outline: 2px solid #fff;
  outline-offset: -2px;
  background: rgba(255,255,255,0.14);
}
.hotbar-slot .slot-icon {
  width: 32px; height: 32px;
  image-rendering: pixelated;
}
.hotbar-slot .slot-count {
  position: absolute; right: 3px; bottom: 1px;
  color: #fff; font-size: 12px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- 物品栏界面 ---------- */
#inventory-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
}
.inv-panel {
  background: #c6c6c6;
  border: 3px solid;
  border-color: #ffffff #555555 #555555 #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 14px 16px 16px;
}
.inv-title {
  color: #3f3f3f;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 2px;
}
.inv-hotbar-label {
  color: #3f3f3f;
  font-size: 12px;
  margin: 10px 0 6px;
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 44px);
  gap: 0;
}
.inv-slot {
  width: 44px; height: 44px;
  background: #8b8b8b;
  border: 2px solid;
  border-color: #373737 #ffffff #ffffff #373737;
  margin: 1px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
}
.inv-slot:hover { background: #a8a8a8; }
.inv-slot.selected { outline: 2px solid #fff; outline-offset: -2px; }
.inv-slot .slot-icon { width: 30px; height: 30px; image-rendering: pixelated; }
.inv-slot .slot-count {
  position: absolute; right: 2px; bottom: 0;
  color: #fff; font-size: 12px;
  text-shadow: 1px 1px 0 #3f3f3f;
}
#cursor-stack {
  position: fixed;
  width: 36px; height: 36px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 90;
}
#cursor-stack img { width: 32px; height: 32px; image-rendering: pixelated; }
#cursor-stack .slot-count {
  position: absolute; right: 0; bottom: 0;
  color: #fff; font-size: 12px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- 操作提示 ---------- */
#hint {
  position: absolute; left: 50%; bottom: 76px;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px #000;
  background: rgba(0,0,0,0.35);
  padding: 6px 14px;
  border-radius: 4px;
  z-index: 60;
  pointer-events: none;
  white-space: nowrap;
}

/* 水下视野染色（I3） */
#water-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 64, 110, 0.42);
  pointer-events: none;
  display: none;
  z-index: 5;
}

/* ---- I3：菜单 / 设置 / 状态条 / 触屏 ---- */
.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 40px;
}
.game-title.big { font-size: 52px; }
.menu-sub { color: #c8c8c8; text-shadow: 2px 2px 0 #3f3f3f; font-size: 15px; }
.menu-version { color: #8a8a8a; font-size: 12px; margin-top: 8px; }
.mc-btn {
  width: 320px;
  padding: 10px 0;
  font-size: 16px;
  color: #f0f0f0;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: linear-gradient(#8b8b8b, #6f6f6f);
  border: 2px solid #000;
  box-shadow: inset 0 2px 0 #a8a8a8, inset 0 -2px 0 #565656;
  cursor: pointer;
  font-family: inherit;
}
.mc-btn:hover { background: linear-gradient(#9da3d0, #7d84b8); }
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 340px;
  color: #e0e0e0;
  text-shadow: 1px 1px 0 #333;
  font-size: 14px;
}
.set-row input { flex: 1; }
.set-row span { width: 56px; text-align: right; color: #ffd76a; }
#status-bars {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 74px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
#status-bars .heart, #status-bars .bubble {
  font-size: 16px;
  margin: 0 1px;
  text-shadow: 1px 1px 0 #000;
}
#status-bars .heart { color: #e33b3b; }
#status-bars .heart.empty { color: #3a3a3a; }
#status-bars .bubble { color: #7ec8f7; }
#status-bars .bubble.empty { color: #3a3a3a; }
#status-bars {
  width: 364px;
  flex-direction: row;
  justify-content: space-between;
}
#hearts, #bubbles { display: flex; }
#bubbles { justify-content: flex-end; }
#status-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#status-bars .meat { color: #c8793a; }
#status-bars .meat.empty { color: #3a3a3a; }

/* 死亡界面（I4） */
#death-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(120, 10, 10, 0.45), rgba(60, 0, 0, 0.78));
}
#death-screen.hidden { display: none; }
#death-box { text-align: center; }
#death-title {
  font-size: 44px;
  color: #fff;
  letter-spacing: 8px;
  text-shadow: 3px 3px 0 #3f3f3f;
}
#death-sub { margin: 14px 0 22px; color: rgba(255, 255, 255, 0.85); font-size: 14px; }
/* 受击红闪 */
body.hurt-flash #app::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(180, 20, 20, 0.35);
  z-index: 40;
  pointer-events: none;
}
#touch-ui { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
#touch-stick {
  position: absolute;
  left: 26px;
  bottom: 96px;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: auto;
}
#touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}
#touch-buttons {
  position: absolute;
  right: 22px;
  bottom: 96px;
  display: flex;
  gap: 14px;
  pointer-events: auto;
}
#touch-buttons button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 18px;
  font-family: inherit;
}