: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);
  }
}


