:root {
  --bg: #050712;
  --bg-alt: #0b1020;
  --accent: #4af2c5;
  --accent2: #ff4fd8;
  --accent3: #ffc857;
  --text: #f5f7ff;
  --grid-border: #1b2238;
  --shadow-strong: 0 0 30px rgba(74, 242, 197, 0.4);
  --shadow-soft: 0 0 20px rgba(255, 79, 216, 0.3);
}

/* GLOBAL RESET + FONT */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
#game-wrapper,
#game-header,
#game-footer,
.hud-block,
.overlay,
.combo-popup {
  font-family: Verdana, sans-serif;
  font-size: 24px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #151a33 0, #050712 55%, #02030a 100%);
  color: var(--text);
}

/* ANIMATED NEON BACKGROUND GRID */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(74,242,197,0.15) 1px, transparent 1px),
    linear-gradient(0deg, rgba(74,242,197,0.15) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridScroll 18s linear infinite;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,79,216,0.15), transparent 70%);
  mix-blend-mode: screen;
  z-index: -1;
}

@keyframes gridScroll {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 120px 120px, 120px 120px; }
}


/* WRAPPER */
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ============================= */
/* HEADER (Right Side)           */
/* ============================= */
#game-header {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: right;
  z-index: 9999;

  /* Unified neon theme */
  animation: neonPulse 3s ease-in-out infinite alternate,
             slideGlow 4s linear infinite;
}

#game-header h1 {
  margin: 0;
  font-size: 32px;
  color: var(--accent);
  text-shadow: var(--shadow-strong);
}

/* HUD */
#hud {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-block {
  background: linear-gradient(135deg, #11162a, #1b2238);
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(74, 242, 197, 0.25);
}

.hud-block .label {
  opacity: 0.7;
  margin-right: 4px;
}

.hud-block span:last-child {
  font-weight: 600;
}

.hud-block.hud-left.glow,
.hud-block.hud-right.glow {
  animation: hudPulse 0.4s ease-out;
}

/* ============================= */
/* CANVAS + GAME AREA            */
/* ============================= */
#canvas-container {
  position: relative;
  padding: 10px;
  border-radius: 18px;
  background: radial-gradient(circle at top, #1b2238 0, #050712 60%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
}

#game-canvas {
  display: block;
  background: linear-gradient(180deg, #050712 0, #050712 40%, #0b1020 100%);
  border-radius: 12px;
  border: 2px solid var(--grid-border);
}

/* ============================= */
/* OVERLAYS                      */
/* ============================= */
#overlay-ui {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  display: none;
  text-align: center;
  background: rgba(5, 7, 18, 0.85);
  border-radius: 12px;
  padding: 20px 26px;
  border: 1px solid rgba(74, 242, 197, 0.4);
  box-shadow: var(--shadow-strong);
}

.overlay.visible {
  display: block;
}

.overlay h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--accent2);
}

.overlay p {
  margin: 0;
  font-size: 20px;
  opacity: 0.8;
}

/* ============================= */
/* LEADERBOARD OVERLAY (NEON)    */
/* ============================= */

/* Base overlay behaviour */
.overlay {
    display: none;
}

.overlay.visible {
    display: block !important;
}

/* Neon leaderboard container */
.leaderboard-overlay {
    width: 420px;
    max-height: 520px;
    overflow-y: auto;
    padding: 20px 26px;
    background: rgba(5, 7, 18, 0.92);
    border-radius: 14px;

    /* Neon border */
    border: 2px solid rgba(74, 242, 197, 0.55);
    box-shadow:
        0 0 25px rgba(74, 242, 197, 0.45),
        0 0 45px rgba(255, 79, 216, 0.35),
        inset 0 0 18px rgba(74, 242, 197, 0.25);

    /* Animation */
    animation: leaderboardFade 0.35s ease-out forwards,
               leaderboardGlow 3s ease-in-out infinite alternate;
}

/* Leaderboard title */
.leaderboard-overlay h2 {
    margin: 0 0 12px;
    font-size: 30px;
    color: var(--accent2);
    text-shadow: 0 0 14px rgba(255, 79, 216, 0.8);
}

