:root {
  color-scheme: dark;
  --bg: #05060f;
  --panel: rgba(13,16,32,0.92);
  --panel-alt: #171b3355;
  --border: #2b3060;
  --text: #eaf1ff;
  --muted: #8a92c2;
  --accent: #5dffb0;
  --accent2: #5be3ff;
  --danger: #ff5d7a;
  --gold: #ffe14d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body {
  background:
    radial-gradient(1px 1px at 8% 22%, rgba(255,255,255,0.9), transparent 60%),
    radial-gradient(1px 1px at 22% 68%, rgba(255,255,255,0.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 38% 12%, rgba(255,255,255,0.8), transparent 60%),
    radial-gradient(1px 1px at 55% 80%, rgba(255,255,255,0.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 68% 35%, rgba(255,255,255,0.85), transparent 60%),
    radial-gradient(1px 1px at 82% 60%, rgba(255,255,255,0.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 92% 15%, rgba(255,255,255,0.8), transparent 60%),
    radial-gradient(1px 1px at 12% 90%, rgba(255,255,255,0.6), transparent 60%),
    radial-gradient(ellipse 60% 40% at 25% 15%, rgba(93,110,255,0.16), transparent 60%),
    radial-gradient(ellipse 55% 45% at 80% 85%, rgba(255,93,180,0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 12px 48px;
}

h1, h2, h3 { margin: 0 0 8px; }

h1 { text-shadow: 0 0 14px rgba(93,255,176,0.45), 0 0 32px rgba(91,227,255,0.25); letter-spacing: 0.02em; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  touch-action: manipulation;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(93,255,176,0.35); }

input[type="text"], select {
  font: inherit;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

/* ---------- Setup screen ---------- */

.setup {
  max-width: 640px;
  margin: 24px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.setup .subtitle { color: var(--muted); margin-bottom: 20px; }

.name-label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9em; color: var(--muted); margin-bottom: 8px; }
.name-label input { font-size: 1em; }

.setup-error { color: var(--danger); min-height: 1.2em; margin: 8px 0; font-size: 0.9em; }

.start-btn { margin-top: 16px; width: 100%; background: var(--accent); color: #0b1a0e; font-weight: 700; border: none; padding: 12px; font-size: 1.05em; }

.rules {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 0.9em;
  color: var(--muted);
  line-height: 1.5;
}
.rules summary { cursor: pointer; color: var(--text); font-weight: 600; }

/* ---------- Level map (campaign) ---------- */

.level-map {
  position: relative;
  max-width: 480px;
  margin: 16px auto;
  background: linear-gradient(180deg, rgba(18,20,42,0.96), rgba(9,10,22,0.96));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 0 40px rgba(93,110,255,0.12), inset 0 0 60px rgba(93,110,255,0.05);
  overflow: hidden;
}

/* Sci-fi HUD corner brackets framing the whole panel. */
.hud-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent2);
  opacity: 0.7;
  pointer-events: none;
  z-index: 2;
}
.hud-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.hud-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.hud-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.hud-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }

.level-map-header { position: relative; z-index: 1; }
.level-map-header .commander-line { color: var(--muted); font-size: 0.9em; }

.campaign-progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.campaign-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--panel-alt);
  border-radius: 3px;
  overflow: hidden;
}
.campaign-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 8px rgba(93,255,176,0.6);
  transition: width 0.3s;
}
.campaign-progress-label { font-size: 0.72em; color: var(--muted); white-space: nowrap; }

.level-map-scroll {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 68vh;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.level-map-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: block;
}

.level-nodes { position: relative; }

/* Plain in-flow block that gives .level-map-scroll its true (huge)
   scrollable height -- see the comment in levelMap.js for why the
   virtualized, absolutely-positioned node/canvas layers can't do this
   themselves. */
.level-map-spacer { width: 1px; pointer-events: none; }

.level-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: radial-gradient(circle at 35% 30%, #2a3060, #12142a);
  border: 2px solid var(--border);
  color: var(--text);
  z-index: 1;
  box-shadow: 0 0 0 0 transparent;
}
.level-node[style*='--node-color'] {
  background: radial-gradient(circle at 35% 30%, rgba(var(--node-color-rgb), 0.55), #0c0d1c 75%);
  border-color: var(--node-color);
  box-shadow: 0 0 16px rgba(var(--node-color-rgb), 0.5);
}
.level-node-glyph { font-size: 1.5em; line-height: 1; filter: drop-shadow(0 0 4px rgba(0,0,0,0.6)); }
.level-node-id {
  position: absolute;
  bottom: -6px;
  right: -4px;
  background: #0c0d1c;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.62em;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-node-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  letter-spacing: -1px;
  color: var(--gold);
  font-size: 0.85em;
  filter: drop-shadow(0 0 4px rgba(255,225,77,0.8));
}

.galaxy-stars {
  color: var(--gold);
  font-size: 0.85em;
  margin-left: 6px;
}

.level-node.locked {
  filter: grayscale(1) brightness(0.55);
  cursor: not-allowed;
  box-shadow: none;
}
.level-node.locked .level-node-glyph { font-size: 1.3em; }

.level-node.current {
  animation: level-node-pulse 1.8s ease-in-out infinite;
}
@keyframes level-node-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(var(--node-color-rgb), 0.5), 0 0 0 3px rgba(var(--node-color-rgb), 0.18); }
  50% { box-shadow: 0 0 30px rgba(var(--node-color-rgb), 0.85), 0 0 0 7px rgba(var(--node-color-rgb), 0.1); }
}

