:root {
  --cyan: #3fd6ff;
  --cyan-bright: #eafcff;
  --ink: #04060c;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  font-family: 'Consolas', 'Courier New', monospace;
}

canvas { position: fixed; inset: 0; display: block; }
#bgCanvas { z-index: 1; }
#gameCanvas { z-index: 2; }

#scanlines {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.035) 0px,
    rgba(255,255,255,0.035) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.5;
}
#vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}
body.no-crt #scanlines { display: none; }

/* ---------- overlays / menus ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,4,10,0.74);
  padding: 20px;
}
.overlay.hidden { display: none; }

.panel {
  border: 1px solid var(--cyan);
  box-shadow: 0 0 20px rgba(63,214,255,0.35), inset 0 0 30px rgba(63,214,255,0.07);
  padding: 28px 34px;
  text-align: center;
  color: var(--cyan-bright);
  letter-spacing: 1px;
  max-width: min(92vw, 480px);
  background: rgba(4,6,12,0.9);
  border-radius: 2px;
}

.gameTitle {
  font-size: clamp(30px, 8vw, 54px);
  color: var(--cyan-bright);
  text-shadow: 0 0 10px var(--cyan), 0 0 26px rgba(63,214,255,0.55);
  letter-spacing: 7px;
  margin: 0 0 4px;
}
.subtitle {
  margin: 0 0 18px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 4px;
}
.hiscoreRow {
  font-size: 12px;
  color: rgba(234,252,255,0.7);
  margin-bottom: 20px;
  letter-spacing: 2px;
}
.hiscoreRow span { color: #ffd23f; margin-left: 8px; }

.panel h2 {
  margin: 0 0 18px;
  font-size: 20px;
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(63,214,255,0.6);
}

.hint {
  font-size: 11px;
  line-height: 1.6;
  color: rgba(234,252,255,0.65);
  letter-spacing: 0.5px;
  margin: 16px 0 0;
}

.bigBtn, .smallBtn, .toggleBtn {
  font-family: inherit;
  letter-spacing: 2px;
  background: rgba(63,214,255,0.08);
  border: 1px solid var(--cyan);
  color: var(--cyan-bright);
  cursor: pointer;
  border-radius: 2px;
  display: block;
  width: 100%;
}
.bigBtn:hover, .smallBtn:hover, .toggleBtn:hover { background: rgba(63,214,255,0.18); }
.bigBtn:active, .smallBtn:active, .toggleBtn:active { background: rgba(63,214,255,0.32); }

.bigBtn {
  font-size: 18px;
  padding: 14px 20px;
  margin: 6px 0;
  box-shadow: 0 0 14px rgba(63,214,255,0.3);
}
.smallBtn {
  font-size: 12px;
  padding: 9px 16px;
  margin: 8px 0 0;
  background: transparent;
}
.toggleBtn {
  font-size: 11px;
  padding: 8px 10px;
  margin: 0;
  width: auto;
  flex: 1;
}
.toggleRow { display: flex; gap: 8px; margin: 14px 0; }

.controlsGrid { text-align: left; margin: 0 0 6px; }
.controlsGrid > div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(63,214,255,0.18);
  font-size: 12px;
}
.controlsGrid b { color: #ffd23f; letter-spacing: 1px; white-space: nowrap; }
.controlsGrid span { color: rgba(234,252,255,0.8); text-align: right; }

.tally { margin: 6px 0 18px; font-size: 13px; line-height: 2; }
.tally b { color: #ffd23f; letter-spacing: 1px; }

.bigicon { font-size: 40px; margin-bottom: 8px; }

/* ---------- touch controls ---------- */

#touchControls {
  position: fixed; inset: 0; z-index: 6;
  pointer-events: none;
  transition: opacity 0.25s;
}
#touchControls.hidden { display: none; }
#touchControls.faded { opacity: 0.25; }

#stickBase {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(63,214,255,0.55);
  background: radial-gradient(circle, rgba(63,214,255,0.08), transparent 70%);
  pointer-events: auto;
  touch-action: none;
}
#stickKnob {
  position: absolute; left: 36px; top: 36px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(63,214,255,0.25);
  border: 2px solid rgba(63,214,255,0.85);
  box-shadow: 0 0 14px rgba(63,214,255,0.7);
  pointer-events: none;
}

#rightControls {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 14px;
}

.touchBtn {
  pointer-events: auto;
  touch-action: none;
  font-family: inherit;
  color: var(--cyan-bright);
  background: rgba(63,214,255,0.1);
  border: 2px solid rgba(63,214,255,0.6);
  border-radius: 50%;
  letter-spacing: 1px;
}
.touchBtn.active { background: rgba(63,214,255,0.4); }

.boostBtn { width: 62px; height: 62px; font-size: 10px; }
.boostBtn.active { background: rgba(255,210,63,0.4); border-color: #ffd23f; }

/* Aim stick: same mechanic as the movement stick, but dragging it also
   fires — an orange/red accent marks it as the weapons control. */
.aimStick {
  position: relative;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(255,90,60,0.55);
  background: radial-gradient(circle, rgba(255,90,60,0.08), transparent 70%);
  pointer-events: auto;
  touch-action: none;
}
#aimStickKnob {
  position: absolute; left: 36px; top: 36px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,90,60,0.25);
  border: 2px solid rgba(255,90,60,0.85);
  box-shadow: 0 0 14px rgba(255,90,60,0.7);
  pointer-events: none;
}

.pauseBtn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 40px; height: 40px;
  font-size: 13px;
}

@media (max-height: 480px) {
  .boostBtn { width: 50px; height: 50px; }
  #stickBase, .aimStick { width: 100px; height: 100px; }
  #stickKnob, #aimStickKnob { width: 40px; height: 40px; left: 30px; top: 30px; }
}
