@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  src: url(https://fonts.gstatic.com/s/vt323/v12/pxiKyp0ihIEF2isfFJXUdVNF.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }
html { font-family: "VT323", monospace; font-size: 16px; height: 100%; overflow: hidden; }
body {
  background-color: #050505;
  background-image:
    linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.25) 50%),
    linear-gradient(90deg, rgba(255,0,0,0.06), rgba(255,0,0,0.02));
  background-size: 100% 2px, 3px 100%;
  margin: 0; padding: 0; display: flex; justify-content: center; align-items: center;
  min-height: 100vh; color: #d32f2f;
}

#container {
  position: relative;
  width: 860px;
  max-width: 100%;
  height: 700px; /* fit header + 800x600 screen + footer */
  border: 4px solid #444; border-radius: 20px; background: #000;
  box-shadow: 0 0 0 4px #1a1a1a, 0 0 50px rgba(220,20,60,0.4), inset 0 0 100px rgba(0,0,0,0.9);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.monitor-header {
  width: 100%; display: flex; justify-content: space-between; padding: 0 10px 10px 10px;
  border-bottom: 2px solid #333; margin-bottom: 10px; color: #ff3333; text-shadow: 0 0 5px #ff3333;
  font-size: 1.2rem; letter-spacing: 2px; flex-shrink: 0;
}

.screen-wrapper {
  position: relative;
  width: 800px;
  height: 600px; /* fixed 4:3 requested */
  max-width: 100%;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid #222; border-radius: 4px; box-shadow: inset 0 0 20px rgba(0,0,0,1);
  background-color: #000;
}

canvas.frame {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-color: #000; image-rendering: pixelated; display: block;
}

.crt-overlay {
  position: absolute; top:0; left:0; width:100%; height:100%; pointer-events:none;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.2));
  background-size: 100% 4px; z-index: 10; box-shadow: inset 0 0 80px rgba(0,0,0,0.7);
}
.crt-glare {
  position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 40%); z-index: 11; border-radius: 4px;
}

#ascii-output { display: none; }
.monitor-footer {
  margin-top: 10px;
  width: 100%;
  text-align: center;
  color: #555;
  font-size: 0.9rem;
  flex-shrink: 0;
  line-height: 1.4;
  word-break: keep-all;
  white-space: normal;
}
.noselect { user-select: none; }

.control-button {
  background: #333;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 2px;
}
.control-button--engine {
  color: #0f0;
  border: 1px solid #0f0;
  margin-right: 8px;
}
.control-button--simd {
  color: #0f0;
  border: 1px solid #0f0;
  margin-right: 8px;
}
.control-button--benchmark {
  color: #ff3333;
  border: 1px solid #ff3333;
}

#benchmark-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95); border: 2px solid #ff3333; border-radius: 8px;
  padding: 20px; min-width: 400px; z-index: 100; display: none;
  color: #ff3333; font-family: "VT323", monospace; box-shadow: 0 0 20px rgba(255,51,51,0.5);
}
#benchmark-panel.active { display: block; }
#benchmark-panel h3 { margin: 0 0 15px 0; font-size: 1.5rem; text-align: center; text-shadow: 0 0 5px #ff3333; }
.benchmark-stats { margin: 10px 0; padding: 10px; background: rgba(255,51,51,0.1); border-left: 3px solid #ff3333; }
.benchmark-stats h4 { margin: 0 0 8px 0; font-size: 1.2rem; }
.benchmark-stats .stat-row { display: flex; justify-content: space-between; margin: 4px 0; font-size: 1rem; }
.benchmark-stats .stat-label { color: #aaa; }
.benchmark-stats .stat-value { color: #ff3333; font-weight: bold; }
#benchmark-current-mode { text-align: center; margin: 15px 0; font-size: 1.3rem; color: #0f0; text-shadow: 0 0 5px #0f0; }
