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

:root {
  --bg: #0a0a0a;
  --text: #b8c4b8;
  --text-dim: #4a5a4a;
  --text-ghost: #1a2a1a;
  --accent: #7ab87a;
  --human: #c9a86c;
  --machine: #6c9ec9;
  --error: #c96c6c;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98% { opacity: 0.8; }
  99% { opacity: 0.9; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

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

@keyframes typeIn {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes glitch {
  0%, 90%, 100% { transform: translate(0); filter: none; }
  92% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  94% { transform: translate(2px, -1px); filter: hue-rotate(-90deg); }
  96% { transform: translate(-1px, 2px); }
  98% { transform: translate(1px, -2px); }
}

@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  position: relative;
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1) 0px,
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  z-index: 1000;
}

.noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  z-index: 999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.terminal {
  height: 100%;
  padding: 40px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.output {
  flex: 1;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.line {
  margin-bottom: 4px;
  animation: fadeIn 0.5s ease-out;
}

.line.human {
  color: var(--human);
}

.line.machine {
  color: var(--machine);
}

.line.dim {
  color: var(--text-dim);
}

.line.ghost {
  color: var(--text-ghost);
  animation: breathe 4s ease-in-out infinite;
}

.line.error {
  color: var(--error);
}

.line.fading {
  animation: fadeOut 3s ease-out forwards;
}

@keyframes fadeOut {
  to { opacity: 0.1; color: var(--text-ghost); }
}

.line.glitch {
  animation: glitch 0.3s ease-in-out;
}

.line .struck {
  text-decoration: line-through;
  opacity: 0.4;
}

.line .replaced {
  color: var(--machine);
  font-style: italic;
}

.line .whisper {
  opacity: 0.3;
  font-size: 0.85em;
}

.input-line {
  display: flex;
  align-items: center;
  padding-top: 20px;
  min-height: 40px;
}

.prompt {
  color: var(--accent);
  margin-right: 8px;
  animation: breathe 3s ease-in-out infinite;
}

.input-text {
  color: var(--text);
}

.cursor {
  animation: blink 1s step-end infinite;
  color: var(--accent);
}

.cursor.dying {
  animation: blink 2s step-end infinite;
  opacity: 0.5;
}

.cursor.dead {
  animation: none;
  opacity: 0.1;
}

.suggestion {
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.suggestion.visible {
  opacity: 0.5;
}

.suggestion.taking-over {
  opacity: 1;
  color: var(--machine);
  transition: all 0.5s ease;
}

/* Poetry sections */
.poetry {
  margin: 40px 0;
  padding-left: 20px;
  border-left: 1px solid var(--text-ghost);
}

.poetry .verse {
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeIn 2s ease-out forwards;
}

.poetry .verse:nth-child(2) { animation-delay: 1s; }
.poetry .verse:nth-child(3) { animation-delay: 2s; }
.poetry .verse:nth-child(4) { animation-delay: 3s; }

/* Overwritten text effect */
.overwrite-container {
  position: relative;
  display: inline;
}

.original {
  position: relative;
}

.original.fading {
  animation: textFade 2s ease-out forwards;
}

@keyframes textFade {
  0% { opacity: 1; filter: blur(0); }
  100% { opacity: 0.2; filter: blur(1px); }
}

.replacement {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--machine);
  opacity: 0;
  animation: replaceIn 1s ease-out 1.5s forwards;
}

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

/* Section dividers */
.divider {
  margin: 60px 0;
  color: var(--text-ghost);
  text-align: center;
  letter-spacing: 8px;
}

/* Final section */
.alone {
  text-align: center;
  padding: 100px 0;
}

.alone .cursor-final {
  font-size: 24px;
  animation: blink 1s step-end infinite;
}

.alone .cursor-final.slowing {
  animation: blink 2s step-end infinite;
}

.alone .cursor-final.stopped {
  animation: none;
  opacity: 0.3;
}

/* Scrollbar */
.terminal::-webkit-scrollbar {
  width: 4px;
}

.terminal::-webkit-scrollbar-track {
  background: var(--bg);
}

.terminal::-webkit-scrollbar-thumb {
  background: var(--text-ghost);
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .terminal {
    padding: 20px;
    font-size: 13px;
  }
}
