:root {
  --neon-green: #39ff14;
  --neon-pink: #ff2bd6;
  --neon-cyan: #2bf7ff;
  --neon-yellow: #fff733;
  --bg: #0b0014;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Press Start 2P', monospace;
  color: var(--neon-green);
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

/* Retro CRT scanline + grid overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.035) 0px,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: overlay;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    linear-gradient(rgba(57, 255, 20, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 255, 20, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
}

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  pointer-events: none;
  text-shadow: 0 0 6px currentColor;
}

.hud-title {
  font-size: 22px;
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink), 0 0 16px var(--neon-pink);
  letter-spacing: 2px;
}

.hud-sub {
  margin-top: 8px;
  font-size: 9px;
  color: var(--neon-cyan);
  opacity: 0.8;
}

.hud-stats {
  margin-top: 14px;
  font-size: 10px;
  display: flex;
  gap: 18px;
  color: var(--neon-yellow);
}

.hud-stats b {
  color: #fff;
}

.hud-arcade {
  margin-top: 10px;
  font-size: 10px;
  display: flex;
  gap: 18px;
  color: var(--neon-cyan);
}

.hud-arcade b {
  color: #fff;
}

#comboWrap, #rushWrap {
  color: var(--neon-pink);
  animation: comboPulse 0.5s ease-in-out infinite alternate;
}

#comboWrap.hidden, #rushWrap.hidden {
  display: none;
}

#rushWrap {
  color: var(--neon-yellow);
}

@keyframes comboPulse {
  from { text-shadow: 0 0 6px currentColor; }
  to { text-shadow: 0 0 16px currentColor, 0 0 24px currentColor; }
}

/* Rush mode: whole screen pulses with a neon border flash */
body.rush-active::before {
  animation: rushFlash 0.6s ease-in-out infinite alternate;
}

@keyframes rushFlash {
  from { box-shadow: none; }
  to { box-shadow: inset 0 0 120px rgba(255, 247, 51, 0.35); }
}

#challengeBanner {
  position: fixed;
  top: 190px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 190;
  max-width: min(90vw, 480px);
  background: #14001f;
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 20px rgba(255, 247, 51, 0.5);
  padding: 10px 16px;
  font-size: 10px;
  color: var(--neon-yellow);
  text-shadow: 0 0 6px var(--neon-yellow);
  text-align: center;
  cursor: default;
  animation: slideDown 0.35s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

#challengeBanner.hidden {
  display: none;
}

#targetZone {
  position: fixed;
  border: 2px dashed var(--neon-cyan);
  background: rgba(43, 247, 255, 0.06);
  box-shadow: 0 0 16px rgba(43, 247, 255, 0.5), inset 0 0 16px rgba(43, 247, 255, 0.2);
  z-index: 12;
  pointer-events: none;
  animation: targetPulse 1s ease-in-out infinite alternate;
}

#targetZone.hidden {
  display: none;
}

#targetZone::after {
  content: "TARGET";
  position: absolute;
  top: -20px;
  left: 0;
  font-size: 9px;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
}

@keyframes targetPulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

#leaderboardToggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  font-family: inherit;
  font-size: 10px;
  background: transparent;
  color: var(--neon-cyan);
  border: 2px solid var(--neon-cyan);
  padding: 10px 14px;
  cursor: pointer;
  text-shadow: 0 0 6px var(--neon-cyan);
  box-shadow: 0 0 10px rgba(43, 247, 255, 0.4);
}

#leaderboardToggle:hover {
  background: rgba(43, 247, 255, 0.15);
}

#shopToggle {
  position: fixed;
  top: 16px;
  right: 160px;
  z-index: 30;
  font-family: inherit;
  font-size: 10px;
  background: transparent;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  padding: 10px 14px;
  cursor: pointer;
  text-shadow: 0 0 6px var(--neon-yellow);
  box-shadow: 0 0 10px rgba(255, 247, 51, 0.4);
}

#shopToggle:hover {
  background: rgba(255, 247, 51, 0.15);
}

#modeToggles {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.mode-toggles-label {
  font-size: 7px;
  color: var(--neon-cyan);
  opacity: 0.7;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.mode-toggle {
  font-family: inherit;
  font-size: 8px;
  background: transparent;
  color: var(--neon-pink);
  border: 2px solid var(--neon-pink);
  padding: 7px 10px;
  cursor: pointer;
  opacity: 0.6;
  text-shadow: 0 0 4px var(--neon-pink);
  transition: opacity 0.15s ease;
}

.mode-toggle:hover {
  opacity: 0.9;
}