/* Leaderboard table */
#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 22px;
}

#leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#leaderboard-table td {
    padding: 6px 10px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

/* Fade-in animation */
@keyframes leaderboardFade {
    0% { opacity: 0; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

/* Soft neon pulsing */
@keyframes leaderboardGlow {
    0% {
        box-shadow:
            0 0 20px rgba(74, 242, 197, 0.35),
            0 0 35px rgba(255, 79, 216, 0.25),
            inset 0 0 12px rgba(74, 242, 197, 0.2);
    }
    100% {
        box-shadow:
            0 0 30px rgba(74, 242, 197, 0.55),
            0 0 55px rgba(255, 79, 216, 0.45),
            inset 0 0 18px rgba(74, 242, 197, 0.35);
    }
}

/* NEON STORY BOX */
.neon-story-box {
  margin-top: 20px;
  padding: 18px 22px;
  background: rgba(5, 7, 18, 0.85);
  border: 2px solid rgba(74, 242, 197, 0.45);
  border-radius: 12px;
  font-size: 20px;
  line-height: 1.35;
  text-align: left;
  color: var(--text);
  box-shadow:
    0 0 18px rgba(74, 242, 197, 0.35),
    0 0 28px rgba(255, 79, 216, 0.25);
  animation: storyGlow 3s ease-in-out infinite alternate;
}

.neon-story-box strong {
  color: var(--accent2);
  font-size: 22px;
  text-shadow: 0 0 12px rgba(255, 79, 216, 0.7);
}

@keyframes storyGlow {
  0% {
    box-shadow:
      0 0 12px rgba(74, 242, 197, 0.25),
      0 0 22px rgba(255, 79, 216, 0.15);
  }
  100% {
    box-shadow:
      0 0 22px rgba(74, 242, 197, 0.45),
      0 0 38px rgba(255, 79, 216, 0.35);
  }
}


/* ============================= */
/* COMBO POPUPS                  */
/* ============================= */
#combo-layer {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  overflow: visible;
}

.combo-popup {
  position: absolute;
  color: var(--accent3);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(255,200,87,0.9);
  animation: comboPop 0.7s ease-out forwards;
  white-space: nowrap;
}

.combo-popup.p2 {
  color: var(--accent2);
  text-shadow: 0 0 12px rgba(255,79,216,0.9);
}

/* ============================= */
/* FOOTER (Left Side)            */
/* ============================= */
#game-footer {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  opacity: 0.9;
  z-index: 9999;

  /* Unified neon theme */
  animation: neonPulse 3s ease-in-out infinite alternate,
             borderFlicker 2.2s infinite steps(2);
}

#game-footer span {
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(11, 16, 32, 0.9);
  border: 2px solid rgba(74, 242, 197, 0.35);
}

/* ============================= */
/* SCREEN SHAKE                  */
/* ============================= */
.shake {
  animation: screenShake 0.25s ease-in-out;
}

/* ============================= */
/* ANIMATIONS                    */
/* ============================= */

@keyframes neonPulse {
  0% { opacity: 0.85; text-shadow: 0 0 10px rgba(74,242,197,0.4); }
  100% { opacity: 1; text-shadow: 0 0 24px rgba(255,79,216,0.7); }
}

@keyframes slideGlow {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
  100% { filter: brightness(1); }
}

@keyframes borderFlicker {
  0% { border-color: rgba(74,242,197,0.3); }
  50% { border-color: rgba(255,79,216,0.6); }
  100% { border-color: rgba(74,242,197,0.3); }
}

@keyframes hudPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(255,255,255,0); }
  50% { transform: scale(1.06); box-shadow: 0 0 24px rgba(255,255,255,0.4); }
  100% { transform: scale(1); box-shadow: var(--shadow-soft); }
}

@keyframes comboPop {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  20% { transform: translate(-50%, -10px) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -40px) scale(1); opacity: 0; }
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(3px, -3px); }
  60% { transform: translate(-2px, 3px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0, 0); }
}

