:root {
  color-scheme: dark;
  --case: #24272b;
  --case-edge: #0e0f11;
  --screen: #030607;
  --ink: #d4d7da;
  --bright: #ffffff;
  --accent: #55ffff;
  --dim: #747b83;
  --danger: #ff6a6a;
  --glow: 0 0 5px color-mix(in srgb, var(--ink) 60%, transparent);
  --columns: 80ch;
  --font-size: clamp(12px, 1.45vw, 18px);
}

* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  padding: clamp(6px, 2vw, 24px);
  background:
    radial-gradient(circle at 50% 15%, #30353b 0, #15181c 42%, #08090b 100%);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
}

button, select, input { font: inherit; }

.machine {
  width: min(1180px, 100%);
  height: calc(100dvh - clamp(12px, 4vw, 48px));
  min-height: 460px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(8px, 1.5vw, 18px);
  border: 1px solid #4b5055;
  border-radius: 12px;
  background: linear-gradient(145deg, #33373c, var(--case) 45%, #1a1c20);
  box-shadow: 0 28px 60px #000c, inset 0 1px #ffffff24, inset 0 -3px #0008;
}

.hardware, .hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #c4c6c7;
  font-size: 11px;
  letter-spacing: .08em;
  text-shadow: 0 1px #000;
}

.hardware { padding: 0 4px 10px; }
.brand { white-space: nowrap; }
.brand small { margin-left: 10px; color: #80868b; }
.lamp { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #3a1111; box-shadow: inset 0 1px #000; }
.lamp.on { background: #6aff77; box-shadow: 0 0 8px #42ff52; }

.controls { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.controls label { display: inline-flex; align-items: center; gap: 4px; }
.controls select, .controls button {
  height: 25px;
  padding: 2px 7px;
  border: 1px solid #08090a;
  border-radius: 2px;
  background: #16181b;
  color: #cdd0d2;
  box-shadow: inset 0 1px #ffffff1c, 0 1px #53585c;
  cursor: pointer;
  font-size: 10px;
}
.controls button:focus-visible, .controls select:focus-visible { outline: 2px solid #73d8ff; outline-offset: 2px; }

.bezel {
  min-height: 0;
  padding: clamp(7px, 1.6vw, 18px);
  overflow: hidden;
  border: 2px solid #0a0b0c;
  border-radius: 26px / 18px;
  background: linear-gradient(145deg, #090a0c, #1a1c20 46%, #050607);
  box-shadow: inset 7px 7px 18px #000, inset -4px -4px 12px #51586026;
}

.terminal {
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 1px solid #000;
  border-radius: 22px / 15px;
  background: var(--screen);
  box-shadow: inset 0 0 34px #000, 0 0 12px #000;
  font-size: var(--font-size);
  line-height: 1.2;
  text-shadow: var(--glow);
  isolation: isolate;
}

.terminal::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 2px, #00000040 3px, #00000040 4px);
  mix-blend-mode: multiply;
  opacity: .65;
}

.terminal::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(ellipse at center, transparent 50%, #0009 115%);
}

html[data-effects="off"] .terminal::before { display: none; }

.screen {
  width: min(calc(100% - 28px), var(--columns));
  height: calc(100% - 58px);
  margin: 16px auto 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.command-line {
  width: min(calc(100% - 28px), var(--columns));
  height: 38px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  color: var(--accent);
}

.command-line.busy { visibility: hidden; }
.command-line label { flex: 0 0 auto; margin-right: 1ch; }
.command-line input {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--bright);
  caret-color: transparent;
}
.cursor { display: block; width: .65em; height: 1.05em; margin-top: .05em; background: var(--bright); animation: blink 1s steps(1) infinite; box-shadow: var(--glow); }
@keyframes blink { 0%, 48% { opacity: 1; } 49%, 100% { opacity: 0; } }

.line { min-height: 1.2em; }
.line.bright { color: var(--bright); }
.line.accent { color: var(--accent); }
.line.dim { color: var(--dim); }
.line.danger { color: var(--danger); }
.line.center { text-align: center; }

.hint { min-height: 25px; padding: 8px 5px 0; color: #777d82; }

html[data-era="1983"] {
  --screen: #3526a5;
  --ink: #9e9cff;
  --bright: #c9c8ff;
  --accent: #7effe7;
  --dim: #7472ca;
  --danger: #ffb0c7;
  --columns: 40ch;
  --font-size: clamp(14px, 2vw, 21px);
}

html[data-era="1986"] { --screen: #020406; --ink: #c9cccf; --bright: #fff; --accent: #44e8ef; --dim: #6f767e; --columns: 80ch; }

html[data-era="1991"] { --screen: #020105; --ink: #d9d9de; --bright: #fff; --accent: #ff61f4; --dim: #77758b; --danger: #ffcf42; --columns: 80ch; }

html[data-monitor="green"] { --screen: #001005; --ink: #65ff89; --bright: #c0ffce; --accent: #94ffaa; --dim: #2e7540; --danger: #baffc6; }
html[data-monitor="amber"] { --screen: #120900; --ink: #ffb84d; --bright: #ffe1a1; --accent: #ffcb6b; --dim: #805922; --danger: #fff0c2; }

@media (max-width: 720px) {
  body { padding: 0; }
  .machine { height: 100dvh; min-height: 0; border: 0; border-radius: 0; padding: 5px; }
  .hardware { padding: 2px 3px 6px; }
  .brand { display: none; }
  .controls { width: 100%; justify-content: space-between; gap: 3px; }
  .controls label { font-size: 0; }
  .controls select, .controls button { font-size: 9px; padding-inline: 5px; }
  .bezel { padding: 4px; border-radius: 10px; }
  .terminal { border-radius: 8px; font-size: 10px; }
  .screen, .command-line { width: calc(100% - 14px); }
  .screen { margin-top: 8px; height: calc(100% - 44px); }
  .hint span:nth-child(-n+2) { display: none; }
  .hint { justify-content: flex-end; min-height: 18px; padding-top: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .terminal::before { display: none; }
}