.level-node-label {
  position: absolute;
  transform: translate(-50%, 0);
  width: 130px;
  text-align: center;
  font-size: 0.74em;
  color: var(--muted);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  pointer-events: none;
}

/* One galaxy header per PLANETS_PER_GALAXY block, floating above that
   galaxy's first planet node -- see the comment in levelMap.js for why this
   rides inside the existing row rather than adding its own row. */
.level-map-galaxy-header {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  width: 90%;
  text-align: center;
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-shadow: 0 0 10px rgba(93,110,255,0.5), 0 1px 3px rgba(0,0,0,0.8);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(140,160,255,0.25);
  pointer-events: none;
}
.level-map-galaxy-header.locked { color: var(--muted); border-bottom-color: var(--border); }
/* Echoes the big rotating spiral behind it (see levelMap.js drawSpiralGalaxy)
   at header-text scale, so the "galaxy" reads as a spinning object even
   where the canvas backdrop itself is scrolled out of alignment. */
.galaxy-header-icon {
  display: inline-block;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
  animation: galaxy-header-spin 14s linear infinite;
}
@keyframes galaxy-header-spin {
  to { transform: rotate(360deg); }
}

.level-node.mini-boss { width: 70px; height: 70px; border-width: 3px; }
.level-node.mini-boss .level-node-glyph { font-size: 1.7em; }
.level-node.boss { width: 78px; height: 78px; border-width: 3px; }
.level-node.boss .level-node-glyph { font-size: 1.9em; }
.level-node.boss:not(.locked), .level-node.mini-boss:not(.locked) {
  animation: level-node-boss-glow 2.4s ease-in-out infinite;
}
@keyframes level-node-boss-glow {
  0%, 100% { box-shadow: 0 0 16px rgba(var(--node-color-rgb), 0.55), 0 0 0 0 rgba(255,180,80,0.35); }
  50% { box-shadow: 0 0 26px rgba(var(--node-color-rgb), 0.9), 0 0 0 8px rgba(255,180,80,0.12); }
}

/* ---------- Game screen ---------- */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.game-header .income-note { color: var(--muted); font-size: 0.85em; }
.game-header .prep-banner {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9em;
  flex-basis: 100%;
}

