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

:root {
  --c64-blue: #6C6CFF;
  --c64-dark-blue: #40318D;
  --c64-border-blue: #6C6CFF;
  --c64-black: #000000;
  --c64-white: #FFFFFF;
  --c64-red: #880000;
  --c64-cyan: #AAFFEE;
  --c64-purple: #CC44CC;
  --c64-green: #00CC55;
  --c64-dk-blue: #0000AA;
  --c64-yellow: #EEEE77;
  --c64-orange: #DD8855;
  --c64-brown: #664400;
  --c64-lt-red: #FF7777;
  --c64-dk-gray: #333333;
  --c64-md-gray: #777777;
  --c64-lt-green: #AAFF66;
  --c64-lt-blue: #0088FF;
  --c64-lt-gray: #BBBBBB;
  --bezel-color: #C8C0B8;
  --bezel-dark: #9E9690;
  --bezel-light: #E0D8D0;
}

body {
  background: #0a0a1a;
  background-image: 
    radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1a 70%);
  min-height: 100vh;
  font-family: 'Share Tech Mono', monospace;
  overflow-x: hidden;
}

.c64-font {
  font-family: 'VT323', 'Share Tech Mono', monospace;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0px;
}

.crt-monitor {
  position: relative;
  background: var(--bezel-color);
  border-radius: 20px;
  padding: 30px 35px 45px 35px;
  box-shadow: 
    inset 0 2px 0 var(--bezel-light),
    inset 0 -2px 0 var(--bezel-dark),
    inset 2px 0 0 var(--bezel-light),
    inset -2px 0 0 var(--bezel-dark),
    0 8px 32px rgba(0,0,0,0.6),
    0 2px 8px rgba(0,0,0,0.4);
}

.crt-screen-outer {
  position: relative;
  background: #1a1a1a;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 
    inset 0 0 30px rgba(0,0,0,0.8),
    inset 0 0 8px rgba(0,0,0,0.5);
}

.crt-screen {
  position: relative;
  background: var(--c64-dark-blue);
  border: 16px solid var(--c64-border-blue);
  border-radius: 6px;
  overflow: hidden;
  image-rendering: pixelated;
}

.crt-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 10;
}

.crt-screen::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.3) 100%
  );
  pointer-events: none;
  z-index: 11;
}

.screen-content {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

@keyframes flicker {
  0% { opacity: 1; }
  5% { opacity: 0.98; }
  10% { opacity: 1; }
  15% { opacity: 0.97; }
  20% { opacity: 1; }
  50% { opacity: 1; }
  55% { opacity: 0.99; }
  70% { opacity: 1; }
  80% { opacity: 0.98; }
  100% { opacity: 1; }
}

.crt-flicker {
  animation: flicker 4s infinite;
}

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

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

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #880000;
  transition: all 0.3s;
}

.power-led.on {
  background: #ff2222;
  box-shadow: 0 0 6px #ff2222, 0 0 12px #ff000088;
}

.retro-btn {
  font-family: 'Share Tech Mono', monospace;
  background: #4a4a4a;
  color: #ddd;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  box-shadow: 
    inset 0 1px 0 #6a6a6a,
    inset 0 -1px 0 #2a2a2a,
    0 2px 4px rgba(0,0,0,0.4);
  transition: all 0.1s;
}

.retro-btn:hover {
  background: #5a5a5a;
}

.retro-btn:active {
  box-shadow: 
    inset 0 1px 0 #3a3a3a,
    inset 0 -1px 0 #5a5a5a;
  transform: translateY(1px);
}

.retro-btn.danger {
  background: #8a2222;
}
.retro-btn.danger:hover {
  background: #aa3333;
}

.retro-btn.primary {
  background: #2a4a6a;
}
.retro-btn.primary:hover {
  background: #3a5a7a;
}

.power-switch {
  width: 48px;
  height: 24px;
  border-radius: 12px;
  background: #333;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  transition: background 0.3s;
}

.power-switch.on {
  background: #1a4a1a;
}

.power-switch-knob {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #888;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.power-switch.on .power-switch-knob {
  left: 26px;
  background: #4a4;
}

.cassette-deck {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: rgba(0,0,0,0.85);
  padding: 30px;
  border-radius: 16px;
}

.cassette-body {
  width: 260px;
  height: 160px;
  background: #2a2a2a;
  border-radius: 8px;
  border: 2px solid #555;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 50px;
}

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

.reel {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #888;
  position: relative;
}

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

.reel::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #555;
  border-radius: 50%;
}

.reel::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 16px;
  background: #888;
}

.memory-panel {
  font-family: 'VT323', monospace;
  font-size: 14px;
  background: #0a0a0a;
  color: #00cc55;
  overflow-y: auto;
  max-height: 300px;
}

.memory-panel .rom-area {
  color: #eeee77;
}

.status-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-led.active {
  box-shadow: 0 0 4px currentColor;
}

@media (max-width: 768px) {
  .crt-monitor {
    padding: 15px 12px 25px 12px;
    border-radius: 12px;
  }
  
  .crt-screen {
    border-width: 8px;
  }
  
  .c64-font {
    font-size: 10px;
  }
}

@keyframes boot-glow {
  0% { filter: brightness(0); }
  30% { filter: brightness(0.5); }
  100% { filter: brightness(1); }
}

.boot-glow {
  animation: boot-glow 1.5s ease-out;
}

.phosphor-glow {
  text-shadow: 0 0 3px currentColor;
}

.virtual-key {
  font-family: 'VT323', monospace;
  background: #3a3a3a;
  color: #ddd;
  border: 1px solid #555;
  border-bottom: 3px solid #222;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  user-select: none;
  min-width: 28px;
  height: 32px;
  padding: 2px 4px;
  transition: all 0.05s;
}

.virtual-key:active {
  border-bottom-width: 1px;
  transform: translateY(2px);
  background: #4a4a4a;
}

.virtual-key.space-key {
  min-width: 180px;
}

.virtual-key.wide {
  min-width: 56px;
}

.virtual-key.return-key {
  min-width: 68px;
  background: #4a3a2a;
}