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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

.game-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* 头部 */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 1rem;
  backdrop-filter: blur(10px);
}

.back-link {
  color: #4ecca3;
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: #7fffff;
}

.game-header h1 {
  font-size: 1.5rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header-stats {
  color: #ffd700;
  font-size: 0.9375rem;
}

/* 游戏主区域 */
.game-main {
  display: grid;
  grid-template-columns: 180px 1fr 260px;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 1200px) {
  .game-main {
    grid-template-columns: 1fr;
  }
  
  .game-status-bar {
    flex-direction: row !important;
    order: -1;
  }
  
  .canvas-and-towers {
    grid-column: 1 / -1;
  }
}

/* 游戏状态栏（左侧竖直面板） */
.game-status-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  height: fit-content;
  min-width: 180px;
}

.status-title {
  font-size: 1rem;
  color: #4ecca3;
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid rgba(78, 204, 163, 0.3);
  margin-bottom: 0.5rem;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: all 0.2s;
}

.status-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.status-item.highlight {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.status-label {
  font-size: 0.75rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-icon {
  font-size: 1.5rem;
}

.status-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #4ecca3;
}

.status-divider {
  height: 2px;
  background: rgba(78, 204, 163, 0.3);
  margin: 0.5rem 0;
}

/* 画布和防御塔容器 */
.canvas-and-towers {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1rem;
}

@media (max-width: 1100px) {
  .canvas-and-towers {
    grid-template-columns: 1fr;
  }
}

.status-icon {
  font-size: 1.5rem;
}

.status-value {
  font-size: 1.25rem;
  font-weight: bold;
  color: #4ecca3;
}

/* 画布区域 */
.canvas-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#gameCanvas {
  display: block;
  background: #1a1a2e;
  cursor: crosshair;
  max-width: 100%;
  height: auto;
}

/* 覆盖层 */
.game-start, .game-over {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.game-start h2, .game-over h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 20px rgba(78, 204, 163, 0.5);
}

.game-desc {
  font-size: 1.2rem;
  color: #aaa;
  margin-bottom: 2rem;
}

.instructions {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.5rem 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  max-width: 400px;
}

.instructions h3 {
  color: #4ecca3;
  margin-bottom: 1rem;
}

.instructions ul {
  list-style: none;
  text-align: left;
}

.instructions li {
  padding: 0.5rem 0;
  color: #ddd;
}

.btn-start, .btn-restart {
  padding: 1rem 3rem;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #4ecca3 0%, #38b58b 100%);
  color: #1a1a2e;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(78, 204, 163, 0.4);
}

.btn-start:hover, .btn-restart:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(78, 204, 163, 0.6);
}

.hidden {
  display: none !important;
}

/* 防御塔面板 */
.tower-panel {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  height: fit-content;
}

.tower-panel h3 {
  margin-bottom: 1rem;
  color: #4ecca3;
  font-size: 1.1rem;
}

.tower-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.tower-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.tower-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tower-option.selected {
  border-color: #4ecca3;
  background: rgba(78, 204, 163, 0.15);
}

.tower-icon {
  font-size: 1.75rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.tower-info {
  flex: 1;
}

.tower-name {
  font-weight: bold;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.tower-cost {
  color: #ffd700;
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}

.tower-stats {
  font-size: 0.6875rem;
  color: #aaa;
  line-height: 1.3;
}

.selected-tower {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(78, 204, 163, 0.1);
  border-radius: 8px;
  text-align: center;
}

.selected-tower .prompt {
  color: #aaa;
  font-size: 0.8125rem;
}

.selected-tower .tower-name {
  color: #4ecca3;
  font-weight: bold;
}

/* 升级提示 */
.tower-tips {
  margin-top: 1rem;
  padding: 0.875rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 0.8125rem;
}

.tip-title {
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 0.5rem;
}

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

.tip-list li {
  padding: 0.25rem 0;
  color: #aaa;
  line-height: 1.5;
}

.tip-list li::before {
  content: "▸ ";
  color: #4ecca3;
}

/* 游戏控制 */
.game-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.btn-control {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-control:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #4ecca3;
}

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

/* 升级信息面板 */
.upgrade-info {
  background: rgba(78, 204, 163, 0.15);
  border: 2px solid #4ecca3;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  backdrop-filter: blur(10px);
}

.upgrade-title {
  font-size: 1rem;
  font-weight: bold;
  color: #4ecca3;
  margin-bottom: 0.75rem;
  text-align: center;
}

.upgrade-details {
  font-size: 0.8125rem;
  color: #ddd;
  line-height: 1.8;
}

.upgrade-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.upgrade-stat:last-child {
  border-bottom: none;
}

.stat-name {
  color: #aaa;
}

.stat-value {
  color: #4ecca3;
  font-weight: 600;
}

.stat-value.upgrade {
  color: #ffd700;
}

/* 响应式 */
@media (max-width: 768px) {
  .game-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .game-status-bar {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .status-item {
    min-width: 80px;
  }

  .game-controls {
    flex-wrap: wrap;
  }

  #gameCanvas {
    max-width: 100%;
    height: auto;
  }
}
