:root {
  --fg: #33ff66; --mid: #22c050; --dim: #11702c; --bg: #031207;
  --glow: rgba(51, 255, 102, .45); --hi: var(--fg); --link: var(--fg);
  --bezel: #2c2a26; --bezel-hi: #3d3a34; --bezel-lo: #171613; --label: #a39d8e;
}
:root[data-phosphor="amber"] {
  --fg: #ffb000; --mid: #cc8a00; --dim: #6e4b00; --bg: #120a00;
  --glow: rgba(255, 176, 0, .45);
}
:root[data-phosphor="white"] {
  --fg: #e6ecff; --mid: #a9b1c3; --dim: #585e6e; --bg: #0a0b0e;
  --glow: rgba(220, 230, 255, .35);
}
:root[data-phosphor="cga"] {
  --fg: #aaaaaa; --mid: #aaaaaa; --dim: #555555; --bg: #000000;
  --glow: rgba(170, 170, 170, .25); --hi: #55ffff; --link: #ffff55;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; padding: 16px;
  background: #020203;
  font-family: 'VT323', monospace;
}
/* A dark terminal room at night, lit only by this screen */
body::before, body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none;
}
body::before {
  z-index: -2; filter: brightness(.7);
  background:
    radial-gradient(ellipse 75% 70% at 50% 50%, transparent 35%, rgba(0, 0, 0, .7)),
    url(room.svg) center / cover no-repeat;
}
body::after {
  z-index: -1; mix-blend-mode: screen; opacity: .6;
  background:
    radial-gradient(ellipse 50% 60% at 50% 46%, var(--glow), transparent 72%),
    radial-gradient(ellipse 42% 12% at 50% 100%, var(--glow), transparent 80%);
  animation: roomglow-in 1.2s ease-out, roomglow 5s 1.2s ease-in-out infinite alternate;
}
@keyframes roomglow { from { opacity: .55; } to { opacity: .68; } }
@keyframes roomglow-in { 0%, 40% { opacity: 0; } 100% { opacity: .55; } }

.monitor {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 28px 10px;
  border-radius: 18px;
  background: linear-gradient(var(--bezel-hi), var(--bezel) 30%, var(--bezel-lo));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65),
              inset 0 2px 0 rgba(255, 255, 255, .08),
              inset 0 -3px 0 rgba(0, 0, 0, .45);
}

.crt {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  border-radius: 24px / 32px;
  background: var(--bg);
  box-shadow: 0 0 0 6px var(--bezel-lo), 0 0 0 7px #000;
  color: var(--fg);
  text-shadow: 0 0 1px var(--fg), 0 0 7px var(--glow);
  font-size: 22px; line-height: 1.15;
  animation: glass-on 1.2s ease-out;
}
.crt::before {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    transparent 0, transparent 2px, rgba(0, 0, 0, .28) 3px);
}
.crt::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 12%, rgba(255, 255, 255, .07), transparent 40%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .65) 100%);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .9);
  animation: flicker .12s infinite;
}
.screen {
  position: absolute; inset: 0; overflow: auto; padding: 26px 34px; isolation: isolate;
  scrollbar-width: thin; scrollbar-color: var(--dim) transparent;
  animation: poweron 1.2s ease-out;
}
.screen.inverse { background: var(--fg); }
.curved .screen { filter: url(#crt-curve); }

/* Switching on mirrors switching off: dark glass, a dot, a line, then the picture */
@keyframes glass-on { 0%, 50% { background-color: #050505; } 100% { background-color: var(--bg); } }
@keyframes poweron {
  0%, 15% { transform: scale(0, 0);      filter: brightness(0);  background-color: var(--bg); }
  27%     { transform: scale(.03, .004); filter: brightness(10); background-color: var(--bg); }
  50%     { transform: scale(1, .004);   filter: brightness(6);  background-color: var(--bg); }
  75%     { transform: scale(1, 1);      filter: brightness(2); }
  100%    { transform: scale(1, 1);      filter: brightness(1); }
}
.crt.off { background: #050505; animation: none; }
.poweroff body::after { animation: none; opacity: 0; transition: opacity .6s ease-in; }
.crt.off .screen { background: var(--bg); animation: poweroff .6s ease-in forwards; }
@keyframes poweroff {
  0%   { transform: scale(1, 1);       filter: brightness(1); }
  45%  { transform: scale(1, .004);    filter: brightness(6); }
  75%  { transform: scale(.03, .004);  filter: brightness(10); }
  100% { transform: scale(0, 0);       filter: brightness(0); }
}
@keyframes flicker { 0% { opacity: .94; } 50% { opacity: 1; } 100% { opacity: .97; } }
@keyframes blink { 50% { visibility: hidden; } }

.panel {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px;
  color: var(--label); font: 600 11px/1 Helvetica, Arial, sans-serif;
  letter-spacing: .15em; text-transform: uppercase;
}
.badge { margin-right: auto; }
.badge b { color: #d8d2c2; letter-spacing: .25em; }
.key {
  font: 600 11px/1 Helvetica, Arial, sans-serif; letter-spacing: .08em;
  padding: 6px 9px 5px; border: 0; border-radius: 3px; cursor: pointer;
  color: #2b2924; background: linear-gradient(#e2dccb, #b6af9c);
  box-shadow: 0 3px 0 #6b6656, inset 0 1px 0 rgba(255, 255, 255, .6);
}
.key[aria-pressed="true"], .key:active {
  transform: translateY(2px); box-shadow: 0 1px 0 #6b6656, inset 0 1px 3px rgba(0, 0, 0, .35);
}
.key:focus-visible { outline: 2px solid #d8d2c2; outline-offset: 2px; }
.led {
  width: 9px; height: 9px; border-radius: 50%; background: #3a1210;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6);
}
.led.on { background: #ff3b2f; box-shadow: 0 0 8px #ff3b2f; }

.blink, .cursor::after { animation: blink 1s steps(1) infinite; }
.cursor::after { content: '\2588'; }

@media (min-width: 900px) {
  body { padding: 3vh 16px 8vh; }
  .monitor { max-width: min(1000px, 74vw); }
}

@media (max-width: 640px) {
  body { padding: 0; }
  .monitor { border-radius: 0; padding: 12px 12px 8px; }
  .crt { font-size: 19px; border-radius: 12px / 16px; }
  .screen { padding: 14px 16px; }
  .badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .crt, .crt::after, .screen, .blink, .cursor::after, body::after { animation: none; }
}
