/* =========================================================
   VECTRUN — design tokens
   Palette: near-black void, electric cyan primary, violet
   secondary, amber for warnings/danger. Display face Orbitron
   (technical, geometric), body/UI face Rajdhani, data face Inter.
   ========================================================= */
:root {
  --void-900: #05060a;
  --void-800: #0a0d14;
  --void-700: #10141d;
  --void-600: #1a2130;
  --line-soft: rgba(140, 170, 220, 0.14);

  --cyan: #35f0ff;
  --cyan-dim: #14a3b8;
  --violet: #8b6bff;
  --amber: #ffb020;
  --danger: #ff3b5c;
  --success: #3dffb0;

  --text-hi: #eef3fb;
  --text-mid: #9aa8bf;
  --text-lo: #5c6b84;

  --font-display: 'Orbitron', sans-serif;
  --font-ui: 'Rajdhani', sans-serif;
  --font-data: 'Inter', sans-serif;

  --glass-bg: rgba(12, 16, 24, 0.55);
  --glass-border: rgba(120, 200, 255, 0.18);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--void-900);
  color: var(--text-hi);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: radial-gradient(ellipse at 50% 30%, #0d1420 0%, #05060a 70%);
}

/* subtle vignette + scanline for a cinematic camera feel, sits above canvas */
#screen-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 2px, transparent 3px);
  mix-blend-mode: normal;
}

.hidden { display: none !important; }

/* =========================================================
   Shared button styles
   ========================================================= */
.btn {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 16px;
  padding: 15px 34px;
  border-radius: 4px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  background: transparent;
  color: var(--text-hi);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, rgba(53,240,255,0.18), rgba(53,240,255,0.05));
  border-color: rgba(53,240,255,0.55);
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(53,240,255,0.25), inset 0 0 20px rgba(53,240,255,0.06);
}
.btn-primary:hover {
  box-shadow: 0 0 30px rgba(53,240,255,0.45), inset 0 0 20px rgba(53,240,255,0.1);
  background: linear-gradient(180deg, rgba(53,240,255,0.26), rgba(53,240,255,0.08));
}
.btn-glyph { margin-right: 8px; }

.btn-ghost {
  background: rgba(139,107,255,0.08);
  border-color: rgba(139,107,255,0.4);
  color: var(--violet);
  font-size: 14px;
  padding: 14px 22px;
}
.btn-ghost:hover { background: rgba(139,107,255,0.16); }

/* =========================================================
   Generic full-screen overlay scaffolding
   ========================================================= */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 20%, rgba(20,40,60,0.35), rgba(4,5,8,0.92) 70%);
}

/* =========================================================
   START SCREEN
   ========================================================= */
.grid-horizon {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 55%;
  background-image:
    linear-gradient(rgba(53,240,255,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53,240,255,0.12) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(400px) rotateX(72deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  opacity: 0.8;
  animation: horizonScroll 3s linear infinite;
}
@keyframes horizonScroll {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 60px, 0 0; }
}

.start-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 1s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand-eyebrow {
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: var(--text-lo);
  margin-bottom: 18px;
}

.brand-logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(48px, 11vw, 108px);
  line-height: 1;
  margin: 0;
  letter-spacing: 0.03em;
  color: var(--text-hi);
  text-shadow: 0 0 40px rgba(53,240,255,0.25);
}
.brand-logo .accent {
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(53,240,255,0.85), 0 0 60px rgba(53,240,255,0.4);
}

.brand-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(13px, 2.4vw, 18px);
  letter-spacing: 0.55em;
  color: var(--violet);
  margin: 18px 0 6px 4px;
  text-shadow: 0 0 20px rgba(139,107,255,0.5);
}

.brand-line {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(14px, 2.2vw, 18px);
  color: var(--text-mid);
  margin: 4px 0 34px;
}

#start-btn { margin-bottom: 40px; font-size: clamp(14px, 2vw, 17px); }

.controls-hint {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  justify-content: center;
}
.controls-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 190px;
}
.controls-title {
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--text-lo);
  margin-bottom: 4px;
  text-align: left;
}
.key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-mid);
}
.key-row span { text-align: left; }
kbd {
  font-family: var(--font-data);
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line-soft);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 3px 7px;
  color: var(--text-hi);
  min-width: 18px;
  text-align: center;
}

.start-footer {
  position: absolute;
  bottom: 18px;
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--text-lo);
  z-index: 2;
}

