.mobile-controls {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  pointer-events: none;
}

/* 移动端控制器容器 */
.controls-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  pointer-events: none;
}

/* 方向键区域 */
.direction-pad {
  position: absolute;
  left: 30px;
  bottom: 40px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.direction-button {
  position: absolute;
  width: 45px;
  height: 45px;
  background: rgba(255, 255, 255, 0.2);
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(2px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-style: preserve-3d;
  will-change: background, border-color, box-shadow;
  transition: background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

/* 方向按钮箭头 */
.direction-button::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border: 8px solid transparent;
}

.up-button::after {
  border-bottom-color: rgba(255, 255, 255, 0.8);
  border-top: 0;
  top: 35%;
  left: 50%;
  transform: translateX(-50%);
}

.down-button::after {
  border-top-color: rgba(255, 255, 255, 0.8);
  border-bottom: 0;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
}

.left-button::after {
  border-right-color: rgba(255, 255, 255, 0.8);
  border-left: 0;
  left: 35%;
  top: 50%;
  transform: translateY(-50%);
}

.right-button::after {
  border-left-color: rgba(255, 255, 255, 0.8);
  border-right: 0;
  right: 35%;
  top: 50%;
  transform: translateY(-50%);
}

/* 按钮激活时箭头效果 */
.direction-button:active::after {
  opacity: 1;
  transform: scale(1.1) translateX(-45%);
}

.up-button:active::after {
  transform: translateX(-50%) translateY(-2px);
}

.down-button:active::after {
  transform: translateX(-50%) translateY(2px);
}

.left-button:active::after {
  transform: translateY(-50%) translateX(-2px);
}

.right-button:active::after {
  transform: translateY(-50%) translateX(2px);
}

/* 方向键布局 */
.up-button {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  touch-action: none;
}

.down-button {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  touch-action: none;
}

.left-button {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  touch-action: none;
}

.right-button {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  touch-action: none;
}

/* 系统按钮区域 */
.system-buttons {
  position: absolute;
  left: 50%;
  bottom: 35px;
  transform: translateX(-50%);
  display: flex;
  gap: 25px;
  pointer-events: auto;
  z-index: 1000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* 系统按钮样式 */
.system-button {
  width: 70px;
  height: 35px;
  background: rgba(255, 255, 255, 0.25);
  border: 2.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 1);
  font-size: 14px;
  font-weight: normal;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-style: preserve-3d;
  will-change: background, border-color, box-shadow;
  transition: background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

/* 动作按钮区域 */
.action-buttons {
  position: absolute;
  right: 30px;
  bottom: 40px;
  display: flex;
  gap: 20px;
  pointer-events: auto;
  transform: rotate(-35deg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* AB按钮样式 */
.action-button {
  width: 55px;
  height: 55px;
  background: rgba(255, 255, 255, 0.3);
  border: 2.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 1);
  font-size: 26px;
  font-weight: normal;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform-style: preserve-3d;
  will-change: background, border-color, box-shadow;
  transition: background 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

/* 按钮激活效果 */
.direction-button:active,
.action-button:active {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4),
    inset 0 2px 3px rgba(0, 0, 0, 0.2);
}

/* 系统按钮激活效果 */
.system-button:active {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4),
    inset 0 1px 3px rgba(0, 0, 0, 0.1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.action-button:active {
  background: rgba(255, 255, 255, 0.5);
}

/* 移动端布局 */
@media screen and (max-width: 926px) and (orientation: landscape) {
  .mobile-controls {
    display: block;
    top: 50px;
    /* 为顶部控制栏留出空间 */
  }

  /* 给按钮添加标签 */
  .action-button::after {
    content: attr(data-key);
    position: absolute;
    transform: rotate(35deg);
    font-size: 28px;
    display: none;
  }
}

/* 小屏幕设备优化 - 固定缩放比例 */
@media screen and (max-width: 926px) and (orientation: landscape) and (max-height: 400px) {
  .direction-pad {
    transform: scale(0.85);
    left: 20px;
    bottom: 30px;
    transform-origin: center center;
    will-change: transform;
  }

  .action-buttons {
    transform: scale(0.85) rotate(-35deg);
    right: 20px;
    bottom: 30px;
    transform-origin: center center;
    will-change: transform;
  }

  .system-buttons {
    transform: translateX(-50%) scale(0.85);
    bottom: 15px;
    transform-origin: center center;
    will-change: transform;
  }
}

/* 超小屏幕设备优化 - 固定缩放比例 */
@media screen and (max-width: 360px) and (orientation: landscape) {
  .direction-pad {
    transform: scale(0.75);
    left: 15px;
    bottom: 25px;
    transform-origin: center center;
    will-change: transform;
  }

  .action-buttons {
    transform: scale(0.75) rotate(-35deg);
    right: 15px;
    bottom: 25px;
    transform-origin: center center;
    will-change: transform;
  }

  .system-buttons {
    transform: translateX(-50%) scale(0.75);
    bottom: 12px;
    transform-origin: center center;
    will-change: transform;
  }

  .system-button {
    width: 50px;
    height: 25px;
    font-size: 10px;
  }
}

/* 竖屏提示 */
@media screen and (max-width: 926px) and (orientation: portrait) {
  .rotate-prompt {
    display: flex;
  }

  .mobile-controls {
    display: none;
  }
}

/* 桌面端隐藏控件 */
@media screen and (min-width: 927px) {

  .mobile-controls,
  .rotate-prompt {
    display: none;
  }
}

/* 触摸反馈优化 */
@media (hover: none) and (pointer: coarse) {

  .direction-button,
  .system-button,
  .action-button {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
}