:root {
  --bg-1: #0c0f14;
  --bg-2: #161b22;
  --panel: #1d242e;
  --panel-2: #232c38;
  --accent: #f0b400;
  --accent-2: #ff5d2a;
  --good: #4ee07a;
  --bad: #ff4b4b;
  --text: #e6edf3;
  --text-dim: #9aa6b3;
  --border: #2a3340;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: var(--text);
  font-family: 'Courier New', 'Menlo', monospace;
  overflow: hidden;
  height: 100%;
  width: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

#game-root {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a2030 0%, #050709 100%);
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
  z-index: 5;
}
.hud-top, .hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.hud-stat {
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 110px;
  backdrop-filter: blur(4px);
}
.hud-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.hud-value {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
  margin-left: auto;
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#hud-health .hud-bar {
  width: 140px;
  height: 12px;
  background: #2a1212;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.hud-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4b4b, #ffa14b);
  transition: width 0.15s ease-out;
}
#powerup-indicators {
  display: flex;
  gap: 8px;
}
.powerup-chip {
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#enemies-remaining {
  background: rgba(15, 20, 28, 0.78);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 1px;
}

/* Touch controls */
#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.joystick {
  position: absolute;
  bottom: 30px;
  width: 130px;
  height: 130px;
  pointer-events: auto;
  touch-action: none;
}
#joy-move { left: 30px; }
#joy-aim { right: 30px; }
.joy-base {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(40, 50, 65, 0.55) 0%, rgba(20, 26, 35, 0.65) 100%);
  border: 2px solid rgba(240, 180, 0, 0.4);
  border-radius: 50%;
}
.joy-stick {
  position: absolute;
  width: 60px;
  height: 60px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #5a6677, #2a3340);
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
}
.joy-label {
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
}
.fire-button {
  position: absolute;
  right: 180px;
  bottom: 70px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid #ff4b4b;
  background: radial-gradient(circle at 40% 35%, #ff7060, #b81c1c);
  color: #fff;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 2px;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(255, 75, 75, 0.4);
  font-family: inherit;
}
.fire-button:active {
  background: radial-gradient(circle at 40% 35%, #b81c1c, #7a1414);
  transform: scale(0.95);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(6px);
}
.overlay-card {
  background: linear-gradient(140deg, var(--panel) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 48px;
  max-width: 560px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255,255,255,0.04);
}
.title {
  font-size: 48px;
  letter-spacing: 6px;
  margin: 0 0 4px;
  color: var(--accent);
  text-shadow: 0 2px 0 #1a1408, 0 4px 24px rgba(240, 180, 0, 0.3);
}
.subtitle {
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 30px;
  font-size: 14px;
}
.overlay-card h2 {
  font-size: 32px;
  letter-spacing: 4px;
  margin: 0 0 14px;
  color: var(--text);
}
.overlay-card h2.bad { color: var(--bad); }
.overlay-card h2.good { color: var(--good); }
.overlay-card p {
  color: var(--text-dim);
  letter-spacing: 1px;
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
}
.big-button {
  background: linear-gradient(180deg, var(--accent) 0%, #c89800 100%);
  color: #1a1408;
  border: none;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(240, 180, 0, 0.3);
  transition: transform 0.08s ease;
}
.big-button:hover { transform: translateY(-1px); }
.big-button:active { transform: translateY(1px); }
.small-button {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 12px;
  letter-spacing: 2px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  margin-top: 14px;
  margin-left: 8px;
}
.small-button:hover { color: var(--text); border-color: var(--accent); }

.instructions {
  text-align: left;
  margin-top: 26px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.instructions h3 {
  color: var(--accent);
  letter-spacing: 2px;
  font-size: 13px;
  margin: 16px 0 6px;
}
.instructions ul {
  margin: 0;
  padding-left: 18px;
}
.instructions b { color: var(--text); }

.pause-button {
  position: absolute;
  top: 64px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(15, 20, 28, 0.78);
  color: var(--text-dim);
  cursor: pointer;
  z-index: 7;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pause-button:hover { color: var(--accent); border-color: var(--accent); }

/* Hide touch controls on desktop browsers (mouse-primary, fine pointer).
   Devices with primary touch input keep them. Chrome DevTools device mode
   sets pointer: coarse, so mobile-emulation testing still works. */
@media (hover: hover) and (pointer: fine) {
  #touch-controls { display: none !important; }
}

/* Mobile-specific */
@media (hover: none) and (pointer: coarse) {
  .hud { padding: 10px 12px; }
  .hud-stat { padding: 6px 10px; min-width: 90px; }
  #hud-health .hud-bar { width: 100px; }
  .title { font-size: 36px; }
}

/* Narrow viewport: reposition fire button so it doesn't overlap the move joystick */
@media (max-width: 700px) {
  .joystick { width: 110px; height: 110px; bottom: 24px; }
  #joy-move { left: 18px; }
  #joy-aim { right: 18px; }
  .joy-stick { width: 50px; height: 50px; }
  .fire-button {
    width: 76px;
    height: 76px;
    right: 30px;
    bottom: 150px;
    font-size: 15px;
  }
  .overlay-card { padding: 24px 18px; max-width: 96%; }
  .title { font-size: 30px; letter-spacing: 4px; }
  .overlay-card h2 { font-size: 24px; }
  .instructions { font-size: 12px; }
  .big-button { padding: 12px 24px; font-size: 14px; }
}
