:root {
  --bg: #1f2530;
  --panel: #2b3340;
  --ink: #eef2f7;
  --muted: #9fb0c3;
  --accent: #f0a83c;
  --green: #4caf50;
  --red: #e8604a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 8px;
  gap: 8px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 {
  font-size: 18px;
  margin: 0;
  white-space: nowrap;
}
.hud {
  display: flex;
  gap: 12px;
  flex: 1;
  flex-wrap: wrap;
}
.stat {
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
}
.stat b { color: var(--ink); }
.stat.timer { color: var(--accent); }

.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.speed { display: flex; gap: 2px; background: var(--panel); border-radius: 8px; padding: 2px; }
.speed button {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 9px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.speed button.active { background: var(--accent); color: #1f2530; font-weight: 600; }

.controls button {
  border: 0; background: var(--panel); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.controls button:hover { filter: brightness(1.15); }
.controls button:disabled { opacity: 0.4; cursor: default; }
#start-wave { background: var(--green); color: #fff; font-weight: 600; }

/* ---------- 画布舞台 ---------- */
.stage {
  position: relative;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
#game {
  display: block;
  width: 100%;
  max-width: 960px;
  touch-action: manipulation;
  cursor: pointer;
}

.flash {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.75); color: #fff;
  padding: 6px 14px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.flash.show { opacity: 1; }

.overlay {
  position: absolute; inset: 0;
  background: rgba(15,19,26,0.82);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }
.overlay-card {
  background: var(--panel);
  padding: 28px 36px; border-radius: 16px; text-align: center;
}
.overlay-card h2 { margin: 0 0 8px; font-size: 24px; }
.overlay-card p { color: var(--muted); margin: 0 0 18px; }
.overlay-card button {
  border: 0; background: var(--accent); color: #1f2530;
  font-weight: 600; padding: 10px 22px; border-radius: 10px; cursor: pointer; font-size: 15px;
}

/* ---------- 商店 ---------- */
.shopbar { display: flex; flex-direction: column; gap: 8px; }
.shop {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.card {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 2px solid transparent;
  color: var(--ink); padding: 8px 12px; border-radius: 10px;
  cursor: pointer; font-size: 13px; min-width: 96px; justify-content: center;
}
.card:hover { filter: brightness(1.12); }
.card.active { border-color: var(--accent); }
.card.disabled { opacity: 0.4; cursor: default; }
.card .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.card .c-cost { color: var(--accent); font-weight: 600; }

.selected-panel {
  background: var(--panel); border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center;
}
.selected-panel.hidden { display: none; }
.sp-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.sp-title .dot { width: 12px; height: 12px; border-radius: 50%; }
.sp-stat { color: var(--muted); font-size: 13px; }
.sp-actions { display: flex; gap: 8px; }
.sp-actions button {
  border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
  background: var(--accent); color: #1f2530; font-weight: 600;
}
.sp-actions button:disabled { opacity: 0.4; cursor: default; }
#sell-btn { background: #5a6678; color: #fff; }

/* 移动端：卡片不换行、不截断（PRD R7） */
@media (max-width: 480px) {
  .topbar h1 { font-size: 15px; }
  .stat { padding: 4px 7px; font-size: 12px; }
  .card { min-width: 0; flex: 1; padding: 8px 4px; }
  .card .c-name { display: none; }
}
