/* ============================================
   我的世界 - 游戏界面样式
   ============================================ */

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

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

/* 游戏画布 - 全屏 */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
}

/* 十字准星 */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 24px;
  font-weight: 200;
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 0 2px rgba(0,0,0,0.8);
  opacity: 0.8;
  display: none;
}

/* 物品栏 */
#hotbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 90vw;
}
#hotbar::-webkit-scrollbar { display: none; }

.hotbar-slot {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.12s ease-out;
}

.hotbar-slot.selected {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.45), 0 0 3px rgba(255, 255, 255, 0.5);
  transform: scale(1.08);
  outline: 1px solid rgba(255, 255, 255, 0.3);
  outline-offset: -2px;
}

.hotbar-slot .block-preview {
  width: 36px;
  height: 36px;
  border-radius: 2px;
  image-rendering: pixelated;
}

.hotbar-slot .slot-key {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.5);
  letter-spacing: 0;
  line-height: 1;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 0 2px;
  border-radius: 0 0 3px 3px;
  pointer-events: none;
}

/* 当前选中方块名称 - 热键栏上方 */
#selectedBlockName {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  z-index: 11;
  pointer-events: none;
  display: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 16px;
  border-radius: 4px;
  letter-spacing: 1px;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* 调试信息 */
#debugInfo {
  position: fixed;
  top: 12px;
  left: 12px;
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  z-index: 10;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 12px;
  border-radius: 4px;
  display: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* 目标方块高亮提示 */
#blockHighlight {
  position: fixed;
  top: 53%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 13px;
  z-index: 10;
  pointer-events: none;
  display: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 4px;
}

/* 开始界面 - 水彩天空 + 液态玻璃风格 */
#startScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(248,251,255,0.35) 0%, rgba(232,244,255,0.45) 30%, rgba(245,251,255,0.35) 60%, rgba(239,247,255,0.4) 100%);
  background-image: url('https://img.freepik.com/free-vector/hand-painted-watercolor-pastel-sky-background_23-2148902771.jpg');
  background-size: cover;
  background-attachment: fixed;
  background-blend-mode: soft-light;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  animation: pageFadeIn 1.5s ease-out;
}

@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.start-glass {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 50px;
  border-radius: 24px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 8px 40px rgba(59,130,246,0.12), inset 0 1px 0 rgba(255,255,255,0.6);
}

.start-title {
  font-size: 48px;
  font-weight: 800;
  color: #2563eb;
  text-shadow: 0 2px 4px rgba(59,130,246,0.2), 0 0 40px rgba(147,197,253,0.3);
  letter-spacing: 6px;
  margin-bottom: 8px;
  animation: titleFloat 4s ease-in-out infinite;
}

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

.start-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 32px;
  letter-spacing: 3px;
  font-weight: 500;
}

.start-hint {
  font-size: 18px;
  color: rgba(37, 99, 235, 0.85);
  font-weight: 600;
  animation: hintBlink 2.5s ease-in-out infinite;
  margin-bottom: 24px;
  padding: 8px 24px;
  border-radius: 20px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(147, 197, 253, 0.35);
}

@keyframes hintBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.controls-info {
  background: rgba(255,255,255,0.3);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 16px;
  padding: 20px 28px;
  max-width: 420px;
  text-align: left;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.controls-info h3 {
  color: #3b82f6;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 2px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.control-row .key {
  color: #A5D6A7;
  font-weight: bold;
  min-width: 80px;
  text-align: right;
  margin-right: 12px;
}

/* ============================================
   右上角操作说明面板（桌面端常驻）
   ============================================ */
#controlsPanel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  display: none;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.controls-trigger {
  display: none;
}

.controls-body {
  display: block;
}

/* 面板内标题 */
.controls-body::before {
  content: "操作说明";
  display: block;
  color: #81C784;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

/* 暂停界面 */
#pauseScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 90;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

#pauseScreen .pause-text {
  font-size: 36px;
  color: #fff;
  margin-bottom: 16px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#pauseScreen .pause-hint {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  animation: hintBlink 2s ease-in-out infinite;
}

