* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', sans-serif;
  transition: background 0.3s, color 0.3s;
}
/* ===== Dark Theme (default) ===== */
body.theme-dark {
  background: #0d1117;
  color: #c9d1d9;
}
body.theme-dark #sidebar { background: #161b22; }
body.theme-dark .stat { color: #8b949e; }
body.theme-dark .stat-val { color: #58a6ff; }
body.theme-dark .tower-btn {
  border-color: #30363d;
  background: #0d1117;
  color: #c9d1d9;
}
body.theme-dark .tower-btn:hover { border-color: #58a6ff; }
body.theme-dark .tower-btn.active { border-color: #58a6ff; background: #161b22; }
body.theme-dark .tower-btn .cost-label { color: #8b949e; }
body.theme-dark #wave-btn { background: #238636; color: #fff; }
body.theme-dark #theme-btn { background: #161b22; color: #c9d1d9; border-color: #30363d; }
body.theme-dark #theme-btn:hover { border-color: #58a6ff; }
body.theme-dark #sell-dialog-bg { background: rgba(0,0,0,0.6); }
body.theme-dark #sell-dialog { background: #161b22; color: #c9d1d9; }
body.theme-dark #sell-dialog hr { border-color: #30363d; }
body.theme-dark .sell-btn-cancel { background: #30363d; color: #c9d1d9; }
body.theme-dark .sell-btn-confirm { background: #da3633; color: #fff; }
body.theme-dark .sell-dialog-refund { color: #58a6ff; }
body.theme-dark #overlay { background: rgba(0,0,0,0.6); }
body.theme-dark #overlay-box { background: #161b22; }
body.theme-dark .hint-text { color: #484f58; }
body.theme-dark canvas { border-color: #30363d; }

/* ===== Light Theme ===== */
body.theme-light {
  background: #f6f8fa;
  color: #24292f;
}
body.theme-light #sidebar { background: #fff; border: 1px solid #d0d7de; }
body.theme-light #sidebar h2 { color: #24292f; }
body.theme-light .stat { color: #57606a; }
body.theme-light .stat-val { color: #0969da; }
body.theme-light .tower-btn {
  border-color: #d0d7de;
  background: #fff;
  color: #24292f;
}
body.theme-light .tower-btn:hover { border-color: #0969da; }
body.theme-light .tower-btn.active { border-color: #0969da; background: #ddf4ff; }
body.theme-light .tower-btn .cost-label { color: #656d76; }
body.theme-light #wave-btn { background: #238636; color: #fff; }
body.theme-light #theme-btn { background: #fff; color: #24292f; border-color: #d0d7de; }
body.theme-light #theme-btn:hover { border-color: #0969da; }
body.theme-light #sell-dialog-bg { background: rgba(0,0,0,0.35); }
body.theme-light #sell-dialog { background: #fff; color: #24292f; }
body.theme-light #sell-dialog hr { border-color: #d0d7de; }
body.theme-light .sell-btn-cancel { background: #f6f8fa; color: #24292f; border: 1px solid #d0d7de; }
body.theme-light .sell-btn-confirm { background: #da3633; color: #fff; }
body.theme-light .sell-dialog-refund { color: #0969da; }
body.theme-light #overlay { background: rgba(0,0,0,0.35); }
body.theme-light #overlay-box { background: #fff; }
body.theme-light .hint-text { color: #8b949e; }

#game-container {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
canvas {
  border: 2px solid #444;
  border-radius: 8px;
  cursor: crosshair;
}
body.theme-dark canvas { border-color: #30363d; }
#sidebar {
  width: 200px;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#sidebar h2 { font-size: 18px; }
.stat { display: flex; justify-content: space-between; font-size: 14px; }
.stat-val { font-weight: bold; }
.tower-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid #333;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.2s;
}
.tower-btn:hover { border-color: #e94560; }
.tower-btn.active { border-color: #e94560; }
.tower-btn .icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tower-btn .cost-label { margin-left: auto; font-size: 11px; }
#wave-btn {
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
}
#wave-btn:hover { opacity: 0.85; }
#wave-btn:disabled { opacity: 0.4; cursor: default; }
#theme-btn {
  padding: 8px 12px;
  border: 2px solid #30363d;
  border-radius: 6px;
  background: #161b22;
  color: #c9d1d9;
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.2s;
}
#theme-btn:hover { border-color: #58a6ff; }

/* Sell dialog overlay */
#sell-dialog-bg {
  position: fixed; inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20;
}
#sell-dialog-bg.open { display: flex; }
#sell-dialog {
  padding: 20px 28px;
  border-radius: 10px;
  text-align: center;
  min-width: 220px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
#sell-dialog h3 { margin-bottom: 6px; font-size: 15px; }
#sell-dialog p { font-size: 13px; margin-bottom: 2px; }
#sell-dialog .refund { font-size: 16px; font-weight: bold; margin: 6px 0 12px; }
#sell-dialog .sell-actions { display: flex; gap: 10px; justify-content: center; }
.sell-btn-cancel, .sell-btn-confirm {
  padding: 8px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
}
.sell-btn-cancel:hover { opacity: 0.8; }
.sell-btn-confirm:hover { opacity: 0.85; }

#overlay {
  position: fixed; inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
#overlay.hidden { display: none; }
#overlay-box {
  padding: 40px;
  border-radius: 12px;
  text-align: center;
}
#overlay-box h1 { margin-bottom: 12px; }
#overlay-box p { margin-bottom: 20px; }
#overlay-box button {
  padding: 10px 32px;
  border: none;
  border-radius: 6px;
  background: #e94560;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
.hint-text { font-size: 11px; color: #555; text-align: center; margin-top: auto; }
