:root {
  --bg: #000;
  --fg: #c2fe0c;
  --dim: #7a7a7a;
  --bright: #fff;
  --error: #d02020;
  --link: #4a8cff;
  --font: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 22px;
  line-height: 1.45;
}

/* Windows 3.1 arrow everywhere (set from script.js), text caret in the input */
* { cursor: var(--cursor, default); }
#input { cursor: text; }

::selection { background: var(--fg); color: var(--bg); }

/* DOS-style screen: full height, text anchored bottom-left, growing upward */
.terminal {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 20px;
}

.terminal[hidden] { display: none; }

/* `exit` message: covers the screen, text centred */
#exit-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
#exit-screen > div { max-width: 100%; }
#exit-screen > div > div { white-space: pre-wrap; word-break: break-word; }

#output > div { white-space: pre-wrap; word-break: break-word; min-height: 1.45em; }

b, .bright { color: var(--bright); font-weight: 700; }
.dim { color: var(--dim); }
.error { color: var(--error); }

a { color: var(--link); text-decoration: underline; }
a:hover { background: var(--link); color: var(--bg); }

/* Same inverse-on-hover as links, but white, for plain text rows (the about text) */
.hover-row { width: fit-content; max-width: min(1200px, 100%); }
.hover-row:hover { background: var(--bright); color: var(--bg); }

#coords {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  font-size: 9px;
  line-height: 1.3;
  padding: 2px 6px;
  color: #d0d0d0;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  white-space: pre;
  pointer-events: none;
  user-select: none;
  opacity: 0;
}

/* Fixed bottom-right button: square green outline, grey-white text */
#modern-terminal {
  position: fixed;
  right: 20px;
  bottom: 16px;
  z-index: 10;
  padding: 4px 12px;
  font: inherit;
  font-size: 14px;
  color: #d0d0d0;
  background: var(--bg);
  border: 1px solid var(--fg);
  border-radius: 0;
}
#modern-terminal:hover { background: var(--fg); color: var(--bg); }
#modern-terminal:focus-visible { outline: 1px solid var(--bright); outline-offset: 2px; }

#prompt { display: flex; gap: 8px; align-items: center; }
#prompt[hidden] { display: none; }
.ps1 { white-space: nowrap; }

.input-wrap { position: relative; flex: 1; min-width: 0; }

/* Autocomplete hint: typed text is invisible, only the suggested rest shows */
#ghost {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  white-space: pre;
  color: var(--dim);
}
#ghost span { visibility: hidden; }

#input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 0;
  color: var(--fg);
  font: inherit;
  caret-color: var(--bright);
}

/* Glitch effect: text sits still, then bursts with RGB-split slices */
.glitch { position: relative; animation: jitter 15s infinite steps(1); }

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  pointer-events: none;
  white-space: pre-wrap;
  opacity: 0;
}

.glitch::before { color: #ff2a4d; animation: slice-a 15s infinite steps(1); }
.glitch::after  { color: #22e0ff; animation: slice-b 15s infinite steps(1); }

.glitch, .glitch::before, .glitch::after { animation-delay: var(--d, 0s); }

/* One short (~0.15s), faint burst per 15s cycle */
@keyframes jitter {
  0%, 96%, 100% { transform: none; }
  96.2% { transform: translateX(-1px); }
  96.6% { transform: translateX(1px); }
  97% { transform: none; }
}

@keyframes slice-a {
  0%, 96%, 100% { opacity: 0; }
  96.2% { opacity: 0.6; transform: translateX(-2px); clip-path: inset(10% 0 60% 0); }
  96.6% { opacity: 0.6; transform: translateX(1px);  clip-path: inset(55% 0 15% 0); }
  97% { opacity: 0; }
}

@keyframes slice-b {
  0%, 96%, 100% { opacity: 0; }
  96.2% { opacity: 0.6; transform: translateX(2px);  clip-path: inset(50% 0 20% 0); }
  96.6% { opacity: 0.6; transform: translateX(-1px); clip-path: inset(5% 0 70% 0); }
  97% { opacity: 0; }
}

/* ---- Modern terminal window ---- */
#modern {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(1000px, 92vw);
  height: min(700px, 90dvh);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  background: #0a0c0a;
  border: 1px solid var(--fg);
  box-shadow: 0 0 0 1px #000, 0 0 40px rgba(194, 254, 12, 0.12);
  font-size: 15px;
  line-height: 1.5;
  animation: m-open 0.28s ease-out;
}

@keyframes m-open {
  from { transform: translate(-50%, -50%) scale(0.92, 0.02); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1, 0.02); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(1, 1); }
}

.m-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--fg);
  color: #d0d0d0;
  font-size: 13px;
}
.m-dots { display: flex; gap: 6px; }
.m-dots i { width: 9px; height: 9px; border: 1px solid var(--fg); border-radius: 50%; }
.m-name { flex: 1; text-align: center; }
.m-close {
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: #d0d0d0;
  background: none;
  border: 0;
  padding: 0 4px;
}
.m-close:hover { background: var(--bright); color: var(--bg); }

.m-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px; }
/* Scrollbar: square, solid green thumb on a dark track, no arrows or rounding */
.m-body { scrollbar-width: auto; scrollbar-color: var(--fg) #0a0c0a; }
.m-body::-webkit-scrollbar { width: 40px; }
.m-body::-webkit-scrollbar-track { background: #0a0c0a; border-left: 4px solid var(--fg); }
.m-body::-webkit-scrollbar-thumb { background: var(--fg); border: 4px solid #0a0c0a; border-radius: 0; }
.m-body::-webkit-scrollbar-button { display: none; }
.m-cmds { flex: none; padding: 8px 18px; border-top: 1px solid var(--fg); }
.m-row { white-space: pre-wrap; word-break: break-word; min-height: 1.5em; }
.m-text { width: fit-content; max-width: 100%; color: #d0d0d0; }
.m-text:hover { background: var(--bright); color: var(--bg); }
.m-dim { color: var(--dim); }
.m-ok { color: var(--fg); }
.m-prompt { color: var(--fg); }
.m-echo { color: var(--bright); margin-top: 8px; }
.m-bar { color: var(--fg); }

.m-menu { display: flex; flex-direction: column; align-items: flex-start; margin: 4px 0 8px; }
.m-cmd {
  display: flex;
  gap: 14px;
  width: 100%;
  padding: 1px 6px;
  font: inherit;
  text-align: left;
  color: #d0d0d0;
  background: none;
  border: 0;
  border-radius: 0;
}
.m-cmd b { min-width: 10ch; }
.m-cmd span { color: var(--dim); }
.m-cmd:hover, .m-cmd:focus-visible { background: var(--bright); color: var(--bg); outline: 0; }
.m-cmd:hover span, .m-cmd:focus-visible span { color: var(--bg); }
.m-cmd:hover b, .m-cmd:focus-visible b { color: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  .glitch, .glitch::before, .glitch::after { animation: none; }
}

@media (max-width: 640px) {
  html, body { font-size: 18px; }
}
