/* General Styling */
body {
  background: linear-gradient(270deg, #ff00ff, #00ffff, #ffcc00, #ff00ff);
  background-size: 400% 400%;
  animation: backgroundShift 10s infinite alternate ease-in-out;
  color: #fff;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px #ff00ff, 0 0 20px #00ffff;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  line-height: 1.6;
}

@keyframes backgroundShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* Navigation Bar */
nav {
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 20px;
  text-align: left; /* Align to left for hamburger icon */
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 999;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Hamburger Menu */
.hamburger-menu {
  display: none;
  cursor: pointer;
}

.hamburger-menu span {
  display: block;
  width: 30px;
  height: 3px;
  background-color: #00ffff;
  margin: 6px 0;
  transition: 0.4s;
}

/* Nav Links */
.nav-links {
  display: flex;
  justify-content: center; /* This centers the buttons on desktop */
}

.nav-button {
  display: inline-block;
  background: #ff00ff;
  color: #00ffff;
  padding: 10px 20px;
  margin: 0 5px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: bold;
  text-shadow: 0 0 5px #00ffff;
  box-shadow: 0 0 10px #00ffff, 0 0 20px #ff00ff;
  transition: all 0.3s ease;
  font-family: 'Orbitron', sans-serif;
  max-width: calc(100% - 10px); /* Prevents overflow on small screens */
}

.nav-button:hover {
  background: #00ffff;
  color: #ff00ff;
  box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ffff;
  transform: scale(1.1);
}

/* Responsive design for mobile */
@media screen and (max-width: 768px) {
  .hamburger-menu {
    display: block;
  }

  .nav-links {
    position: fixed;
    width: 100%;
    height: 0; /* Initially hide the menu */
    top: 60px; /* Position below the nav bar */
    left: 0;
    background: rgba(0, 0, 0, 0.8);
    overflow: hidden; /* Hide the content when not active */
    transition: height 0.3s ease;
    display: block;
    text-align: center;
  }

  .nav-links.active {
    height: auto; /* Show the menu when active */
  }

  .nav-links .nav-button {
    display: block;
    padding: 8px 15px; /* Reduce padding for smaller buttons */
    font-size: 14px; /* Smaller font size for mobile */
    width: calc(100% - 20px); /* Adjust width to account for margin */
    margin: 5px 10px; /* Add margin for better touch interaction */
  }

  /* Hide the nav buttons by default on mobile */
  .nav-links .nav-button:not(.active) {
    display: none;
  }

  /* Show nav buttons when menu is active */
  .nav-links.active .nav-button {
    display: block;
  }
}

/* Animation for hamburger menu */
.hamburger-menu.active span:nth-child(1) {
  transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: rotate(45deg) translate(-5px, -6px);
}

/* CRT Screen Effect */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9999;
  animation: scanlines 0.1s infinite;
}

@keyframes scanlines {
  0% { transform: translateY(0); }
  100% { transform: translateY(-2px); }
}

/* Typography */
h1, h2, h3 {
  font-family: 'Impact', 'Arial Black', sans-serif;
  color: #ff00ff;
  text-shadow: 0 0 10px #00ffff, 0 0 20px #ff00ff;
  font-size: 4rem;
  animation: glitch 2s infinite alternate;
}

@keyframes glitch {
  0% { transform: skew(0deg); }
  20% { transform: skew(-10deg); }
  40% { transform: skew(10deg); }
  60% { transform: skew(0deg); }
  80% { transform: skew(-5deg); }
  100% { transform: skew(5deg); }
}

p {
  font-size: 1.5rem;
  color: #00ffff;
  text-shadow: 0 0 5px #ff00ff;
  animation: flicker 1s infinite alternate;
}

@keyframes flicker {
  0% { opacity: 1; }
  50% { opacity: 0.8; }
  100% { opacity: 1; }
}

/* Links */
a {
  color: #00ffff;
  font-size: 1.5rem;
  text-decoration: none;
  transition: color 0.3s ease-in-out, transform 0.2s;
  text-shadow: 0 0 10px #ff00ff;
}

a:hover {
  color: #ff00ff;
  transform: scale(1.1);
  text-shadow: 0 0 20px #00ffff;
}

/* Navigation - This is redundant with the nav selector above, so we'll keep the initial one */
/* Buttons */
.button {
  display: inline-block;
  background: #ff00ff;
  color: #00ffff;
  padding: 10px 20px;
  border-radius: 5px;
  box-shadow: 0 0 10px #00ffff, 0 0 20px #ff00ff;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  animation: pulse 2s infinite alternate;
  width: 100%;
  text-align: center;
}

.button:hover {
  background: #00ffff;
  color: #ff00ff;
  box-shadow: 0 0 20px #ff00ff, 0 0 30px #00ffff;
  transform: scale(1.05);
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* Marquee Effects */
.marquee {
  font-size: 3rem;
  color: #ff00ff;
  font-weight: bold;
  text-shadow: 0 0 10px #00ffff, 0 0 20px #ff00ff;
  animation: flashText 1s infinite alternate, glitch 2s infinite alternate;
}

@keyframes flashText {
  0% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* Forms and Buttons */
#mad-libs-form, #submit-button, #mad-libs-form button, #story-output {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 850px) {
  body {
    font-size: 1rem;
  }
  h1, h2, h3 {
    font-size: 2.5rem;
  }
  nav a {
    font-size: 1.2rem;
    margin: 5px 0;
  }
  .button, .button-link, #mad-libs-form button {
    font-size: 1.2rem;
  }
  .marquee {
    font-size: 2rem;
  }
  /* Stack navigation links for mobile */
  nav a {
    display: block;
  }
  /* Adjust form elements for mobile */
  #mad-libs-form input, #mad-libs-form button, #submit-button {
    width: 100%;
  }
  .button:hover {
    cursor: pointer;
}
}

/* Footer */
footer {
  background: rgba(0, 0, 0, 0.8);
  color: #00ffff;
  text-align: center;
  padding: 10px 0;
  font-size: 1.2rem;
  position: relative;
  width: 100%;
  margin-top: 50px;
  box-shadow: 0 0 20px #ff00ff;
}