/* General Body Styles */
body {
  margin: 0;
  overflow: hidden;
  background-color: #000;
  font-family: "monospace", sans-serif;
  color: var(--matrix-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  /* Prevent double-tap zoom */
}

/* CSS Custom Properties for Theming */
:root {
  --matrix-color: #00ff00;
  --matrix-glow: #00ff00;
  --konami-hold-border-color: #00ff00;
  --konami-hold-text-color: #00ff00;
  --button-hover-bg: rgba(0, 255, 0, 0.25);
  --button-hover-shadow: 0 0 15px var(--matrix-glow);
  --terminal-glow-color: #00ff00b3;
  --terminal-header-bg: #00ff0033;
  --window-control-minimize-bg: #00ff004d;
  --window-control-maximize-bg: #00ff0080;
  --window-control-close-color: #000000;
}

/* Canvas Styles */
canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
}

/* Error Message for Canvas */
#canvas-error {
  display: none;
  color: #ff0000;
  text-align: center;
  padding-top: 50px;
  font-size: 1.2em;
}

/* Center Text Styles */
#center-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--matrix-color);
  font-size: 2.5em;
  text-shadow: 0 0 10px var(--matrix-glow);
  white-space: nowrap;
  cursor: pointer;
  z-index: 10;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

@media (max-width: 768px) {
  #center-text {
    font-size: 1.8em;
  }
}

@media (max-width: 480px) {
  #center-text {
    font-size: 1.2em;
    padding: 0 10px;
    /* Add some padding to prevent text from touching screen edges */
  }
}

#center-text:hover {
  color: #ffffff;
  text-shadow: 0 0 15px #ffffff;
}

/* Character Span Styles for Typewriter Effect */
.char {
  opacity: 0;
  animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Sound Toggle Button */
#sound-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #000000b3;
  border: 1px solid var(--matrix-color);
  color: var(--matrix-color);
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-family: monospace;
  font-size: 1em;
  z-index: 100;
  transition: background-color 0.3s ease, color 0.3s ease,
    border-color 0.3s ease, text-shadow 0.3s ease;
  text-shadow: 0 0 5px var(--matrix-glow);
}

#sound-toggle:hover {
  background-color: var(--button-hover-bg);
  text-shadow: var(--button-hover-shadow);
}

/* Konami Message */
#konami-message {
  display: none;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }

  to {
    transform: translateX(-50%) scale(1.05);
    opacity: 0.9;
  }
}

/* Skip to main content for accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: -1;
}

.skip-link:focus {
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  padding: 10px;
  background-color: #000000;
  color: #00ff00;
  z-index: 9999;
  text-decoration: none;
}

/* Main content */
#main-content {
  position: relative;
  z-index: 1;
}

/* FPS Counter */
#fps-counter {
  background: #000000b3;
  border: 1px solid var(--matrix-color);
  color: var(--matrix-color);
  padding: 10px 15px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 0.9em;
  text-shadow: 0 0 5px var(--matrix-glow);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Footer */
#matrix-footer {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Push items to ends */
  padding: 0 20px;
  /* Add padding to the sides */
  z-index: 100;
}

#matrix-footer a {
  background: #000000b3;
  border: 1px solid var(--matrix-color);
  color: var(--matrix-color);
  padding: 10px 15px;
  border-radius: 20px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.3s ease, color 0.3s ease,
    border-color 0.3s ease, text-shadow 0.3s ease;
  text-shadow: 0 0 5px var(--matrix-glow);
}

#matrix-footer a:hover {
  background-color: var(--button-hover-bg);
  color: #ffffff;
  text-shadow: var(--button-hover-shadow);
}

#matrix-footer a svg {
  fill: currentColor;
}

/* Playback Controls */
#playback-controls {
  position: fixed;
  bottom: 80px;
  /* Above the footer */
  left: 50%;
  transform: translateX(-50%);
  display: none;
  /* Hidden by default, shown when paused */
  gap: 10px;
  z-index: 110;
  /* Above the footer */
}

