/* VOLTLINE — retro neon circuit dash. No external dependencies. */

:root {
  --bg: #05070f;
  --panel: #0b1022;
  --ink: #cfe8ff;
  --dim: #6f87ad;
  --cyan: #35f0ff;
  --gold: #ffd23f;
  --magenta: #ff4dd8;
  --red: #ff4757;
  --font: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* Stage keeps the 4:7 logical aspect, letterboxed inside the viewport. */
#stage {
  position: relative;
  height: 100dvh;
  width: min(100vw, calc(100dvh * 4 / 7));
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

@supports not (height: 100dvh) {
  #stage { height: 100vh; width: min(100vw, calc(100vh * 4 / 7)); }
}

canvas { display: block; width: 100%; height: 100%; }

/* CRT scanlines + subtle vignette. Static under reduced motion. */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg,
      rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 1px,
      transparent 1px, transparent 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 10, 0.45) 100%);
  z-index: 5;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 0;
  z-index: 10;
  pointer-events: none;
}

/* Scrim so scrolling entities stay readable under the HUD text. */
#stage::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 64px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 7, 15, 0.9), rgba(5, 7, 15, 0));
  z-index: 6;
}


.hud-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 52px;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.hud-value {
  font-size: 20px;
  font-weight: bold;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(53, 240, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

#best { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, 0.5); }

.hud-combo { opacity: 0; transition: opacity 150ms linear; }
.hud-combo.on { opacity: 1; }
.hud-combo .hud-value { color: var(--magenta); text-shadow: 0 0 8px rgba(255, 77, 216, 0.55); }

.hud-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-actions button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(111, 135, 173, 0.5);
  border-radius: 6px;
  background: rgba(11, 16, 34, 0.75);
  color: var(--dim);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.hud-actions button:hover { color: var(--cyan); border-color: var(--cyan); }
.hud-actions button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.hud-actions button[aria-pressed="true"] { color: var(--gold); }

/* Shield indicator pip */
#shieldPip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 46px);
  left: 10px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--magenta);
  box-shadow: 0 0 10px var(--magenta);
  opacity: 0;
  transition: opacity 120ms linear;
  z-index: 10;
}
#shieldPip.on { opacity: 1; }

/* ---------- Overlay screens ---------- */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 7, 15, 0.82);
  backdrop-filter: blur(2px);
}
#overlay.show { display: flex; }

#ovTitle {
  font-size: clamp(30px, 11vw, 44px);
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(53, 240, 255, 0.7), 0 0 40px rgba(53, 240, 255, 0.35);
}

#ovTag {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--dim);
}

#ovBody {
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink);
  max-width: 300px;
}

#ovBody .k {
  display: inline-block;
  border: 1px solid var(--dim);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 2px;
  font-size: 11px;
  color: var(--cyan);
}

#ovBody .bit { color: var(--gold); }
#ovBody .wall { color: var(--red); }
#ovBody .core { color: var(--magenta); }

#ovScore {
  font-size: 34px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 210, 63, 0.6);
}

#ovNewBest {
  color: var(--magenta);
  letter-spacing: 3px;
  font-weight: bold;
  animation: pulse 900ms ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.35; } }

#ovBtn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--cyan);
  border: 0;
  border-radius: 8px;
  padding: 12px 34px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(53, 240, 255, 0.5);
}
#ovBtn:hover { filter: brightness(1.12); }
#ovBtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#ovHint { font-size: 11px; color: var(--dim); letter-spacing: 1px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #ovNewBest { animation: none; }
  .hud-combo, #shieldPip { transition: none; }
  #stage::after {
    /* Drop the vignette gradient layering flicker source; keep static lines only */
    background: repeating-linear-gradient(0deg,
      rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px,
      transparent 1px, transparent 4px);
  }
}
