:root {
  --bg: #05080a;
  --phosphor: #53ff9e;
  --phosphor-dim: #2bd47e;
  --amber: #ffc861;
  --glow: 0 0 6px rgba(83, 255, 158, 0.55), 0 0 18px rgba(83, 255, 158, 0.22);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --crt: "VT323", var(--mono);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 800px at 50% 30%, #0b1a12 0%, var(--bg) 60%),
    var(--bg);
  color: var(--phosphor);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- CRT overlay: scanlines + subtle flicker --------------------------- */
.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
  mix-blend-mode: multiply;
  animation: crt-flicker 4s infinite;
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 255, 160, 0.03), rgba(0, 0, 0, 0.05));
}
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  97% { opacity: 1; }
  98% { opacity: 0.86; }
  99% { opacity: 0.96; }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 41;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* --- Center stage ------------------------------------------------------- */
.stage {
  position: relative;
  z-index: 10;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;   /* front and center, middle of the screen */
  gap: 18px;
  padding: 24px;
}

/* --- Terminal window ---------------------------------------------------- */
.terminal {
  width: min(1080px, 94vw);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(4, 12, 8, 0.82);
  border: 1px solid rgba(83, 255, 158, 0.28);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 10px 40px rgba(0, 0, 0, 0.6),
    0 0 42px rgba(83, 255, 158, 0.12);
  backdrop-filter: blur(2px);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(#0d1712, #080f0b);
  border-bottom: 1px solid rgba(83, 255, 158, 0.18);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot-red   { background: #ff5f56; }
.dot-amber { background: #ffbd2e; }
.dot-green { background: #27c93f; }
.terminal-title {
  margin-left: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(83, 255, 158, 0.6);
}

/* --- Screen ------------------------------------------------------------- */
.screen {
  font-family: var(--crt);
  font-size: clamp(19px, 2.4vw, 27px);
  line-height: 1.45;
  padding: 24px 30px 16px;
  height: min(64vh, 620px);
  overflow-y: auto;
  text-shadow: var(--glow);
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(83, 255, 158, 0.35) transparent;
}
.screen::-webkit-scrollbar { width: 8px; }
.screen::-webkit-scrollbar-thumb { background: rgba(83, 255, 158, 0.3); border-radius: 4px; }

.line { display: block; min-height: 1.45em; }
.line.dim { color: var(--phosphor-dim); opacity: 0.85; }
.line.motd { color: var(--amber); text-shadow: 0 0 8px rgba(255, 200, 97, 0.5); }
.line.error { color: #ff7a72; text-shadow: 0 0 8px rgba(255, 122, 114, 0.45); }
.line.echo { margin-top: 0.35em; }

/* --- Prompt (shared by input row and echoed lines) ---------------------- */
.prompt { white-space: nowrap; }
.prompt-user { color: #6ee7ff; text-shadow: 0 0 8px rgba(110, 231, 255, 0.45); }
.prompt-sep { color: var(--phosphor-dim); }
.prompt-path { color: var(--amber); text-shadow: 0 0 8px rgba(255, 200, 97, 0.4); }
.prompt-glyph { color: var(--phosphor); margin-left: 2px; }

/* --- Input row ---------------------------------------------------------- */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 26px 24px;
  font-family: var(--crt);
  font-size: clamp(19px, 2.4vw, 27px);
  text-shadow: var(--glow);
}
#option-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--phosphor);
  font: inherit;
  text-shadow: inherit;
  caret-color: var(--phosphor);
}
#option-input::placeholder { color: rgba(83, 255, 158, 0.35); }

.hint {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(83, 255, 158, 0.4);
  margin: 0;
}

@media (max-width: 560px) {
  .screen { padding: 18px 18px 12px; height: min(66vh, 560px); }
  .input-row { padding: 0 18px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .crt { animation: none; }
}

/* --- Text editor overlay ------------------------------------------------ */
/* Sits on top of the output screen, inside the terminal window. */
.terminal { position: relative; }

.editor {
  position: absolute;
  inset: 44px 0 0 0;             /* below the window title bar */
  display: flex;
  flex-direction: column;
  background: rgba(3, 10, 6, 0.97);
  z-index: 20;
}
/* The [hidden] attribute must always win over display:flex above, so the
   editor stays hidden until the shell opens it. */
.editor[hidden] {
  display: none !important;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(83, 255, 158, 0.12);
  border-bottom: 1px solid rgba(83, 255, 158, 0.25);
  font-family: var(--crt);
  font-size: clamp(16px, 2vw, 22px);
}
.editor-title { color: var(--phosphor); }
.editor-dirty { color: var(--amber); font-size: 0.85em; letter-spacing: 0.05em; }

.editor-area {
  flex: 1;
  width: 100%;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--phosphor);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  padding: 14px 16px;
  text-shadow: 0 0 4px rgba(83, 255, 158, 0.35);
  caret-color: var(--phosphor);
  white-space: pre;
  overflow: auto;
}

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px;
  background: rgba(83, 255, 158, 0.12);
  border-top: 1px solid rgba(83, 255, 158, 0.25);
  font-family: var(--mono);
  font-size: 12px;
}
#editor-status { color: var(--phosphor-dim); }
.editor-keys { color: rgba(83, 255, 158, 0.6); letter-spacing: 0.02em; }

@media (max-width: 560px) {
  .editor { inset: 40px 0 0 0; }
  .editor-keys { display: none; }
}
