* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0a0a0a;
  color: #00ff9c;
  font-family: "Courier New", monospace;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Matrix rain canvas */
#matrix-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.15;
  pointer-events: none;
}

/* CRT scanline effect - z-index 1000 places scanlines over content for authentic CRT look */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1000;
}

/* CRT flicker effect */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 16, 16, 0.1);
  opacity: 0;
  z-index: 999;
  pointer-events: none;
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0% { opacity: 0.3; }
  5% { opacity: 0.4; }
  10% { opacity: 0.2; }
  15% { opacity: 0.9; }
  20% { opacity: 0.2; }
  25% { opacity: 0.8; }
  30% { opacity: 0.6; }
  35% { opacity: 0.7; }
  40% { opacity: 0.3; }
  45% { opacity: 0.8; }
  50% { opacity: 1; }
  55% { opacity: 0.1; }
  60% { opacity: 0.2; }
  65% { opacity: 0.7; }
  70% { opacity: 0.5; }
  75% { opacity: 0.4; }
  80% { opacity: 0.7; }
  85% { opacity: 0.7; }
  90% { opacity: 0.7; }
  95% { opacity: 0.4; }
  100% { opacity: 0.2; }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
    opacity: 0;
  }
  
  input:focus {
    animation: none;
  }
}

#terminal {
  padding: 20px;
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow-y: auto;
  text-shadow: 0 0 5px #00ff9c, 0 0 10px #00ff9c;
}

#output {
  white-space: pre-wrap;
  line-height: 1.5;
}

.input-line {
  display: flex;
  align-items: center;
}

.prompt {
  margin-right: 8px;
  text-shadow: 0 0 8px #00ff9c, 0 0 15px #00ff9c;
}

input {
  background: transparent;
  border: none;
  outline: none;
  color: #00ff9c;
  font-family: inherit;
  font-size: 1em;
  flex: 1;
  caret-color: #00ff9c;
  text-shadow: 0 0 5px #00ff9c;
}

/* Blinking cursor - only animate caret color, not entire input */
input:focus {
  animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { caret-color: #00ff9c; }
  50% { caret-color: transparent; }
}

/* Link styling */
a {
  color: #00ffff;
  text-decoration: none;
  text-shadow: 0 0 5px #00ffff;
}

a:hover {
  text-decoration: underline;
  text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff;
}

/* Autocomplete suggestions */
#autocomplete {
  color: #666;
  font-style: italic;
  margin-left: 4px;
}

/* Scrollbar styling */
#terminal {
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #00ff9c #111;
}

/* WebKit browsers (Chrome, Safari, Edge) */
#terminal::-webkit-scrollbar {
  width: 8px;
}

#terminal::-webkit-scrollbar-track {
  background: #111;
}

#terminal::-webkit-scrollbar-thumb {
  background: #00ff9c;
  border-radius: 4px;
}

#terminal::-webkit-scrollbar-thumb:hover {
  background: #00cc7a;
}
