:root {
  --bg: #000000;
  --panel: #0f1113cc;
  --neon-green: #07f60b;
  --neon-green-soft: #279c40;
  --accent: #e20057;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-2: rgba(0, 0, 0, 0.02);
  --glass-border: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --muted: #9aa3a3;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  --color-bg-dark: rgba(15, 17, 19, 0.8);
  --color-glass-light: rgba(255, 255, 255, 0.03);
}

* {
  box-sizing: border-box;
}

/* 🖤 Full-page deep black animated background */
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(120deg, #000000, #070707, #0d0d0d, #060606, #000000);
  background-size: 400% 400%;
  animation: darkWave 12s ease-in-out infinite, darkPulse 10s ease-in-out infinite;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  position: relative;
  line-height: 1.6;
  transition: background-color 0.3s ease;
}

/* 🌫 Soft dark shimmer — no white glow */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(20, 20, 20, 0.25), transparent 70%),
    radial-gradient(circle at 70% 60%, rgba(15, 15, 15, 0.25), transparent 70%);
  animation: darkGlow 10s ease-in-out infinite alternate;
  z-index: -1;
}

/* 🔁 Gradient motion */
@keyframes darkWave {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ✨ Gentle brightness change (dark tones only) */
@keyframes darkPulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08);
  }
}

/* 🌊 Floating soft glow */
@keyframes darkGlow {
  0% {
    transform: translateY(0px) scale(1);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-15px) scale(1.05);
    opacity: 0.7;
  }
  100% {
    transform: translateY(10px) scale(1);
    opacity: 0.5;
  }
}

/* Layout */
.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  backdrop-filter: blur(10px);
  background: var(--color-bg-dark);
}

.title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
  text-align: center;
}

.neon {
  font-size: 36px;
  letter-spacing: 6px;
  margin: 0;
  color: var(--neon-green);
  text-shadow: 0 0 6px rgba(184, 26, 20, 0.97), 0 0 18px rgba(7, 178, 87, 0.3), 0 0 36px rgba(0, 255, 120, 0.12);
  line-height: 1;
  transform: translateZ(0);
  /* animation: edgeGlowPulse 6s ease-in-out infinite, neonScale 12s ease-in-out infinite; */
}

@keyframes neonScale {
  0%,
  100% {
    transform: translateZ(0) scale(1);
  }
  50% {
    transform: translateZ(0) scale(1.05);
  }
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

/* Game layout */
.game-wrap {
  display: flex;
  gap: 100px;
  align-items: flex-start;
  max-width: 960px;
  width: 100%;
  align-items: center;
  justify-content: center;
}

/* 💚 Neon Edge Pulse Animation */
@keyframes edgeGlowPulse {
  0%,
  100% {
    box-shadow: 0 0 12px rgba(0, 255, 100, 0.15), 0 0 24px rgba(0, 255, 100, 0.08), inset 0 0 20px rgba(0, 255, 100, 0.05);
  }
  50% {
    box-shadow: 0 0 28px rgba(0, 255, 100, 0.35), 0 0 50px rgba(0, 255, 100, 0.25), inset 0 0 30px rgba(0, 255, 100, 0.12);
  }
}

/* ✨ Apply the pulse to key UI elements */
canvas,
.hud,
.modal-card {
  position: relative;
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 100, 0.2);
  animation: edgeGlowPulse 6s ease-in-out infinite;
}

/* Canvas styling */
canvas {
  width: 480px;
  height: 480px;
  background: linear-gradient(180deg, #050607, #0b0b0f);
  display: block;
  box-shadow: 0 8px 20px rgba(0, 255, 100, 0.4);
}

/* HUD styling */
.hud {
  width: 240px;
  background: linear-gradient(180deg, var(--panel), transparent);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.02);
}

.label {
  color: var(--muted);
  font-size: 13px;
}

.value {
  font-weight: 700;
  color: var(--text);
  font-size: 20px;
}

.controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s ease;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
  outline-offset: 3px;
}

.btn:hover {
  transform: translateY(-2px) scale(1.05);
  color: var(--neon-green-soft);
  text-shadow: 0 0 10px var(--neon-green);
  box-shadow: 0 0 20px var(--neon-green-soft);
}

.btn.primary {
  background: linear-gradient(90deg, var(--neon-green), var(--neon-green-soft));
  color: #071012;
  border: none;
  box-shadow: 0 8px 26px rgba(60, 255, 0, 0.12), 0 0 20px rgba(60, 255, 0, 0.06);
}

.btn:focus-visible {
  outline: 2px solid var(--neon-green);
  outline-offset: 4px;
}

.options {
  margin-top: 12px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 14px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(2, 2, 2, 0.55), rgba(2, 2, 2, 0.8));
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: linear-gradient(180deg, #0c0f11, #071018);
  padding: 22px;
  text-align: center;
  min-width: 260px;
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 100, 0.2);
  animation: edgeGlowPulse 6s ease-in-out infinite;
}

.modal-card h2 {
  margin: 0 0 8px;
  color: var(--neon-green);
}

.modal-card p {
  color: var(--text);
  margin: 6px 0 16px;
}

/* Touch pad (mobile) */
.touch-pad {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.touch-pad.hidden {
  display: none;
}

.touch-pad > div {
  background: transparent;
  border-radius: 8px;
  min-width: 80px;
  min-height: 80px;
}

.touch-pad > div:active {
  background: rgba(141, 16, 16, 0.03);
}

/* Responsive */
@media (max-width: 900px) {
  .game-wrap {
    flex-direction: column;
    gap: 14px;
  }
  .hud {
    width: 100%;
    max-width: 520px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  canvas {
    width: 360px;
    height: 360px;
  }
  .touch-pad.hidden {
    display: grid;
  }
}

@media (max-width: 600px) {
  .touch-pad > div {
    min-width: 60px;
    min-height: 60px;
  }
  .restart-text {
    font-size: 12px;
    width: 320px;
    left: 50%;
    transform: translateX(-160px); /* half of width */
  }
}

/* 💻 Flowing Binary Rain Effect */
.binary-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -2;
  pointer-events: none;
  background: transparent;
}

/* Subtle binary number layer */
.binary-bg::before {
  content: "0101011010010110010110100101100101101001011001011010010110010110100";
  position: absolute;
  top: -200%;
  left: 0;
  width: 100%;
  height: 300%;
  font-family: monospace;
  font-size: 14px;
  line-height: 20px;
  color: rgba(0, 255, 100, 0.05);
  white-space: pre;
  text-shadow: 0 0 8px rgba(0, 255, 100, 0.05);
  animation: binaryFlow 18s linear infinite;
  transform: rotate(15deg);
}

/* Gradient fade for smoothness */
.binary-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 30%, rgba(0, 0, 0, 0.9) 90%);
  pointer-events: none;
}

/* Animation for slow continuous flow */
@keyframes binaryFlow {
  0% {
    transform: translateY(0) rotate(15deg);
  }
  100% {
    transform: translateY(100%) rotate(15deg);
  }
}

.footer {
  position: fixed;
  bottom: 10px;
  right: 20px;
  font-size: 14px;
  color: #999;
  font-family: sans-serif;
}

.restart-text {
  position: relative;
  left: 50%;
  transform: translateX(-240px); /* half of canvas width (480 / 2) */
  margin-top: 24px;
  width: 480px; /* same as canvas width */
  text-align: center;
  color: #aaa;
  font-size: 14px;
  opacity: 0.85;
}