.mode-toggle.active {
  opacity: 1;
  background: rgba(255, 43, 214, 0.18);
  box-shadow: 0 0 12px rgba(255, 43, 214, 0.6);
}

#leaderboardPanel {
  position: fixed;
  top: 230px;
  right: 16px;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(10, 0, 20, 0.92);
  border: 2px solid var(--neon-pink);
  box-shadow: 0 0 20px rgba(255, 43, 214, 0.5);
  padding: 16px;
  z-index: 40;
  cursor: default;
}

#leaderboardPanel.hidden {
  display: none;
}

#leaderboardPanel h2 {
  font-size: 14px;
  color: var(--neon-pink);
  margin: 0 0 12px 0;
  text-shadow: 0 0 6px var(--neon-pink);
}

#leaderboardList {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 10px;
  line-height: 1.9;
  color: var(--neon-green);
}

#leaderboardList li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px dashed rgba(57, 255, 20, 0.25);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

#leaderboardList .rank {
  color: var(--neon-yellow);
  width: 20px;
  flex: none;
}

#leaderboardList .lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#closeLeaderboard {
  margin-top: 12px;
  width: 100%;
  font-family: inherit;
  font-size: 10px;
  background: transparent;
  color: var(--neon-pink);
  border: 2px solid var(--neon-pink);
  padding: 8px;
  cursor: pointer;
}

#shopPanel {
  position: fixed;
  top: 230px;
  right: 16px;
  width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(10, 0, 20, 0.94);
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 20px rgba(255, 247, 51, 0.5);
  padding: 16px;
  z-index: 41;
  cursor: default;
}

#shopPanel.hidden {
  display: none;
}

#shopPanel h2 {
  font-size: 14px;
  color: var(--neon-yellow);
  margin: 0 0 12px 0;
  text-shadow: 0 0 6px var(--neon-yellow);
}

.shop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.shop-tab {
  flex: 1;
  font-family: inherit;
  font-size: 9px;
  background: transparent;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  padding: 8px 4px;
  cursor: pointer;
  opacity: 0.6;
}

.shop-tab.active {
  opacity: 1;
  background: rgba(255, 247, 51, 0.15);
}

.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 9px;
  color: var(--neon-green);
}

.shop-list.hidden {
  display: none;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px dashed rgba(255, 247, 51, 0.25);
  padding: 8px 0;
}

.shop-item-info {
  flex: 1;
  min-width: 0;
}

.shop-item-name {
  color: #fff;
  font-size: 9px;
  margin-bottom: 4px;
}

.shop-item-level {
  color: var(--neon-cyan);
  font-size: 8px;
}

.shop-item-desc {
  font-size: 8px;
  color: var(--neon-cyan);
  opacity: 0.8;
  line-height: 1.5;
}

.shop-buy-btn {
  flex: none;
  font-family: inherit;
  font-size: 8px;
  background: transparent;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  padding: 8px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.shop-buy-btn:hover:not(:disabled) {
  background: rgba(255, 247, 51, 0.15);
}

.shop-buy-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

#closeShop {
  margin-top: 12px;
  width: 100%;
  font-family: inherit;
  font-size: 10px;
  background: transparent;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  padding: 8px;
  cursor: pointer;
}

#selectionBox {
  position: fixed;
  border: 2px solid var(--neon-yellow);
  background: rgba(255, 247, 51, 0.08);
  box-shadow: 0 0 14px var(--neon-yellow), inset 0 0 14px rgba(255, 247, 51, 0.25);
  display: none;
  z-index: 15;
  pointer-events: none;
}

/* Blackout mode: the drag box goes invisible so you're drawing blind,
   leaving only a faint crosshair dot at the drag origin. */
body.mode-blackout #selectionBox {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

body.mode-blackout #selectionBox::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-yellow);
  box-shadow: 0 0 8px var(--neon-yellow);
}

#mirrorBox {
  position: fixed;
  border: 2px dashed var(--neon-cyan);
  background: rgba(43, 247, 255, 0.05);
  box-shadow: 0 0 10px var(--neon-cyan);
  display: none;
  z-index: 14;
  pointer-events: none;
}

/* Chaos mode: a brief invert + shake punches the screen after every score. */
body.chaos-pulse {
  animation: chaosShake 0.4s ease-in-out;
}

body.chaos-pulse::before {
  animation: chaosInvert 0.4s ease-in-out;
}

@keyframes chaosShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px) rotate(-0.5deg); }
  40% { transform: translate(5px, -5px) rotate(0.5deg); }
  60% { transform: translate(-4px, -3px) rotate(-0.3deg); }
  80% { transform: translate(6px, 3px) rotate(0.3deg); }
}

