* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background-color: #87CEEB;
  touch-action: none;
}

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

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* HUD 顶部信息 */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  z-index: 10;
}

#scoreDisplay {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  background: rgba(0,0,0,0.2);
  padding: 6px 12px;
  border-radius: 12px;
}

#energyContainer {
  width: 120px;
  height: 16px;
  background: rgba(255,255,255,0.4);
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.6);
}

#energyBar {
  width: 100%;
  height: 100%;
  background: #FF6B6B;
  border-radius: 6px;
  transition: width 0.2s ease-out;
}

/* 遮罩层通用样式 */
.overlay {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(135, 206, 235, 0.85);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  z-index: 20;
  text-align: center;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

.overlay h1, .overlay h2 {
  font-size: 32px;
  color: #fff;
  text-shadow: 2px 2px 0 #FF6B6B;
  margin-bottom: 12px;
}

.overlay p {
  font-size: 18px;
  color: #333;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* 按钮基础样式 */
button {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  touch-action: manipulation;
}

#btnStart, #btnRestart {
  background: #FF6B6B;
  color: #fff;
  font-size: 22px;
  padding: 14px 36px;
  border-radius: 30px;
  box-shadow: 0 4px 0 #D94D4D;
  transition: transform 0.1s, box-shadow 0.1s;
}

#btnStart:active, #btnRestart:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #D94D4D;
}

/* 底部控制区 */
#controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px;
  bottom: 0;
  top: auto;
  height: auto;
  z-index: 15;
  pointer-events: auto;
}

#btnLeft, #btnRight {
  width: 45%;
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  font-size: 20px;
  padding: 16px 0;
  border-radius: 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  transition: background 0.1s, transform 0.1s;
}

#btnLeft:active, #btnRight:active {
  background: #fff;
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

/* 桌面端适配 */
@media (min-width: 768px) {
  #controls {
    justify-content: center;
    gap: 40px;
    padding-bottom: 40px;
  }
  #btnLeft, #btnRight {
    width: 160px;
  }
  .overlay h1, .overlay h2 {
    font-size: 40px;
  }
  #scoreDisplay {
    font-size: 24px;
  }
}