/* ==================== 全局变量 ==================== */
:root {
  --primary-color: #00d4ff;
  --secondary-color: #ff6b6b;
  --accent-color: #ffd700;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --pacman-color: #ffff00;
  --ghost-red: #ff0000;
  --ghost-pink: #ffb8ff;
  --ghost-cyan: #00ffff;
  --ghost-orange: #ffb852;
  --bg-dark: #0a0e27;
  --bg-card: #1a1f3a;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --border-color: rgba(0, 212, 255, 0.3);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.7);
  --border-radius: 15px;
  --border-radius-sm: 10px;
  --transition: all 0.3s ease;
}

/* ==================== 重置和基础样式 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

/* ==================== 游戏容器 ==================== */
.game-container {
  max-width: 800px;
  width: 100%;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== 头部样式 ==================== */
.header {
  text-align: center;
  margin-bottom: 25px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border-color);
}

.title {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==================== 信息栏 ==================== */
.info-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 25px;
}

.info-item {
  background: var(--bg-card);
  padding: 15px;
  border-radius: var(--border-radius-sm);
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--border-color);
  transition: var(--transition);
}

.info-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.score-item {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 150, 255, 0.15));
  border-color: var(--primary-color);
}

.level-item {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 50, 100, 0.15));
  border-color: var(--secondary-color);
}

.lives-item {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 165, 0, 0.15));
  border-color: var(--accent-color);
}

.dots-item {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(200, 200, 200, 0.15));
  border-color: rgba(255, 255, 255, 0.5);
}

.dots-item .info-value {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.highscore-item {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(139, 195, 74, 0.15));
  border-color: var(--success-color);
}

.info-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.info-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.score-item .info-value {
  color: var(--primary-color);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.level-item .info-value {
  color: var(--secondary-color);
  text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.lives-item .info-value {
  color: var(--accent-color);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  font-size: 1.2rem;
  letter-spacing: 3px;
}

.highscore-item .info-value {
  color: var(--success-color);
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* ==================== 画布包装器 ==================== */
.canvas-wrapper {
  position: relative;
  background: #000;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 3px solid var(--primary-color);
  margin-bottom: 25px;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 600px;
  background: #000;
}

/* ==================== 覆盖层样式 ==================== */
.start-overlay,
.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.overlay-content {
  text-align: center;
  padding: 40px;
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.start-icon,
.pause-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: bounce 1s infinite;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.overlay-title {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-color), var(--warning-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
  letter-spacing: 3px;
}

.overlay-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
}

.overlay-hint {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
  opacity: 0.8;
  font-style: italic;
}

.start-btn {
  background: linear-gradient(135deg, var(--primary-color), #0096ff);
  color: white;
  border: none;
  padding: 18px 40px;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 212, 255, 0.4);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 212, 255, 0.6);
}

.start-btn:active {
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 1.4rem;
}

.pause-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
}

.pause-btn {
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pause-btn.primary {
  background: linear-gradient(135deg, var(--success-color), #45a049);
  color: white;
  box-shadow: 0 6px 15px rgba(76, 175, 80, 0.4);
}

.pause-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.6);
}

.pause-btn.secondary {
  background: linear-gradient(135deg, var(--secondary-color), #ff5252);
  color: white;
  box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
}

.pause-btn.secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6);
}
/* Developer: SinceraXY - CUPB */

.pause-tips {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

kbd {
  background: var(--bg-card);
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  font-family: monospace;
  font-weight: 600;
  color: var(--primary-color);
}

/* ==================== 控制按钮 ==================== */
.controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 25px;
}

.control-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  padding: 12px 25px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

.control-btn:hover {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 150, 255, 0.2));
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.control-btn:active {
  transform: translateY(-1px);
}

/* ==================== 移动端控制 ==================== */
.mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 25px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 2px solid var(--border-color);
}

.direction-row {
  display: flex;
  gap: 10px;
}

.direction-btn {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 150, 255, 0.2));
  border: 2px solid var(--primary-color);
  border-radius: 15px;
  font-size: 2rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.direction-btn:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.4), rgba(0, 150, 255, 0.4));
  box-shadow: 0 2px 10px rgba(0, 212, 255, 0.6);
}