/* Hacking Terminal */
#hacking-terminal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  /* Responsive width */
  max-width: 800px;
  /* Max width for desktop */
  height: 90%;
  /* Responsive height */
  max-height: 600px;
  /* Max height for desktop */
  background-color: #000000;
  /* Dark background for terminal content */
  color: var(--matrix-color);
  font-family: monospace;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  border: 1px solid var(--matrix-color);
  /* Window border */
  border-radius: 8px;
  /* Rounded corners for the window */
  box-shadow: 0 0 30px var(--terminal-glow-color);
  /* Stronger glow for the window */
  overflow: hidden;
  /* Hide overflow from rounded corners */
}

#hacking-terminal.visible {
  opacity: 1;
  visibility: visible;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--terminal-header-bg);
  /* Title bar background */
  padding: 8px 15px;
  border-bottom: 1px solid var(--matrix-color);
  cursor: grab;
  /* Indicate draggable */
  user-select: none;
}

#terminal-title {
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 0 8px var(--matrix-glow);
  font-size: 1.1em;
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-control-button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8em;
  color: #000000;
  /* Default icon color */
}

.window-control-button:hover {
  opacity: 1;
}

.window-control-button.minimize {
  background-color: var(--window-control-minimize-bg);
  /* Darker matrix green */
}

.window-control-button.maximize {
  background-color: var(--window-control-maximize-bg);
  /* Medium matrix green */
}

.window-control-button.close {
  background-color: var(--matrix-color);
  /* Matrix green */
  color: var(--window-control-close-color);
  /* Black 'x' for contrast */
  font-weight: bold;
}

#terminal-close-button {
  /* Override previous styles for the close button */
  background: none;
  border: none;
  padding: 0;
  font-size: 1.2em;
  color: #000000;
  /* Black 'x' for contrast */
  line-height: 1;
}

#terminal-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 15px 20px;
  /* Add padding inside the terminal content area */
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1em;
  /* Base font size for terminal */
  line-height: 1.4;
  padding-right: 10px;
  /* For scrollbar */
}

#terminal-content::-webkit-scrollbar {
  width: 8px;
}

#terminal-content::-webkit-scrollbar-track {
  background: #00ff001a;
  border-radius: 10px;
}

#terminal-content::-webkit-scrollbar-thumb {
  background: var(--matrix-color);
  border-radius: 10px;
}

/* Blinking cursor for terminal */
.blinking {
  animation: blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {

  from,
  to {
    color: transparent;
  }

  50% {
    color: var(--matrix-color);
  }
}

/* Styles for the quote source in the terminal */
.quote-source {
  color: var(--quote-source-color) !important;
  font-style: italic;
  text-align: right;
  display: block;
  margin-top: 5px;
}

/* Pause Message Styles */
#pause-message {
  color: var(--matrix-color);
}

/* New styles for bold terminal content */
.terminal-content-bold {
  font-weight: bold;
  font-size: 1.25em;
}

/* Responsive Design for Terminal */
@media (max-width: 768px) {
  #hacking-terminal {
    width: 95%;
    height: 95%;
    border-radius: 5px;
  }

  #terminal-content {
    font-size: 0.9em;
    padding: 10px 15px;
    line-height: 1.3;
    /* Adjusted line-height for better mobile scaling */
  }

  .terminal-header {
    padding: 6px 10px;
  }

  #terminal-title {
    font-size: 1em;
  }

  .window-control-button {
    width: 10px;
    height: 10px;
  }
}

@media (max-width: 480px) {
  #hacking-terminal {
    width: 98%;
    /* Slightly less than 100% to prevent stretching */
    height: 100%;
    border-radius: 0;
    margin: 0 auto;
    /* Center the terminal */
  }

  #terminal-content {
    font-size: 0.75em;
    /* Slightly smaller font for very small screens */
    padding: 8px 10px;
    line-height: 1.2;
    /* Further adjusted line-height */
  }

  .terminal-header {
    padding: 5px 8px;
  }

  #terminal-title {
    font-size: 0.9em;
  }

  .window-control-button {
    width: 8px;
    height: 8px;
  }
}