* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --dos-black: #000000;
  --dos-blue: #0000AA;
  --dos-green: #00AA00;
  --dos-cyan: #00AAAA;
  --dos-red: #AA0000;
  --dos-magenta: #AA00AA;
  --dos-brown: #AA5500;
  --dos-lightgray: #AAAAAA;
  --dos-darkgray: #555555;
  --dos-lightblue: #5555FF;
  --dos-lightgreen: #55FF55;
  --dos-lightcyan: #55FFFF;
  --dos-lightred: #FF5555;
  --dos-lightmagenta: #FF55FF;
  --dos-yellow: #FFFF55;
  --dos-white: #FFFFFF;
  --bg: #0a0a0e;
  --panel-bg: #000088;
  --panel-border: #5555FF;
}

body {
  background: var(--bg);
  color: var(--dos-lightgray);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 13px;
  overflow-x: hidden;
  min-height: 100vh;
}

#titlebar {
  background: var(--dos-blue);
  color: var(--dos-white);
  padding: 6px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(85,85,255,0.5);
  border-bottom: 2px solid var(--dos-lightblue);
}
.title-right { color: var(--dos-yellow); }

.blink { animation: blink 1s step-end infinite; }
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

#main-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 4px;
  padding: 4px;
  min-height: calc(100vh - 220px);
}

.dos-panel {
  background: rgba(0,0,80,0.85);
  border: 1px solid var(--dos-lightblue);
  padding: 8px;
  position: relative;
}

.panel-header {
  color: var(--dos-yellow);
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#dropzone {
  border: 2px dashed var(--dos-cyan);
  padding: 24px 12px;
  text-align: center;
  color: var(--dos-white);
  font-size: 13px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
#dropzone:hover, #dropzone.dragover {
  background: rgba(0,170,170,0.15);
  border-color: var(--dos-yellow);
}
.prompt-char { color: var(--dos-lightgreen); font-size: 18px; }

.dos-button {
  background: var(--dos-darkgray);
  color: var(--dos-white);
  border: 1px solid var(--dos-lightgray);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  transition: all 0.1s;
}
.dos-button:hover {
  background: var(--dos-lightgray);
  color: var(--dos-black);
}
.dos-button.active {
  background: var(--dos-cyan);
  color: var(--dos-black);
}
.dos-button.small {
  padding: 2px 6px;
  font-size: 11px;
}
.dos-button.fun {
  margin: 4px 2px;
  background: var(--dos-red);
  border-color: var(--dos-lightred);
}
.dos-button.fun:hover {
  background: var(--dos-lightred);
}
.dos-button.ctrl {
  padding: 6px 8px;
  font-size: 11px;
  margin: 0 2px;
}

#file-info {
  margin-bottom: 8px;
}
#filename-display { color: var(--dos-lightgreen); word-break: break-all; }
#filesize-display { color: var(--dos-yellow); font-size: 11px; }

.dos-radio {
  display: block;
  color: var(--dos-white);
  cursor: pointer;
  padding: 2px 0;
  font-size: 11px;
}
.dos-radio input[type="radio"] { display: none; }
.dos-radio input[type="radio"]:checked + span::first-letter { }
.dos-radio span { color: var(--dos-lightcyan); }
.dos-radio input[type="radio"]:checked + span { color: var(--dos-yellow); }

#signal-toggle { display: flex; gap: 4px; }

#fun-buttons { margin-top: 12px; display: flex; gap: 4px; }

/* Monitor */
#center-panel { display: flex; flex-direction: column; align-items: center; }

#monitor-bezel {
  background: linear-gradient(145deg, #3a3a3a, #1a1a1a);
  border-radius: 18px;
  padding: 18px 22px 12px;
  box-shadow: 
    inset 0 2px 4px rgba(255,255,255,0.1),
    inset 0 -2px 4px rgba(0,0,0,0.5),
    0 8px 32px rgba(0,0,0,0.8);
  margin: 8px 0;
  position: relative;
}
#monitor-inner {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}
#cga-display {
  display: block;
  width: 640px;
  height: 400px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#scanline-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.2) 1px,
    rgba(0,0,0,0.2) 2px
  );
  pointer-events: none;
}
#crt-vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}
#monitor-label {
  text-align: center;
  color: var(--dos-darkgray);
  font-size: 10px;
  margin-top: 6px;
  letter-spacing: 2px;
}