.game-header .assault-banner {
  color: #9db8ff;
  font-weight: 700;
  font-size: 0.9em;
  flex-basis: 100%;
}

.game-header .assault-banner.imminent {
  color: #ff5d7a;
  animation: assault-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes assault-pulse {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

.game-header .mutator-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-basis: 100%;
}

.game-header .event-banner {
  flex-basis: 100%;
  font-size: 0.9em;
  font-weight: 700;
  color: #ffd0a0;
}

.game-header .event-banner .urgent {
  color: #ff5d7a;
  animation: assault-pulse 0.6s ease-in-out infinite alternate;
}

.mutator-chip.assist-chip {
  border-color: rgba(93, 255, 176, 0.55);
  background: rgba(93, 255, 176, 0.12);
  color: #c8ffe4;
}

.stars {
  color: #ffd23d;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(255, 210, 61, 0.6);
}

.stars .stars-empty {
  color: rgba(255, 255, 255, 0.18);
  text-shadow: none;
}

.stars-line {
  font-size: 2em;
  margin: 4px 0;
}

.reward-line {
  color: var(--gold);
  font-weight: 700;
}

.hint-line {
  font-size: 0.85em;
  opacity: 0.75;
}

.mutator-chip {
  font-size: 0.8em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 93, 122, 0.55);
  background: rgba(255, 93, 122, 0.12);
  color: #ffd0d8;
  cursor: help;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.player-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-panel.is-human { border-color: var(--accent); box-shadow: 0 0 18px rgba(93,255,176,0.18); }
.player-panel.eliminated { opacity: 0.75; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.panel-header .name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.panel-header .badge {
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--panel-alt);
  color: var(--muted);
}

.stat-row { display: flex; gap: 14px; font-size: 0.9em; flex-wrap: wrap; row-gap: 4px; }
.stat { display: flex; align-items: center; gap: 5px; }
.hp-bar-wrap, .gold-wrap, .resource-wrap { display: flex; align-items: center; gap: 6px; }
.hp-bar {
  width: 90px;
  height: 8px;
  background: var(--panel-alt);
  border-radius: 4px;
  overflow: hidden;
}
.hp-bar-fill { height: 100%; background: var(--danger); transition: width 0.2s; }
.gold-value { color: var(--gold); font-weight: 700; }
.resource-value { color: var(--text); font-weight: 700; }

canvas.map-canvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  touch-action: manipulation;
  cursor: pointer;
}

.controls { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.shop-row, .monster-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.type-item { display: flex; flex-direction: column; gap: 3px; }

.shop-btn, .monster-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 74px;
  padding: 6px 8px;
  font-size: 0.78em;
  line-height: 1.3;
}
.shop-btn .cost, .monster-btn .cost { color: var(--gold); white-space: nowrap; }
.level-badge { color: var(--muted); font-size: 0.85em; }
.shop-btn.locked, .monster-btn.locked { opacity: 0.55; }
.lock-note { color: var(--muted); font-size: 0.85em; }
.anti-tower-badge {
  color: #ffe14d;
  font-size: 0.78em;
  font-weight: 600;
  white-space: nowrap;
}

.level-btn {
  width: 100%;
  min-height: 34px;
  padding: 6px;
  font-size: 0.74em;
  color: var(--text);
  background: var(--panel-alt);
}
.level-btn.sent { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 2px rgba(93,255,176,0.35); }

.armory-panel { border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.hero-xp-bar {
  width: 100%;
  height: 6px;
  background: var(--panel-alt);
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0 8px;
}
.hero-xp-fill { height: 100%; background: var(--gold); transition: width 0.2s; }
.weapon-row { display: flex; gap: 6px; flex-wrap: wrap; }
.weapon-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 74px;
  padding: 6px 8px;
  font-size: 0.78em;
  line-height: 1.3;
}
.weapon-btn .cost { color: var(--gold); }
.weapon-btn.selected { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 2px rgba(93,255,176,0.35); }
.weapon-btn.selected .cost { color: var(--accent); }