/* =========================================================
   HUD — glassmorphism gaming HUD
   ========================================================= */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  gap: 12px;
}
.hud-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}
.hud-label {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-lo);
}
.hud-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(53,240,255,0.5);
}
.hud-coins .hud-value { color: var(--amber); text-shadow: 0 0 14px rgba(255,176,32,0.55); }

.hud-level {
  align-items: center;
  min-width: 220px;
  flex: 1;
  max-width: 340px;
}
#level-label {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-hi);
  margin-bottom: 6px;
}
#level-pct { color: var(--cyan); }
.progress-track {
  position: relative;
  width: 100%;
  height: 7px;
  background: rgba(255,255,255,0.06);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  border-radius: 5px;
  transition: width 0.4s ease;
}
.progress-glow {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 14px;
  left: 0%;
  background: radial-gradient(circle, rgba(53,240,255,0.9), transparent 70%);
  filter: blur(2px);
  transition: left 0.4s ease;
}

#speed-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(53,240,255,0.06) 100%);
  transition: opacity 0.3s ease;
}
#speed-fx.active { opacity: 1; }

#phase-banner {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(14px, 2.4vw, 20px);
  letter-spacing: 0.3em;
  color: var(--text-hi);
  text-shadow: 0 0 20px rgba(53,240,255,0.6);
  padding: 8px 22px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  animation: bannerPulse 1.8s ease forwards;
}
@keyframes bannerPulse {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* =========================================================
   Overlay panels — Game Over / Level Complete
   ========================================================= */
.panel-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 40px 44px;
  max-width: 440px;
  width: 100%;
  animation: popIn 0.5s cubic-bezier(.2,.9,.25,1) both;
}
.overlay-panel-wide { max-width: 560px; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.status-tag {
  display: inline-block;
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: 0.3em;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 18px;
}
.status-danger { background: rgba(255,59,92,0.12); color: var(--danger); border: 1px solid rgba(255,59,92,0.4); }
.status-success { background: rgba(61,255,176,0.12); color: var(--success); border: 1px solid rgba(61,255,176,0.4); }

.overlay-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(30px, 6vw, 44px);
  margin: 0 0 20px;
  letter-spacing: 0.05em;
}
#gameover-screen .overlay-title { color: var(--danger); text-shadow: 0 0 30px rgba(255,59,92,0.4); }
#levelcomplete-screen .overlay-title { color: var(--success); text-shadow: 0 0 30px rgba(61,255,176,0.4); }

.overlay-copy {
  color: var(--text-mid);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.overlay-highlight {
  font-family: var(--font-display);
  font-size: clamp(13px, 2.4vw, 16px);
  letter-spacing: 0.18em;
  color: var(--violet);
  text-shadow: 0 0 18px rgba(139,107,255,0.5);
  margin-bottom: 26px;
}

.stat-grid {
  display: flex;
  gap: 12px;
  margin: 22px 0 30px;
}
.stat-box {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-lo);
}
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--text-hi);
}

.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.cd-unit { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.cd-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(24px, 5vw, 34px);
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(53,240,255,0.5);
  font-variant-numeric: tabular-nums;
}
.cd-unit-label {
  font-family: var(--font-data);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-lo);
  margin-top: 2px;
}
.cd-sep {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-lo);
  transform: translateY(-8px);
}

.notify-form {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.notify-form input[type="email"] {
  flex: 1;
  min-width: 180px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 13px 16px;
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
}
.notify-form input[type="email"]:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(53,240,255,0.15); }
.notify-msg {
  min-height: 18px;
  font-size: 13px;
  color: var(--success);
  margin: 6px 0 20px;
}

#playagain-btn { margin-top: 6px; }

#confetti-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 720px) {
  .hud-panel { padding: 6px 12px; }
  .hud-value { font-size: 17px; }
  .hud-level { max-width: 46vw; min-width: 120px; }
  #level-label { font-size: 10px; }
  .controls-hint { gap: 26px; }
  .controls-col { min-width: 150px; }
  .panel-glass { padding: 28px 22px; }
  .stat-grid { flex-direction: row; }
  .cd-unit { min-width: 44px; }
}

@media (max-width: 420px) {
  .brand-eyebrow { font-size: 9px; letter-spacing: 0.3em; }
  .controls-hint { gap: 18px; }
  .stat-value { font-size: 17px; }
}

@media (max-height: 480px) {
  .brand-logo { font-size: 40px; }
  .controls-hint { display: none; }
  .start-footer { display: none; }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .grid-horizon { animation: none; }
  .start-content { animation: none; }
  .panel-glass { animation: none; }
}
