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

:root {
  --phosphor: #33FF33;
  --phosphor-dim: #1a8a1a;
  --screen-bg: #001100;
  --bezel: #C4B59A;
  --bezel-dark: #a89a7e;
  --panel-bg: #1A1A1A;
  --panel-border: #333;
  --keycap: #D4CAB0;
  --keycap-pressed: #b8a88e;
  --keycap-text: #2A2A2A;
  --accent: #FF6600;
  --error: #FF3333;
  --success: #33FF33;
  --body-bg: #0a0a0a;
}

body {
  background: var(--body-bg);
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 49px, rgba(60,40,20,0.03) 49px, rgba(60,40,20,0.03) 50px),
    repeating-linear-gradient(0deg, transparent, transparent 49px, rgba(60,40,20,0.03) 49px, rgba(60,40,20,0.03) 50px);
  color: #ccc;
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

/* TOP BAR */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.top-bar-title {
  font-family: 'VT323', monospace;
  font-size: 28px;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255,102,0,0.5);
  line-height: 1;
}

.top-bar-subtitle {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: #888;
}

.top-bar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.power-led.off {
  background: #550000;
  box-shadow: none;
}

.power-led.on {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.hw-button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border: 2px solid #555;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
  letter-spacing: 1px;
}

.hw-button:active {
  transform: translateY(1px);
}

.hw-button.power {
  background: #333;
  color: var(--success);
  border-color: #555;
}

.hw-button.power.on {
  background: #1a3a1a;
  border-color: var(--success);
  box-shadow: 0 0 6px rgba(51,255,51,0.3);
}

.hw-button.reset {
  background: #553333;
  color: #ff9999;
  border-color: #884444;
}

.hw-button.break-btn {
  background: #554433;
  color: #ffaa66;
  border-color: #886644;
}

/* MAIN LAYOUT */
.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* PANELS */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, #2a2a2a, #222);
  border-bottom: 1px solid var(--panel-border);
  cursor: pointer;
  user-select: none;
}

.panel-header h3 {
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: var(--accent);
}

.panel-header .toggle {
  font-size: 12px;
  color: #666;
}

.panel-body {
  padding: 12px;
}

.panel-body.collapsed {
  display: none;
}

/* ROM UPLOAD */
.rom-zone {
  border: 2px dashed #444;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.rom-zone:hover, .rom-zone.dragover {
  border-color: var(--accent);
  background: rgba(255,102,0,0.05);
}

.rom-zone.loaded {
  border-color: var(--success);
  border-style: solid;
  background: rgba(51,255,51,0.05);
}

.rom-zone.error {
  border-color: var(--error);
  border-style: solid;
  background: rgba(255,51,51,0.05);
}

.rom-label {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: #aaa;
  margin-bottom: 4px;
}

.rom-addr {
  font-size: 11px;
  color: #666;
  font-family: 'IBM Plex Mono', monospace;
}

.rom-status {
  font-size: 12px;
  margin-top: 6px;
  font-family: 'VT323', monospace;
}

