@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400&family=VT323&display=swap');

:root {
  --bg-terminal: #0a0a0a;
  --text-neon: #33ff00;
  --text-neon-dim: rgba(51, 255, 0, 0.65);
  --border-neon: #33ff00;
  --glow-sm: 0 0 5px rgba(51, 255, 0, 0.55), 0 0 12px rgba(51, 255, 0, 0.25);
  --glow-lg: 0 0 8px rgba(51, 255, 0, 0.8), 0 0 20px rgba(51, 255, 0, 0.4);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(51, 255, 0, 0.2);
}

html,
body {
  background-color: var(--bg-terminal);
  color: var(--text-neon);
  font-family: 'JetBrains Mono', 'VT323', monospace;
  text-shadow: var(--glow-sm);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  selection-background-color: var(--text-neon);
  selection-color: var(--bg-terminal);
}

::selection {
  background-color: var(--text-neon);
  color: var(--bg-terminal);
  text-shadow: none;
}

/* Phosphor Glow Utilities */
.phosphor-glow {
  text-shadow: var(--glow-sm);
}

.phosphor-glow-strong {
  text-shadow: var(--glow-lg);
}

.vt-font {
  font-family: 'VT323', monospace;
  letter-spacing: 0.04em;
}

/* Responsive ASCII Banner - scales automatically on mobile without horizontal overflow */
.ascii-banner {
  font-family: 'VT323', monospace;
  font-size: clamp(0.56rem, 2.75vw, 1.85rem);
  line-height: 1.02;
  letter-spacing: 0.02em;
  white-space: pre;
  overflow-x: hidden;
}

/* Fullscreen CRT Scanline & Flicker Overlay */
.crt-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  background:
    linear-gradient(
      rgba(18, 16, 16, 0) 50%,
      rgba(0, 0, 0, 0.42) 50%
    ),
    radial-gradient(
      circle at center,
      transparent 65%,
      rgba(0, 0, 0, 0.65) 100%
    );
  background-size: 100% 4px, 100% 100%;
}

/* Moving CRT Scanbar Animation */
.crt-overlay::after {
  content: "";
  position: absolute;
  top: -20%;
  left: 0;
  width: 100%;
  height: 140px;
  background: linear-gradient(
    to bottom,
    rgba(51, 255, 0, 0) 0%,
    rgba(51, 255, 0, 0.06) 50%,
    rgba(51, 255, 0, 0) 100%
  );
  animation: crt-scanline 7s linear infinite;
  pointer-events: none;
}

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

/* Terminal Container */
.terminal-container {
  border: 1px solid var(--border-neon);
  box-shadow:
    0 0 15px rgba(51, 255, 0, 0.12),
    inset 0 0 20px rgba(51, 255, 0, 0.05);
  background-color: rgba(10, 10, 10, 0.94);
  position: relative;
}

/* Blinking Block Cursor (█) */
@keyframes cursor-blink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

.cli-input-wrapper .block-cursor {
  display: inline-block;
  color: var(--text-neon);
  text-shadow: var(--glow-lg);
  opacity: 0.25;
  transition: opacity 0.15s ease;
  user-select: none;
}

.cli-input-wrapper:focus-within .block-cursor {
  opacity: 1;
  animation: cursor-blink 1s step-end infinite;
}

/* Hide native caret or keep subtle so block cursor stands out */
.cli-input {
  caret-color: var(--text-neon);
}

.cli-input::placeholder {
  color: rgba(51, 255, 0, 0.35);
  text-shadow: none;
}

/* Bracketed CLI Buttons [ BUTON ] with Inverted Hover & Touch Ergonomics */
.cli-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-neon);
  background-color: transparent;
  border: 1px solid transparent;
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-shadow: var(--glow-sm);
  transition: all 0.12s ease-in-out;
  cursor: pointer;
  user-select: none;
  text-align: center;
  touch-action: manipulation;
}

.cli-btn:hover,
.cli-btn:focus-visible {
  background-color: var(--text-neon);
  color: var(--bg-terminal);
  text-shadow: none;
  box-shadow: 0 0 12px rgba(51, 255, 0, 0.65);
  outline: none;
}

.cli-btn:active {
  transform: translateY(1px);
  background-color: var(--text-neon);
  color: var(--bg-terminal);
}

/* Custom Terminal Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0a0a0a;
  border-left: 1px solid rgba(51, 255, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(51, 255, 0, 0.5);
}

::-webkit-scrollbar-thumb:hover {
  background: #33ff00;
}

/* Error Log Styling (#ff3333) */
.terminal-error {
  color: #ff3333 !important;
  text-shadow: 0 0 6px rgba(255, 51, 51, 0.75), 0 0 14px rgba(255, 51, 51, 0.35);
}

/* Active Mode Highlight for Bracket Buttons */
.cli-btn-active {
  border-color: var(--border-neon);
  background-color: rgba(51, 255, 0, 0.18);
  box-shadow: 0 0 10px rgba(51, 255, 0, 0.35);
}

/* Cipher Wall Transmission Cards */
.wall-card {
  border: 1px solid rgba(51, 255, 0, 0.38);
  background: linear-gradient(180deg, rgba(16, 28, 16, 0.28) 0%, rgba(5, 5, 5, 0.85) 100%);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wall-card:hover {
  border-color: var(--border-neon);
  box-shadow: 0 0 14px rgba(51, 255, 0, 0.22);
}

.wall-stamp {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid rgba(51, 255, 0, 0.35);
  background-color: rgba(51, 255, 0, 0.08);
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

@keyframes pulse-neon {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 8px #33ff00;
  }
  50% {
    opacity: 0.3;
    box-shadow: none;
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: #33ff00;
  display: inline-block;
  flex-shrink: 0;
  animation: pulse-neon 1.6s infinite ease-in-out;
}

/* Mobile-Specific Optimizations */
@media (max-width: 640px) {
  /* Prevent iOS Safari zoom-on-focus by keeping inputs >= 16px on mobile */
  input.cli-input,
  select#quick-book-select {
    font-size: 16px !important;
  }

  .cli-btn {
    min-height: 40px;
    padding: 0.4rem 0.5rem;
  }

  .wall-stamp {
    font-size: 0.66rem;
    padding: 0.12rem 0.38rem;
  }
}
