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

:root {
  --beige: #C9C0AB;
  --beige-light: #D8D0BA;
  --beige-dark: #B0A890;
  --brown: #3E2723;
  --brown-light: #5D4037;
  --green-phosphor: #33FF33;
  --green-dim: #1A8A1A;
  --screen-bg: #0A1A0A;
  --off-white: #F5F0E1;
  --bg-dark: #1a1a2e;
  --led-on: #00ff00;
  --led-off: #333;
}

body {
  background: var(--bg-dark);
  background-image: 
    radial-gradient(ellipse at 50% 30%, #2a2a4e 0%, var(--bg-dark) 70%);
  font-family: 'Courier New', 'Lucida Console', monospace;
  color: var(--off-white);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  overflow-x: hidden;
}

#app-container {
  max-width: 780px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Monitor Housing */
#monitor-housing {
  background: linear-gradient(180deg, #d4ccb5 0%, var(--beige) 20%, var(--beige-dark) 100%);
  border-radius: 20px 20px 8px 8px;
  padding: 18px 24px 12px;
  width: 100%;
  max-width: 760px;
  box-shadow: 
    0 2px 0 #e0d8c5 inset,
    0 -2px 0 #9a9280 inset,
    2px 0 0 #b5ad98 inset,
    -2px 0 0 #b5ad98 inset,
    0 8px 32px rgba(0,0,0,0.5);
  position: relative;
}

#monitor-housing::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 20px 20px 8px 8px;
  background: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='4' height='4' fill='%23b0a890' opacity='0.08'/%3E%3Crect x='0' y='0' width='2' height='2' fill='%23c0b8a0' opacity='0.06'/%3E%3C/svg%3E");
  pointer-events: none;
}

#monitor-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-left: 4px;
}

.apple-logo {
  font-size: 22px;
  filter: saturate(1.5);
}

.apple-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--brown);
  letter-spacing: 2px;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
}

/* Screen Bezel */
#screen-bezel {
  background: #222;
  border-radius: 16px;
  padding: 16px;
  box-shadow:
    0 0 0 2px #444 inset,
    0 4px 12px rgba(0,0,0,0.6) inset;
}

#screen-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 280 / 192;
  border-radius: 12px;
  overflow: hidden;
  background: var(--screen-bg);
  box-shadow: 0 0 40px rgba(51, 255, 51, 0.08);
}

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

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  pointer-events: none;
  z-index: 2;
}

#vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
  pointer-events: none;
  z-index: 3;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.985; }
}

#screen-container {
  animation: flicker 0.1s infinite;
}

#focus-hint {
  text-align: center;
  font-size: 10px;
  color: #887;
  margin-top: 8px;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Computer Case */
#computer-case {
  background: linear-gradient(180deg, var(--beige) 0%, var(--beige-dark) 100%);
  border-radius: 0 0 12px 12px;
  padding: 12px 20px 8px;
  width: 100%;
  max-width: 760px;
  box-shadow:
    0 -1px 0 var(--beige-light) inset,
    0 4px 16px rgba(0,0,0,0.3);
}

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

#extra-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.ctrl-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(180deg, #666 0%, #444 100%);
  color: #eee;
  cursor: pointer;
  box-shadow:
    0 3px 0 #222,
    0 4px 8px rgba(0,0,0,0.3);
  transition: all 0.05s;
  user-select: none;
}

.ctrl-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #222,
    0 2px 4px rgba(0,0,0,0.3);
}

.ctrl-btn:hover {
  background: linear-gradient(180deg, #777 0%, #555 100%);
}

.ctrl-btn.small {
  font-size: 11px;
  padding: 6px 10px;
}

.ctrl-btn.active {
  background: linear-gradient(180deg, #4a7a4a 0%, #2a5a2a 100%);
}

.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-off);
  margin-right: 4px;
  transition: all 0.2s;
}

.led.on {
  background: var(--led-on);
  box-shadow: 0 0 6px var(--led-on), 0 0 12px rgba(0,255,0,0.4);
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  color: var(--brown);
  font-weight: 600;
}

#speed-slider {
  width: 60px;
  accent-color: var(--brown);
}

#speed-label {
  min-width: 45px;
  font-size: 11px;
}

#keyboard-strip {
  height: 6px;
  background: linear-gradient(90deg, var(--brown) 0%, var(--brown-light) 50%, var(--brown) 100%);
  border-radius: 3px;
  margin-top: 4px;
}

/* Inspector Panel */
#inspector-panel {
  background: rgba(10, 10, 20, 0.95);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  width: 100%;
  max-width: 760px;
  margin-top: 8px;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#inspector-panel.hidden {
  display: none;
}

#inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#inspector-header h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--green-phosphor);
}

#registers {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.reg {
  display: flex;
  gap: 4px;
  align-items: center;
}

.reg-label {
  color: #888;
  font-size: 12px;
}

.reg-val {
  color: var(--green-phosphor);
  font-size: 13px;
  font-weight: bold;
  background: rgba(51, 255, 51, 0.08);
  padding: 2px 6px;
  border-radius: 3px;
}

#flags {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.flag-label {
  color: #888;
  font-size: 11px;
  margin-right: 4px;
}

.flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  background: #222;
  color: #555;
  border: 1px solid #333;
}

.flag.on {
  background: #1a3a1a;
  color: var(--green-phosphor);
  border-color: var(--green-dim);
  box-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
}

.flag-unused {
  opacity: 0.3;
}

#mem-jump {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}

#mem-addr {
  background: #111;
  border: 1px solid #444;
  color: var(--green-phosphor);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 4px 8px;
  width: 60px;
  border-radius: 3px;
}

#hex-dump {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--green-dim);
  overflow-y: auto;
  flex: 1;
  white-space: pre;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

#hex-dump .pc-highlight {
  background: rgba(255, 255, 0, 0.2);
  color: #ff0;
}

/* Status Bar */
#status-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  color: #666;
  padding: 8px;
  width: 100%;
  max-width: 760px;
}

#status-bar span {
  white-space: nowrap;
}

/* Footer */
#app-footer {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #555;
  text-align: center;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

#app-footer a {
  color: var(--green-dim);
  text-decoration: none;
}

#app-footer a:hover {
  color: var(--green-phosphor);
}

/* Responsive */
@media (max-width: 600px) {
  body { padding: 8px; }
  #monitor-housing { padding: 12px 12px 8px; border-radius: 12px 12px 6px 6px; }
  #screen-bezel { padding: 8px; border-radius: 10px; }
  .ctrl-btn { font-size: 11px; padding: 6px 10px; }
  .ctrl-btn.small { font-size: 10px; padding: 5px 8px; }
  #registers { gap: 8px; }
  #hex-dump { font-size: 9px; }
  .apple-text { font-size: 11px; }
}