/* 深色太空背景主题 */
:root {
  --space-dark: #0a0a1a;
  --space-blue: #0d1b2a;
  --space-light: #1b263b;
  --neon-blue: #00d4ff;
  --neon-purple: #7b2cbf;
  --neon-pink: #ff006e;
  --star-white: #e0e1dd;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
}

/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--space-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  overflow: hidden;
  position: relative;
}

/* 星空背景 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at center, var(--space-blue) 0%, var(--space-dark) 100%);
  z-index: -2;
}

/* 星星粒子 */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(2px 2px at 25vw 10vh, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 50vw 20vh, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 75vw 15vh, rgba(255,255,255,0.9), transparent),
    radial-gradient(2px 2px at 10vw 40vh, rgba(255,255,255,0.5), transparent),
    radial-gradient(2px 2px at 90vw 35vh, rgba(255,255,255,0.7), transparent),
    radial-gradient(2px 2px at 30vw 60vh, rgba(255,255,255,0.4), transparent),
    radial-gradient(2px 2px at 60vw 70vh, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 85vw 55vh, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 20vw 30vh, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 40vw 50vh, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 65vw 25vh, rgba(255,255,255,0.5), transparent);
}

/* 游戏容器 */
.game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
}

/* info-bar */
.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 400px;
  padding: 10px 15px;
  background: linear-gradient(135deg, var(--space-light) 0%, var(--space-blue) 100%);
  border: 2px solid rgba(0, 212, 255, 0.3);
  border-radius: 10px 10px 0 0;
  box-shadow: 
    0 0 15px rgba(0, 212, 255, 0.2),
    inset 0 0 20px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

#scoreDisplay, #levelDisplay, #highScoreDisplay {
  font-size: 18px;
  color: var(--neon-blue);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
  font-weight: bold;
}

#pauseBtn, #soundToggle {
  padding: 6px 12px;
  font-size: 14px;
  background: rgba(0, 212, 255, 0.2);
  border: 1px solid var(--neon-blue);
  color: var(--text-primary);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s;
}

#pauseBtn:hover, #soundToggle:hover {
  background: rgba(0, 212, 255, 0.4);
}

/* Buff状态显示（性能优化：使用DOM代替Canvas文本） */
.buff-display {
  position: absolute;
  top: 60px;
  left: 10px;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.buff-item {
  font-size: 14px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  text-shadow: 0 0 5px currentColor;
  animation: buffPulse 1s ease-in-out infinite;
}

.buff-item.auto-fire {
  color: #ff00ff;
  background: rgba(255, 0, 255, 0.1);
}

.buff-item.double-fire {
  color: #00ffff;
  background: rgba(0, 255, 255, 0.1);
}

.buff-item.enhanced-damage {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

@keyframes buffPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 游戏画布容器 */
.canvas-wrapper {
  position: relative;
  width: 400px;
  height: 600px;
  border: 2px solid var(--neon-blue);
  border-radius: 0 0 8px 8px;
  box-shadow: 
    0 0 20px rgba(0, 212, 255, 0.4),
    0 0 40px rgba(0, 212, 255, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  background: linear-gradient(180deg, var(--space-dark) 0%, var(--space-blue) 50%, #0d0d25 100%);
}

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

/* 覆盖层通用样式 */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 26, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 10;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

.overlay h1, .overlay h2 {
  font-size: 32px;
  font-weight: bold;
  color: var(--neon-blue);
  text-shadow: 
    0 0 10px var(--neon-blue),
    0 0 20px var(--neon-blue);
}

.overlay p {
  font-size: 16px;
  color: var(--text-secondary);
}

/* 按钮样式 */
.overlay button, #pauseBtn, #soundToggle {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-purple) 100%);
  border: none;
  border-radius: 25px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 
    0 0 15px rgba(0, 212, 255, 0.4);
}

.overlay button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 0 25px rgba(0, 212, 255, 0.6);
}

/* 排行榜样式 */
.ranking-header {
  display: flex;
  width: 90%;
  max-width: 250px;
  padding: 8px 10px;
  background: rgba(27, 38, 59, 0.9);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--neon-blue);
  font-weight: bold;
  font-size: 14px;
  text-align: center;
}

#rankingList {
  width: 90%;
  max-width: 250px;
  max-height: 250px;
  overflow-y: auto;
  background: rgba(27, 38, 59, 0.8);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 0 0 8px 8px;
  padding: 10px;
}

#rankingList div {
  display: flex;
  justify-content: space-between;
  padding: 8px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
  color: var(--text-primary);
}

#rankingList div:first-child { color: var(--gold); }
#rankingList div:nth-child(2) { color: var(--silver); }
#rankingList div:nth-child(3) { color: var(--bronze); }

/* 输入框 */
#playerNameInput {
  padding: 10px 15px;
  font-size: 16px;
  background: rgba(13, 27, 42, 0.8);
  border: 2px solid var(--neon-blue);
  color: var(--text-primary);
  border-radius: 8px;
  outline: none;
  text-align: center;
}

#playerNameInput:focus {
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

/* 虚拟控制按钮 */
.virtual-controls {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  padding: 0 20px;
  justify-content: space-between;
  align-items: end;
  z-index: 5;
}

.direction-buttons {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(2, 50px);
  gap: 5px;
}

.ctrl-btn {
  width: 50px;
  height: 50px;
  border: 2px solid var(--neon-blue);
  border-radius: 50%;
  background: rgba(13, 27, 42, 0.8);
  color: var(--neon-blue);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.ctrl-btn:active {
  background: rgba(0, 212, 255, 0.3);
  transform: scale(0.95);
}

.ctrl-btn.fire-btn {
  width: 70px;
  height: 70px;
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  font-size: 14px;
}

/* 方向按钮布局 */
#btnUp { grid-column: 2; grid-row: 1; }
#btnLeft { grid-column: 1; grid-row: 2; }
#btnDown { grid-column: 2; grid-row: 2; }
#btnRight { grid-column: 3; grid-row: 2; }

/* 移动端适配 */
@media (max-width: 450px) {
  .canvas-wrapper {
    width: 100vw;
    height: calc(100vw * 1.5);
    max-width: 400px;
    max-height: 600px;
  }

  .info-bar {
    max-width: 100vw;
    width: calc(100vw - 4px);
  }

  .virtual-controls {
    display: flex;
  }
}
