/* ==========================================================
   NEAR MISS — style.css
   Theme overrides + HUD / popup / overlay styling
   ========================================================== */

/* ---------- Theme overrides (ui.css variables) ---------- */
:root {
  --accent: #ff7a1a;            /* warm orange accent */
  --accent-2: #ff9a4a;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --bg: #0a0a16;

  --bg-2: #12121f;
  --surface: rgba(18, 18, 32, 0.88);
  --text: #f0eef5;
  --muted: #8a87a0;
  --radius: 14px;
}

.hidden {
  display: none !important;
}

/* ---------- Stage: full-viewport 3D canvas ---------- */
#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: var(--bg);
  overflow: hidden;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD top bar ---------- */
#hud,
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 0;
  pointer-events: none;
}

/* Subtle dark gradient behind the HUD for readability */
#hud::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.15) 60%,
    transparent 100%
  );
  pointer-events: none;
}

/* ---------- Score: big, centered, glowing ---------- */
#score {
  font-family: var(--display);
  font-size: clamp(2.1rem, 7vw, 4.2rem);
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.02em;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  text-shadow:
    0 0 18px rgba(255, 122, 26, 0.55),
    0 0 44px rgba(255, 122, 26, 0.25),
    0 2px 6px rgba(0, 0, 0, 0.6);
}

/* ---------- Best: top-right ---------- */
#best {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  position: absolute;
  top: 14px;
  right: 20px;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.55);
}

#best .best-label {
  opacity: 0.7;
  margin-right: 5px;
  font-size: 0.88em;
}

/* ---------- Speed: tiny, under best ---------- */
#speed {
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: absolute;
  top: 48px;
  right: 20px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  opacity: 0.85;
}

/* ==========================================================
   NEAR-MISS POPUP
   ========================================================== */
#popup {
  position: fixed;
  top: 38%;
  left: 50%;
  z-index: 30;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 6vw, 3.6rem);
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  white-space: nowrap;
  line-height: 1.15;
  text-shadow:
    0 0 24px rgba(255, 122, 26, 0.75),
    0 0 60px rgba(255, 122, 26, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.65);
  will-change: transform, opacity;
}

/* Combo / streak line inside the popup */
#popup .combo {
  font-family: var(--display);
  font-size: 0.48em;
  font-weight: 600;
  color: #ffffff;
  display: block;
  margin-top: 6px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow:
    0 0 14px rgba(255, 122, 26, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Pop animation: scale 0.6 → 1, then fade + drift up over 1s */
#popup.show {
  animation: popup-pop 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes popup-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  28% {
    transform: translate(-50%, -50%) scale(1.08);
  }
  48% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.1) translateY(-38px);
    opacity: 0;
  }
}

/* ==========================================================
   OVERLAYS  (ui .overlay > .panel)
   ========================================================== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(5, 5, 14, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.overlay[hidden] {
  display: none;
}

.overlay .panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
  max-width: 460px;
  width: min(92vw, 460px);
  box-shadow:
    0 16px 56px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Title */
.overlay .panel h1 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 10vw, 4.2rem);
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, var(--accent) 0%, #ffb060 55%, #ffd9a0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* Pitch line */
.overlay .panel .pitch {
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}

/* Controls hint */
.overlay .panel .controls-hint {
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--muted);
  opacity: 0.85;
  margin: 0 0 14px;
  line-height: 1.7;
}

.overlay .panel .controls-hint kbd {
  font-family: var(--font);
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------- Buttons ---------- */
.overlay .panel .btn {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  padding: 13px 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 26px rgba(255, 122, 26, 0.32);
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.overlay .panel .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 36px rgba(255, 122, 26, 0.5);
  filter: brightness(1.08);
}

.overlay .panel .btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 14px rgba(255, 122, 26, 0.3);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Menu-specific ---------- */
#menu .menu-best {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 18px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 14px rgba(255, 122, 26, 0.3);
}

#menu .menu-best::before {
  content: '🏆 ';
  font-size: 0.9em;
}

/* ---------- Game-over-specific ---------- */
#over .panel .final-stats {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 5vw, 40px);
  margin: 24px 0 16px;
}

#over .panel .final-stats .stat {
  text-align: center;
  min-width: 64px;
}

#over .panel .final-stats .stat b {
  font-family: var(--display);
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 700;
  color: #ffffff;
  display: block;
  line-height: 1;
  text-shadow: 0 0 14px rgba(255, 122, 26, 0.35);
}

#over .panel .final-stats .stat span {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 6px;
  display: block;
}

#new-best {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 8px;
  text-shadow: 0 0 18px rgba(255, 122, 26, 0.6);
  letter-spacing: 0.05em;
  animation: best-pulse 1.5s ease-in-out infinite;
}

@keyframes best-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.65;
    transform: scale(1.05);
  }
}

#over .final-best-line {
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0 0;
}

/* ==========================================================
   RESPONSIVE TWEAKS
   ========================================================== */
@media (max-width: 520px) {
  #score {
    top: 10px;
    font-size: clamp(1.8rem, 8vw, 3rem);
  }

  #best {
    top: 10px;
    right: 14px;
    font-size: 0.9rem;
  }

  #speed {
    top: 40px;
    right: 14px;
    font-size: 0.68rem;
  }

  #popup {
    top: 40%;
  }

  .overlay .panel {
    padding: 26px 20px;
  }
}
