/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  user-select: none;
}

/* ─── Canvas ────────────────────────────────────────────────────────────────── */
#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  /* Disable browser touch gestures (scroll, zoom) so our touch controls work */
  touch-action: none;
}

/* ─── Screen-edge vignette ──────────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.65) 100%);
  z-index: 5;
}

/* ─── HUD ───────────────────────────────────────────────────────────────────── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud-top {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 3px;
  color: #00ff88;
  text-shadow: 0 0 10px #00ff88;
}

#hud-bottom-left {
  position: absolute;
  bottom: 28px;
  left: 28px;
  font-size: 12px;
  letter-spacing: 2px;
  color: #00aaff;
  text-shadow: 0 0 8px #00aaff;
}

#hud-warning {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #ff3333;
  text-shadow: 0 0 12px #ff3333;
  animation: blink 0.4s step-start infinite;
}

#hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 2px solid rgba(0, 255, 136, 0.45);
  border-radius: 50%;
}

#hud-crosshair::before,
#hud-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(0, 255, 136, 0.45);
}

/* horizontal tick */
#hud-crosshair::before {
  width: 8px;
  height: 1px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* vertical tick */
#hud-crosshair::after {
  width: 1px;
  height: 8px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ─── Overlays ──────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.72);
  z-index: 20;
  /* Soft scanline texture */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 4px
    ),
    linear-gradient(rgba(0,0,0,0.72), rgba(0,0,0,0.72));
}

.title {
  font-size: clamp(32px, 6vw, 64px);
  letter-spacing: 8px;
  text-transform: uppercase;
  text-shadow: 0 0 30px currentColor;
}

.title.win  { color: #00ff88; }
.title.lose { color: #ff3333; }
/* default (menu) */
.overlay:not(.hidden) > .title:not(.win):not(.lose) {
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255,255,255,0.4);
}

.subtitle {
  font-size: 14px;
  letter-spacing: 2px;
  color: #888;
}

/* Controls hint grid */
.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 20px;
  font-size: 13px;
  color: #555;
  letter-spacing: 2px;
  margin-top: 4px;
}

.controls-grid span:nth-child(odd) {
  color: #aaa;
  text-align: right;
}

/* Buttons */
.overlay button {
  margin-top: 10px;
  padding: 13px 44px;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.overlay button:hover {
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  border-color: #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Controls hint for touch users */
.controls-touch-hint {
  font-size: 12px;
  letter-spacing: 2px;
  color: #555;
  margin-top: 2px;
}

/* ─── Virtual Joystick ──────────────────────────────────────────────────────── */
#joystick-base,
#joystick-knob {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
  /* Centre the element on the touch coordinate */
  transform: translate(-50%, -50%);
  transition: opacity 0.1s;
}

#joystick-base {
  width: 130px;
  height: 130px;
  border: 2px solid rgba(0, 255, 136, 0.28);
  background: rgba(0, 255, 136, 0.05);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.12) inset;
}

#joystick-knob {
  width: 56px;
  height: 56px;
  background: rgba(0, 255, 136, 0.28);
  border: 2px solid rgba(0, 255, 136, 0.65);
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.35);
}

/* ─── Utility ───────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
