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

:root {
  --green: #00FF00;
  --green-dim: #00AA00;
  --green-dark: #004400;
  --amber: #FFB000;
  --amber-dim: #AA7500;
  --bg: #0A0A0A;
  --bg-panel: #0D0D0D;
  --border: #00AA00;
  --text: #00FF00;
  --highlight: #00FF00;
  --highlight-bg: #003300;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 12px;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

body.amber-mode {
  --green: #FFB000;
  --green-dim: #AA7500;
  --green-dark: #442E00;
  --border: #AA7500;
  --text: #FFB000;
  --highlight: #FFB000;
  --highlight-bg: #332200;
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#title-bar {
  padding: 2px 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-panel);
  white-space: pre;
  font-size: 13px;
  line-height: 1.3;
}

#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#left-panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

#source-panel {
  border-bottom: 1px solid var(--border);
  padding: 4px;
}

#controls-panel {
  padding: 4px;
  flex: 1;
  overflow-y: auto;
}

#center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

#mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-panel);
}

#canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #000;
}

#output-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

#scanline-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  transition: opacity 0.3s;
}

#scanline-overlay.active {
  opacity: 1;
}

#right-panel {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#hex-dump-panel {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  font-size: 10px;
  line-height: 1.4;
}

#status-bar {
  padding: 2px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-panel);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}

.dos-box {
  border: 1px solid var(--border);
  margin: 2px;
  padding: 4px;
}

.dos-box-title {
  color: var(--highlight);
  font-weight: bold;
  margin-bottom: 2px;
}

.dos-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s;
}

.dos-btn:hover {
  background: var(--highlight-bg);
  color: var(--highlight);
}

.dos-btn.active {
  background: var(--highlight);
  color: var(--bg);
}

.dos-btn.recording {
  background: #AA0000;
  color: #FF0000;
  border-color: #FF0000;
  animation: blink-rec 1s infinite;
}

@keyframes blink-rec {
  50% { opacity: 0.5; }
}

.btn-row {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin: 4px 0;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 3px 0;
  font-size: 10px;
}

.slider-row label {
  width: 70px;
  flex-shrink: 0;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--green-dark);
  outline: none;
  border: 1px solid var(--border);
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 14px;
  background: var(--highlight);
  cursor: pointer;
  border: none;
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 14px;
  background: var(--highlight);
  cursor: pointer;
  border: none;
}

.slider-row span {
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.video-preview {
  border: 1px solid var(--border);
  background: #000;
  width: 100%;
  max-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 4px 0;
}

.video-preview canvas {
  max-width: 100%;
  max-height: 138px;
  image-rendering: pixelated;
}

.source-info {
  font-size: 10px;
  color: var(--green-dim);
  margin-top: 2px;
}

.hex-header {
  color: var(--highlight);
  font-weight: bold;
  border-bottom: 1px solid var(--green-dark);
  margin-bottom: 4px;
  padding-bottom: 2px;
}

.hex-line {
  white-space: pre;
  color: var(--green-dim);
}

.hex-line .offset {
  color: var(--amber);
}

.hex-line .hex-byte {
  color: var(--text);
}

.hex-line .ascii {
  color: var(--green-dim);
}

.blink-cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.crt-effect #canvas-container {
  border-radius: 20px;
  box-shadow: 
    inset 0 0 60px rgba(0,0,0,0.5),
    0 0 20px rgba(0,255,0,0.1);
}

.crt-effect #output-canvas {
  filter: contrast(1.1) brightness(1.05);
}

.footer-link {
  color: var(--green-dim);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--highlight);
  text-decoration: underline;
}

.select-dos {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 4px;
  cursor: pointer;
}

.select-dos option {
  background: var(--bg);
  color: var(--text);
}

/* Mobile */
@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
  }
  #left-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
    overflow-y: auto;
  }
  #source-panel {
    flex: 1;
    min-width: 200px;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  #controls-panel {
    flex: 1;
    min-width: 200px;
  }
  #right-panel {
    width: 100%;
    max-height: 150px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 600px) {
  #right-panel {
    display: none;
  }
  #left-panel {
    flex-direction: column;
    max-height: 160px;
  }
  #source-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .dos-btn {
    font-size: 10px;
    padding: 2px 5px;
  }
  #mode-selector {
    gap: 1px;
    padding: 2px;
  }
}