:root {
  --bbc-orange: #cc5500;
  --bbc-dark-orange: #993d00;
  --bbc-cream: #f5f0e1;
  --bbc-dark: #1a1a2e;
  --bbc-darker: #0f0f1e;
  --phosphor-green: #33ff33;
  --phosphor-amber: #ffaa00;
  --phosphor-white: #e0e0e0;
  --pcb-green: #0a2e0a;
  --pcb-border: #1a5e1a;
  --led-red: #ff2222;
  --led-green: #22ff22;
}

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

body {
  background: var(--bbc-dark);
  font-family: 'Share Tech Mono', monospace;
  color: #ccc;
  overflow-x: hidden;
  min-height: 100vh;
}

/* CRT Screen Effects */
.crt-screen {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 0 40px rgba(51, 255, 51, 0.15),
    0 0 80px rgba(51, 255, 51, 0.05),
    inset 0 0 60px rgba(0,0,0,0.4);
}

.crt-screen.amber {
  box-shadow:
    0 0 40px rgba(255, 170, 0, 0.15),
    0 0 80px rgba(255, 170, 0, 0.05),
    inset 0 0 60px rgba(0,0,0,0.4);
}

.crt-screen.white-phosphor {
  box-shadow:
    0 0 40px rgba(224, 224, 224, 0.15),
    0 0 80px rgba(224, 224, 224, 0.05),
    inset 0 0 60px rgba(0,0,0,0.4);
}

.scanlines {
  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;
  z-index: 2;
}

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

.screen-flicker {
  animation: flicker 0.08s infinite alternate;
}

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

/* CRT Power On/Off */
@keyframes crt-on {
  0% { transform: scaleY(0.005) scaleX(0.3); filter: brightness(10); }
  20% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  50% { transform: scaleY(1) scaleX(1); filter: brightness(2); }
  100% { transform: scaleY(1) scaleX(1); filter: brightness(1); }
}

@keyframes crt-off {
  0% { transform: scaleY(1) scaleX(1); filter: brightness(1); }
  30% { transform: scaleY(0.005) scaleX(1); filter: brightness(5); }
  60% { transform: scaleY(0.005) scaleX(0.3); filter: brightness(10); }
  100% { transform: scaleY(0) scaleX(0); filter: brightness(0); }
}

.crt-power-on canvas {
  animation: crt-on 0.8s ease-out forwards;
}

.crt-power-off canvas {
  animation: crt-off 0.5s ease-in forwards;
}

/* Bezel */
.monitor-bezel {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 3px solid #333;
  border-radius: 24px;
  padding: 16px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* LED Indicators */
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.1);
}

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

.led-off {
  background: #333;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

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

/* PCB-style panels */
.pcb-panel {
  background: var(--pcb-green);
  border: 1px solid var(--pcb-border);
  border-radius: 4px;
  position: relative;
}

.pcb-panel::before {
  content: '';
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border: 1px dashed rgba(26,94,26,0.5);
  border-radius: 6px;
  pointer-events: none;
}

/* Solder dots */
.solder-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #c0c0c0, #808080);
  position: absolute;
}