#welcome-banner {
  position: fixed;
  top: 10px;                 /* moved higher */
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: rgba(11, 16, 32, 0.85);
  border: 2px solid rgba(74, 242, 197, 0.4);
  border-radius: 12px;
  color: var(--accent);
  font-size: 22px;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(74,242,197,0.7);
  animation: welcomeFade 4s ease-out forwards;
  z-index: 99999;            /* ensure always visible */
}

@keyframes welcomeFade {
  0% { opacity: 0; transform: translate(-50%, -10px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

.neon-start {
  color: var(--accent);
  text-shadow:
    0 0 8px rgba(74, 242, 197, 0.8),
    0 0 16px rgba(74, 242, 197, 0.6),
    0 0 28px rgba(74, 242, 197, 0.4);
  animation: neonStartPulse 2.2s ease-in-out infinite alternate;
}

@keyframes neonStartPulse {
  0% {
    text-shadow:
      0 0 6px rgba(74, 242, 197, 0.6),
      0 0 14px rgba(74, 242, 197, 0.4),
      0 0 22px rgba(255, 79, 216, 0.25);
  }
  100% {
    text-shadow:
      0 0 12px rgba(74, 242, 197, 1),
      0 0 26px rgba(74, 242, 197, 0.8),
      0 0 40px rgba(255, 79, 216, 0.45);
  }
}

.debug-level {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 6px 12px;
  background: rgba(5,7,18,0.65);
  border: 1px solid rgba(74,242,197,0.4);
  border-radius: 8px;
  font-size: 16px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(74,242,197,0.7);
  pointer-events: none;
  z-index: 9999;
}

.levelup-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 24px;
  background: rgba(5,7,18,0.85);
  border: 2px solid var(--accent2);
  border-radius: 12px;
  font-size: 32px;
  color: var(--accent2);
  text-shadow: 0 0 14px rgba(255,79,216,0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-out;
  z-index: 9999;
}
.levelup-overlay.visible {
  opacity: 1;
}

.boss-overlay {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px 30px;
  background: rgba(5, 7, 18, 0.9);
  border: 3px solid var(--accent2);
  border-radius: 14px;
  font-size: 42px;
  color: var(--accent2);
  text-shadow:
    0 0 12px rgba(255, 79, 216, 0.9),
    0 0 24px rgba(255, 79, 216, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-out;
  z-index: 9999;
}

.boss-overlay.visible {
  opacity: 1;
}

.tag-icons {
  position: absolute;
  top: 50px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 9999;
}

.tag-icon {
  width: 32px;
  height: 32px;
  padding: 4px;
  border-radius: 6px;
  background: rgba(5,7,18,0.75);
  border: 1px solid rgba(74,242,197,0.45);
  box-shadow:
    0 0 10px rgba(74,242,197,0.4),
    0 0 18px rgba(255,79,216,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tag-icon svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 6px rgba(74,242,197,0.8));
}

#canvas-container {
  position: relative; /* REQUIRED */
}

.neon-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 760px;   /* MUST MATCH CANVAS */
  height: 640px;  /* MUST MATCH CANVAS */
  z-index: 9998;
  pointer-events: none;

  border-radius: 12px;
  box-shadow: 0 0 0 rgba(74,242,197,0);
  opacity: 0;
  transition: opacity 0.25s ease-out, box-shadow 0.25s ease-out;
}

.neon-flash.active {
  opacity: 1;
  box-shadow:
    0 0 30px rgba(74,242,197,0.8),
    0 0 60px rgba(255,79,216,0.6),
    0 0 90px rgba(74,242,197,0.5);
}

.level-preview {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 22px;
  background: rgba(5,7,18,0.85);
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-size: 20px;
  text-align: center;
  text-shadow: 0 0 8px rgba(74,242,197,0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-out;
  z-index: 9999;
}

.level-preview.visible {
  opacity: 1;
}

#attract-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 500; /* below overlays, above background */
  pointer-events: none;
  opacity: 0; /* hidden unless start screen is active */
  transition: opacity 0.4s ease-out;
}

.start-tag-preview {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: var(--accent2);
  text-shadow: 0 0 10px rgba(255,79,216,0.8);
  opacity: 0.8;
}

#fever-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: bold;
    color: magenta;
    text-shadow: 0 0 12px magenta;
    opacity: 0;
    transition: opacity 0.2s ease;
}
#fever-indicator.visible {
    opacity: 1;
}

