* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #121212;
  color: #ffffff;
}

/*NAVIGATION*/
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: #1e1e1e;
}

nav h1 {
  color: #00f7ff;
}

h1 a.header-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 20px;
}

nav a {
  text-decoration: none;
  color: #ffffff;
  transition: 0.3s;
}

nav a:hover {
  color: #ff00c8;
}

nav a.active {
  color: #00f7ff;
  font-weight: bold;
}

/*HERO SECTION*/
.hero {
  text-align: center;
  margin-top: 100px;
}

.hero-text {
  max-width: 600px;
  margin: 80px auto;
  text-align: center;
}

/*BUTTONS*/
.btn {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 24px;
  background: linear-gradient(45deg, #00f7ff, #ff00c8);
  color: #121212;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: 0.3s;
}

.btn:hover {
  transform: scale(1.05);
}

/*MONITOR READOUT*/
.monitor {
  background: #000;
  border: 2px solid #00f7ff;
  padding: 10px;
  width: 90%;
  max-width: 600px;
  margin: 0 auto 20px auto;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: #4affff;
  height: 40px;
  overflow: hidden;
  position: relative;
}

.monitor-text {
  position: absolute;
  white-space: nowrap;
}

/*FINE PRINT*/
.fine-print {
  font-size: 0.45em; /*Extra tiny fine print*/
  color: #555;
  margin-top: 2rem;
  line-height: 1.2;
}

/*GAME PAGE HTML*/
.game-area {
  text-align: center;
  margin-top: 60px;
}

#gridContainer {
  display: grid;
  gap: 8px;
  width: 95vw;
  max-width: 500px;
  margin: 40px auto;
}

.square {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: #2a2a2a;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.3s;
}

.square.active {
  background: linear-gradient(45deg, #00f7ff, #ff00c8);
  box-shadow: 0 0 15px #00f7ff;
}

.square.correct {
  background-color: #00ff88;
}

.square.incorrect {
  background-color: #ff3c3c;
}

/*DIFFICULTY*/
.difficulty {
  margin-bottom: 20px;
}

.diffBtn {
  padding: 8px 16px;
  margin: 5px;
  background-color: #1e1e1e;
  border: 1px solid #00f7ff;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.3s;
}

.diffBtn.active-diff {
  background-color: #00f7ff;
  color: #121212;
}

.diffBtn:hover {
  background-color: #00f7ff;
  color: #121212;
}

/*HIDE DIFFICULTY & START BUTTONS WHEN GAME BEGINS*/
.hidden-smooth {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.difficulty,
#startBtn {
  transition: opacity 0.8s ease;
}

/*ROUND DISPLAY*/
#roundDisplay {
  font-weight: bold;
  margin-top: 20px;
  color: #00f7ff;
  font-size: 1.2em;
  display: block;
  min-height: 30px;
  line-height: 30px;
  margin: 20px 0;
}

/*BOSS LEVEL*/

/*SCREEN DARKEN*/
.boss-dark {
  background: rgba(0, 0, 0, 0.6);
  transition: background 0.4s ease;
}

/*SCREEN SHAKE*/
@keyframes bossShake {
  0% {
    transform: translate(0);
  }
  25% {
    transform: translate(-6px, 4px);
  }
  50% {
    transform: translate(6px, -4px);
  }
  75% {
    transform: translate(-4px, 3px);
  }
  100% {
    transform: translate(0);
  }
}

.boss-shake {
  animation: bossShake 0.6s ease-in-out 3;
}

/*GRID PULSE*/
@keyframes bossPulse {
  0% {
    box-shadow: 0 0 0px red;
  }
  50% {
    box-shadow: 0 0 25px red;
  }
  100% {
    box-shadow: 0 0 0px red;
  }
}

.boss-pulse {
  animation: bossPulse 0.8s ease-in-out infinite;
}

/*GLITCH FLICKER*/
.glitch {
  background: #ff2a2a !important;
  box-shadow: 0 0 10px #ff0000;
}

/*MESSAGE ABOVE THE GRID*/
#message {
  margin: 5px 0 8px 0;
  min-height: 20px;
  text-align: center;
}

/*ABOUT PAGE*/
.container {
  max-width: 600px;
  margin: 80px auto;
  text-align: center;
}

