:root {
  color-scheme: dark;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #121512;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 16% 10%, rgba(239, 204, 106, 0.16), transparent 28%),
    linear-gradient(135deg, #1f2b26, #141816 58%, #111312);
  overflow: hidden;
}

.game-shell {
  position: relative;
  width: min(100vw, 1280px);
  height: min(100vh, 720px);
  max-height: 100vh;
  background: #20372f;
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud,
.actions {
  position: absolute;
  left: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.hud {
  top: 14px;
}

.actions {
  bottom: 16px;
  justify-content: center;
}

.stat,
button,
.toast,
.panel,
.result {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(25, 29, 28, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.stat {
  min-width: 96px;
  padding: 8px 12px;
  border-radius: 8px;
}

.stat span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.2;
}

.stat strong {
  display: block;
  color: #fff4cf;
  font-size: 22px;
  line-height: 1.1;
}

button {
  min-width: 112px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff8dc;
  font-weight: 700;
  font-size: 14px;
  pointer-events: auto;
  cursor: pointer;
}

button:hover {
  background: rgba(61, 74, 64, 0.9);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.toast {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 30px));
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff8dc;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.toast.hide {
  opacity: 0;
  transform: translate(-50%, -8px);
}

.panel {
  position: absolute;
  right: 18px;
  bottom: 76px;
  width: min(280px, calc(100% - 36px));
  padding: 14px;
  border-radius: 8px;
  color: white;
}

.panel h2,
.result h1 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.panel p,
.result p {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.5;
}

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

.tower-choices button {
  width: 100%;
  justify-content: flex-start;
}

.panel > button,
.result button {
  width: 100%;
}

.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: white;
  text-align: center;
}

.result h1 {
  font-size: clamp(32px, 5vw, 58px);
}

@media (max-width: 720px) {
  .hud {
    left: 10px;
    right: 10px;
    gap: 6px;
  }

  .stat {
    min-width: 0;
    flex: 1;
    padding: 7px 8px;
  }

  .stat strong {
    font-size: 18px;
  }

  .actions {
    left: 8px;
    right: 8px;
    gap: 6px;
    flex-wrap: wrap;
  }

  button {
    min-width: 0;
    flex: 1 1 31%;
    padding: 0 8px;
    font-size: 12px;
  }

  #soundBtn,
  #upgradeBtn {
    flex-basis: 46%;
  }
}
