:root {
  color-scheme: dark;
  --black: #000000;
  --night: #000018;
  --blue: #0000aa;
  --bright-blue: #0000ff;
  --cyan: #55ffff;
  --green: #00aa00;
  --red: #aa0000;
  --yellow: #ffff55;
  --gray: #aaaaaa;
  --white: #ffffff;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--night);
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  background:
    radial-gradient(circle at 50% -20%, rgba(0, 0, 255, 0.24), transparent 48%),
    repeating-linear-gradient(118deg, transparent 0 46px, rgba(85, 255, 255, 0.025) 47px 48px),
    #000008;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 14px 18px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 10px;
  width: min(100%, 944px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--white);
  font-weight: 900;
  letter-spacing: -0.08em;
  text-shadow: 3px 3px 0 var(--blue);
}

.brand span,
.brand strong { font-size: clamp(23px, 5vw, 42px); }
.brand span { color: var(--gray); }
.brand strong { color: var(--white); font-style: italic; }
.brand i {
  width: clamp(22px, 5vw, 54px);
  height: 5px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transform: skewX(-28deg);
  box-shadow: 0 7px 0 var(--blue);
}
.brand small {
  color: var(--yellow);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-shadow: none;
}

.toolbar {
  display: flex;
  gap: 7px;
}

button {
  color: var(--white);
  border: 1px solid var(--bright-blue);
  border-radius: 2px;
  background: linear-gradient(#000044, #000018);
  padding: 8px 11px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(85, 255, 255, 0.12), 2px 2px 0 #000;
}

button:hover,
button:focus-visible {
  border-color: var(--cyan);
  color: var(--yellow);
  outline: none;
}

button:active { transform: translateY(1px); }

.cabinet {
  position: relative;
  width: min(100%, 944px);
  margin: 0 auto;
  padding: 15px;
  overflow: hidden;
  border: 2px solid var(--bright-blue);
  background:
    linear-gradient(90deg, transparent 48%, rgba(85,255,255,.14) 50%, transparent 52%) 0 0 / 28px 100%,
    linear-gradient(#000044, #000018 18%, #000018 82%, #000044);
  box-shadow:
    0 0 0 3px #000,
    0 0 0 5px var(--gray),
    0 16px 40px rgba(0,0,0,.75),
    0 0 34px rgba(0,0,255,.3);
}

.speed-stripes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .4;
}

.speed-stripes i {
  position: absolute;
  left: -10%;
  width: 46%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  transform: skewX(-32deg);
}
.speed-stripes i:nth-child(1) { top: 9%; }
.speed-stripes i:nth-child(2) { top: 25%; left: 65%; }
.speed-stripes i:nth-child(3) { top: 53%; left: 78%; width: 26%; }
.speed-stripes i:nth-child(4) { top: 78%; left: 3%; width: 33%; }
.speed-stripes i:nth-child(5) { top: 92%; left: 55%; }

.screen-bezel {
  position: relative;
  padding: 10px;
  border: 2px solid var(--gray);
  background: #000;
  box-shadow: inset 0 0 22px #000, 0 0 0 2px var(--blue);
}

.screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 5;
  overflow: hidden;
  background: #000;
}

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

.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg, rgba(255,255,255,.055), transparent 26%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.11) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
  opacity: .45;
}

.mobile-controls {
  display: none;
  grid-template-columns: 1fr .72fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.mobile-controls button {
  min-height: 58px;
  touch-action: none;
}

.mobile-controls span { display: block; color: var(--cyan); font-size: 18px; }
.mobile-controls b { display: block; margin-top: 3px; font-size: 10px; }
.mobile-controls .start-button span { color: var(--red); }

.cabinet-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 3px 0;
  color: var(--gray);
  font-size: 10px;
}

#status-text { color: var(--yellow); text-align: right; }

dialog {
  width: min(92vw, 520px);
  color: var(--white);
  border: 2px solid var(--bright-blue);
  border-radius: 3px;
  background: #000018;
  box-shadow: 0 0 0 3px #000, 0 18px 70px #000;
}

dialog::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(2px); }
dialog form { padding: 10px 14px 16px; }
dialog h2 { color: var(--yellow); margin: 4px 0 18px; }
dialog p { line-height: 1.55; }
.dialog-close { float: right; padding: 4px 9px; font-size: 20px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 9px 15px; align-items: center; }
kbd { color: var(--cyan); border: 1px solid var(--blue); padding: 4px 7px; background: #000; text-align: center; }
.help-note { color: var(--gray); font-size: 12px; }

@media (hover: none), (pointer: coarse), (max-width: 720px) {
  .app-shell { padding: 8px 7px 15px; }
  .topbar { align-items: flex-end; }
  .toolbar button { padding: 7px 8px; font-size: 10px; }
  .cabinet { padding: 9px; }
  .screen-bezel { padding: 6px; }
  .mobile-controls { display: grid; }
  .cabinet-footer { font-size: 8px; }
}

@media (max-width: 470px) {
  .brand i, .brand small { display: none; }
  .brand { gap: 3px; }
  .toolbar { gap: 4px; }
  .toolbar button { padding-inline: 6px; }
  .cabinet-footer span:first-child { display: none; }
  .cabinet-footer { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
  }
}