a {
  text-decoration: none;
  font-weight: bold;
}

/*ERROR PAGE*/
#errorContainer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  text-align: center;
  background: radial-gradient(circle at center, #0d0d0d, #000000);
  color: white;
  font-family: "Arial", sans-serif;
}

#errorContainer h1 {
  font-size: 6rem;
  margin: 0;
}

#errorContainer h2 {
  font-size: 2rem;
  margin: 1rem 0;
}

#errorContainer p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

/*NEUROLAB GAME BACKGROUND*/

/*MOVING LAB GRID*/
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -2;

  background-image:
    linear-gradient(rgba(0, 247, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 0, 200, 0.04) 1px, transparent 1px);

  background-size: 80px 80px;

  animation: labGridMove 25s linear infinite;
}

@keyframes labGridMove {
  from {
    background-position:
      0 0,
      0 0;
  }
  to {
    background-position:
      80px 80px,
      80px 80px;
  }
}

/*STRONGER CRT SCANLINES*/
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;

  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );

  animation: scanlineMove 4s linear infinite;
}

/*SUBTLE MONITOR FLICKER*/
@keyframes monitorFlicker {
  0% {
    opacity: 1;
  }
  97% {
    opacity: 1;
  }
  98% {
    opacity: 0.96;
  }
  99% {
    opacity: 0.98;
  }
  100% {
    opacity: 1;
  }
}

body {
  animation: monitorFlicker 3s infinite;
}

/*RETRO SYSTEM GRID BACKGROUND*/
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;

  background-image:
    linear-gradient(rgba(0, 255, 150, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 150, 0.05) 1px, transparent 1px);

  background-size: 80px 80px;

  animation: gridDrift 20s linear infinite;
}

@keyframes gridDrift {
  from {
    background-position:
      0 0,
      0 0;
  }
  to {
    background-position:
      80px 80px,
      80px 80px;
  }
}

/*CRT SCANLINES OVERLAY*/
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none; /*Click-through*/
  z-index: 5;

  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.08) 1px,
    transparent 1px,
    transparent 3px
  );

  animation: scanlineMove 4s linear infinite;
}

@keyframes scanlineMove {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 20px;
  }
}

/*RESPONSIVE GRID DESIGN*/

/*BURGER*/
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.burger span {
  width: 26px;
  height: 3px;
  background: white;
  border-radius: 3px;
  transition: all 0.3s ease;
}

nav.open .burger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

nav.open .burger span:nth-child(2) {
  opacity: 0;
}

nav.open .burger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 992px) {
  nav {
    position: relative;
    padding: 15px;
  }

  .burger {
    display: flex;
    position: absolute;
    right: 20px;
    top: 20px;
  }

  nav ul {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: black;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
      max-height 0.6s ease,
      opacity 0.3s ease;
  }

  nav.open ul {
    max-height: 400px;
    opacity: 1;
  }
}

/*BURGER MENU FIX*/
@media (max-width: 992px) {
  nav ul {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: black;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
      max-height 0.6s ease,
      opacity 0.3s ease;
    z-index: 10;
  }

  nav.open ul {
    max-height: 400px;
    opacity: 1;
  }

  .burger {
    z-index: 11; /*Makes sure the burger icon stays on top*/
  }
}

@media (min-width: 993px) {
  nav ul {
    max-height: none !important;
    opacity: 1 !important;
  }
}

/*GRID RESPONSIVENESS*/

/*TABLETS & SMALL LAPTOPS*/
@media (max-width: 1024px) {
  #gridContainer {
    width: 86vw; /*Slightly smaller*/
    max-width: 400px; /*Reduces overflow vertically*/
    gap: 5px; /*Tighter gap*/
    margin: -5px auto; /*Trims top/bottom spacing*/
  }

  #message {
    margin: 4px 0 12px 0; /*Reduces space above/below message*/
  }

  .square {
    border-radius: 8px; /*Keeps corners proportional*/
  }
}

/*SMALL TABLETS & LARGE PHONES*/
@media (max-width: 768px) {
  #gridContainer {
    width: 95vw;
    max-width: 350px; /*Shrink further*/
    gap: 5px; /*Tighter gap*/
  }

  .square {
    border-radius: 6px;
  }
}