/* ===== 基础样式和字体 ===== */
@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap");

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

body {
  font-family: "Orbitron", sans-serif;
  background: #0a0e27;
  color: #00ffff;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== 赛博朋克网格背景 ===== */
.cyber-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(
      rgba(0, 255, 255, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: gridMove 20s linear infinite;
  pointer-events: none;
  z-index: 1;
}

.cyber-grid-horizontal {
  background-image: linear-gradient(
      rgba(255, 0, 255, 0.02) 2px,
      transparent 2px
    ),
    linear-gradient(90deg, rgba(255, 0, 255, 0.02) 2px, transparent 2px);
  background-size: 100px 100px;
  animation: gridMove 30s linear infinite reverse;
}

@keyframes gridMove {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(50px, 50px);
  }
}

/* ===== 游戏容器 ===== */
.game-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 30px;
}

/* ===== 游戏标题 ===== */
.game-header {
  text-align: center;
  margin-bottom: 10px;
}

.game-title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 8px;
  margin-bottom: 20px;
  text-transform: uppercase;
}

/* 故障效果文字 */
.glitch {
  position: relative;
  color: #00ffff;
  text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff, 0 0 30px #00ffff,
    0 0 40px #ff00ff, 0 0 70px #ff00ff, 0 0 80px #ff00ff;
  animation: glitchAnimation 3s infinite;
}

@keyframes glitchAnimation {
  0%,
  90%,
  100% {
    transform: translate(0);
  }
  92% {
    transform: translate(-2px, 2px);
  }
  94% {
    transform: translate(2px, -2px);
  }
  96% {
    transform: translate(-2px, -2px);
  }
  98% {
    transform: translate(2px, 2px);
  }
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 #ff00ff;
  clip: rect(24px, 550px, 90px, 0);
  animation: glitchBefore 3s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 #00ffff;
  clip: rect(85px, 550px, 140px, 0);
  animation: glitchAfter 2.5s infinite linear alternate-reverse;
}

@keyframes glitchBefore {
  0% {
    clip: rect(61px, 9999px, 90px, 0);
  }
  20% {
    clip: rect(35px, 9999px, 71px, 0);
  }
  40% {
    clip: rect(21px, 9999px, 100px, 0);
  }
  60% {
    clip: rect(71px, 9999px, 43px, 0);
  }
  80% {
    clip: rect(14px, 9999px, 81px, 0);
  }
  100% {
    clip: rect(48px, 9999px, 29px, 0);
  }
}

@keyframes glitchAfter {
  0% {
    clip: rect(26px, 9999px, 85px, 0);
  }
  20% {
    clip: rect(71px, 9999px, 31px, 0);
  }
  40% {
    clip: rect(44px, 9999px, 91px, 0);
  }
  60% {
    clip: rect(18px, 9999px, 61px, 0);
  }
  80% {
    clip: rect(83px, 9999px, 15px, 0);
  }
  100% {
    clip: rect(55px, 9999px, 72px, 0);
  }
}

/* ===== 分数板 ===== */
.score-board {
  display: flex;
  gap: 40px;
  justify-content: center;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px 30px;
  background: rgba(0, 255, 255, 0.05);
  border: 2px solid rgba(0, 255, 255, 0.3);
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3),
    inset 0 0 20px rgba(0, 255, 255, 0.05);
}

.score-label {
  font-size: 0.8rem;
  letter-spacing: 3px;
  color: #00ffff;
  opacity: 0.7;
  margin-bottom: 5px;
}

.score-value {
  font-size: 2rem;
  font-weight: 900;
  color: #ff00ff;
  text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff, 0 0 30px #ff00ff;
}

/* ===== 画布容器 ===== */
.canvas-wrapper {
  position: relative;
  border: 3px solid rgba(0, 255, 255, 0.5);
  border-radius: 15px;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.4), 0 0 60px rgba(255, 0, 255, 0.2),
    inset 0 0 30px rgba(0, 255, 255, 0.1);
  background: rgba(10, 14, 39, 0.8);
  overflow: hidden;
}

#gameCanvas {
  display: block;
  background: linear-gradient(
    135deg,
    rgba(10, 14, 39, 0.95),
    rgba(20, 10, 40, 0.95)
  );
}

/* ===== 游戏覆盖层 ===== */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 39, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.overlay-content {
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay-title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 6px;
  margin-bottom: 20px;
  color: #00ffff;
  text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff, 0 0 30px #ff00ff;
}

.overlay-subtitle {
  font-size: 1.2rem;
  letter-spacing: 3px;
  color: rgba(0, 255, 255, 0.7);
  margin-bottom: 40px;
}

/* ===== 开始按钮 ===== */
.start-button {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  padding: 18px 40px;
  background: rgba(255, 0, 255, 0.1);
  border: 2px solid #ff00ff;
  border-radius: 50px;
  color: #ff00ff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(255, 0, 255, 0.3),
    inset 0 0 20px rgba(255, 0, 255, 0.05);
}

.start-button:hover {
  background: rgba(255, 0, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.6),
    inset 0 0 30px rgba(255, 0, 255, 0.1);
}

.button-icon {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 5px currentColor);
}

/* ===== 控制说明 ===== */
.controls-info {
  display: flex;
  gap: 30px;
  margin-top: 10px;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 10px;
  font-size: 0.9rem;
  letter-spacing: 1px;
  color: rgba(0, 255, 255, 0.8);
  transition: all 0.3s ease;
}

.control-item:hover {
  background: rgba(0, 255, 255, 0.1);
  border-color: rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.control-icon {
  width: 30px;
  height: 30px;
  color: #ff00ff;
  filter: drop-shadow(0 0 5px currentColor);
}

.control-icon svg {
  width: 100%;
  height: 100%;
}

/* ===== 粒子效果 ===== */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #00ffff;
  border-radius: 50%;
  box-shadow: 0 0 10px #00ffff;
  animation: particleFloat 3s ease-in-out forwards;
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0);
  }
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
    letter-spacing: 4px;
  }

  .score-board {
    gap: 20px;
  }

  .score-item {
    padding: 10px 20px;
  }

  .score-value {
    font-size: 1.5rem;
  }

  #gameCanvas {
    width: 400px;
    height: 400px;
  }

  .controls-info {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 15px;
  }

  .game-title {
    font-size: 1.5rem;
  }

  #gameCanvas {
    width: 300px;
    height: 300px;
  }
}
