:root {
  --bg: #11110f;
  --surface: #191916;
  --surface-2: #22221e;
  --line: #37362f;
  --text: #f5f0df;
  --muted: #b9b09b;
  --accent: #36d6a1;
  --cyan: #55d6f5;
  --gold: #f2c45d;
  --coral: #ff6b7d;
  --violet: #b991ff;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #25251f;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  border-color: var(--accent);
  background: #2d2d26;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  color: #716d61;
  cursor: not-allowed;
  opacity: 0.72;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.play-surface,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 40px var(--shadow);
}

.play-surface {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  min-width: 0;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0;
}

.mechanic-text,
#wavePlanText {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-top: 8px;
  max-width: 760px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.header-actions button {
  min-width: 104px;
}

.arena-wrap {
  position: relative;
  min-height: 360px;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #12120f;
}

.arena-status {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  border: 1px solid rgba(245, 240, 223, 0.14);
  border-radius: 8px;
  background: rgba(18, 18, 15, 0.84);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  padding: 10px 12px;
  pointer-events: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  min-width: 0;
}

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

.stat-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  min-height: 70px;
  padding: 10px;
}

.stat-tile span,
.section-heading span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.stat-tile strong {
  display: block;
  font-size: 23px;
  line-height: 1.1;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.panel-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.panel-block.compact {
  margin-top: auto;
}

.section-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.button-stack {
  display: grid;
  gap: 8px;
}

.build-button,
.upgrade-button {
  align-items: center;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  text-align: left;
}

.build-button.selected {
  border-color: var(--accent);
  background: #26352e;
}

.swatch {
  border-radius: 50%;
  display: inline-block;
  height: 16px;
  width: 16px;
}

.button-copy {
  min-width: 0;
}

.button-copy strong,
.button-copy span {
  display: block;
}

.button-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  margin-top: 2px;
}

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    order: 2;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 8px;
  }

  .game-header {
    display: grid;
    gap: 12px;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1 1 120px;
    min-width: 0;
  }

  .arena-status {
    font-size: 13px;
  }
}
