:root{
  --ink:#0a0b0f;
  --panel:#14161d;
  --line:#2a2e3a;
  --cream:#e9e1cf;
  --gold:#e8b84b;
  --green:#7fd08a;
}

*{box-sizing:border-box}

html,body{height:100%}

body{
  margin:0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:24px;
  background:
    radial-gradient(1200px 700px at 50% 38%, #1a2030 0%, #0b0d13 55%, #05060a 100%);
  color:var(--cream);
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  overflow:hidden;
  user-select:none;
  -webkit-user-select:none;
}

body::after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
  background-size:4px 4px;
  opacity:.25;
}

.cabinet{
  width:min(calc(100vw - 32px), calc((100vh - 128px) * 1.77778));
  display:flex;
  flex-direction:column;
  gap:10px;
  z-index:1;
}

.marquee{
  display:flex;
  align-items:center;
  gap:10px;
  padding:2px 4px 0;
  font-size:11px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:#8f98ad;
  white-space:nowrap;
}

.marquee .led{
  width:8px;height:8px;border-radius:50%;
  background:var(--green);
  box-shadow:0 0 8px var(--green), 0 0 16px rgba(127,208,138,.5);
  flex:none;
  animation:pulse 2.6s steps(2,end) infinite;
}

@keyframes pulse{50%{opacity:.45}}

.marquee .title{color:var(--cream);font-weight:700;letter-spacing:.18em}
.marquee .title b{color:var(--gold)}
.marquee .sub{margin-left:auto;color:#6d768a;font-size:10px}

.screen{
  position:relative;
  width:100%;
  aspect-ratio:16/9;
  background:#000;
  border:2px solid var(--line);
  border-radius:6px;
  box-shadow:
    0 0 0 1px #05060a,
    0 24px 60px rgba(0,0,0,.7),
    0 0 90px rgba(90,130,200,.10);
  overflow:hidden;
  isolation:isolate;
}

canvas{
  display:block;
  width:100%;
  height:100%;
  image-rendering:pixelated;
  image-rendering:-moz-crisp-edges;
  image-rendering:crisp-edges;
  outline:none;
}

.crt{
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.16) 0 1px, rgba(0,0,0,0) 1px 3px),
    radial-gradient(120% 100% at 50% 50%, rgba(255,255,255,.04) 0%, rgba(0,0,0,.28) 100%);
  mix-blend-mode:multiply;
  opacity:.9;
}

.screen::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  box-shadow:inset 0 0 40px rgba(0,0,0,.55);
  border-radius:5px;
}

.hints{
  display:flex;
  flex-wrap:wrap;
  gap:6px 16px;
  font-size:10.5px;
  letter-spacing:.06em;
  color:#7d869c;
  padding:0 4px;
  text-transform:uppercase;
}

kbd{
  font:inherit;
  color:#cfd6e4;
  background:#1b202b;
  border:1px solid #2c3341;
  border-bottom-width:2px;
  border-radius:3px;
  padding:1px 5px;
  margin:0 1px;
}

.sound{margin-left:auto;color:var(--gold);cursor:pointer}
.sound.off{color:#5a6172}

.loader{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:14px;
  background:#05060a;
  font-size:11px;
  letter-spacing:.3em;
  color:#9aa4bb;
  transition:opacity .35s ease;
  z-index:5;
}
.loader.hide{opacity:0;pointer-events:none}
.loader .bar{width:180px;height:6px;border:1px solid #333c4d;padding:1px}
.loader .bar i{display:block;height:100%;width:38%;background:var(--gold);animation:load 1.1s steps(6,end) infinite}
@keyframes load{0%{width:8%}100%{width:100%}}

.touch{
  position:fixed;
  inset:auto 0 0 0;
  display:none;
  justify-content:space-between;
  align-items:flex-end;
  padding:18px 22px calc(18px + env(safe-area-inset-bottom));
  z-index:20;
  pointer-events:none;
}
.touch.show{display:flex}
.touch button{
  pointer-events:auto;
  font:inherit;
  color:#dfe6f2;
  background:rgba(20,24,33,.82);
  border:2px solid rgba(120,135,160,.55);
  border-radius:12px;
  width:56px;height:56px;
  font-size:16px;
  touch-action:none;
}
.touch button:active{background:rgba(120,135,160,.4)}
.touch .dpad{
  display:grid;
  grid-template-columns:repeat(3,52px);
  grid-template-rows:repeat(3,52px);
  gap:4px;
}
.touch .dpad button{width:52px;height:52px}
.touch .dpad [data-dir="up"]{grid-area:1/2}
.touch .dpad [data-dir="left"]{grid-area:2/1}
.touch .dpad [data-dir="down"]{grid-area:3/2}
.touch .dpad [data-dir="right"]{grid-area:2/3}
.touch .tbtns{display:flex;align-items:flex-end;gap:12px}
.touch .tbtns button{width:74px;height:74px;border-radius:50%;font-size:20px}
.touch .tbtns button.small{width:56px;height:56px;font-size:11px;letter-spacing:.08em}

@media (max-width:700px){
  body{overflow:auto}
  .marquee .sub{display:none}
  .hints{font-size:9px;gap:4px 10px}
  .cabinet{width:calc(100vw - 16px)}
}
