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

body {
  font-family: 'VT323', 'Courier New', monospace;
  background: #000080;
  color: #AAAAAA;
  overflow-x: hidden;
  min-height: 100vh;
  font-size: 16px;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.03) 0px,
    rgba(0,0,0,0.03) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* Boot screen */
#boot-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#boot-text {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: #AAAAAA;
  text-align: left;
  line-height: 1.6;
}

#boot-cursor {
  animation: blink 0.5s step-end infinite;
  color: #FFFF55;
}

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

/* Title bar */
#title-bar {
  background: #0000AA;
  color: #FFFF55;
  text-align: center;
  padding: 6px 12px;
  font-size: 22px;
  letter-spacing: 2px;
  border-bottom: 2px solid #5555FF;
  position: relative;
}

#title-cursor {
  animation: blink 0.6s step-end infinite;
  color: #FFFFFF;
}

/* Main layout */
#main-layout {
  display: flex;
  min-height: calc(100vh - 100px);
  gap: 0;
}

#left-panel {
  width: 220px;
  min-width: 180px;
  background: #1A1A4A;
  padding: 8px;
  border-right: 2px solid #5555FF;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#center-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000033;
  padding: 12px;
  position: relative;
}

#right-panel {
  width: 280px;
  min-width: 220px;
  background: #1A1A4A;
  padding: 8px;
  border-left: 2px solid #5555FF;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* DOS Panel */
.dos-panel {
  background: #2A2A5A;
  border: 2px solid #5555FF;
  padding: 8px;
}

.panel-title {
  color: #55FFFF;
  font-size: 14px;
  margin: -8px -8px 6px -8px;
  padding: 2px 4px;
  background: #0000AA;
  text-align: center;
}

/* Config row */
.config-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.config-row label {
  color: #55FF55;
  font-size: 15px;
  white-space: nowrap;
}

.config-row input[type="number"] {
  width: 48px;
  background: #000;
  color: #55FF55;
  border: 1px solid #555;
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 2px 4px;
  text-align: center;
}

/* DOS Button */
.dos-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  background: #AAAAAA;
  color: #000;
  border: none;
  border-top: 2px solid #FFF;
  border-left: 2px solid #FFF;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  padding: 3px 10px;
  cursor: pointer;
  text-transform: uppercase;
  white-space: nowrap;
}

.dos-btn:hover {
  background: #CCCCCC;
}

.dos-btn:active, .dos-btn.active {
  border-top: 2px solid #555;
  border-left: 2px solid #555;
  border-right: 2px solid #FFF;
  border-bottom: 2px solid #FFF;
  background: #888;
  color: #FFF;
}

/* Toolbar */
#toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#toolbar .tool-btn {
  flex: 1 0 45%;
  text-align: center;
  font-size: 14px;
  padding: 4px 4px;
}

/* Palette */
#palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.palette-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #333;
  cursor: pointer;
  position: relative;
  min-width: 16px;
}

.palette-swatch:hover {
  border-color: #FFF;
}

.palette-swatch.selected {
  border-color: #FFFF55;
  box-shadow: 0 0 0 1px #FFFF55;
  animation: swatch-blink 0.8s step-end infinite;
}

@keyframes swatch-blink {
  50% { border-color: #FF5555; box-shadow: 0 0 0 1px #FF5555; }
}

.palette-swatch .marker {
  position: absolute;
  top: -2px;
  left: -1px;
  color: #FFFF55;
  font-size: 12px;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

#color-label {
  color: #FFFF55;
  font-size: 14px;
  margin-top: 4px;
  text-align: center;
}

/* Canvas */
#canvas-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(100vh - 140px);
}

#canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 3px solid #5555FF;
  cursor: crosshair;
  background: #000;
  max-width: 100%;
  max-height: calc(100vh - 140px);
}

/* Textareas */
#save-output, #load-input {
  width: 100%;
  background: #000;
  color: #55FF55;
  font-family: 'VT323', monospace;
  font-size: 13px;
  border: 1px solid #555;
  padding: 4px;
  resize: vertical;
  margin-top: 4px;
}

#load-error {
  color: #FF5555;
  font-size: 14px;
  margin-top: 4px;
  min-height: 18px;
}

/* Status bar */
#status-bar {
  background: #555;
  color: #FFF;
  display: flex;
  justify-content: space-between;
  padding: 3px 12px;
  font-size: 15px;
  border-top: 2px solid #888;
  gap: 12px;
  flex-wrap: wrap;
}

/* Footer */
#footer {
  background: #0000AA;
  color: #AAAAAA;
  text-align: center;
  padding: 4px 12px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #5555FF;
}

#footer a {
  color: #55FFFF;
  text-decoration: none;
}

#footer a:hover {
  color: #FFFF55;
  text-decoration: underline;
}

/* Help modal */
#help-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#help-content {
  background: #1A1A4A;
  border: 3px solid #FFFF55;
  padding: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

#help-content pre {
  color: #55FF55;
  font-family: 'VT323', monospace;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Mobile responsive */
@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
  }
  #left-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 2px solid #5555FF;
  }
  #left-panel .dos-panel {
    flex: 1 1 auto;
    min-width: 160px;
  }
  #right-panel {
    width: 100%;
    border-left: none;
    border-top: 2px solid #5555FF;
  }
  #center-panel {
    min-height: 300px;
  }
  #canvas-wrapper {
    max-height: 50vh;
  }
  #canvas {
    max-height: 50vh;
  }
}

@media (max-width: 600px) {
  #title-bar {
    font-size: 16px;
    letter-spacing: 0;
  }
  #status-bar {
    font-size: 13px;
  }
  .config-row label {
    font-size: 13px;
  }
  #toolbar .tool-btn {
    font-size: 12px;
    padding: 3px 2px;
  }
}