* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --red: #e74c3c;
  --red-dark: #a93226;
  --red-glow: rgba(231, 76, 60, 0.5);
  --blue: #3498db;
  --blue-dark: #2471a3;
  --blue-glow: rgba(52, 152, 219, 0.5);
  --gold: #f1c40f;
  --diamond: #00d4ff;
  --dark-bg: #0a0a1a;
  --panel-bg: rgba(15, 15, 35, 0.92);
  --panel-border: rgba(100, 120, 200, 0.3);
  --text: #e8e8f0;
  --text-dim: #8888aa;
}

html, body {
  width: 100%; height: 100%;
  background: var(--dark-bg);
  color: var(--text);
  font-family: 'Courier New', 'Microsoft YaHei', monospace;
  overflow: hidden;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, #1a1a3a 0%, #0a0a1a 70%),
    #0a0a1a;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a1a2e;
  border: 2px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(80, 100, 200, 0.2);
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* ===== Overlays ===== */
.overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}
.overlay.active { display: flex; }

/* 顶级菜单：固定定位，脱离 game-container，永远在最上层 */
.overlay-top {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background:
    radial-gradient(ellipse at center, rgba(80, 60, 120, 0.6) 0%, rgba(10, 10, 26, 0.95) 70%),
    #0a0a1a;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.overlay-top.active { display: flex; }
.overlay-top .menu-box {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.menu-box {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 48px 56px;
  text-align: center;
  box-shadow: 0 0 60px rgba(80, 100, 200, 0.3),
              inset 0 1px 0 rgba(255,255,255,0.05);
  min-width: 420px;
  max-width: 600px;
}

.game-title {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  text-shadow: 0 0 30px rgba(100, 150, 255, 0.3);
}

.subtitle {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 32px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
}

.btn {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: bold;
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(40, 40, 70, 0.8);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  letter-spacing: 1px;
}
.btn:hover {
  background: rgba(60, 60, 100, 0.9);
  border-color: var(--blue);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--red), #c0392b);
  border-color: var(--red);
  box-shadow: 0 4px 20px var(--red-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #ec7063, var(--red));
  box-shadow: 0 6px 25px var(--red-glow);
}

.btn-toggle-mobile {
  font-size: 13px;
  padding: 10px 20px;
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.4);
  color: #2ecc71;
  letter-spacing: 0;
}
.btn-toggle-mobile:hover {
  background: rgba(46, 204, 113, 0.25);
  border-color: #2ecc71;
}

.menu-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-dim);
}

/* How to play */
.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin: 20px 0;
  text-align: left;
}
.how-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(30, 30, 60, 0.6);
  border-radius: 6px;
  font-size: 14px;
}
.key {
  background: var(--blue-dark);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  min-width: 70px;
  text-align: center;
}
h2 { margin-bottom: 16px; font-size: 28px; }
h3 { margin: 20px 0 10px; color: var(--gold); font-size: 18px; }
.goal-text {
  text-align: left;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ===== HUD ===== */
.hud { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.hud.hidden { display: none; }

.hud-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 30px;
}

.team-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  min-width: 140px;
}
.team-info.red { border-color: var(--red); }
.team-info.blue { border-color: var(--blue); }

.bed-icon { font-size: 24px; }
.bed-icon.destroyed { filter: grayscale(1) opacity(0.4); }

.team-text .team-name { font-weight: bold; font-size: 14px; }
.team-text.right { text-align: right; }
.team-status { font-size: 12px; color: var(--text-dim); }
.team-info.red .team-name { color: var(--red); }
.team-info.blue .team-name { color: var(--blue); }

.center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mode-badge {
  padding: 6px 16px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  font-size: 13px;
}
.timer {
  font-size: 22px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
  font-family: 'Courier New', monospace;
}

.hud-left {
  position: absolute;
  bottom: 90px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.health-bar {
  width: 220px;
  height: 26px;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e74c3c, #ec7063);
  transition: width 0.2s ease;
  box-shadow: 0 0 10px var(--red-glow);
}
.health-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.resource-row { display: flex; gap: 12px; }
.resource {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--panel-border);
  border-radius: 20px;
  font-weight: bold;
  font-size: 14px;
}
.resource.gold .res-icon { color: var(--gold); }
.resource.diamond .res-icon { color: var(--diamond); }