#playback-controls {
  display: flex;
  gap: 2px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
  justify-content: center;
}

#frame-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dos-lightgreen);
  font-size: 12px;
}
#progress-bar {
  position: relative;
  width: 200px;
  height: 16px;
  background: var(--dos-black);
  border: 1px solid var(--dos-darkgray);
  overflow: hidden;
}
#progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--dos-green);
  width: 0%;
  transition: width 0.1s;
}
#progress-text {
  position: absolute;
  top: 0; left: 2px;
  color: var(--dos-lightgreen);
  font-size: 10px;
  line-height: 16px;
  pointer-events: none;
  letter-spacing: 1px;
}

#speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dos-yellow);
  font-size: 11px;
  margin: 4px 0;
}
#speed-slider {
  width: 120px;
  accent-color: var(--dos-cyan);
}

#stats-bar {
  display: flex;
  gap: 16px;
  color: var(--dos-darkgray);
  font-size: 10px;
  margin-top: 4px;
}

/* Right Panel */
#header-info {
  font-size: 11px;
  color: var(--dos-lightgray);
  max-height: 320px;
  overflow-y: auto;
}
.header-placeholder { color: var(--dos-darkgray); text-align: center; padding: 20px; }

.header-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(85,85,255,0.2);
  padding: 2px 0;
}
.header-label { color: var(--dos-cyan); }
.header-value { color: var(--dos-white); }
.header-hex { color: var(--dos-darkgray); font-size: 10px; }
.glitch-warning {
  color: var(--dos-lightred);
  font-weight: 700;
  text-align: center;
  padding: 8px;
  animation: blink 0.5s step-end infinite;
}

#register-display {
  font-size: 11px;
  color: var(--dos-lightcyan);
  line-height: 1.5;
}

/* Bottom Panel */
#bottom-panel {
  margin: 4px;
  max-height: 200px;
}
#disassembly-scroll {
  max-height: 160px;
  overflow-y: auto;
  font-size: 11px;
}
.disasm-placeholder { color: var(--dos-darkgray); text-align: center; padding: 16px; }

.disasm-line {
  display: flex;
  gap: 12px;
  padding: 1px 4px;
  white-space: nowrap;
}
.disasm-line.current {
  background: rgba(0,170,0,0.3);
}
.disasm-addr { color: var(--dos-darkgray); min-width: 80px; }
.disasm-bytes { color: var(--dos-lightblue); min-width: 100px; }
.disasm-mnemonic { color: var(--dos-white); min-width: 160px; }
.disasm-unknown .disasm-mnemonic { color: var(--dos-yellow); }
.disasm-cycles { color: var(--dos-darkgray); font-size: 10px; }

/* Footer */
#footer {
  background: var(--dos-blue);
  color: var(--dos-white);
  padding: 4px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  border-top: 2px solid var(--dos-lightblue);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
#footer a {
  color: var(--dos-lightcyan);
  text-decoration: underline;
}

/* Hex Modal */
#hex-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#hex-modal.hidden { display: none; }
.hex-modal-inner {
  width: 700px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 16px;
}
#hex-content {
  font-size: 11px;
  white-space: pre;
  color: var(--dos-lightgray);
  line-height: 1.4;
}
.hex-offset { color: var(--dos-darkgray); }
.hex-byte { color: var(--dos-lightcyan); }
.hex-ascii { color: var(--dos-yellow); }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--dos-black); }
::-webkit-scrollbar-thumb { background: var(--dos-darkgray); }
::-webkit-scrollbar-thumb:hover { background: var(--dos-lightgray); }

/* Responsive */
@media (max-width: 1100px) {
  #main-layout {
    grid-template-columns: 1fr;
  }
  #cga-display { width: 100%; height: auto; }
  #monitor-bezel { width: 100%; max-width: 680px; }
  #left-panel, #right-panel { order: 2; }
  #center-panel { order: 1; }
}

@media (max-width: 700px) {
  #titlebar { font-size: 11px; padding: 4px 8px; }
  .dos-button.ctrl { font-size: 10px; padding: 4px 5px; }
  #stats-bar { flex-wrap: wrap; gap: 8px; }
  #footer { font-size: 9px; flex-wrap: wrap; gap: 4px; justify-content: center; }
  #monitor-bezel { padding: 8px 10px 6px; border-radius: 10px; }
}