:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050b14;
  color: #eaf4ff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #162a4a 0, #091525 35%, #050b14 75%);
}

.game-shell {
  width: min(100%, 1060px);
  padding: 18px;
}

.hud, .instructions {
  background: rgba(8, 19, 35, .86);
  border: 1px solid rgba(126, 195, 255, .2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .25);
}

.hud {
  min-height: 76px;
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 14px 14px 0 0;
}

.brand { letter-spacing: .16em; font-weight: 800; font-size: clamp(.9rem, 2vw, 1.25rem); color: #8ed9ff; }
.brand-mark { font-size: 1.8em; vertical-align: middle; margin-right: 8px; }
.brand small { display: block; margin: -2px 0 0 42px; color: #91a9bf; font-size: .55rem; font-weight: 700; letter-spacing: .08em; }
.stats { display: flex; gap: clamp(14px, 4vw, 42px); }
.stat { min-width: 56px; text-align: right; }
.label { display: block; color: #7f96ac; font-size: .62rem; letter-spacing: .13em; font-weight: 700; }
.stat strong { font-size: 1.2rem; }
.gold strong { color: #ffd464; }
.danger strong { color: #ff8d8d; }

.game-area {
  position: relative;
  height: min(66vh, 650px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(126, 195, 255, .2);
  border-top: 0;
  background: #071221;
}

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

.message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  background: rgba(4, 10, 20, .63);
  transition: opacity .25s ease, visibility .25s ease;
}
.message.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.message h1 { margin: 0; color: #a6e5ff; font-size: clamp(1.55rem, 5vw, 2.7rem); letter-spacing: .12em; }
.message p { color: #bed2e5; max-width: 390px; line-height: 1.5; }
button { justify-self: center; border: 1px solid #7ed5ff; border-radius: 8px; background: #114d70; color: #effaff; padding: 11px 21px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
button:hover, button:focus-visible { background: #19709e; outline: 3px solid rgba(126, 213, 255, .35); outline-offset: 3px; }
.google-login { justify-self: center; display: inline-block; margin: 4px 0 9px; padding: 11px 21px; border: 1px solid #e8eef5; border-radius: 8px; background: #f8fbff; color: #1b2734; font-size: .83rem; font-weight: 800; letter-spacing: .04em; text-decoration: none; }
.google-login[hidden] { display: none; }
.google-login:hover, .google-login:focus-visible { background: #dcecff; outline: 3px solid rgba(126, 213, 255, .35); outline-offset: 3px; }

.battle-info { display: grid; grid-template-columns: 1fr; gap: 1px; background: rgba(126, 195, 255, .2); border-inline: 1px solid rgba(126, 195, 255, .2); }
.info-box { padding: 13px 18px; background: rgba(8, 19, 35, .96); }
.info-box h2 { margin: 0 0 9px; color: #8ed9ff; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.info-box dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.player-info dl { grid-template-columns: repeat(4, 1fr); }
.enemy-info dl { grid-template-columns: repeat(3, 1fr); }
.info-box dl div { min-width: 0; }
.info-box dt { color: #7f96ac; font-size: .58rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.info-box dd { margin: 3px 0 0; color: #eaf4ff; font-size: .88rem; font-weight: 750; white-space: nowrap; }
.enemy-info dd { color: #ffb3c0; }

.upgrades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgba(126, 195, 255, .2); border-inline: 1px solid rgba(126, 195, 255, .2); }
.upgrade { min-height: 68px; display: grid; gap: 4px; justify-self: stretch; border: 0; border-radius: 0; background: rgba(8, 19, 35, .96); text-align: left; padding: 12px 16px; }
.upgrade span { color: #eaf4ff; font-weight: 800; }
.upgrade small { color: #9ab3c8; font-weight: 600; }
.upgrade:disabled { cursor: not-allowed; opacity: .55; }

.instructions { border-radius: 0 0 14px 14px; border-top: 0; color: #a9bfd0; padding: 13px 20px; display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; font-size: .78rem; }
.instructions b { color: #ffd464; }
.legend { display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; }
.legend.tower { background: #7ed5ff; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.legend.enemy { background: #fa6883; }

@media (max-width: 520px) {
  .game-shell { padding: 0; }
  .hud { padding: 10px 14px; border-radius: 0; }
  .brand { letter-spacing: .08em; }
  .stats { gap: 12px; }
  .player-info dl { grid-template-columns: repeat(2, 1fr); }
  .game-area { min-height: 430px; }
  .upgrades { grid-template-columns: repeat(2, 1fr); }
  .instructions { border-radius: 0; gap: 10px 18px; }
}