.rom-status.loaded { color: var(--success); }
.rom-status.error { color: var(--error); }
.rom-status.empty { color: #666; }

/* MEMORY MAP */
.mem-map {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
}

.mem-block {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 2px;
}

.mem-block .bar {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  border: 1px solid #555;
}

.mem-block .bar.active { border-color: var(--success); }
.mem-block.ram .bar.active { background: #2266aa; }
.mem-block.rom .bar.active { background: var(--success); }
.mem-block.io .bar.active { background: var(--accent); }
.mem-block.video .bar.active { background: #aa22aa; }

/* BOOT BUTTON */
.boot-button {
  width: 100%;
  padding: 10px;
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: linear-gradient(180deg, #2a5a2a, #1a3a1a);
  color: var(--success);
  border: 2px solid var(--success);
  border-radius: 6px;
  cursor: pointer;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.2s;
}

.boot-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: #555;
  color: #555;
  background: #1a1a1a;
}

.boot-button:not(:disabled):hover {
  background: linear-gradient(180deg, #3a7a3a, #2a5a2a);
  box-shadow: 0 0 15px rgba(51,255,51,0.3);
}

/* CRT MONITOR */
.monitor-frame {
  background: linear-gradient(145deg, #d4c4a4, #b4a484);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 
    0 4px 20px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
}

.monitor-inner {
  background: #111;
  border-radius: 12px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.crt-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--screen-bg);
}

.crt-canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

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

.crt-glow {
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 10px;
  box-shadow: inset 0 0 60px rgba(51,255,51,0.08);
  pointer-events: none;
}

.monitor-label {
  text-align: center;
  margin-top: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #665;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* VIRTUAL KEYBOARD */
.keyboard-container {
  background: linear-gradient(180deg, #c8b898, #b8a888);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

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

.key {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--keycap-text);
  background: linear-gradient(180deg, #e8dcc8, var(--keycap));
  border: 1px solid #a09080;
  border-bottom: 3px solid #908070;
  border-radius: 4px;
  padding: 6px 8px;
  min-width: 34px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.05s;
  white-space: nowrap;
}

.key:active, .key.pressed {
  background: var(--keycap-pressed);
  border-bottom-width: 1px;
  transform: translateY(2px);
}

.key.wide { min-width: 60px; }
.key.wider { min-width: 80px; }
.key.space { flex: 1; max-width: 400px; }

.key.shift-active {
  background: linear-gradient(180deg, #ffe0a0, #eec880);
  border-color: var(--accent);
}

/* CASSETTE PANEL */
.cassette-transport {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  justify-content: center;
}

.transport-btn {
  font-size: 16px;
  padding: 6px 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
  transition: all 0.1s;
}

.transport-btn:hover {
  background: #3a3a3a;
  color: #fff;
}

.transport-btn.active {
  background: #3a2a1a;
  color: var(--accent);
  border-color: var(--accent);
}

.transport-btn.record {
  color: #ff4444;
}

.transport-btn.record.active {
  background: #3a1a1a;
  border-color: #ff4444;
  animation: record-pulse 1s infinite;
}

@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 5px rgba(255,0,0,0.3); }
  50% { box-shadow: 0 0 15px rgba(255,0,0,0.6); }
}

.tape-counter {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--accent);
  text-align: center;
  background: #111;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid #333;
  letter-spacing: 3px;
}

.tape-reels {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 8px 0;
}

.tape-reel {
  width: 40px;
  height: 40px;
  border: 3px solid #555;
  border-radius: 50%;
  position: relative;
  background: #222;
}

.tape-reel::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 12px; height: 12px;
  background: #444;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #333;
}

.tape-reel.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ACIA Status */
.acia-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
}

.acia-flag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
}

.acia-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #550000;
}

.acia-dot.on {
  background: var(--success);
  box-shadow: 0 0 4px var(--success);
}

/* DEBUG PANEL */
.debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.debug-reg {
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px 8px;
  text-align: center;
}

.debug-reg-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.debug-reg-value {
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--phosphor);
}

.speed-slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.speed-slider {
  flex: 1;
  accent-color: var(--accent);
}

.speed-label {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--accent);
  min-width: 50px;
}

/* HEX VIEWER */
.hex-viewer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre;
  color: var(--phosphor-dim);
  line-height: 1.4;
}

.hex-input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #111;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--phosphor);
  width: 80px;
}

/* FOOTER */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: #555;
  border-top: 1px solid #222;
  margin-top: 10px;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* WELCOME MODAL */
.modal-overlay {
  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;
  padding: 20px;
}

.modal-content {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-family: 'VT323', monospace;
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 16px;
}

.modal-content p {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-close {
  padding: 10px 30px;
  font-family: 'VT323', monospace;
  font-size: 18px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 10px;
}

/* Upload zone for cassette */
.cassette-upload {
  border: 2px dashed #444;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.cassette-upload:hover {
  border-color: var(--accent);
}

.cassette-upload.loaded {
  border-color: var(--success);
  border-style: solid;
}

/* Volume control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: #888;
}

.volume-control input {
  flex: 1;
  accent-color: var(--accent);
}

/* Disassembly */
.disasm-view {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px;
  max-height: 100px;
  overflow-y: auto;
  color: #888;
  line-height: 1.5;
}

.disasm-current {
  color: var(--phosphor);
  font-weight: bold;
}

/* Screenshot button */
.screenshot-btn {
  font-size: 11px;
  padding: 4px 8px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
}

.screenshot-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Paste button */
.paste-btn {
  font-size: 11px;
  padding: 4px 8px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  cursor: pointer;
}

.paste-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .top-bar { flex-direction: column; align-items: flex-start; }
  .key { font-size: 9px; padding: 4px 5px; min-width: 26px; }
  .key.wide { min-width: 45px; }
  .key.wider { min-width: 58px; }
  .monitor-frame { padding: 10px; border-radius: 10px; }
}