:root {
  --bg-color: #a8d5e2;
  --grass-color: #95d678;
  --path-color: #e6c795;
  --ui-bg: rgba(255, 255, 255, 0.9);
  --text-color: #5d4037;
  --accent-color: #ff8a65;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--text-color);
  /* 禁止移动端默认的触摸行为（如滚动、缩放） */
  touch-action: none; 
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 新增包装层，用于辅助定位 */
#game-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  background-color: var(--grass-color);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  width: 800px;
  height: 700px;
  flex-shrink: 0; /* 防止被 flex 压缩 */
  transform-origin: center center;
  /* 初始状态可能需要，JS 会覆盖它 */
}

#game-canvas {
  display: block;
  background-color: transparent;
  cursor: crosshair;
}

#ui-header {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none; /* 让点击穿透到 Canvas */
}

.stat-box {
  background: var(--ui-bg);
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 20px;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

#ui-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100px;
  background: var(--ui-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-sizing: border-box;
  border-top: 4px solid rgba(0,0,0,0.05);
}

#controls {
  display: flex;
  gap: 20px;
  align-items: center;
}

.tower-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  padding: 5px 15px;
  border-radius: 10px;
  border: 3px solid #ddd;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  user-select: none; /* 防止文字被选中 */
}

.tower-select:hover {
  transform: translateY(-2px);
}

.tower-select:active {
  transform: scale(0.95);
}

.tower-select.selected {
  border-color: var(--accent-color);
  background-color: #fff5f0;
}

.tower-preview {
  font-size: 32px;
}

.tower-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}

.tower-info .cost {
  color: #e65100;
  font-weight: bold;
}

#message-area {
  font-size: 14px;
  color: #666;
  font-style: italic;
  /* 移动端如果屏幕小，可能需要隐藏部分文字，或者允许换行 */
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#start-wave-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #e64a19;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  white-space: nowrap;
}

#start-wave-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #e64a19;
}

#start-wave-btn:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

#game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  z-index: 100;
}

.hidden {
  display: none !important;
}

#game-over-screen h2 {
  font-size: 48px;
  margin-bottom: 20px;
  text-shadow: 2px 2px 0 #000;
}

#game-over-screen button {
  background: var(--grass-color);
  border: none;
  padding: 15px 30px;
  font-size: 24px;
  border-radius: 10px;
  cursor: pointer;
  color: white;
  font-weight: bold;
}
