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

/* ── Light mode (default) — classic TOPS blue ── */
:root {
  --bg: #000080;
  --bg-deep: #000060;
  --text: #ffffff;
  --cyan: #00ffff;
  --yellow: #ffff00;
  --green: #00ff00;
  --red: #ff4444;
  --dim: #8080c0;
  --header-bg: #00ffff;
  --header-fg: #000080;
  --status-bg: #ffff00;
  --status-fg: #000080;
  --scrollbar-thumb: #4040a0;
  --scanline-alpha: 0.12;
}

/* ── Dark mode — green phosphor on black ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-deep: #050505;
    --text: #cccccc;
    --cyan: #33ccaa;
    --yellow: #ccaa33;
    --green: #33ff33;
    --red: #ff4444;
    --dim: #555555;
    --header-bg: #33ff33;
    --header-fg: #0a0a0a;
    --status-bg: #ccaa33;
    --status-fg: #0a0a0a;
    --scrollbar-thumb: #1a3a1a;
    --scanline-alpha: 0.15;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
}

#terminal {
  width: 100%;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

#output {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

#output .line {
  display: block;
  min-height: 1.4em;
}

/* TOPS/TRUST colour classes */
#output .cyan {
  color: var(--cyan);
}

#output .yellow {
  color: var(--yellow);
}

#output .white {
  color: var(--text);
}

#output .green {
  color: var(--green);
}

#output .dim {
  color: var(--dim);
}

#output .red {
  color: var(--red);
}

#output .header-bar {
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  padding: 0 0.5ch;
  white-space: nowrap;
}

#output .status-bar {
  background: var(--status-bg);
  color: var(--status-fg);
  display: block;
  font-weight: bold;
  padding: 0 0.5ch;
}

#output .prompt {
  color: var(--green);
}

#output .link {
  color: var(--cyan);
}

.contact-link {
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contact-link:hover {
  color: var(--header-bg);
}

#output .alert {
  color: var(--yellow);
  animation: blink-text 1.2s step-end infinite;
}

#output .reverse {
  background: var(--cyan);
  color: var(--bg);
  font-weight: bold;
}

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

/* Blinking cursor */
#cursor {
  display: inline-block;
  color: var(--green);
  visibility: hidden;
}

#cursor.blink {
  visibility: visible;
  animation: blink 1s step-end infinite;
}

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

/* CRT scanline overlay */
#scanlines {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, var(--scanline-alpha)) 2px,
    rgba(0, 0, 0, var(--scanline-alpha)) 4px
  );
}

/* Scrollbar */
#terminal::-webkit-scrollbar {
  width: 6px;
}

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

#terminal::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* Mobile */
@media (max-width: 600px) {
  body {
    font-size: 11px;
  }

  #terminal {
    padding: 8px;
  }
}