@keyframes chaosInvert {
  0%, 100% { filter: none; }
  50% { filter: invert(1) hue-rotate(180deg); }
}

/* Grid Snap mode: brighten the background grid to reflect that drags snap to it. */
body.mode-gridsnap::after {
  background-image:
    linear-gradient(rgba(255, 247, 51, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 247, 51, 0.18) 1px, transparent 1px);
}

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

.score-pop {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.2);
  font-size: 34px;
  font-weight: normal;
  white-space: nowrap;
  opacity: 0;
  text-shadow:
    0 0 6px currentColor,
    0 0 16px currentColor,
    0 0 32px currentColor,
    3px 3px 0 rgba(0, 0, 0, 0.6);
  animation: popScore 1.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.score-pop .rating {
  display: block;
  font-size: 0.38em;
  margin-top: 10px;
  letter-spacing: 2px;
}

.score-pop .shape-callout {
  display: block;
  font-size: 0.3em;
  margin-top: 8px;
  letter-spacing: 1.5px;
  animation: shapeFlicker 0.6s steps(2, jump-none) 3;
}

.score-pop .bonus-callout {
  display: block;
  font-size: 0.32em;
  margin-top: 8px;
  letter-spacing: 1.5px;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow), 0 0 16px var(--neon-yellow);
}

.score-pop .shard-callout {
  display: block;
  font-size: 0.3em;
  margin-top: 6px;
  letter-spacing: 1px;
  color: var(--neon-yellow);
}

.shard-pop {
  font-size: 18px !important;
}

@keyframes shapeFlicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes popScore {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1) rotate(-6deg);
  }
  8% {
    opacity: 1;
  }
  12% {
    transform: translate(-50%, -50%) scale(1.5) rotate(4deg);
  }
  20% {
    transform: translate(-50%, -50%) scale(0.85) rotate(-2deg);
  }
  28% {
    transform: translate(-50%, -50%) scale(1.15) rotate(1deg);
  }
  38% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  46% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -65%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -130%) scale(0.9) rotate(0deg);
  }
}

#loginBanner {
  position: fixed;
  top: 130px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(90vw, 520px);
  background: #14001f;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 20px rgba(43, 247, 255, 0.6);
  padding: 12px 18px;
  cursor: default;
  animation: slideDown 0.35s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

#loginBanner.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -40px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

#loginBannerText {
  font-size: 10px;
  color: var(--neon-yellow);
  text-shadow: 0 0 6px var(--neon-yellow);
  white-space: normal;
  flex: 1;
  min-width: 0;
}

#loginBannerBtn {
  font-family: inherit;
  font-size: 9px;
  background: transparent;
  color: var(--neon-green);
  border: 2px solid var(--neon-green);
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

#loginBannerBtn:hover {
  background: rgba(57, 255, 20, 0.15);
}

#loginBannerDismiss {
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  background: transparent;
  color: var(--neon-pink);
  border: none;
  cursor: pointer;
  padding: 0 4px;
}

/* ============================================================
   SHOP COSMETICS — background themes & color themes
   ============================================================ */

/* Background themes: layered onto body::before/after via extra background-image
   so the retro scanline/grid overlays are preserved regardless of theme. */
