.app {
  max-width: 880px;
  width: 100%;
  gap: 12px;
}

.board-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #5e8a4a;
  user-select: none;
  touch-action: none;
  cursor: default;
}

#game-canvas { display: block; width: 100%; height: 100%; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--surface);
  color: var(--text-strong);
  padding: 24px 28px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  text-align: center;
  min-width: 240px;
  max-width: 86%;
}
.overlay-card h2 { margin: 0 0 8px; font-size: 1.45rem; }
.overlay-card p  { margin: 0 0 14px; font-size: 0.95rem; color: var(--text-muted); }
.overlay-card .btn { font-weight: 600; font-size: 1rem; padding: 10px 24px; }

.td-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.td-shop {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.td-shop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px 4px;
  min-width: 76px;
  background: var(--btn-bg);
  color: var(--text-strong);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.12s, background 0.12s;
}
.td-shop-btn img {
  width: 36px;
  height: 36px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.td-shop-btn.td-tint-slow    img { filter: hue-rotate(150deg) saturate(1.6) brightness(1.05); }
.td-shop-btn.td-tint-poison  img { filter: hue-rotate(70deg)  saturate(1.7) brightness(1.05); }
.td-shop-btn.td-tint-missile img { filter: hue-rotate(330deg) saturate(2.0) brightness(0.95); }
.td-shop-btn.td-tint-tesla   img { filter: hue-rotate(190deg) saturate(1.8) brightness(1.15); }
.td-shop-name { font-size: 0.78rem; font-weight: 600; }
.td-shop-cost {
  font-size: 0.78rem;
  font-weight: 700;
  color: #d4a200;
}
.td-shop-cost::before { content: "🪙 "; }
.td-shop-btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.td-shop-btn.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.td-shop-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.td-shop-btn.affordable {
  border-color: #ffd34a;
  box-shadow: 0 0 8px rgba(255, 211, 74, 0.45),
              inset 0 0 0 1px rgba(255, 211, 74, 0.5);
  animation: tdShopPulse 1.6s ease-in-out infinite;
}
.td-shop-btn.affordable .td-shop-cost { color: #ff9a00; font-weight: 800; }
.td-shop-btn.affordable.selected {
  /* selected wins over affordable — solid accent ring */
  animation: none;
}
@keyframes tdShopPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 211, 74, 0.35),
                          inset 0 0 0 1px rgba(255, 211, 74, 0.5); }
  50%      { box-shadow: 0 0 14px rgba(255, 211, 74, 0.75),
                          inset 0 0 0 1px rgba(255, 211, 74, 0.7); }
}

.td-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.td-start {
  background: #2a9d4f;
  color: #fff;
  font-weight: 700;
}
.td-start:hover { background: #36b85e; }
.td-start.spawning { background: #777; pointer-events: none; }

.score-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 1px;
}

@media (max-width: 540px) {
  .board-wrapper { aspect-ratio: 4 / 5; }
  .td-shop-btn { min-width: 64px; padding: 4px 6px; }
  .td-shop-btn img { width: 28px; height: 28px; }
}