/* Hotbar */
.hotbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.hotbar-slot {
  width: 64px;
  height: 64px;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
}
.hotbar-slot:hover { border-color: var(--blue); }
.hotbar-slot.active {
  border-color: var(--gold);
  background: rgba(241, 196, 15, 0.15);
  box-shadow: 0 0 15px rgba(241, 196, 15, 0.3);
}
.slot-icon { font-size: 22px; line-height: 1; }
.slot-name { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.slot-count {
  position: absolute;
  bottom: 2px; right: 4px;
  font-size: 11px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
.slot-num {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

/* Minimap */
.minimap-wrap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 4px;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--panel-border);
  border-radius: 6px;
}
#minimap {
  display: block;
  image-rendering: pixelated;
}

/* ===== Shop ===== */
.shop-overlay {
  background: rgba(5, 5, 15, 0.7);
  backdrop-filter: blur(2px);
}

.shop-box {
  background: var(--panel-bg);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px;
  width: 640px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  box-shadow: 0 0 40px rgba(241, 196, 15, 0.2);
}

.shop-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 16px;
}
.shop-header h2 { flex: 1; margin: 0; font-size: 22px; color: var(--gold); }
.shop-resources { display: flex; gap: 12px; }
.shop-resources .resource { padding: 4px 10px; font-size: 13px; }

.close-btn {
  width: 32px; height: 32px;
  background: rgba(200, 50, 50, 0.3);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 14px;
}
.close-btn:hover { background: var(--red); }

.shop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  background: rgba(30, 30, 60, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.tab-btn.active {
  background: var(--blue-dark);
  border-color: var(--blue);
  color: white;
}

.shop-items {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  padding-right: 8px;
}
.shop-item {
  padding: 12px;
  background: rgba(30, 30, 60, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.shop-item:hover {
  border-color: var(--gold);
  background: rgba(241, 196, 15, 0.1);
}
.shop-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.shop-item-icon { font-size: 32px; margin-bottom: 6px; }
.shop-item-name { font-size: 13px; font-weight: bold; margin-bottom: 4px; }
.shop-item-cost {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
}
.shop-item-cost .gold { color: var(--gold); }
.shop-item-cost .diamond { color: var(--diamond); }

.shop-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Result Screen ===== */
.result-box h2 {
  font-size: 42px;
  margin-bottom: 8px;
}
.result-box.win h2 { color: var(--gold); }
.result-box.lose h2 { color: var(--red); }

.result-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 24px 0;
  padding: 20px;
  background: rgba(30, 30, 60, 0.6);
  border-radius: 8px;
}
.stat-item { text-align: center; }
.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: var(--gold);
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Spectate ===== */
.spectate-tip {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: rgba(200, 50, 50, 0.85);
  border: 2px solid var(--red);
  border-radius: 8px;
  font-weight: bold;
  z-index: 60;
  animation: pulse 1.5s ease-in-out infinite;
}
.spectate-tip.hidden { display: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== Damage Numbers ===== */
.damage-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 55;
  overflow: hidden;
}
.damage-num {
  position: absolute;
  font-weight: bold;
  font-size: 18px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  animation: damageFloat 0.8s ease-out forwards;
  pointer-events: none;
}
.damage-num.crit { font-size: 24px; color: var(--gold); }
.damage-num.heal { color: #2ecc71; }
@keyframes damageFloat {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-45px) scale(1); opacity: 0; }
}

/* ===== Toast ===== */
.toast-wrap {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 70;
  pointer-events: none;
}
.toast {
  padding: 10px 24px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 14px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
}
.toast.gold { border-color: var(--gold); color: var(--gold); }
.toast.red { border-color: var(--red); color: var(--red); }
.toast.blue { border-color: var(--blue); color: var(--blue); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* Scrollbar */
.shop-items::-webkit-scrollbar { width: 6px; }
.shop-items::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
.shop-items::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }

 @media (max-width: 768px) {
   .menu-box { min-width: 300px; padding: 32px 24px; }
   .game-title { font-size: 28px; }
   .how-grid { grid-template-columns: 1fr; }
   .shop-box { width: 95vw; }
   .hotbar-slot { width: 52px; height: 52px; }
   .health-bar { width: 160px; }
 }

/* ===== Hotbar 新结构 ===== */
.hotbar-slot.rare {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.4);
}
.hotbar-slot.epic {
  border-color: #9b59b6;
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.5);
}
.hotbar-slot.legendary {
  border-color: #ff8c00;
  box-shadow: 0 0 14px rgba(255, 140, 0, 0.5);
  animation: legendaryGlow 2s ease-in-out infinite;
}
.hotbar-slot.active.rare {
  background: rgba(52, 152, 219, 0.2);
  box-shadow: 0 0 18px rgba(52, 152, 219, 0.5);
}
.hotbar-slot.active.epic {
  background: rgba(155, 89, 182, 0.2);
  box-shadow: 0 0 20px rgba(155, 89, 182, 0.6);
}
.hotbar-slot.active.legendary {
  background: rgba(255, 140, 0, 0.2);
  box-shadow: 0 0 22px rgba(255, 200, 0, 0.7);
}
.hotbar-icon {
  font-size: 24px;
  line-height: 1;
  margin-bottom: 2px;
}
.hotbar-count {
  position: absolute;
  bottom: 2px; right: 4px;
  font-size: 11px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}
