* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #060810;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', monospace;
  overflow: hidden;
}

.back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  color: rgba(140, 180, 255, 0.6);
  font-size: 0.7rem;
  text-decoration: none;
  z-index: 100;
}

.back-link:hover { color: #38bdf8; }

#game-container {
  position: relative;
  width: min(100vw, 420px);
  aspect-ratio: 11 / 16;
  max-height: 94vh;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.12);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a1018;
  cursor: crosshair;
  touch-action: manipulation;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 10;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hud-item .label {
  font-size: 0.45rem;
  letter-spacing: 0.12em;
  color: rgba(140, 180, 220, 0.5);
}

#gold { color: #fbbf24; text-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
#lives { color: #f472b6; text-shadow: 0 0 8px rgba(244, 114, 182, 0.5); }
#wave { color: #38bdf8; text-shadow: 0 0 8px rgba(56, 189, 248, 0.5); }

#gold, #lives, #wave {
  font-size: 0.95rem;
  font-weight: 700;
}

#tower-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(6, 10, 20, 0.92);
  border-top: 1px solid rgba(56, 189, 248, 0.15);
  z-index: 10;
}

.tower-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid rgba(100, 140, 200, 0.25);
  border-radius: 8px;
  background: rgba(20, 30, 50, 0.8);
  color: #94a3b8;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.tower-btn.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  color: #e0f2fe;
}

.t-name { font-size: 0.5rem; letter-spacing: 0.05em; }
.t-cost { font-size: 0.45rem; color: #fbbf24; }

#wave-btn {
  flex: 0.9;
  font-family: inherit;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #0891b2, #2563eb);
  color: white;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.35);
}

#wave-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#overlay, #result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 16, 0.9);
  backdrop-filter: blur(6px);
  z-index: 20;
  text-align: center;
  padding: 20px;
  transition: opacity 0.35s;
}

#overlay.hidden, #result.hidden {
  opacity: 0;
  pointer-events: none;
}

h1 {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

h2.win { color: #4ade80; text-shadow: 0 0 16px rgba(74, 222, 128, 0.5); }
h2.lose { color: #f87171; text-shadow: 0 0 16px rgba(248, 113, 113, 0.5); }

.subtitle {
  color: rgba(160, 190, 230, 0.65);
  font-size: 0.68rem;
  margin-bottom: 16px;
}

.rules {
  list-style: none;
  color: rgba(140, 170, 210, 0.55);
  font-size: 0.6rem;
  line-height: 1.9;
  margin-bottom: 22px;
}

.rules strong { color: #bae6fd; }

#result p {
  color: rgba(180, 200, 230, 0.7);
  font-size: 0.75rem;
  margin: 12px 0 20px;
}

button#start-btn,
button#restart-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 12px 36px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: white;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(14, 165, 233, 0.4);
}
