* { margin:0; padding:0; box-sizing:border-box; }
body { background:#0d0d0d; color:#e0e0e0; font-family:'Share Tech Mono',monospace; overflow-x:hidden; }

.header { text-align:center; padding:16px 0 0; }
.header h1 { font-size:32px; color:#fff; text-shadow:0 0 20px rgba(255,255,255,0.3),0 0 40px rgba(0,150,255,0.15); letter-spacing:4px; }
.rainbow-bar { height:6px; display:flex; margin:10px auto 0; max-width:600px; border-radius:3px; overflow:hidden; }
.rainbow-bar div { flex:1; }

.main-layout { display:flex; flex-wrap:wrap; justify-content:center; gap:16px; padding:16px; max-width:1400px; margin:0 auto; }

.screen-section { flex:0 0 auto; }
.screen-wrapper { position:relative; background:#000; padding:0; border-radius:4px; border:2px solid #222; display:inline-block; }
.screen-wrapper.crt::after {
  content:''; position:absolute; top:0; left:0; right:0; bottom:0; pointer-events:none; border-radius:4px;
  background:repeating-linear-gradient(0deg,rgba(0,0,0,0.12) 0px,rgba(0,0,0,0.12) 1px,transparent 1px,transparent 3px);
  z-index:2;
}
.screen-wrapper.crt::before {
  content:''; position:absolute; top:0; left:0; right:0; bottom:0; pointer-events:none; border-radius:4px;
  background:radial-gradient(ellipse at center,transparent 60%,rgba(0,0,0,0.35) 100%);
  z-index:3;
}
#spectrumCanvas { display:block; image-rendering:pixelated; image-rendering:crisp-edges; }

.controls { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; align-items:center; justify-content:center; }

.zx-btn {
  font-family:'Share Tech Mono',monospace; font-size:13px; padding:8px 18px;
  background:linear-gradient(180deg,#d4d4d4 0%,#b0b0b0 100%);
  color:#1a1a1a; border:none; border-radius:6px; cursor:pointer;
  box-shadow:0 3px 0 #666,0 4px 6px rgba(0,0,0,0.4);
  transition:all 0.08s; text-transform:uppercase; letter-spacing:1px;
}
.zx-btn:hover { background:linear-gradient(180deg,#e0e0e0 0%,#c0c0c0 100%); }
.zx-btn:active { transform:translateY(2px); box-shadow:0 1px 0 #666,0 2px 3px rgba(0,0,0,0.4); }
.zx-btn.running { background:linear-gradient(180deg,#ff6666 0%,#cc3333 100%); color:#fff; }
.zx-btn.load-btn { background:linear-gradient(180deg,#66bbff 0%,#3388cc 100%); color:#fff; }

.toggle-group { display:flex; align-items:center; gap:4px; font-size:11px; color:#888; }
.toggle-group input[type="checkbox"] { accent-color:#00cc66; }
.toggle-group label { cursor:pointer; }

.speed-group { display:flex; align-items:center; gap:6px; font-size:11px; color:#888; }
.speed-group input[type="range"] { width:80px; accent-color:#ffcc00; }

.file-info { font-size:11px; color:#888; margin-top:6px; text-align:center; min-height:16px; }

.side-panel { flex:1; min-width:320px; max-width:480px; display:flex; flex-direction:column; gap:12px; }

.panel {
  background:#1a1a1a; border:1px solid #333; border-radius:6px; overflow:hidden;
}
.panel-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:8px 12px; background:#222; cursor:pointer; user-select:none;
}
.panel-header h3 { font-size:13px; color:#00cc66; letter-spacing:2px; }
.panel-header .toggle-icon { color:#666; font-size:14px; transition:transform 0.2s; }
.panel-header .toggle-icon.collapsed { transform:rotate(-90deg); }
.panel-body { padding:10px 12px; }
.panel-body.hidden { display:none; }

.reg-grid { display:grid; grid-template-columns:1fr 1fr; gap:4px 16px; }
.reg-row { display:flex; justify-content:space-between; align-items:center; font-size:12px; padding:2px 0; }
.reg-name { color:#888; min-width:30px; }
.reg-val { color:#00ff88; font-weight:bold; transition:color 0.15s; }
.reg-val.changed { color:#ffff00; }
.reg-alt .reg-val { color:#007744; }

.flags-row { display:flex; gap:4px; margin-top:6px; flex-wrap:wrap; }
.flag-box {
  width:28px; height:28px; display:flex; flex-direction:column; align-items:center; justify-content:center;
  border-radius:3px; font-size:9px; font-weight:bold; transition:all 0.15s;
}
.flag-box.set { background:#00cc66; color:#000; }
.flag-box.clear { background:#2a2a2a; color:#555; }
.flag-label { font-size:7px; opacity:0.7; }

.status-info { font-size:11px; color:#888; margin-top:8px; }
.status-info div { padding:1px 0; }
.status-info .val { color:#00cc66; }
.disasm { color:#ffcc00; font-size:12px; padding:4px 6px; background:#111; border-radius:3px; margin-bottom:6px; min-height:20px; }

.mem-viewer { font-size:11px; line-height:1.5; }
.mem-nav { display:flex; gap:6px; margin-bottom:8px; align-items:center; }
.mem-nav input {
  background:#111; border:1px solid #444; color:#00ff88; font-family:'Share Tech Mono',monospace;
  font-size:12px; padding:4px 8px; width:80px; border-radius:3px;
}
.mem-nav button { padding:4px 10px; }
.mem-scroll { max-height:240px; overflow-y:auto; background:#0a0a0a; padding:6px; border-radius:3px; }
.mem-scroll::-webkit-scrollbar { width:6px; }
.mem-scroll::-webkit-scrollbar-track { background:#111; }
.mem-scroll::-webkit-scrollbar-thumb { background:#444; border-radius:3px; }
.mem-row { white-space:pre; }
.mem-addr { color:#666; }
.mem-hex { color:#00cc66; }
.mem-hex.screen-mem { color:#cc8800; }
.mem-hex.pc-highlight { background:#333; color:#ffff00; }
.mem-ascii { color:#555; }

.keyboard-panel { margin-top:8px; }
.kb-row { display:flex; gap:3px; margin-bottom:3px; justify-content:center; }
.kb-key {
  width:52px; height:36px; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(180deg,#555 0%,#3a3a3a 100%);
  color:#ddd; font-size:10px; border-radius:4px; cursor:pointer; user-select:none;
  box-shadow:0 2px 0 #222; transition:all 0.06s; text-align:center; line-height:1.1;
  border:1px solid #666;
}
.kb-key:hover { background:linear-gradient(180deg,#666 0%,#4a4a4a 100%); }
.kb-key.pressed { transform:translateY(2px); box-shadow:none; background:#00cc66; color:#000; }
.kb-key.wide { width:72px; }
.kb-key.space { width:280px; }

.footer {
  text-align:center; padding:16px; margin-top:20px; font-size:11px; color:#555;
  border-top:1px solid #222;
}
.footer .rainbow-bar { max-width:300px; height:3px; margin:0 auto 8px; }
.footer a { color:#888; text-decoration:none; }
.footer a:hover { color:#00cc66; }

@media(max-width:900px) {
  .main-layout { flex-direction:column; align-items:center; }
  .side-panel { max-width:100%; }
  .screen-wrapper { padding:0; }
  #spectrumCanvas { width:100% !important; height:auto !important; }
  .kb-key { width:36px; height:30px; font-size:8px; }
  .kb-key.wide { width:50px; }
  .kb-key.space { width:180px; }
}