.hotbar-key {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
}

/* ===== 蓄力条 ===== */
.charge-bar {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  height: 14px;
  background: rgba(0,0,0,0.7);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 40;
  pointer-events: none;
}
.charge-fill {
  height: 100%;
  width: 0%;
  background: var(--blue);
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.6);
}
.charge-bar span {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  color: white;
}

/* ===== 减速提示 ===== */
.slow-badge {
  position: absolute;
  bottom: 130px;
  left: 20px;
  padding: 6px 12px;
  background: rgba(52, 152, 219, 0.8);
  border: 1px solid #85c1e9;
  border-radius: 16px;
  font-size: 12px;
  font-weight: bold;
  color: white;
  z-index: 40;
  animation: pulse 1s ease-in-out infinite;
  pointer-events: none;
}

/* ===== 商店稀有度样式 ===== */
.shop-item.rarity-rare {
  border-color: var(--blue);
  background: rgba(52, 152, 219, 0.1);
}
.shop-item.rarity-epic {
  border-color: #9b59b6;
  background: rgba(155, 89, 182, 0.1);
}
.shop-item.rarity-legendary {
  border-color: #ff8c00;
  background: rgba(255, 140, 0, 0.1);
  animation: legendaryGlow 2s ease-in-out infinite;
}
@keyframes legendaryGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 140, 0, 0.3); }
  50% { box-shadow: 0 0 20px rgba(255, 200, 0, 0.5); }
}
.shop-item.rarity-rare:hover {
  border-color: var(--blue);
  background: rgba(52, 152, 219, 0.2);
  box-shadow: 0 0 12px rgba(52, 152, 219, 0.3);
}
.shop-item.rarity-epic:hover {
  border-color: #9b59b6;
  background: rgba(155, 89, 182, 0.2);
  box-shadow: 0 0 15px rgba(155, 89, 182, 0.4);
}
.shop-item.rarity-legendary:hover {
  border-color: #ffd700;
  background: rgba(255, 140, 0, 0.2);
  box-shadow: 0 0 20px rgba(255, 200, 0, 0.5);
}
.shop-item-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.3;
}
.shop-rarity {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: bold;
}
.shop-rarity.rarity-common { background: rgba(170,170,170,0.3); color: #bbb; }
.shop-rarity.rarity-rare { background: rgba(52,152,219,0.3); color: var(--blue); }
.shop-rarity.rarity-epic { background: rgba(155,89,182,0.3); color: #bb77dd; }
.shop-rarity.rarity-legendary { background: rgba(255,140,0,0.35); color: #ffd700; }
.shop-item { position: relative; }

/* ===== 暴击数字增强 ===== */
.damage-num.crit {
  font-size: 26px !important;
  color: #ffd700 !important;
  text-shadow: 0 0 8px rgba(255,215,0,0.8), 2px 2px 0 rgba(0,0,0,0.9) !important;
  animation: critFloat 0.9s ease-out forwards !important;
}
@keyframes critFloat {
  0% { transform: translateY(0) scale(0.3); opacity: 0; }
  20% { transform: translateY(-12px) scale(1.4); opacity: 1; }
  100% { transform: translateY(-55px) scale(1.1); opacity: 0; }
}

/* ============================================================
   移动端虚拟控制 (Mobile Controls)
   ============================================================ */
.mobile-controls {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 50;
  display: none;
}
.mobile-controls.active { display: block; }
.mobile-controls.force-active { display: block !important; pointer-events: auto !important; }

/* 桌面端（非触屏）默认不显示移动端控件，防止误遮挡菜单 */
@media (pointer: fine) and (hover: hover) {
  .mobile-controls { display: none !important; }
  .mobile-controls.force-active { display: block !important; pointer-events: auto !important; }
}

/* 左侧摇杆区 */
.joystick-wrap {
  position: absolute;
  left: 40px;
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
}
.joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  position: relative;
  backdrop-filter: blur(4px);
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

/* 右侧动作按钮区 */
.action-buttons {
  position: absolute;
  right: 24px;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 14px;
  pointer-events: auto;
}
.action-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 22px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.05s, background 0.1s;
  font-family: inherit;
}
.action-btn:active, .action-btn.pressed {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}
.jump-btn {
  grid-column: 2;
  grid-row: 1;
  background: rgba(46, 204, 113, 0.45);
  border-color: rgba(46, 204, 113, 0.6);
}
.attack-btn {
  grid-column: 2;
  grid-row: 2;
  background: rgba(231, 76, 60, 0.45);
  border-color: rgba(231, 76, 60, 0.6);
  font-size: 20px;
}
.shop-btn {
  grid-column: 1;
  grid-row: 2;
  background: rgba(241, 196, 15, 0.4);
  border-color: rgba(241, 196, 15, 0.6);
  font-size: 18px;
}
.switch-btn {
  grid-column: 1;
  grid-row: 1;
  background: rgba(52, 152, 219, 0.45);
  border-color: rgba(52, 152, 219, 0.6);
  font-size: 18px;
}

/* ============================================================
   响应式 / 移动端适配
   ============================================================ */
@media (max-width: 768px), (pointer: coarse) {
  .menu-box {
    padding: 28px 24px;
    min-width: 280px;
    max-width: 90vw;
  }
  .game-title {
    font-size: 28px;
    letter-spacing: 2px;
  }
  .subtitle {
    font-size: 13px;
    margin-bottom: 20px;
  }
  .how-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* 移动端 HUD 调整 */
  .hud {
    font-size: 12px;
  }
  .hud-top {
    padding: 8px 10px;
    font-size: 11px;
  }
  .bed-icon {
    font-size: 18px;
  }
  .team-name { font-size: 11px; }
  .team-status { font-size: 10px; }
  .mode-badge {
    font-size: 11px;
    padding: 3px 8px;
  }
  .timer { font-size: 13px; }

  .hud-left {
    left: 8px;
    bottom: 90px;
    gap: 4px;
  }
  .health-bar {
    height: 18px;
    min-width: 110px;
    font-size: 10px;
  }
  .resource-row {
    gap: 6px;
    font-size: 11px;
  }

  .hotbar {
    bottom: 10px;
    gap: 4px;
    padding: 4px;
  }
  .hotbar-slot {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
  .hotbar-key { font-size: 9px; }
  .hotbar-count { font-size: 9px; bottom: 1px; right: 2px; }

  .minimap-wrap {
    right: 8px;
    top: 50px;
  }
  #minimap {
    width: 120px;
    height: 60px;
  }

  /* 移动端隐藏鼠标光标提示 */
  #game-canvas {
    cursor: default;
  }
}

/* 横屏手机适配 */
@media (max-height: 500px) and (orientation: landscape) {
  .joystick-wrap {
    left: 20px;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    width: 100px;
    height: 100px;
  }
  .joystick-knob {
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
  }
  .action-buttons {
    right: 16px;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }
  .action-btn {
    width: 52px;
    height: 52px;
    font-size: 16px;
  }
  .hud-left { bottom: 70px; }
  .hotbar { bottom: 6px; }
}
