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

body {
  background: #0d0d1a;
  color: #d4c5a9;
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2 {
  font-family: 'Press Start 2P', monospace;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: linear-gradient(180deg, #3a2a14 0%, #2a1a0a 100%);
  border-bottom: 3px solid #8b6914;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left h1 {
  font-size: 14px;
  color: #e9b287;
  text-shadow: 0 0 10px rgba(233,178,135,0.3);
  letter-spacing: 2px;
}

.header-right {
  font-size: 10px;
  color: #8b6914;
}

.power-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333;
  border: 1px solid #555;
  transition: all 0.3s;
}

.power-led.on {
  background: #4cff4c;
  box-shadow: 0 0 8px #4cff4c, 0 0 16px rgba(76,255,76,0.4);
}

#main-layout {
  display: flex;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

#left-panel {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.panel-section {
  background: linear-gradient(145deg, #2a2215, #1e1810);
  border: 1px solid #5a4a2a;
  border-radius: 8px;
  padding: 12px;
}

.panel-section h2 {
  font-size: 9px;
  color: #e9b287;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rom-upload {
  margin-bottom: 10px;
}

.rom-upload label {
  display: block;
  font-size: 11px;
  color: #d4c5a9;
  margin-bottom: 4px;
}

.addr {
  color: #8b6914;
  font-size: 9px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="file"] {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: #d4c5a9;
  width: 100%;
  padding: 4px;
  background: #111;
  border: 1px solid #5a4a2a;
  border-radius: 4px;
}

input[type="file"]::file-selector-button {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  background: #3a2a14;
  color: #e9b287;
  border: 1px solid #8b6914;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
}

.rom-status {
  font-size: 14px;
  min-width: 20px;
  text-align: center;
}

.file-info {
  font-size: 9px;
  color: #8b6914;
  margin-top: 2px;
  min-height: 12px;
}

select {
  width: 100%;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  background: #111;
  color: #e9b287;
  border: 1px solid #5a4a2a;
  border-radius: 4px;
  padding: 6px;
}

.peripheral {
  margin-bottom: 10px;
}

.peripheral-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  margin-bottom: 4px;
}

.disk-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #330000;
  border: 1px solid #555;
}

.disk-led.active {
  background: #ff3333;
  box-shadow: 0 0 6px #ff3333;
}

.tape-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}

.tape-btn {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  background: #2a2215;
  color: #d4c5a9;
  border: 1px solid #5a4a2a;
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
}

.tape-btn:hover { background: #3a3225; }

.tape-counter {
  font-size: 12px;
  color: #4cff4c;
  background: #111;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Share Tech Mono', monospace;
}

textarea {
  width: 100%;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  background: #111;
  color: #4cff4c;
  border: 1px solid #5a4a2a;
  border-radius: 4px;
  padding: 6px;
  resize: vertical;
}

#monitor-bezel {
  background: linear-gradient(145deg, #c8b896, #a89878);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 
    0 0 0 3px #7a6a4a,
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.2);
}

#monitor-screen {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 
    inset 0 0 60px rgba(0,0,0,0.8),
    0 0 20px rgba(76,130,255,0.1);
  line-height: 0;
}

#canvas {
  display: block;
  border-radius: 8px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#scanlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  border-radius: 8px;
}

#monitor-label {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #5a4a3a;
  margin-top: 8px;
  letter-spacing: 3px;
}

#controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: linear-gradient(145deg, #2a2215, #1e1810);
  border: 1px solid #5a4a2a;
  border-radius: 8px;
  width: 100%;
  max-width: 580px;
}

.ctrl-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: linear-gradient(180deg, #d4c5a9, #b8a888);
  color: #2a1a0a;
  border: 2px outset #d4c5a9;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: linear-gradient(180deg, #e9d8b8, #c8b898);
}

.ctrl-btn:active {
  border-style: inset;
}

.power-btn {
  background: linear-gradient(180deg, #cc4444, #aa2222);
  color: #fff;
  border-color: #ee6666;
}

.power-btn.on {
  background: linear-gradient(180deg, #44cc44, #22aa22);
  border-color: #66ee66;
}

.speed-control, .sound-control {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
}

input[type="range"] {
  width: 60px;
  accent-color: #8b6914;
}

#keyboard-container {
  width: 100%;
  max-width: 700px;
  background: linear-gradient(145deg, #c8b896, #a89878);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.kb-row {
  display: flex;
  gap: 3px;
  margin-bottom: 3px;
  justify-content: center;
}

.kb-key {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  min-width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e8dcc8, #d4c5a9);
  color: #2a1a0a;
  border: 1px solid #8b7b5b;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 0 #8b7b5b;
  padding: 0 4px;
  user-select: none;
  white-space: nowrap;
}

.kb-key:active, .kb-key.pressed {
  box-shadow: none;
  transform: translateY(2px);
  background: linear-gradient(180deg, #c8b898, #b8a888);
}

.kb-key.dark {
  background: linear-gradient(180deg, #5a4a3a, #3a2a1a);
  color: #d4c5a9;
  border-color: #4a3a2a;
  box-shadow: 0 2px 0 #2a1a0a;
}

.kb-key.dark:active, .kb-key.dark.pressed {
  background: linear-gradient(180deg, #4a3a2a, #2a1a0a);
  box-shadow: none;
  transform: translateY(2px);
}

.kb-key.wide { min-width: 50px; }
.kb-key.wider { min-width: 70px; }
.kb-key.widest { min-width: 100px; }
.kb-key.space { min-width: 220px; }

.collapsible h2 {
  cursor: pointer;
  user-select: none;
}

.hidden { display: none !important; }

.sound-channels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.channel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
}

.channel canvas {
  background: #111;
  border: 1px solid #333;
  border-radius: 2px;
}

#status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: #111;
  border-top: 1px solid #333;
  font-size: 11px;
  color: #4cff4c;
  font-family: 'Share Tech Mono', monospace;
}

#status-bar a {
  color: #8b6914;
  text-decoration: none;
  margin-left: auto;
}

#status-bar a:hover {
  color: #e9b287;
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #1e1810;
  border: 2px solid #8b6914;
  border-radius: 10px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  color: #d4c5a9;
  font-size: 12px;
  line-height: 1.6;
}

.modal-content h2 {
  font-size: 12px;
  color: #e9b287;
  margin-bottom: 12px;
}

.modal-content h3 {
  font-size: 10px;
  color: #e9b287;
  margin: 12px 0 6px;
}

.modal-content ul { padding-left: 20px; }
.modal-content code {
  background: #111;
  padding: 1px 4px;
  border-radius: 2px;
  color: #4cff4c;
}

.modal-close {
  float: right;
  font-size: 20px;
  background: none;
  border: none;
  color: #d4c5a9;
  cursor: pointer;
}

@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
  }
  #left-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  #left-panel .panel-section {
    flex: 1;
    min-width: 250px;
  }
  #monitor-bezel {
    padding: 10px;
  }
  #canvas {
    width: 100%;
    height: auto;
  }
}