/* ==================== CSS变量 ==================== */
:root {
  --primary-color: #ff6b6b;
  --primary-dark: #ee5a52;
  --primary-light: #ff8787;
  --secondary-color: #ffd93d;
  --success-color: #51cf66;
  --error-color: #ff6b6b;
  --warning-color: #ffa94d;
  
  --bg-gradient-start: #ffd3a5;
  --bg-gradient-end: #fd6585;
  
  --card-bg: rgba(255, 255, 255, 0.98);
  --card-shadow: rgba(0, 0, 0, 0.15);
  --card-shadow-hover: rgba(0, 0, 0, 0.25);
  
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-light: #b2bec3;
  --text-white: #ffffff;
  
  --border-radius: 20px;
  --border-radius-sm: 12px;
  --border-radius-lg: 28px;
  
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ==================== 容器 ==================== */
.container {
  width: 100%;
  max-width: 900px;
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  animation: fadeIn 0.6s ease-in-out;
}

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

/* ==================== 头部 ==================== */
.game-header {
  text-align: center;
  margin-bottom: 30px;
}

.title-icon {
  font-size: 4rem;
  animation: bounce 2s infinite;
  display: inline-block;
}

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

.game-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 15px 0 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* ==================== 统计信息 ==================== */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.stat-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: var(--border-radius);
  padding: 25px;

/* GitHub: https://github.com/nilgpt2024/web-game */

  text-align: center;
  box-shadow: 0 4px 15px var(--card-shadow);
  transition: var(--transition);
  border: 2px solid transparent;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px var(--card-shadow-hover);
  border-color: var(--primary-light);
}

