* {
  box-sizing: border-box;
}

:root {
  --bg: #0c0e13;
  --panel: #141824;
  --panel2: #1b2130;
  --line: #262d3f;
  --text: #e8ebf4;
  --muted: #97a1b6;
  --accent: #c6ff33;
  --accent-dim: #243312;
  --danger: #ff5470;
  --money: #ffd35c;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(rgba(70, 78, 102, 0.25) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app {
  max-width: 1420px;
  margin: 0 auto;
  padding: 12px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.hud__brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 15px;
  color: var(--accent);
  white-space: nowrap;
}

.hud__logo {
  font-size: 18px;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 11px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  white-space: nowrap;
}

.stat b {
  font-weight: 700;
}

.stat--money b {
  color: var(--money);
}

.stat--hp b {
  color: #ff8095;
}

.hud__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10130a;
}

.btn--primary:hover {
  background: #d6ff62;
}

.btn--danger {
  background: #2a1520;
  border-color: #4a2233;
  color: var(--danger);
}

.btn--danger:hover {
  border-color: var(--danger);
}

.btn--big {
  font-size: 17px;
  padding: 13px 26px;
  border-radius: 13px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 12px;
  align-items: start;
}

.stage {
  position: relative;
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 640;
  cursor: crosshair;
  touch-action: none;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.panel__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ---------- Shop ---------- */
.shop {
  display: grid;
  gap: 8px;
}

.card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  text-align: left;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.card:hover {
  border-color: #46507010;
  transform: translateY(-1px);
  border-color: #4a5573;
}

.card__icon {
  grid-row: span 2;
  font-size: 26px;
  text-align: center;
}

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.card__name {
  font-weight: 700;
  font-size: 14px;
}

.card__cost {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: var(--money);
}

.card__desc {
  font-size: 11.5px;
  color: var(--muted);
}

.card.is-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.card.is-poor {
  opacity: 0.5;
}

.card.is-poor .card__cost {
  color: var(--danger);
}

/* ---------- Turret panel ---------- */
.tp__stats {
  display: grid;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}

.tp__line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
}

.tp__line span:last-child {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent);
}

.tp__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Wave ---------- */
.wave__info {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.wave__preview {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  min-height: 34px;
  margin-bottom: 10px;
}

#btnWave {
  width: 100%;
}

.help {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.8;
}

.help b {
  color: var(--text);
}

/* ---------- Author ---------- */
.author {
  border-color: #2f3a24;
  background: linear-gradient(160deg, #171d16, var(--panel));
}

.author__row {
  display: flex;
  align-items: center;
  gap: 11px;
}

.author__avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #10130a;
  background: linear-gradient(135deg, var(--accent), #6fd3ff);
  box-shadow: 0 0 0 3px rgba(198, 255, 51, 0.18);
}

.author__name {
  font-weight: 800;
  font-size: 15px;
}

.author__meta {
  font-size: 12.5px;
  color: var(--muted);
}

.author__bio {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.author-line {
  margin: 14px 0 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.author-line b {
  color: var(--accent);
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 8, 12, 0.88);
  backdrop-filter: blur(4px);
  z-index: 5;
}

.modal {
  max-width: 520px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.modal__emoji {
  font-size: 52px;
  line-height: 1;
  animation: floaty 2.4s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.modal__title {
  margin: 12px 0 8px;
  font-size: 28px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.modal__lead {
  margin: 0 auto;
  max-width: 430px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

.tips {
  margin: 16px auto;
  padding: 12px 14px 12px 30px;
  max-width: 430px;
  text-align: left;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text);
}

.tips b {
  color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 14px);
  background: rgba(10, 12, 18, 0.95);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 11px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 6;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}
