/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'VT323', monospace;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* ===== 游戏画布容器 ===== */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ===== HUD 层 ===== */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  pointer-events: none;
  display: none;
}

#hud.active {
  display: block;
}

/* ===== 准星 ===== */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.cross-h, .cross-v {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  mix-blend-mode: difference;
}

.cross-h {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

.cross-v {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

/* ===== 左上角信息面板 ===== */
#info-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 10px 14px;
  color: #fff;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

#fps {
  color: #7FFF00;
}

#coords, #facing {
  color: #E0E0E0;
}

/* ===== 右上角帮助面板 ===== */
#help-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 10px 14px;
  color: #aaa;
  font-size: 14px;
  line-height: 1.6;
  text-align: right;
}

/* ===== 方块名称提示 ===== */
#block-name {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 18px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

#block-name.visible {
  opacity: 1;
}

/* ===== 快捷栏 ===== */
#hotbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #333;
  border-radius: 4px;
  padding: 3px;
  pointer-events: none;
}

.hotbar-slot {
  width: 48px;
  height: 48px;
  background: rgba(139, 139, 139, 0.3);
  border: 2px solid #555;
  border-radius: 2px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hotbar-slot.selected {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.5) inset;
}

.hotbar-slot canvas {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.slot-number {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 12px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  font-family: 'Press Start 2P', monospace;
}

/* ===== 开始/暂停遮罩 ===== */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  color: #fff;
  max-width: 600px;
  padding: 40px;
}

.title {
  font-family: 'Press Start 2P', monospace;
  font-size: 48px;
  color: #5D9C3D;
  text-shadow:
    4px 4px 0 #2D4C1E,
    -2px -2px 0 #8BC34A;
  margin-bottom: 12px;
  letter-spacing: 4px;
  animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.subtitle {
  font-size: 20px;
  color: #aaa;
  margin-bottom: 40px;
}

#start-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  padding: 18px 36px;
  background: #5D9C3D;
  color: #fff;
  border: 4px solid #2D4C1E;
  border-radius: 0;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 6px 0 #2D4C1E;
  transition: all 0.1s;
  pointer-events: auto;
}

#start-btn:hover {
  background: #6DB348;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #2D4C1E;
}

#start-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #2D4C1E;
}

.controls-info {
  margin-top: 40px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 24px;
}

.controls-info h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: #7FFF00;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  text-align: left;
}

.controls-grid > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.key {
  display: inline-block;
  min-width: 90px;
  padding: 4px 8px;
  background: #333;
  border: 1px solid #555;
  border-radius: 3px;
  font-size: 13px;
  color: #FFD700;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
}

.desc {
  font-size: 16px;
  color: #ccc;
}

/* 模式选择 */
.mode-select { margin: 30px 0; }
.mode-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 16px;
  letter-spacing: 2px;
}
.mode-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}
.mode-btn {
  font-family: 'VT323', monospace;
  background: rgba(255,255,255,0.08);
  border: 3px solid #555;
  border-radius: 6px;
  padding: 24px 20px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 180px;
}
.mode-btn:hover {
  background: rgba(255,255,255,0.15);
  transform: translateY(-3px);
}
.mode-btn.creative { border-color: #5D9C3D; }
.mode-btn.creative:hover { background: rgba(93,156,61,0.2); box-shadow: 0 4px 16px rgba(93,156,61,0.3); }
.mode-btn.survival { border-color: #c0392b; }
.mode-btn.survival:hover { background: rgba(192,57,43,0.2); box-shadow: 0 4px 16px rgba(192,57,43,0.3); }
.mode-icon { font-size: 32px; margin-bottom: 8px; }
.mode-btn.creative .mode-icon { color: #7FFF00; }
.mode-btn.survival .mode-icon { color: #ff4444; }
.mode-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  margin-bottom: 8px;
}
.mode-desc {
  font-size: 15px;
  color: #999;
  line-height: 1.4;
}

/* 模式显示 */
#mode-display {
  margin-top: 4px;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 2px;
  display: inline-block;
}
#mode-display.creative { color: #7FFF00; background: rgba(127,255,0,0.1); }
#mode-display.survival { color: #ff6b6b; background: rgba(255,107,107,0.1); }

/* 生存模式状态条 */
#survival-bars {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  gap: 2px;
  image-rendering: pixelated;
}
#survival-bars.active { display: flex; }

#health-bar, #hunger-bar {
  display: flex;
  gap: 1px;
  justify-content: center;
  height: 16px;
}