/* ==================== 游戏说明 ==================== */
.instructions {
  background: var(--bg-card);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border-color);
  margin-bottom: 25px;
}

.instructions-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--primary-color);
}

.title-icon {
  font-size: 2rem;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

.instructions-grid .instruction-card:nth-child(n+5) {
  grid-column: span 1;
}

.instruction-card {
  background: rgba(0, 212, 255, 0.05);
  padding: 20px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.instruction-card:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* Developer: SinceraXY from CUPB */


.instruction-card.ghost-intro {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.instruction-card.ghost-intro:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.instruction-card.ghost-intro h4 {
  color: var(--accent-color);
  font-size: 0.95rem;
}

.instruction-card.ghost-intro .card-icon {
  font-size: 2rem;
  animation: ghostFloat 2s ease-in-out infinite;
}

@keyframes ghostFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.card-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 15px;
}

.instruction-card h4 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: var(--primary-color);
}

.instruction-card p {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* ==================== 评分规则 ==================== */
.score-rules {
  background: rgba(255, 215, 0, 0.05);
  padding: 20px;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.score-title {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--accent-color);
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  transition: var(--transition);
}

.score-row:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: translateX(5px);
}

.score-row.highlight {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.2));
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.score-row.highlight:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.3));
  border-color: rgba(255, 215, 0, 0.5);
}

.score-row.highlight .score-value {
  color: var(--accent-color);
  font-size: 1.1rem;
  font-weight: 800;
}

.item-preview {
  font-size: 1.8rem;
  width: 40px;
  text-align: center;
}

.item-desc {
  flex: 1;
  color: var(--text-secondary);
  font-weight: 500;
}

.score-value {
  font-weight: 700;
  color: var(--accent-color);
}

/* ==================== 模态框 ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 40px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  border: 2px solid var(--primary-color);
  animation: scaleIn 0.3s ease-out;
  z-index: 1;
}

.game-over-content {
  text-align: center;
}

.game-over-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: rotate 2s infinite;
}

@keyframes rotate {
  0%, 100% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

#gameOverTitle {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--secondary-color), var(--warning-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.game-over-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.game-over-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

.game-over-stats .stat-card:nth-child(5) {
  grid-column: 1 / -1;
}

.stat-card {
  background: rgba(0, 212, 255, 0.1);
  padding: 20px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-card.highscore-card {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.2));
  border-color: var(--accent-color);
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-info {
  text-align: left;
  flex: 1;
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.highscore-card .stat-value {
  color: var(--accent-color);
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal-btn {
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--primary-color), #0096ff);
  color: white;
  box-shadow: 0 6px 15px rgba(0, 212, 255, 0.4);
}

.modal-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 212, 255, 0.6);
}

.modal-btn.secondary {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow);
}

.modal-btn.secondary:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
  border-color: var(--primary-color);
  transform: translateY(-3px);
}

/* ==================== 工具类 ==================== */
.hidden {
  display: none !important;
/* Project: GameHub */
}

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

  .subtitle {
    font-size: 1rem;
  }

  .info-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .info-item:nth-child(4) {
    grid-column: 1;
  }
  
  .info-item:nth-child(5) {
    grid-column: 2;
  }

  .info-label {
    font-size: 0.7rem;
  }

  .info-value {
    font-size: 1.2rem;
  }

  #gameCanvas {
    height: 450px;
  }

  .controls {
    flex-wrap: wrap;
    gap: 10px;
  }

  .control-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .mobile-controls {
    display: flex;
  }

  .instructions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .instructions-grid .instruction-card:nth-child(n+5) {
    grid-column: span 1;
  }

  .instruction-card {
    padding: 15px;
  }

  .card-icon {
    font-size: 2rem;
  }

  .modal-content {
    padding: 30px 20px;
  }

  .overlay-title {
    font-size: 2rem;
  }

  .game-over-stats {
    grid-template-columns: 1fr;
  }

  .modal-buttons {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .header {
    padding: 15px;
    margin-bottom: 15px;
  }

  .title {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  #gameCanvas {
    height: 350px;
  }

  .instructions {
    padding: 20px;
  }

  .score-rules {
    padding: 15px;
  }
}
