* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #16110c;
  font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', serif;
  color: #e8d9b5;
  /* keeps a strip clear along the top so the back link never sits over the board */
  padding-top: 44px;
  /* a click on the board is a game move, not a text drag — without this the
     browser paints a blue selection over the labels as you play */
  -webkit-user-select: none;
  user-select: none;
}

/* Back to the landing page. Same corner and size as Gravity Golf's. */
.back {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  letter-spacing: 1px;
  padding: 7px 11px;
  border: 1px solid #1c1712;
  border-radius: 3px;
  background: #2a1f16;
  box-shadow: inset 0 0 0 1px #4a3524;
  color: #b89a6b;
  text-decoration: none;
}

.back:hover, .back:focus-visible {
  color: #d4af37;
  outline: 2px solid #d4af37;
  outline-offset: 1px;
}

#app {
  display: flex;
  gap: 16px;
  padding: 16px;
}

#game-area {
  position: relative;
}

#canvas {
  background: #3f6b2f;
  border: 6px solid #3a2a1a;
  border-radius: 2px;
  box-shadow: 0 0 0 2px #6b4a2e, inset 0 0 0 2px #1c1712;
  display: block;
  cursor: pointer;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 6, 2, 0.75);
  border-radius: 2px;
}

#overlay.hidden {
  display: none;
}

#overlay-message {
  font-size: 32px;
  font-weight: bold;
  color: #d4af37;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #1c1712;
}

#restart-btn, #start-wave-btn, .tower-btn {
  cursor: pointer;
  border: 2px solid #1c1712;
  border-radius: 3px;
  font-size: 14px;
  padding: 10px 14px;
  background: #7a4a25;
  color: #f4e4c1;
  font-family: inherit;
}

#restart-btn:hover, #start-wave-btn:hover:not(:disabled), .tower-btn:hover:not(:disabled) {
  filter: brightness(1.2);
}

#start-wave-btn {
  width: 100%;
  margin: 10px 0 4px;
  font-size: 16px;
  padding: 10px;
  letter-spacing: 1px;
}

#start-wave-btn:disabled {
  background: #4a4038;
  color: #a89a86;
  cursor: default;
}

#sidebar {
  width: 240px;
  display: flex;
  flex-direction: column;
  background: #2a1f16;
  border: 3px solid #1c1712;
  border-radius: 2px;
  padding: 14px;
  box-shadow: inset 0 0 0 2px #4a3524;
}

#sidebar h1 {
  font-size: 19px;
  margin: 0 0 12px;
  color: #d4af37;
  letter-spacing: 1px;
  text-align: center;
}

#sidebar h2 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: #b89a6b;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid #4a3524;
  padding-bottom: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 15px;
}

.stat-label {
  color: #b89a6b;
}

.stat-value {
  font-weight: bold;
  color: #f4e4c1;
}

.stat-value.boss-wave {
  color: #ff4d4d;
  text-shadow: 0 0 6px rgba(255, 77, 77, 0.6);
}

#tower-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tower-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #3a2a1e;
  border: 2px solid #1c1712;
  text-align: left;
}

.tower-btn.selected {
  border-color: #d4af37;
  box-shadow: 0 0 0 1px #d4af37;
}

.tower-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.tower-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid #1c1712;
  flex-shrink: 0;
}

.tower-info {
  display: flex;
  flex-direction: column;
}

.tower-name {
  font-weight: bold;
  font-size: 13px;
}

.tower-cost {
  font-size: 12px;
  color: #d4af37;
}

#hint {
  margin-top: 16px;
  font-size: 12px;
  color: #a89a86;
  line-height: 1.4;
  font-style: italic;
}

#upgrade-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #221912;
  border: 2px solid #1c1712;
  border-radius: 3px;
  padding: 10px;
  min-height: 20px;
}

.muted {
  margin: 0;
  font-size: 12px;
  color: #a89a86;
  font-style: italic;
}

.upgrade-tower-name {
  font-weight: bold;
  font-size: 13px;
  color: #f4e4c1;
}

.upgrade-cell {
  font-weight: normal;
  font-size: 11px;
  color: #a89a86;
}

.upgrade-stats-line {
  font-size: 11px;
  color: #b89a6b;
  padding-bottom: 4px;
  border-bottom: 1px solid #4a3524;
}

.upgrade-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upgrade-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.upgrade-dots {
  color: #d4af37;
  letter-spacing: 2px;
}

.upgrade-btn {
  cursor: pointer;
  border: 1px solid #1c1712;
  border-radius: 3px;
  font-size: 11px;
  padding: 6px 8px;
  background: #4a3524;
  color: #f4e4c1;
  font-family: inherit;
}

.upgrade-btn:hover:not(:disabled) {
  filter: brightness(1.25);
}

.upgrade-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