#canvas-container {
    position: relative;
    width: 760px;
    height: 640px;
}

#attract-canvas,
#shockwave-layer,
#neon-flash {
    position: absolute;
    top: 0;
    left: 0;
}

/* ============================================
   PLAYER GRID NEON GLOWS
   ============================================ */

/* Shared grid container glow */
.grid-container {
    position: relative;
    border: 3px solid rgba(0,255,255,0.7);
    box-shadow: 0 0 15px rgba(0,255,255,0.6);
    border-radius: 6px;
    overflow: hidden;
}

/* Player 1 grid glow (cyan/blue) */
#grid-p1.grid-container {
    border-color: rgba(0,200,255,0.9);
    box-shadow: 0 0 20px rgba(0,200,255,0.8);
    animation: gridPulseP1 3s infinite ease-in-out;
}

/* Player 2 grid glow (magenta/pink) */
#grid-p2.grid-container {
    border-color: rgba(255,0,150,0.9);
    box-shadow: 0 0 20px rgba(255,0,150,0.8);
    animation: gridPulseP2 3s infinite ease-in-out;
}

/* Pulsing animations */
@keyframes gridPulseP1 {
    0%   { box-shadow: 0 0 12px rgba(0,200,255,0.5); }
    50%  { box-shadow: 0 0 28px rgba(0,200,255,1); }
    100% { box-shadow: 0 0 12px rgba(0,200,255,0.5); }
}

@keyframes gridPulseP2 {
    0%   { box-shadow: 0 0 12px rgba(255,0,150,0.5); }
    50%  { box-shadow: 0 0 28px rgba(255,0,150,1); }
    100% { box-shadow: 0 0 12px rgba(255,0,150,0.5); }
}

/* OUTER CANVAS PULSING NEON */
#game-canvas {
    border: 4px solid rgba(0,255,255,0.7);
    box-shadow: 0 0 20px rgba(0,255,255,0.6);
    animation: outerPulse 3s infinite ease-in-out;
}

@keyframes outerPulse {
    0%   { box-shadow: 0 0 12px rgba(0,255,255,0.4); }
    50%  { box-shadow: 0 0 28px rgba(0,255,255,1); }
    100% { box-shadow: 0 0 12px rgba(0,255,255,0.4); }
}

/* NORMAL OUTER PULSE (already exists) */
#game-canvas {
    border: 4px solid rgba(0,255,255,0.7);
    box-shadow: 0 0 20px rgba(0,255,255,0.6);
    animation: outerPulse 3s infinite ease-in-out;
}

/* DANGER PULSE (new) */
#game-canvas.danger {
    border-color: rgba(255,0,0,0.9);
    box-shadow: 0 0 25px rgba(255,0,0,0.9);
    animation: dangerPulse 0.6s infinite ease-in-out;
}

@keyframes dangerPulse {
    0%   { box-shadow: 0 0 10px rgba(255,0,0,0.4); }
    50%  { box-shadow: 0 0 35px rgba(255,0,0,1); }
    100% { box-shadow: 0 0 10px rgba(255,0,0,0.4); }
}

.hud-audio-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    font-size: 28px;
    cursor: pointer;
    z-index: 99999;
    color: #0ff;
    text-shadow: 0 0 8px #0ff;
    user-select: none;
}
.hud-audio-btn.muted {
    opacity: 0.4;
}

.audio-overlay-ui {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99998;
}

.audio-overlay-ui.visible {
    display: flex;
}

.audio-panel {
    background: rgba(20,20,20,0.9);
    padding: 25px 35px;
    border: 2px solid #0ff;
    border-radius: 12px;
    color: #0ff;
    font-family: Orbitron, sans-serif;
    text-align: center;
    width: 260px;
}

.audio-option {
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #0ff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
}

.audio-option:hover {
    background: rgba(0,255,255,0.1);
}

.audio-close {
    margin-top: 20px;
    padding: 10px;
    border: 1px solid #0ff;
    border-radius: 8px;
    cursor: pointer;
}