.market-panel { border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.market-row { display: flex; gap: 6px; flex-wrap: wrap; }

.hero-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* Sitting in the panel header now (next to the HUMAIN badge) instead of
   down in the controls, so it drops the divider/spacing meant to separate
   it from the row above it there. */
.panel-header .hero-row { gap: 4px; }
.hero-mode-btn { font-size: 0.78em; padding: 6px 8px; }

.wave-panel { border-top: 1px dashed var(--border); padding-top: 8px; }
.wave-panel .row-label { font-size: 0.78em; color: var(--muted); margin-bottom: 4px; }

.factory-panel { border-top: 1px dashed var(--border); padding-top: 8px; }
.factory-panel .row-label { font-size: 0.78em; color: var(--muted); margin-bottom: 4px; }
.robot-count { color: var(--muted); font-weight: 400; }
.factory-row { display: flex; gap: 6px; flex-wrap: wrap; }

.robots-panel { border-top: 1px dashed var(--border); padding-top: 8px; }
.robots-panel .row-label { font-size: 0.78em; color: var(--muted); margin-bottom: 4px; }
.robots-list { display: flex; flex-direction: column; gap: 5px; }
.robot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78em;
}
.robot-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.robot-target-btns { display: flex; gap: 4px; flex-shrink: 0; }
.robot-target-btn { padding: 4px 7px; font-size: 1em; }

.qty-row { display: flex; align-items: center; gap: 8px; }
.qty-row input[type="number"] { width: 56px; }

