:root {
  --phosphor: #33ff33;
  --phosphor-dim: #22cc22;
  --phosphor-glow: #11ff1180;
  --crt-bg: #0a0a0a;
  --bezel: #2a2a2a;
  --keycap: #f0e6d3;
  --keycap-pressed: #d4cbb8;
  --keycap-text: #333;
  --body-bg: #111;
  --panel-bg: #1a1a1a;
}

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

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

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

@keyframes warmup {
  0% { filter: brightness(0) saturate(0); transform: scaleY(0.01); }
  20% { filter: brightness(0.3) saturate(0.5); transform: scaleY(0.01); }
  40% { filter: brightness(0.5) saturate(0.7); transform: scaleY(0.5); }
  60% { filter: brightness(0.7) saturate(0.9); transform: scaleY(0.8); }
  100% { filter: brightness(1) saturate(1); transform: scaleY(1); }
}

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

@keyframes scanmove {
  0% { background-position: 0 0; }
  100% { background-position: 0 4px; }
}

.crt-screen {
  animation: flicker 8s infinite;
  position: relative;
  background: var(--crt-bg);
  border-radius: 12px;
  overflow: hidden;
}

.crt-screen.warming-up {
  animation: warmup 1.5s ease-out forwards;
}

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

.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.5) 100%);
  pointer-events: none;
  z-index: 3;
}

.terminal-char {
  font-family: 'VT323', monospace;
  color: var(--phosphor);
  text-shadow: 0 0 5px var(--phosphor-glow), 0 0 10px rgba(51, 255, 51, 0.3);
  font-size: 18px;
  line-height: 1;
  display: inline-block;
  width: 0.6em;
  text-align: center;
}

.cursor-block {
  animation: blink 1s step-end infinite;
  background: var(--phosphor);
  color: var(--crt-bg);
  text-shadow: none;
}

.key-btn {
  font-family: 'Share Tech Mono', monospace;
  background: linear-gradient(180deg, #f5ede0 0%, #e8dcc8 60%, #d8ccb4 100%);
  color: var(--keycap-text);
  border: 1px solid #b0a898;
  border-radius: 5px;
  box-shadow: 0 3px 0 #a09888, 0 4px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  cursor: pointer;
  user-select: none;
  transition: all 0.08s ease;
  font-size: 13px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 4px 8px;
}

.key-btn:active, .key-btn.pressed {
  background: linear-gradient(180deg, #d8ccb4 0%, #ccc0a8 60%, #c0b49c 100%);
  box-shadow: 0 1px 0 #a09888, 0 2px 3px rgba(0,0,0,0.3), inset 0 1px 2px rgba(0,0,0,0.1);
  transform: translateY(2px);
}

.key-btn.active-modifier {
  background: linear-gradient(180deg, #c8bc9c 0%, #b8ac8c 60%, #a89c7c 100%);
  box-shadow: 0 1px 0 #908878, 0 2px 3px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(2px);
  border-color: #908060;
}

.bezel {
  background: linear-gradient(145deg, #3a3a3a 0%, #252525 50%, #1a1a1a 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.8);
  border: 2px solid #444;
}

.rom-zone {
  border: 2px dashed #555;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #1e1e1e;
}

.rom-zone:hover {
  border-color: var(--phosphor-dim);
  background: #222;
}

.rom-zone.loaded {
  border-color: var(--phosphor-dim);
  border-style: solid;
}

.reset-btn {
  background: linear-gradient(180deg, #cc3333 0%, #991111 100%);
  color: white;
  border: 2px solid #660000;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #550000, 0 6px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.1s;
  user-select: none;
}

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

.debug-panel {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--phosphor-dim);
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px 12px;
}

.speed-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #444;
  border-radius: 2px;
  outline: none;
}
.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--phosphor-dim);
  border-radius: 50%;
  cursor: pointer;
}

@media (max-width: 768px) {
  .terminal-char { font-size: 12px; }
  .key-btn { min-height: 36px; font-size: 10px; padding: 2px 4px; }
  .bezel { padding: 10px; border-radius: 12px; }
}