:root {
  --bg0: #0f1626;
  --bg1: #18243d;
  --panel: #151f34;
  --panel-ink: #dfe8f7;
  --accent: #2f6db3;
  --danger: #c53a3a;
  --ok: #2f8e56;
  --grid: #20314f;
  --path: #355983;
  --target: #ffd166;
  --wall: #8d99ae;
  --basic: #2d7dd2;
  --fire: #e4572e;
  --ice: #58a4b0;
  --bomb: #9c6644;
  --sniper: #7b2cbf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #1f2f4f, #0c1221 65%);
  color: #e9eef8;
  min-height: 100vh;
}

.app {
  max-width: 1420px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(7, 11, 20, 0.45);
  border: 1px solid #2b456d;
  border-radius: 10px;
  padding: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 90px;
}

.stat span {
  font-size: 0.75rem;
  text-transform: uppercase;
  opacity: 0.8;
}

.primary {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.wave-progress-wrap {
  min-width: 230px;
  flex: 1;
  max-width: 420px;
}

.wave-progress-bar {
  width: 100%;
  height: 34px;
  border: 1px solid #395a84;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #05070c;
}

.seg {
  height: 100%;
}

.seg.defeated {
  background: linear-gradient(180deg, #46b86f, #2f8e56);
}

.seg.active {
  background: linear-gradient(180deg, #9aa7bd, #6f7a8c);
}

.seg.unspawned {
  background: #05070c;
}

.main-row {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 12px;
}

.panel {
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 10px;
  padding: 10px;
  border: 2px solid #314d73;
}

.panel h2,
.panel h3 {
  margin: 0 0 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.button-grid button,
.inline-actions button,
select {
  width: 100%;
  border: 1px solid #49688f;
  border-radius: 8px;
  padding: 8px;
  background: #10233e;
  color: #e7f0ff;
  font-weight: 600;
  cursor: pointer;
}

.button-grid button.locked,
button:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.inline-actions {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.selected-info,
.preview-list {
  font-size: 0.92rem;
  background: #0d1a2f;
  border: 1px solid #2d4a72;
  border-radius: 8px;
  padding: 8px;
  min-height: 52px;
}

.preview-item {
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tag {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 2px 8px;
  background: #142845;
  border: 1px solid #4f6f99;
}

.ui-glyph {
  display: inline-flex;
  width: 1.05rem;
  align-items: center;
  justify-content: center;
  margin-right: 0.3rem;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.ui-glyph.tower.wall {
  color: #9fb2ca;
}

.board-wrap {
  position: relative;
  background: linear-gradient(180deg, #162542, #111a2f);
  border: 2px solid #2b456d;
  border-radius: 10px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.message {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  background: rgba(9, 13, 26, 0.8);
  border: 1px solid #5677a7;
  color: #edf4ff;
  padding: 8px 12px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  white-space: nowrap;
}

.message.show {
  opacity: 1;
}

.enemy-tip {
  cursor: help;
  border-bottom: 1px dashed #315272;
}

@media (max-width: 1200px) {
  .main-row {
    grid-template-columns: 240px 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .main-row {
    grid-template-columns: 1fr;
  }
}