.monster-btn.sent { background: #14332a; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(93,255,176,0.35); }

.build-hint { font-size: 0.78em; color: var(--accent); min-height: 1.2em; }

.plant-panel { border-top: 1px dashed var(--border); padding-top: 8px; }
.plant-panel .row-label { font-size: 0.78em; color: var(--muted); margin-bottom: 4px; }
.plant-row { display: flex; gap: 6px; flex-wrap: wrap; }

.cargo-line { font-size: 0.78em; color: var(--accent); margin-top: 6px; }
.no-building-note { font-size: 0.78em; color: var(--muted); }

/* Cadre du plateau : son rapport 2/1 est fixé dans gameScreen.js et le canvas
   le remplit en position absolue (MapRenderer relit sa taille CSS). */
.map-wrap { position: relative; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.map-canvas { display: block; }

/* Tabs only do anything on a phone (see the media query below); a wide
   screen has room for every pane at once, so the bar stays hidden there. */
.tab-bar { display: none; }
.map-toggle { display: none; }

/* ---------- Overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,14,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}
.overlay-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  max-width: 420px;
}
.overlay-box h2 { font-size: 1.6em; margin-bottom: 6px; }
.overlay-box ol { text-align: left; color: var(--muted); }
.overlay-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.level-title { color: var(--accent2); font-weight: 600; width: 100%; }
.level-subtitle { color: var(--muted); font-size: 0.8em; width: 100%; margin-top: -4px; }

@media (max-width: 480px) {
  .players-grid { grid-template-columns: 1fr; }
  .shop-btn, .monster-btn { min-width: 64px; font-size: 0.72em; }
}


/* ---------- Phone layout ----------
   The desktop layout puts two full maps plus every control group in one
   long column, which on a phone is roughly three screens of scrolling
   between the map and whatever button you need. Here the header shrinks to
   a single line, the opponent's map folds away, the controls become tabs
   (one group at a time), and the map sticks to the top of the panel so it
   stays visible while you use them -- so a turn is: look at the map, tap a
   tab, tap a button, without ever losing sight of the board. Tap targets
   are also floored at 44px, the smallest comfortable thumb target. */
@media (max-width: 760px) {
  body { padding: 8px; }
  .app { max-width: 100%; }

  .game-header { margin-bottom: 8px; gap: 6px; row-gap: 4px; }
  .game-header h1 { font-size: 1.15em; margin: 0; }
  .game-header .level-title { font-size: 0.95em; }
  .game-header .level-subtitle { font-size: 0.75em; }
  /* Reference material, not something you act on mid-fight -- the rules
     screen still explains it. The prep countdown stays: it's a live rule,
     and it explains why the wave buttons are greyed out. */
  .game-header .income-note { display: none; }
  .game-header .prep-banner,
  .game-header .assault-banner,
  .game-header .event-banner { font-size: 0.85em; }
  .game-header .mute-btn,
  .game-header .new-game-btn { min-height: 44px; }

  .players-grid { grid-template-columns: 1fr; gap: 10px; }
  .player-panel { padding: 8px; gap: 6px; }
  .panel-header .name { font-size: 0.95em; }

  /* Your own board stays pinned at the top while you scroll the controls
     under it, so choosing a tower and then tapping the cell to put it on
     never means scrolling back and forth. Capped so it can't eat the whole
     screen on a tall map -- past that the board scrolls inside its own box.
     Nothing else may be sticky at top: 0 or the two would overlap. */
  .player-panel.is-human .map-wrap {
    position: sticky;
    top: 0;
    z-index: 2;
    max-height: 42vh;
    overflow: auto;
    background: var(--panel);
    padding-bottom: 4px;
    /* Content scrolling underneath needs a hard edge, or the board looks
       like it is failing to repaint rather than deliberately pinned. */
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 10px rgba(6,8,16,0.6);
  }

  .map-toggle {
    display: block;
    width: 100%;
    min-height: 44px;
    font-size: 0.85em;
  }
  .player-panel.map-collapsed .map-wrap { display: none; }

  .stat-row { gap: 10px; font-size: 0.95em; }
  .hp-bar { width: 64px; }

  /* The hero's four modes are what you tap most -- one full-width row of
     big targets, always visible above the map rather than tucked in a
     wrapping header. */
  .panel-header { gap: 6px; }
  .panel-header .hero-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: 100%;
  }
  .hero-mode-btn {
    font-size: 0.7em;
    padding: 8px 2px;
    min-height: 44px;
    white-space: nowrap;
  }

  /* Pinned to the bottom of the screen, native-app style: always under the
     thumb, and out of the way of the board pinned at the top -- the two
     never fight over the same edge, and the pane scrolls in the band
     between them. */
  .tab-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: var(--panel);
    padding: 6px 0;
    box-shadow: 0 -6px 12px rgba(6,8,16,0.75);
  }
  .tab-btn { min-height: 44px; font-size: 0.78em; padding: 6px 2px; }
  .tab-btn.active { border-color: var(--accent); color: var(--accent); background: #14332a; }

  /* Only the selected group is on screen; the rest keep their state. */
  .controls[data-active-tab] .tab-pane { display: none; }
  .controls[data-active-tab="build"] .tab-pane[data-tab="build"],
  .controls[data-active-tab="units"] .tab-pane[data-tab="units"],
  .controls[data-active-tab="wave"] .tab-pane[data-tab="wave"],
  .controls[data-active-tab="hero"] .tab-pane[data-tab="hero"] { display: block; }

  /* Two columns of chunky buttons beat a wrapping row of tiny ones. */
  .shop-row, .monster-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .shop-btn, .monster-btn, .weapon-btn, .market-btn {
    min-height: 52px;
    font-size: 0.8em;
  }
  .level-btn { min-height: 44px; }
  .market-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .factory-row, .plant-row { display: grid; grid-template-columns: 1fr; gap: 6px; }

  .robot-row { font-size: 0.82em; }
  .robot-target-btn { min-width: 44px; min-height: 44px; font-size: 1.05em; }

  .qty-row input[type="number"] { width: 72px; min-height: 44px; font-size: 1em; }
  .build-hint { font-size: 0.85em; }
}
