/* style.css - NEON DRIVE */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0221;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  color: #ffffff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
}

.hidden {
  display: none !important;
}

/* ---------- Canvas ---------- */

#game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  z-index: 0;
  background: #0d0221;
}

/* ---------- Overlays: scanlines + vignette ---------- */

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

#fx::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  opacity: 0.55;
  mix-blend-mode: multiply;
}

#fx::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.65) 100%),
    linear-gradient(90deg, rgba(255, 42, 109, 0.04), rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0) 80%, rgba(5, 217, 232, 0.04));
  animation: vhsFlicker 6s steps(60) infinite;
}

@keyframes vhsFlicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 1; }
  48% { opacity: 0.86; }
  49% { opacity: 1; }
  83% { opacity: 0.94; }
  84% { opacity: 1; }
}

/* ---------- HUD ---------- */

#hud-score,
#hud-best,
#hud-mult {
  position: fixed;
  top: 12px;
  z-index: 10;
  margin: 0;
  padding: 6px 12px;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(14px, 2.4vw, 22px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #05d9e8;
  background: rgba(13, 2, 33, 0.55);
  border: 2px solid #05d9e8;
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(5, 217, 232, 0.6), inset 0 0 8px rgba(5, 217, 232, 0.25);
  text-shadow: 0 0 6px #05d9e8, 0 0 14px #05d9e8;
  pointer-events: none;
  white-space: nowrap;
}

#hud-score {
  left: 12px;
  color: #ffffff;
  border-color: #ff2a6d;
  box-shadow: 0 0 8px rgba(255, 42, 109, 0.6), inset 0 0 8px rgba(255, 42, 109, 0.25);
  text-shadow: 0 0 6px #ff2a6d, 0 0 14px #ff2a6d;
}

#hud-best {
  left: 50%;
  transform: translateX(-50%);
  color: #ff9e00;
  border-color: #ff9e00;
  box-shadow: 0 0 8px rgba(255, 158, 0, 0.6), inset 0 0 8px rgba(255, 158, 0, 0.25);
  text-shadow: 0 0 6px #ff9e00, 0 0 14px #ff9e00;
}

#hud-mult {
  right: 84px;
  color: #d300c5;
  border-color: #d300c5;
  box-shadow: 0 0 8px rgba(211, 0, 197, 0.6), inset 0 0 8px rgba(211, 0, 197, 0.25);
  text-shadow: 0 0 6px #d300c5, 0 0 14px #d300c5;
}

/* ---------- Mute button ---------- */

#mute {
  position: fixed;
  top: 74px;
  right: 10px;
  z-index: 12;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #05d9e8;
  background: rgba(13, 2, 33, 0.7);
  border: 2px solid #05d9e8;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(5, 217, 232, 0.5);
  text-shadow: 0 0 6px #05d9e8;
  touch-action: manipulation;
}

#mute:hover,
#mute:focus-visible {
  background: rgba(5, 217, 232, 0.15);
  outline: none;
  box-shadow: 0 0 16px rgba(5, 217, 232, 0.9);
}

/* ---------- Title + game-over panels ---------- */

#title,
#over {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vh, 30px);
  padding: 20px;
  text-align: center;
  background: rgba(13, 2, 33, 0.35);
}

#title h1 {
  margin: 0;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(40px, 11vw, 120px);
  letter-spacing: 0.08em;
  line-height: 1;
  color: #ffffff;
  text-shadow:
    0 0 4px #fff,
    0 0 10px #ff2a6d,
    0 0 22px #ff2a6d,
    0 0 42px #d300c5,
    0 0 70px #d300c5;
}

.flicker {
  animation: neonFlicker 3.2s infinite steps(1, end);
}

@keyframes neonFlicker {
  0%, 18%, 22%, 62%, 64%, 100% {
    opacity: 1;
    text-shadow:
      0 0 4px #fff,
      0 0 10px #ff2a6d,
      0 0 22px #ff2a6d,
      0 0 42px #d300c5,
      0 0 70px #d300c5;
  }
  19%, 21%, 63% {
    opacity: 0.55;
    text-shadow: 0 0 2px #fff, 0 0 6px #ff2a6d;
  }
  20% {
    opacity: 0.85;
  }
}

#title .subtitle {
  margin: 0;
  font-size: clamp(12px, 2vw, 16px);
  letter-spacing: 0.3em;
  color: #05d9e8;
  text-shadow: 0 0 6px #05d9e8, 0 0 14px #05d9e8;
}

#start,
#restart {
  min-height: 44px;
  min-width: 44px;
  padding: 14px 32px;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(16px, 2.6vw, 24px);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffffff;
  background: rgba(211, 0, 197, 0.18);
  border: 3px solid #ff2a6d;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 0 6px #ff2a6d, 0 0 16px #ff2a6d;
  box-shadow: 0 0 12px rgba(255, 42, 109, 0.7), inset 0 0 12px rgba(255, 42, 109, 0.35);
  touch-action: manipulation;
}

#start:hover,
#restart:hover,
#start:focus-visible,
#restart:focus-visible {
  outline: none;
  background: rgba(255, 42, 109, 0.3);
  box-shadow: 0 0 22px rgba(255, 42, 109, 1), inset 0 0 16px rgba(255, 42, 109, 0.5);
}

#start:active,
#restart:active {
  transform: scale(0.97);
}

.pulse {
  animation: pulseGlow 1.6s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    text-shadow: 0 0 6px #ff2a6d, 0 0 16px #ff2a6d;
  }
  50% {
    opacity: 0.6;
    transform: scale(1.04);
    text-shadow: 0 0 2px #ff2a6d, 0 0 8px #ff2a6d;
  }
}