#inventoryScreen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 20, 40, 0.85);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.inventory-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 24px 28px;
  max-width: 440px;
  width: 90%;
}

.inventory-title {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.inventory-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  text-align: center;
  margin-top: 14px;
}

#inventoryGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.inv-slot {
  width: 62px;
  height: 62px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.inv-slot:hover {
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.08);
}

.inv-slot.selected {
  border-color: #fff;
  box-shadow: 0 0 18px rgba(0, 211, 255, 0.5), 0 0 4px rgba(255, 255, 255, 0.6);
  transform: scale(1.12);
}

/* 加载提示 */
#loadingBar {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  text-align: center;
  display: none;
}

#loadingBar .loading-text {
  color: #81C784;
  font-size: 18px;
  margin-bottom: 12px;
}

#loadingBar .loading-progress {
  width: 200px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

#loadingBar .loading-fill {
  height: 100%;
  background: #4CAF50;
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

/* 响应式适配（仅按宽度判断，避免 pointer:coarse 误伤触屏笔记本） */
@media (max-width: 768px) {
  .start-title {
    font-size: 32px;
    letter-spacing: 2px;
  }

  .start-subtitle {
    font-size: 14px;
  }

  .controls-info {
    padding: 14px 18px;
    margin: 0 16px;
  }

  .control-row {
    font-size: 12px;
  }

  .hotbar-slot {
    width: 44px;
    height: 44px;
  }

  .hotbar-slot .block-preview {
    width: 30px;
    height: 30px;
  }

  .hotbar-slot .slot-key {
    font-size: 11px;
    padding: 1px 0 1px;
  }

  #debugInfo {
    font-size: 11px;
  }

  #selectedBlockName {
    bottom: 62px;
    font-size: 13px;
    padding: 4px 12px;
  }

  /* 隐藏桌面端操作说明 */
  .desktop-only {
    display: none;
  }
}

@media (max-width: 480px) {
  .start-title {
    font-size: 24px;
  }

  .hotbar-slot {
    width: 38px;
    height: 38px;
  }

  .hotbar-slot .block-preview {
    width: 26px;
    height: 26px;
  }

  .hotbar-slot .slot-key {
    font-size: 10px;
    padding: 1px 0 1px;
  }

  #hotbar {
    bottom: 10px;
  }

  #selectedBlockName {
    bottom: 54px;
    font-size: 12px;
    padding: 3px 10px;
  }

  .inv-slot {
    width: 48px;
    height: 48px;
  }

  .inventory-panel {
    padding: 16px 14px;
  }
}

/* ============================================ */
/*  移动端触控 UI 样式 */
/* ============================================ */

#mobileControls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: none;
}

/* 虚拟摇杆 */
#joystickZone {
  position: absolute;
  bottom: 130px;
  left: 24px;
  width: 110px;
  height: 110px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  z-index: 21;
}

#joystickThumb {
  position: absolute;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

/* 操作按钮区 */
#actionButtons {
  position: absolute;
  bottom: 140px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
  z-index: 21;
}

.action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: auto;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: background 0.1s, border-color 0.1s;
}

.action-btn:active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* 移动端物品栏 */
#mobileHotbar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  pointer-events: auto;
  z-index: 21;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
}

.m-slot {
  width: 38px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.12s ease-out;
}

.m-slot.selected {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
  outline: 1px solid rgba(255, 255, 255, 0.25);
  outline-offset: -2px;
}

.m-block-preview {
  width: 26px;
  height: 26px;
  border-radius: 2px;
  image-rendering: pixelated;
}

/* 移动端暂停界面适配 */
@media (max-width: 768px) {
  #pauseScreen .pause-text {
    font-size: 28px;
  }

  #pauseScreen .pause-hint {
    font-size: 14px;
  }

  #crosshair {
    font-size: 18px;
  }

  #blockHighlight {
    top: 53%;
    font-size: 11px;
  }
}
