:root {
  --bg: #05060f;
  --green: #7dffa0;
  --green-dim: #4fd27a;
  --cyan: #2af6ff;
  --pink: #ff2a6d;
  --lime: #7dff2a;
}
html { background: var(--bg); }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--green);
  font-family: VT323, ui-monospace, monospace;
  overflow-x: hidden;
}
#demo {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: manipulation;
  cursor: pointer;
}
.term {
  position: relative; z-index: 2; box-sizing: border-box;
  width: min(36rem, calc(100% - 32px));
  margin: max(6vh, 44px) auto 24px;
  background: rgba(3, 8, 10, 0.8);
  border: 1px solid rgba(125, 255, 160, 0.45);
  border-radius: 6px;
  box-shadow: 0 0 0 1px #000, 0 0 28px rgba(60, 255, 140, 0.2), inset 0 0 40px rgba(60, 255, 140, 0.06);
}
.term-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(125, 255, 160, 0.3);
  font-size: 1.05rem; color: #c9ffd9; letter-spacing: 0.06em;
}
.term-bar { flex-wrap: wrap; }
#title { margin-right: auto; }
.term-body { padding: 12px 16px 16px; font-size: 1.3rem; line-height: 1.25; }
.js #main { opacity: 0; transform: translateY(6px); transition: opacity 0.5s, transform 0.5s; }
.js #main.show { opacity: 1; transform: none; }
h1 {
  margin: 0.2rem 0 0.7rem;
  font-family: "Press Start 2P", monospace; font-weight: 400;
  font-size: clamp(1rem, 4.6vw, 1.7rem); line-height: 1.35;
  color: #fff;
  text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan);
  animation: glitch 4s infinite steps(1);
}
p { margin: 0.35rem 0; }
b { color: #fff; font-weight: 400; }
code { color: var(--cyan); font-family: inherit; word-break: break-all; }
kbd { font-family: inherit; color: #000; background: var(--lime); padding: 0 0.35em; border-radius: 3px; }
.hint { color: #ffe066; }
.sys { color: #6aa884; font-size: 1.1rem; margin-top: 0.8rem; }
.cursor {
  display: inline-block; width: 0.55em; height: 1em; margin-left: 0.3em; vertical-align: -0.12em;
  background: var(--green); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes glitch {
  0%, 90%, 100% { transform: none; text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan); }
  91% { transform: translate(2px, -1px) skewX(-10deg); text-shadow: -3px 0 var(--pink), 3px 0 var(--cyan); }
  93% { transform: translate(-3px, 1px); text-shadow: 4px 0 var(--pink), -4px 0 var(--cyan); }
  95% { transform: translate(1px, 0) skewX(6deg); }
}
/* CRT: scanlines + vignette over everything */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
@media (prefers-reduced-motion: reduce) {
  h1, .cursor { animation: none; }
  .js #main { transition: none; }
}
#sound, #mode, #reboot {
  font: inherit; font-size: 1rem; letter-spacing: 0.06em;
  color: var(--green); background: transparent;
  border: 1px solid rgba(125, 255, 160, 0.55); border-radius: 3px;
  padding: 0 8px; cursor: pointer;
}
#sound:hover, #mode:hover, #reboot:hover { background: rgba(125, 255, 160, 0.12); }
#sound[aria-pressed="true"] { color: #000; background: var(--lime); border-color: var(--lime); }
#sound:focus-visible, #mode:focus-visible, #reboot:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* Text-mode DOS screen shown before (and after) the demo runs. Only with JS. */
#dos { display: none; }
.js #dos {
  display: block; position: fixed; inset: 0; z-index: 4;
  box-sizing: border-box; padding: 1em 1.3em; overflow: hidden;
  background: #000; color: #aaa;
  font-family: VT323, ui-monospace, monospace;
  font-size: clamp(9px, 2.2vw, 26px); line-height: 1.12;
  transition: opacity 0.35s;
}
.js #dos[hidden] { display: none; }
.js #dos.off { opacity: 0; pointer-events: none; }
#dos-screen { margin: 0; font: inherit; white-space: pre-wrap; word-break: break-word; }
#dos .cur {
  display: inline-block; width: 0.5em; height: 0.14em; margin-left: 1px;
  background: #aaa; vertical-align: -0.05em;
  animation: blink 0.5s steps(1) infinite;
}
#dos-hint { position: absolute; right: 1.3em; bottom: 0.8em; color: #555; font-size: 0.8em; }
@media (prefers-reduced-motion: reduce) { #dos .cur { animation: none; } }

/* SECOND.EXE runs in a fixed 320x240 mode, letterboxed; the panel shrinks to its title bar */
body.sr #demo { object-fit: contain; }
body.sr .term {
  position: fixed; right: 12px; bottom: 12px; margin: 0; width: auto; max-width: calc(100% - 24px);
  opacity: 0.45; transition: opacity 0.2s;
}
body.sr .term:hover, body.sr .term:focus-within { opacity: 1; }
body.sr .term-body { display: none; }
body.sr .term-bar { border-bottom: 0; }

/* MS-DOS Editor look-alike */
#dos.edit { padding: 0; background: #0000aa; color: #fff; }
.ed { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ed-menu { background: #aaa; color: #000; white-space: pre; }
.ed-title { position: relative; text-align: center; margin: 0 0.5em; }
.ed-title::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 0.12em solid #aaa; }
.ed-title span { position: relative; background: #aaa; color: #0000aa; }
.ed-body {
  flex: 1; margin: 0 0.5em; padding: 0 0.5em; overflow: hidden;
  border-left: 0.12em solid #aaa; border-right: 0.12em solid #aaa; border-bottom: 0.12em solid #aaa;
  font: inherit; white-space: pre-wrap; color: #fff;
}
.ed-status { display: flex; justify-content: space-between; background: #00aaaa; color: #000; padding: 0 0.5em; white-space: pre; }
#dos .c { display: inline-block; width: 1ch; overflow: visible; vertical-align: top; }
#dos .bx { transform: scale(var(--bx, 1), 1.12); transform-origin: 0 50%; }