/* Retro buttons */
.retro-btn {
  font-family: 'Share Tech Mono', monospace;
  background: linear-gradient(180deg, #555 0%, #333 50%, #222 100%);
  color: #ddd;
  border: 2px solid #666;
  border-bottom-color: #111;
  border-right-color: #111;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.05s;
  user-select: none;
}

.retro-btn:active {
  background: linear-gradient(180deg, #333 0%, #222 50%, #111 100%);
  border-top-color: #111;
  border-left-color: #111;
  border-bottom-color: #666;
  border-right-color: #666;
  transform: translateY(1px);
}

.retro-btn.run { border-color: #2a7a2a; background: linear-gradient(180deg, #2a5a2a, #1a3a1a); }
.retro-btn.run:hover { background: linear-gradient(180deg, #3a7a3a, #2a5a2a); }
.retro-btn.stop { border-color: #7a2a2a; background: linear-gradient(180deg, #5a2a2a, #3a1a1a); }

/* BBC Keyboard */
.bbc-key {
  font-family: 'VT323', monospace;
  background: linear-gradient(180deg, #3a3a3a, #222);
  color: #eee;
  border: 1px solid #555;
  border-bottom: 3px solid #111;
  border-right: 2px solid #1a1a1a;
  border-radius: 3px;
  padding: 4px 6px;
  min-width: 32px;
  height: 32px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all 0.05s;
}

.bbc-key:active, .bbc-key.pressed {
  background: linear-gradient(180deg, #222, #1a1a1a);
  border-bottom: 1px solid #555;
  border-top: 3px solid #111;
  transform: translateY(2px);
}

.bbc-key.fn-key {
  background: linear-gradient(180deg, #cc3333, #881111);
  color: #fff;
  border-color: #992222;
}

.bbc-key.fn-key:active {
  background: linear-gradient(180deg, #991111, #660000);
}

.bbc-key.break-key {
  background: linear-gradient(180deg, #cc5500, #883300);
  color: #fff;
}

/* Cassette recorder */
.cassette-deck {
  background: linear-gradient(180deg, #d4c8a8, #b8ad8f);
  border: 2px solid #8a7f65;
  border-radius: 8px;
  position: relative;
}

.tape-reel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle, #1a1a1a 30%, #333 60%, #1a1a1a 100%);
  border: 2px solid #444;
  position: relative;
}

.tape-reel-inner {
  position: absolute;
  top: 50%; left: 50%;
  width: 12px; height: 12px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #f5f0e1;
  border: 1px solid #999;
}

@keyframes spin-reel {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

/* Hex editor */
.hex-row {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.hex-byte {
  cursor: pointer;
  padding: 0 2px;
  transition: background 0.1s;
}

.hex-byte:hover {
  background: rgba(51, 255, 51, 0.2);
}

.hex-byte.changed {
  animation: flash-yellow 0.5s;
}

@keyframes flash-yellow {
  0% { background: rgba(255,255,0,0.6); }
  100% { background: transparent; }
}

/* VU Meter */
.vu-bar {
  width: 6px;
  height: 2px;
  margin: 1px 0;
  transition: background 0.1s;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0a0a1a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Power switch */
.power-switch {
  width: 50px;
  height: 24px;
  background: #222;
  border-radius: 12px;
  border: 2px solid #555;
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
}

.power-switch.on {
  background: #1a3a1a;
  border-color: #2a7a2a;
}

.power-switch .knob {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #888, #555);
  position: absolute;
  top: 1px;
  left: 1px;
  transition: all 0.3s;
}

.power-switch.on .knob {
  left: 27px;
  background: linear-gradient(180deg, #4a4, #282);
}

/* Rotary knob */
.rotary-knob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #666, #333);
  border: 2px solid #555;
  cursor: grab;
  position: relative;
}

.rotary-knob .indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 2px;
  height: 10px;
  background: #fff;
  transform-origin: bottom center;
  margin-left: -1px;
}

/* Orange header */
.bbc-header {
  background: linear-gradient(180deg, #dd6611, var(--bbc-orange), var(--bbc-dark-orange));
  border-bottom: 3px solid #772200;
}

/* Acorn logo SVG-like */
.acorn-logo {
  display: inline-block;
  width: 24px;
  height: 28px;
}

/* Mini oscilloscope */
.oscilloscope {
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 2px;
}

/* Footer */
.app-footer {
  background: #0a0a12;
  border-top: 1px solid #222;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar-panel { display: none; }
}

@media (max-width: 768px) {
  .monitor-bezel { padding: 8px; border-radius: 16px; }
  .bbc-key { min-width: 24px; height: 26px; font-size: 9px; }
}

/* Blinking cursor */
@keyframes blink-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.blink-cursor {
  animation: blink-cursor 1s step-end infinite;
}

/* Boot text animation */
@keyframes type-char {
  from { width: 0; }
  to { width: 100%; }
}