.stat-label {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

/* ==================== 游戏区域 ==================== */
.game-area {
  background: linear-gradient(135deg, #a8e6cf, #dcedc1);
  border-radius: var(--border-radius);
  padding: 20px;
  margin: 30px 0;
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 欢迎界面 */
.welcome-screen {
  position: absolute;
  top: 50%;
  left: 50%;
/* Project: GameHub */
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 10;
  width: 90%;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.welcome-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: rotate 3s infinite;
}

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

.welcome-title {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  font-weight: 700;
}

.welcome-text {
  font-size: 1.2rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* 游戏画布 */
.game-canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* 分数显示 */
.score-display {
  position: absolute;
  top: 20px;
  left: 20px;
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 5;
  animation: appear 0.3s ease-out;
}

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

.score-display.active {
  display: flex;
}

.score-icon {
/* Made with love by SinceraXY */
  font-size: 1.8rem;
}

.score-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* 生命显示 */
.lives-display {
  position: absolute;
  top: 20px;
  right: 20px;
  display: none;
  gap: 8px;
  z-index: 5;
}

.lives-display.active {
  display: flex;
}

.life-icon {
  font-size: 2rem;
  animation: pulse 1s infinite;
  transition: var(--transition);
}

.life-icon.lost {
  opacity: 0.2;
  filter: grayscale(100%);
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* 水果 */
.fruit {
  position: absolute;
  width: 80px;
  height: 80px;
  display: none;
  cursor: pointer;
  transition: transform 0.1s;
  filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
  z-index: 3;
}

.fruit:hover {
  transform: scale(1.1);
}

/* 难度提升通知 */
.difficulty-notification {
  position: absolute;
  top: 80px;  /* 移到顶部，不遮挡中间区域 */
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;  /* 关键：不阻挡鼠标事件 */
  animation: difficultySlideIn 0.4s ease-out;
}

@keyframes difficultySlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -30px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.difficulty-notification.fade-out {
  animation: difficultySlideOut 0.3s ease-out forwards;
}

@keyframes difficultySlideOut {
  to {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
}

.notification-content {
  background: linear-gradient(135deg, rgba(255, 217, 61, 0.95), rgba(255, 183, 0, 0.95));
  backdrop-filter: blur(10px);  /* 毛玻璃效果 */
  border: 3px solid #ff922b;
  border-radius: var(--border-radius);
  padding: 12px 25px;  /* 缩小内边距 */
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(255, 146, 43, 0.4);
}

.notification-icon {
  font-size: 2rem;  /* 缩小图标 */
  animation: iconPulse 0.6s ease-in-out 2;  /* 只闪烁2次 */
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

.notification-text {
  font-size: 1.2rem;  /* 缩小文字 */
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
  white-space: nowrap;  /* 不换行 */
}

/* 游戏结束界面 */
.game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15;
  animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.game-over-screen.active {
  display: flex;
}

.game-over-content {
  background: white;
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.game-over-title {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 30px;
  font-weight: 700;
}

.final-score {
  margin: 30px 0;
}

.final-score-label {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.final-score-value {
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.game-over-message {
  font-size: 1.3rem;
  color: var(--text-secondary);
  margin-top: 20px;
  font-weight: 600;
}

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

.action-button,
.reset-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 15px 30px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px var(--card-shadow);
  color: white;
  min-width: 180px;
}

.action-button {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.reset-button {
  background: linear-gradient(135deg, var(--secondary-color), #ffb700);
  color: var(--text-primary);
}

.reset-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 217, 61, 0.4);
}

.action-button:active,
.reset-button:active {
  transform: translateY(0);
}

.button-icon {
  font-size: 1.3rem;
}

/* ==================== 游戏说明 ==================== */
.instructions-container {
  margin: 30px 0;
}

.instructions-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 15px 25px;
  border: 2px solid var(--warning-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, #fff9db, #fff3bf);
  color: var(--text-primary);
  box-shadow: 0 2px 10px var(--card-shadow);
}

.instructions-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--card-shadow-hover);
  border-color: #ff922b;
}

.instructions-toggle:active {
  transform: translateY(0);
}

.toggle-icon {
  font-size: 1.3rem;
}

.instructions {
  background: linear-gradient(135deg, #fff9db, #fff3bf);
  border-radius: var(--border-radius);
  padding: 20px 25px;
  margin-top: 10px;
  border-left: 4px solid var(--warning-color);
  box-shadow: 0 2px 10px var(--card-shadow);
/* GitHub: https://github.com/nilgpt2024/web-game */
  animation: slideDown 0.3s ease-out;
}

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

.instructions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.instructions-list li {
  font-size: 1rem;
  color: var(--text-secondary);
  padding: 8px 0;
  padding-left: 25px;
  position: relative;
}

.instructions-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success-color);
  font-weight: bold;
  font-size: 1.2rem;
}

/* ==================== 页脚 ==================== */
.game-footer {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px solid #e9ecef;
  text-align: center;
}

.game-footer p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
  .container {
    padding: 30px 20px;
  }
  
  .game-title {
    font-size: 2rem;
  }
  
  .title-icon {
    font-size: 3rem;
  }
  
  .stats-container {
    grid-template-columns: 1fr;
  }
  
  .game-area {
    min-height: 400px;
  }
  
  .welcome-icon {
    font-size: 3.5rem;
  }
  
  .welcome-title {
    font-size: 1.5rem;
  }
  
  .welcome-text {
    font-size: 1rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: center;
  }
  
  .action-button,
  .reset-button {
    width: 100%;
    max-width: 400px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 20px 15px;
  }
  
  .game-title {
    font-size: 1.6rem;
  }
  
  .stat-value {
    font-size: 2rem;
  }
  
  .game-area {
    min-height: 350px;
  }
  
  .fruit {
    width: 60px;
    height: 60px;
  }
  
  /* 移动端难度通知优化 */
  .difficulty-notification {
    top: 60px;  /* 移动端位置稍微靠上 */
  }
  
  .notification-content {
    padding: 10px 20px;  /* 更紧凑 */
    gap: 10px;
  }
  
  .notification-icon {
    font-size: 1.5rem;
  }
  
  .notification-text {
    font-size: 1rem;
  }
}
