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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow: hidden;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #1a1a2e;
  /* 使用 UI 目录中的背景图片 */
  background-image: url('../UI/background/bg1.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* UI Overlay */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Start Screen */
.start-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* 使用背景图片 */
  background-image: url('../UI/background/bg1.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 200;
}

.start-screen.hidden {
  display: none;
}

.game-logo {
  font-size: 72px;
  margin-bottom: 16px;
  animation: bounce 1s ease infinite;
}

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

.game-title {
  color: white;
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 8px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.3);
  padding: 20px 40px;
  border-radius: 16px;
}

.game-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 20px;
  margin-bottom: 48px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.start-btn {
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: white;
  border: none;
  padding: 20px 60px;
  font-size: 24px;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.start-btn:active {
  transform: scale(0.98);
}

.controls-hint {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin-top: 32px;
  text-align: center;
  line-height: 2;
  background: rgba(0, 0, 0, 0.4);
  padding: 20px 30px;
  border-radius: 12px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: auto;
}

.player-info {
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  min-width: 200px;
}

.hp-bar-container {
  width: 100%;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #ee5a6f);
  transition: width 0.3s ease;
  border-radius: 10px;
}

.hp-text {
  font-size: 14px;
  font-weight: bold;
}

.level-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 12px;
}

.wave-info {
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  padding: 12px 20px;
  color: white;
  text-align: center;
}

.wave-number {
  font-size: 24px;
  font-weight: bold;
  color: #ffd93d;
}

.enemy-count {
  font-size: 14px;
  margin-top: 4px;
}

/* Audio & Pause Buttons */
.audio-btn {
  position: absolute;
  top: 16px;
  right: 70px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s;
}

.audio-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.audio-btn.muted {
  opacity: 0.5;
}

.pause-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s;
}

.pause-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

/* Character Bar */
.character-bar {
  position: absolute;
  top: 80px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.character-slot {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  position: relative;
  font-size: 28px;
  overflow: hidden;
  padding: 2px;
}

.character-avatar-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.character-avatar {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center center;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.character-slot:hover {
  transform: scale(1.1);
  border-color: #ffd93d;
}

.character-slot.active {
  border-color: #4facfe;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.6);
  transform: scale(1.15);
}

.character-slot.on-cooldown {
  opacity: 0.5;
  cursor: not-allowed;
}

.character-slot .key-hint {
  position: absolute;
  top: -8px;
  left: -8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.character-slot .hp-indicator {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.character-slot .hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #51cf66, #37b24d);
  transition: width 0.3s;
}

.switch-cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: #ffd93d;
  font-size: 11px;
  text-align: center;
  padding: 2px;
  font-weight: bold;
  border-radius: 0 0 9px 9px;
}

/* Skill Bar */
.skill-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.skill-btn {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.skill-btn:hover {
  transform: scale(1.1);
  border-color: #ffd93d;
}

.skill-btn:active {
  transform: scale(0.95);
}

.skill-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.skill-cooldown {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: #ffd93d;
  font-size: 12px;
  text-align: center;
  padding: 4px;
  font-weight: bold;
}

/* EXP Bar */
.exp-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
}

.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4facfe, #00f2fe);
  transition: width 0.3s ease;
}

/* Level Up Modal */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.level-up-modal {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 24px;
  padding: 32px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease;
}

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

.level-up-title {
  color: white;
  font-size: 32px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.level-up-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  text-align: center;
  margin-bottom: 24px;
}

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.upgrade-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  border: 3px solid transparent;
}

.upgrade-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border-color: #ffd93d;
}

.upgrade-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upgrade-name {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
}

.upgrade-desc {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.upgrade-rarity {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  margin-top: 12px;
  color: white;
}

.rarity-common { background: #95a5a6; }
.rarity-rare { background: #3498db; }
.rarity-epic { background: #9b59b6; }
.rarity-legendary { background: #f1c40f; }

/* Game Over Screen */
.game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 300;
}

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

.game-over-title {
  color: #ff6b6b;
  font-size: 64px;
  font-weight: bold;
  margin-bottom: 24px;
  text-shadow: 0 4px 20px rgba(255, 107, 107, 0.5);
}

.stats-container {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  min-width: 300px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  color: white;
  font-size: 20px;
  margin-bottom: 16px;
}

.stat-label { color: rgba(255, 255, 255, 0.7); }
.stat-value { font-weight: bold; color: #ffd93d; }

.restart-btn {
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 20px;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s;
}

.restart-btn:hover {
  transform: scale(1.05);
}

/* Damage Numbers */
.damage-number {
  position: absolute;
  font-weight: bold;
  font-size: 20px;
  pointer-events: none;
  animation: damageFloat 1s ease forwards;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.damage-normal { color: white; }
.damage-crit { color: #ff6b6b; font-size: 28px; }
.damage-heal { color: #51cf66; }

@keyframes damageFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(1.2);
  }
}