#title .controls {
  margin: 0;
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 0.15em;
  line-height: 1.8;
  color: #d300c5;
  text-shadow: 0 0 6px #d300c5;
}

#title .best-line {
  margin: 0;
  font-size: clamp(12px, 1.8vw, 16px);
  letter-spacing: 0.2em;
  color: #ff9e00;
  text-shadow: 0 0 6px #ff9e00;
}

/* ---------- Game over ---------- */

#over {
  background: rgba(13, 2, 33, 0.6);
}

#over h2 {
  margin: 0;
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-weight: 900;
  font-size: clamp(30px, 8vw, 84px);
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: #ff2a6d;
  text-shadow:
    0 0 4px #fff,
    0 0 12px #ff2a6d,
    0 0 28px #ff2a6d,
    0 0 50px #d300c5;
}

#over .final-label {
  margin: 0;
  font-size: clamp(12px, 2vw, 16px);
  letter-spacing: 0.3em;
  color: #05d9e8;
  text-shadow: 0 0 6px #05d9e8;
}

#final {
  margin: 0;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: 0.1em;
  color: #ffffff;
  text-shadow: 0 0 8px #05d9e8, 0 0 20px #05d9e8;
}

.glitch {
  animation: glitchShift 0.6s steps(2, end) infinite, glitchFlash 2.4s infinite;
  position: relative;
}

.glitch#over h2,
#over.glitch h2 {
  animation: glitchText 0.5s steps(3, end) infinite;
}

@keyframes glitchShift {
  0% { transform: translate(0, 0); clip-path: inset(0 0 0 0); }
  20% { transform: translate(-4px, 1px); clip-path: inset(10% 0 60% 0); }
  40% { transform: translate(4px, -1px); clip-path: inset(40% 0 20% 0); }
  60% { transform: translate(-2px, 2px); clip-path: inset(70% 0 5% 0); }
  80% { transform: translate(3px, 0); clip-path: inset(20% 0 50% 0); }
  100% { transform: translate(0, 0); clip-path: inset(0 0 0 0); }
}

@keyframes glitchFlash {
  0%, 92%, 100% { filter: none; }
  94% { filter: hue-rotate(90deg) saturate(2); }
  96% { filter: invert(0.1) hue-rotate(-60deg); }
}

@keyframes glitchText {
  0% { text-shadow: 3px 0 #05d9e8, -3px 0 #ff2a6d; transform: skewX(0deg); }
  33% { text-shadow: -4px 0 #05d9e8, 4px 0 #ff2a6d; transform: skewX(-4deg); }
  66% { text-shadow: 2px 1px #05d9e8, -2px -1px #ff2a6d; transform: skewX(3deg); }
  100% { text-shadow: 0 0 12px #ff2a6d; transform: skewX(0deg); }
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  #hud-score,
  #hud-best,
  #hud-mult {
    top: 56px;
    font-size: 12px;
    padding: 4px 8px;
  }
  #hud-score { left: 8px; }
  #hud-mult { right: 8px; }
  #hud-best { top: 8px; left: 50%; transform: translateX(-50%); }
  #mute { top: 66px; right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .flicker,
  .pulse,
  .glitch,
  #fx::after {
    animation: none;
  }
}

/* ---------- Polish pass: HUD bar, type scale, tap sizes ---------- */

#hud {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 64px;
  z-index: 10;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

#hud .hud-block {
  position: static;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  background: rgba(13, 2, 33, 0.6);
  border: 2px solid #05d9e8;
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(5, 217, 232, 0.5), inset 0 0 8px rgba(5, 217, 232, 0.2);
}

#hud .hud-block.hud-right { align-items: center; }

#hud .hud-label {
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.14em;
  color: #ffffff;
  opacity: 0.85;
  white-space: nowrap;
}

#hud #hud-score,
#hud #hud-best,
#hud #hud-mult {
  position: static;
  transform: none;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
  font-size: clamp(14px, 4vw, 22px);
  line-height: 1.2;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

#hud #hud-score { color: #ffffff; text-shadow: 0 0 6px #ff2a6d, 0 0 12px #ff2a6d; }
#hud #hud-best { color: #ff9e00; text-shadow: 0 0 6px #ff9e00; }
#hud #hud-mult { color: #ff5ce0; text-shadow: 0 0 6px #d300c5, 0 0 12px #d300c5; }

#mute {
  font-size: 13px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 10px;
  color: #ffffff;
}

#title h1 { font-size: clamp(40px, 12vw, 120px); }

#title .subtitle,
#title .controls,
#title .best-line,
#title .hint,
#over .hint,
#over .final-label {
  max-width: 92vw;
  line-height: 1.6;
  letter-spacing: 0.12em;
  color: #ffffff;
  opacity: 0.9;
}

#over .final-label { color: #05d9e8; opacity: 1; }

#start,
#restart {
  min-height: 52px;
  padding: 14px 36px;
  color: #ffffff;
  background: rgba(211, 0, 197, 0.35);
}

#title, #over {
  padding: 16px 16px 24px;
}

@media (max-width: 600px) {
  #hud { top: 8px; left: 8px; right: 60px; gap: 6px; }
  #hud .hud-block { padding: 4px 4px; }
  #hud .hud-label { font-size: 9px; letter-spacing: 0.08em; }
  #hud #hud-score,
  #hud #hud-best,
  #hud #hud-mult { font-size: 14px; }
  #mute { top: 66px; right: 8px; }
}