.bar-icon {
  width: 14px;
  height: 14px;
  position: relative;
}

/* 心形 */
.heart { background: radial-gradient(circle at 30% 35%, #ff4444 3px, transparent 3px),
           radial-gradient(circle at 70% 35%, #ff4444 3px, transparent 3px),
           linear-gradient(45deg, transparent 40%, #ff4444 40%, #ff4444 100%); }
.heart.half { background: radial-gradient(circle at 30% 35%, #ff4444 3px, transparent 3px),
              linear-gradient(45deg, transparent 40%, #553 40%, #553 100%); }
.heart.empty { background: radial-gradient(circle at 30% 35%, #444 3px, transparent 3px),
               radial-gradient(circle at 70% 35%, #444 3px, transparent 3px),
               linear-gradient(45deg, transparent 40%, #444 40%, #444 100%); }

/* 鸡腿 */
.hunger-icon { background: #8B4513; border-radius: 50% 50% 20% 20%; }
.hunger-icon.empty { background: #333; border-radius: 50% 50% 20% 20%; }

/* 死亡遮罩 */
#death-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(120, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
#death-overlay.active { display: flex; }
.death-content { text-align: center; }
.death-content h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 32px;
  color: #ff4444;
  text-shadow: 3px 3px 0 #500;
  margin-bottom: 24px;
  letter-spacing: 4px;
}
#respawn-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 14px 28px;
  background: #c0392b;
  color: #fff;
  border: 3px solid #922b21;
  cursor: pointer;
  box-shadow: 0 5px 0 #922b21;
  pointer-events: auto;
}
#respawn-btn:hover { background: #e74c3c; }
#respawn-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #922b21; }

/* ============================================
   MINECRAFT 风格主菜单
   ============================================ */
#overlay {
  background: none;
  background-image:
    linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Crect width='64' height='64' fill='%234a3520'/%3E%3Crect x='0' y='0' width='16' height='16' fill='%235c4428'/%3E%3Crect x='16' y='16' width='16' height='16' fill='%235c4428'/%3E%3Crect x='32' y='0' width='16' height='16' fill='%233d2c1a'/%3E%3Crect x='48' y='16' width='16' height='16' fill='%233d2c1a'/%3E%3Crect x='0' y='32' width='16' height='16' fill='%233d2c1a'/%3E%3Crect x='16' y='48' width='16' height='16' fill='%233d2c1a'/%3E%3Crect x='32' y='32' width='16' height='16' fill='%235c4428'/%3E%3Crect x='48' y='48' width='16' height='16' fill='%235c4428'/%3E%3C/svg%3E");
  background-size: 64px 64px;
  overflow: hidden;
}

#menu-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, rgba(0,50,100,0.2) 0%, rgba(50,120,50,0.3) 60%, rgba(30,80,30,0.5) 100%);
  z-index: -1;
  animation: bgPan 60s linear infinite;
}
@keyframes bgPan {
  0% { background-position: 0 0; }
  100% { background-position: 0 256px; }
}

.menu-container {
  text-align: center;
  color: #fff;
  width: 100%;
  max-width: 560px;
  padding: 40px 20px;
  position: relative;
}

/* MC 大标题 */
.mc-title {
  margin-bottom: 20px;
  position: relative;
}
.mc-title-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 38px;
  color: #e0e0e0;
  letter-spacing: 2px;
  text-shadow:
    3px 3px 0 #3f3f3f,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  margin: 0;
  animation: titleBounce 2s ease-in-out infinite;
}
.mc-edition {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #FFD700;
  text-shadow: 2px 2px 0 #3f3f00, 1px 1px 0 #000;
  margin-top: 8px;
  transform: rotate(-2deg);
  display: inline-block;
}
@keyframes titleBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.02); }
}

/* 闪烁副标题 */
.mc-splash {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: #FFD700;
  text-shadow: 2px 2px 0 #3f2f00;
  position: absolute;
  top: 10px;
  right: 20px;
  transform: rotate(-15deg);
  animation: splash 0.5s ease-in-out infinite alternate;
  z-index: 5;
}
@keyframes splash {
  from { transform: rotate(-15deg) scale(1); }
  to { transform: rotate(-15deg) scale(1.1); }
}

.mode-section-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #aaa;
  letter-spacing: 2px;
  margin-bottom: 16px;
  text-shadow: 1px 1px 0 #000;
}

/* MC 按钮样式（像素风） */
.mc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: #fff;
  background: #7c7c7c;
  border: 3px solid #000;
  border-top-color: #aaa;
  border-left-color: #aaa;
  border-bottom-color: #555;
  border-right-color: #555;
  padding: 14px 24px;
  cursor: pointer;
  text-shadow: 2px 2px 0 #3f3f3f;
  min-width: 220px;
  position: relative;
  transition: none;
  image-rendering: pixelated;
}
.mc-btn::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border: 1px solid rgba(0,0,0,0.3);
  pointer-events: none;
}
.mc-btn:hover {
  filter: brightness(1.2);
  border-top-color: #fff;
  border-left-color: #fff;
}
.mc-btn:active {
  border-top-color: #555;
  border-left-color: #555;
  border-bottom-color: #aaa;
  border-right-color: #aaa;
  filter: brightness(0.8);
}
.mc-btn-green {
  background: #5D9C3D;
  border-top-color: #7CCF57;
  border-left-color: #7CCF57;
  border-bottom-color: #2D5C1E;
  border-right-color: #2D5C1E;
  text-shadow: 2px 2px 0 #2D4C1E;
}
.mc-btn-green:hover {
  border-top-color: #9fF77;
  border-left-color: #9fF77;
}
.mc-btn-red {
  background: #a33;
  border-top-color: #e55;
  border-left-color: #e55;
  border-bottom-color: #611;
  border-right-color: #611;
  text-shadow: 2px 2px 0 #511;
}
.mc-btn-red:hover { border-top-color: #f88; border-left-color: #f88; }
.mc-btn-gray {
  background: #666;
  border-top-color: #999;
  border-left-color: #999;
  border-bottom-color: #333;
  border-right-color: #333;
}

.mc-btn-label {
  font-size: 22px;
  line-height: 1.2;
}
.mc-btn-sub {
  font-size: 14px;
  color: #ddd;
  opacity: 0.9;
}

.mc-btn-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 12px;
}
.mc-btn-row.small .mc-btn {
  min-width: 160px;
  padding: 10px 20px;
}

.mc-menu {
  margin-top: 30px;
}

.mc-footer {
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: #aaa;
  text-shadow: 1px 1px 0 #000;
  padding: 0 10px;
}

/* 操作说明弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
  background: #c6c6c6;
  border: 4px solid #000;
  border-top-color: #fff;
  border-left-color: #fff;
  border-bottom-color: #555;
  border-right-color: #555;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  position: relative;
}
.modal-content::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border: 2px solid #555;
  border-top-color: #aaa;
  border-left-color: #aaa;
  pointer-events: none;
}
.modal-content h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: #333;
  text-align: center;
  margin: 0 0 16px 0;
}
.controls-grid-mc {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 20px;
}
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: #222;
}
.mc-key {
  display: inline-block;
  min-width: 120px;
  padding: 4px 8px;
  background: #888;
  border: 2px solid #000;
  border-top-color: #bbb;
  border-left-color: #bbb;
  border-bottom-color: #555;
  border-right-color: #555;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-align: center;
  text-shadow: 1px 1px 0 #333;
}
.close-btn {
  display: block;
  margin: 0 auto;
  min-width: 120px;
}

/* 旧样式保留兼容 */
.overlay-content { display: none; }
