@font-face {
  font-family: "Perfect DOS VGA 437";
  src: url("fonts/PerfectDOSVGA437.ttf") format("truetype");
  font-display: block;
}

:root {
  --screen: #061009;
  --phosphor: #b5dbb0;
  --bright: #d1f0c7;
  --dim: #6e9470;
  --bezel: #151713;
  --alarm: #a60d06;
  --scanline-alpha: 0.12;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% 20%, #24261f 0%, #0b0c0a 60%, #000 100%);
  color: var(--phosphor);
  font-family: "Perfect DOS VGA 437", "Courier New", monospace;
  font-size: 16px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bezel {
  width: min(1100px, 100vw);
  height: min(800px, 100vh);
  padding: clamp(10px, 3vw, 34px) clamp(10px, 3vw, 34px) 8px;
  background: linear-gradient(160deg, #383a33 0%, var(--bezel) 30%, #000 100%);
  border-radius: 22px;
  box-shadow: 0 14px 60px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.07);
  display: flex;
  flex-direction: column;
}
body.fullscreen .bezel { width: 100vw; height: 100vh; border-radius: 0; }

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--screen);
  border-radius: 14px / 18px;
  padding: clamp(12px, 2.5vw, 30px);
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,.85), inset 0 0 14px rgba(181,219,176,.08), 0 0 14px rgba(181,219,176,.08);
  text-shadow: 0 0 3px rgba(181,219,176,.45);
}
.screen::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,var(--scanline-alpha)) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.screen::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.45) 100%);
  z-index: 2;
}

[hidden] { display: none !important; }
pre { margin: 0; font: inherit; white-space: pre-wrap; }
.dim { color: var(--dim); }
.bright { color: var(--bright); }

.boot { height: 100%; }

.menu { height: 100%; display: flex; flex-direction: column; }
.menu-head { font-size: 20px; letter-spacing: .08em; margin-bottom: 26px; }
.menu-head div + div { font-size: 14px; margin-top: 6px; }
.menu-body { flex: 1; min-height: 0; display: flex; gap: 58px; align-items: flex-start; }
.art { flex: none; }
.menu-panel { flex: 1; min-width: 0; overflow-y: auto; max-height: 100%; }
.menu-panel .row { display: block; background: none; border: 0; color: inherit; font: inherit; padding: 6px 0 6px 24px; cursor: pointer; text-align: left; width: 100%; position: relative; }
.menu-panel .row.selected { color: var(--bright); background: rgba(181,219,176,.09); }
.menu-panel .row.selected::before { content: ">"; position: absolute; left: 6px; }
.menu-panel .label { margin-bottom: 18px; }
.menu-panel .meta { font-size: 14px; color: var(--dim); }
.menu-panel p { margin: 0 0 14px; white-space: pre-line; }
.menu-foot { display: flex; gap: 10px; border-top: 1px solid rgba(110,148,112,.4); padding-top: 13px; }
.menu-foot .ready { margin-left: auto; }
.cursor { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.game { height: 100%; display: flex; flex-direction: column; position: relative; }
.status { display: flex; gap: 22px; padding-bottom: 4px; }
.status #st-location { color: var(--bright); flex: 1; text-transform: uppercase; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status.sub { font-size: 14px; border-bottom: 1px solid rgba(110,148,112,.35); padding-bottom: 8px; margin-bottom: 10px; justify-content: space-between; }
.power.low { color: #ff6c55; text-shadow: 0 0 8px rgba(255,40,20,.7); }
.power.critical { color: var(--alarm); animation: blink .9s steps(1) infinite; }

.transcript { flex: 1; min-height: 0; overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; }
.entry { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry.command { color: var(--bright); margin-bottom: 6px; }
.entry.system { color: var(--phosphor); }
.entry.dialogue { color: var(--bright); }
.entry.error { color: var(--dim); }
.entry.death { color: #ff6c55; }

.prompt { display: flex; gap: 10px; align-items: center; padding-top: 8px; }
.prompt label { color: var(--bright); }
.prompt input {
  flex: 1; background: transparent; border: 0; outline: 0; color: var(--bright);
  font: inherit; caret-color: var(--bright); text-shadow: inherit; text-transform: uppercase;
}

.overlay {
  position: absolute; inset: 40px 10% auto; z-index: 3;
  background: rgba(6,16,9,.97); border: 1px solid var(--dim); padding: 18px 22px;
  box-shadow: 0 0 30px rgba(0,0,0,.9);
}

.bezel-label { display: flex; align-items: center; gap: 16px; color: #8a8c80; font-size: 12px; letter-spacing: .25em; padding: 8px 6px 2px; }
.bezel-controls { margin-left: auto; display: flex; gap: 8px; }
.bezel-controls button {
  font: inherit; font-size: 11px; letter-spacing: .15em; color: #9b9d90;
  background: linear-gradient(#2b2d27, #121310); border: 1px solid #000; border-radius: 4px; padding: 4px 8px; cursor: pointer;
}
.bezel-controls button[aria-pressed="false"] { color: #55574d; }
.led { width: 9px; height: 9px; border-radius: 50%; background: #3cff6a; box-shadow: 0 0 8px #3cff6a; }
.led.off { background: #1c3a22; box-shadow: none; }

@media (max-width: 720px) {
  body { font-size: 14px; }
  .art { display: none; }
  .menu-body { gap: 0; }
  .bezel { border-radius: 0; }
}
