:root {
  --bg1: #05060f;
  --bg2: #0a0d22;
  --hud: rgba(255, 255, 255, 0.85);
  --accent: #2ee6ff;
  --accent2: #ff3b81;
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-bg-hover: rgba(255, 255, 255, 0.16);
  --overlay: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: #e9f1ff;
  background: radial-gradient(1000px 600px at 50% -200px, #0b1231 0%, var(--bg2) 40%, var(--bg1) 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  overflow: hidden;
}

/* HUD */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.45), rgba(0,0,0,0.05));
  backdrop-filter: blur(4px);
  z-index: 10;
  user-select: none;
}

.hud .left, .hud .right {
  display: flex;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--hud);
}

#container {
  position: fixed;
  inset: 0;
}

/* Canvas */
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background: linear-gradient(180deg, rgba(3, 5, 14, 0.6), rgba(8, 10, 20, 0.2));
  backdrop-filter: blur(2px);
  padding: 24px;
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.overlay h1, .overlay p {
  margin: 8px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

#title {
  font-size: 36px;
  line-height: 1.2;
  background: linear-gradient(90deg, #ffffff, #a8f0ff, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Buttons */
button {
  margin-top: 12px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: linear-gradient(180deg, var(--btn-bg), rgba(255,255,255,0.04));
  color: #eaf7ff;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(255,255,255,0.06);
}

button:hover {
  background: linear-gradient(180deg, var(--btn-bg-hover), rgba(255,255,255,0.08));
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.35), 0 0 0 3px rgba(46,230,255,0.12) inset;
}

button:active {
  transform: translateY(0);
}

/* HP bar */
.hud .right { align-items: center; }

.hpbar {
  width: 240px;
  height: 12px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), inset 0 6px 12px rgba(0,0,0,0.3);
}

.hpbar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  transition: width 180ms ease;
}

/* Small screens */
@media (max-width: 480px) {
  #title {
    font-size: 28px;
  }
  .hud {
    height: 48px;
    font-size: 14px;
  }
}

/* On-screen controls */
.controls {
  position: absolute;
  inset: 0;
  z-index: 12; /* Below overlay (20), above canvas (0) and HUD (10) is fine */
  pointer-events: none; /* Only children receive events */
}

.joystick {
  position: absolute;
  left: 16px;
  bottom: 24px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.joystick .joy-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.15),
    0 8px 24px rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
}

.joystick .joy-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, var(--btn-bg), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow:
    0 6px 16px rgba(0,0,0,0.25),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  transition: transform 80ms ease;
}

.fire-btn {
  position: absolute;
  right: 24px;
  bottom: 36px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--btn-bg), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  box-shadow:
    0 10px 26px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  pointer-events: auto;
  user-select: none;
  touch-action: none;
}

.fire-btn:hover {
  background: linear-gradient(180deg, var(--btn-bg-hover), rgba(255,255,255,0.08));
}

.fire-btn.active {
  box-shadow:
    0 12px 28px rgba(0,0,0,0.45),
    0 0 0 6px rgba(255,59,129,0.18) inset;
}

/* Machine gun button */
.mg-btn {
  position: absolute;
  right: 24px;
  bottom: 140px; /* Above the fire button */
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--btn-bg), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  box-shadow:
    0 10px 26px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  pointer-events: auto;
  user-select: none;
  touch-action: none;
}

.mg-btn:hover {
  background: linear-gradient(180deg, var(--btn-bg-hover), rgba(255,255,255,0.08));
}

.mg-btn.active {
  box-shadow:
    0 12px 28px rgba(0,0,0,0.45),
    0 0 0 6px rgba(46,230,255,0.18) inset;
}

/* Missile button */
.missile-btn {
  position: absolute;
  right: 24px;
  bottom: 220px; /* Above the MG button */
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--btn-bg), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  box-shadow:
    0 10px 26px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  pointer-events: auto;
  user-select: none;
  touch-action: none;
}

.missile-btn:hover {
  background: linear-gradient(180deg, var(--btn-bg-hover), rgba(255,255,255,0.08));
}

.missile-btn.active {
  box-shadow:
    0 12px 28px rgba(0,0,0,0.45),
    0 0 0 6px rgba(46,230,255,0.18) inset;
}

/* Controls - Small screens */
@media (max-width: 480px) {
  .joystick {
    width: 120px;
    height: 120px;
    left: 12px;
    bottom: 16px;
  }
  .joystick .joy-stick {
    width: 64px;
    height: 64px;
  }
  .fire-btn {
    width: 76px;
    height: 76px;
    right: 16px;
    bottom: 24px;
    font-size: 30px;
  }
  .mg-btn {
    width: 64px;
    height: 64px;
    right: 16px;
    bottom: 112px; /* Above the fire button on small screens */
    font-size: 20px;
  }
  .missile-btn {
    width: 64px;
    height: 64px;
    right: 16px;
    bottom: 180px; /* Above the MG button on small screens */
    font-size: 20px;
  }
}