body.bg-sunset {
  background: linear-gradient(180deg, #1a0033 0%, #3a0d5c 40%, #a3195b 75%, #ff6b35 100%);
}

body.bg-matrix {
  background: #000502;
}

body.bg-matrix::after {
  background-image:
    linear-gradient(rgba(0, 255, 70, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 70, 0.12) 1px, transparent 1px);
}

body.bg-vapor {
  background: linear-gradient(180deg, #1b0b34 0%, #4b1668 55%, #ff71ce 100%);
}

body.bg-vapor::after {
  background-image:
    linear-gradient(rgba(255, 113, 206, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(1, 205, 254, 0.14) 1px, transparent 1px);
}

body.bg-city {
  background: linear-gradient(180deg, #050014 0%, #0c0a2e 45%, #1d0f4a 75%, #3a0ca3 100%);
}

body.bg-city::after {
  background-image:
    linear-gradient(rgba(255, 0, 200, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 225, 255, 0.1) 1px, transparent 1px);
  background-size: 60px 60px;
}

body.bg-space {
  background:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 60% 70%, #fff, transparent),
    radial-gradient(2px 2px at 80% 20%, #fff, transparent),
    radial-gradient(1px 1px at 40% 85%, #fff, transparent),
    radial-gradient(1px 1px at 90% 55%, #fff, transparent),
    linear-gradient(180deg, #000005 0%, #050014 50%, #0a0022 100%);
}

body.bg-space::after {
  background-image: none;
}

/* Color themes: override the neon accent variables used across the HUD. */
body.theme-ice {
  --neon-green: #6ad4ff;
  --neon-pink: #b4e1ff;
  --neon-cyan: #2bf7ff;
  --neon-yellow: #d8f7ff;
}

body.theme-gold {
  --neon-green: #ffd700;
  --neon-pink: #ffb347;
  --neon-cyan: #fff2b3;
  --neon-yellow: #ffea00;
}

body.theme-blood {
  --neon-green: #ff2b3d;
  --neon-pink: #ff0844;
  --neon-cyan: #ff6b6b;
  --neon-yellow: #ff9d2b;
}

body.theme-toxic {
  --neon-green: #b6ff00;
  --neon-pink: #d400ff;
  --neon-cyan: #9d4edd;
  --neon-yellow: #e0ff4f;
}

body.theme-cyber {
  --neon-green: #00fff2;
  --neon-pink: #ff003c;
  --neon-cyan: #00b8ff;
  --neon-yellow: #f9f871;
}

/* Exclusive real-money-only cosmetics (Stripe store) */
body.bg-hologram {
  background: linear-gradient(160deg, #050014 0%, #0a0030 45%, #001a2e 100%);
  background-size: 200% 200%;
  animation: hologramShift 8s ease-in-out infinite;
}

@keyframes hologramShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

body.bg-hologram::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 255, 242, 0.06) 0px,
    rgba(0, 255, 242, 0.06) 1px,
    transparent 1px,
    transparent 4px
  );
  z-index: -1;
}

body.theme-hologram {
  --neon-green: #00fff2;
  --neon-pink: #d400ff;
  --neon-cyan: #00b8ff;
  --neon-yellow: #ffffff;
}

/* ============================================================
   MONETIZATION UI — account bar, login modal, ad modal, store note
   ============================================================ */

#accountBar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 70vw;
}

#accountStatus {
  color: var(--neon-cyan);
  opacity: 0.85;
  white-space: nowrap;
}

#accountLoginBtn,
#accountLogoutBtn,
#watchAdBtn {
  font-family: inherit;
  font-size: 8px;
  background: transparent;
  color: var(--neon-green);
  border: 2px solid var(--neon-green);
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

#watchAdBtn {
  color: var(--neon-yellow);
  border-color: var(--neon-yellow);
}

#accountLoginBtn:hover,
#accountLogoutBtn:hover,
#watchAdBtn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#accountLoginBtn.hidden,
#accountLogoutBtn.hidden {
  display: none;
}

#loginModal,
#adModal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

#loginModal.hidden,
#adModal.hidden {
  display: none;
}

#loginModalBox {
  background: #0a0018;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 30px rgba(43, 247, 255, 0.5);
  padding: 24px;
  width: min(90vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#loginModalBox h2 {
  font-size: 12px;
  color: var(--neon-yellow);
  margin: 0 0 4px;
}

.login-modal-sub {
  font-size: 8px;
  color: var(--neon-cyan);
  opacity: 0.8;
  margin: 0 0 8px;
  line-height: 1.5;
}

#loginModalBox input {
  font-family: inherit;
  font-size: 10px;
  background: #000;
  color: var(--neon-green);
  border: 2px solid var(--neon-green);
  padding: 10px;
  outline: none;
}

#loginModalError {
  font-size: 8px;
  color: var(--neon-pink);
  line-height: 1.5;
}

#loginModalError.hidden {
  display: none;
}

.login-modal-actions {
  display: flex;
  gap: 8px;
}

#loginSubmitBtn,
#signupSubmitBtn {
  flex: 1;
  font-family: inherit;
  font-size: 9px;
  background: transparent;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  padding: 10px;
  cursor: pointer;
}

#closeLoginModal {
  font-family: inherit;
  font-size: 8px;
  background: transparent;
  color: var(--neon-pink);
  border: 2px solid var(--neon-pink);
  padding: 8px;
  cursor: pointer;
}

#adModalBox {
  background: #0a0018;
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 40px rgba(255, 247, 51, 0.6);
  padding: 40px 60px;
  text-align: center;
}

#adModalLabel {
  font-size: 12px;
  color: var(--neon-pink);
  margin-bottom: 16px;
}

#adModalCountdown {
  font-size: 40px;
  color: var(--neon-yellow);
  text-shadow: 0 0 20px var(--neon-yellow);
}

#adModalSub {
  font-size: 7px;
  color: var(--neon-cyan);
  opacity: 0.6;
  margin-top: 14px;
}

.shop-item-note {
  font-size: 8px;
  color: var(--neon-pink);
  text-align: center;
  padding: 10px 0;
  list-style: none;
}
