:root {
  --orange-brand: #e87c1e;
  --brown-dark: #2d1b0e;
  --brown-mid: #4a2e14;
  --cream: #f5e6c8;
  --crt-green: #33ff33;
  --crt-amber: #ffb000;
  --crt-white: #e0e0e0;
  --bezel: #8b7355;
  --bezel-dark: #5a4a32;
}

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

body {
  font-family: 'Share Tech Mono', monospace;
  background: linear-gradient(180deg, #1a0f05 0%, #0d0805 100%);
  color: var(--cream);
  min-height: 100vh;
  overflow-x: hidden;
}

.vt323 { font-family: 'VT323', monospace; }

/* CRT Screen Effects */
.crt-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow:
    0 0 20px rgba(0,0,0,0.8),
    inset 0 0 60px rgba(0,0,0,0.5),
    0 0 40px rgba(232,124,30,0.1);
}

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

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

/* Bezel */
.bezel {
  background: linear-gradient(145deg, #9b8b6b 0%, #6b5b3b 50%, #4b3b2b 100%);
  padding: 16px;
  border-radius: 16px;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.15),
    inset 0 -2px 4px rgba(0,0,0,0.3),
    0 8px 32px rgba(0,0,0,0.5);
}

/* Hex Keypad Buttons */
.hex-key {
  font-family: 'VT323', monospace;
  font-size: 1.25rem;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.08s ease;
  background: linear-gradient(180deg, #5a5a5a 0%, #3a3a3a 50%, #2a2a2a 100%);
  color: #ddd;
  box-shadow:
    0 3px 0 #1a1a1a,
    0 4px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.15);
  position: relative;
  top: 0;
}

.hex-key:active, .hex-key.pressed {
  top: 3px;
  box-shadow:
    0 0px 0 #1a1a1a,
    0 1px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.1);
  background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 50%, #1a1a1a 100%);
}

.hex-key.fn-key {
  background: linear-gradient(180deg, #8b5a1e 0%, #6b3a0e 50%, #4b2a0a 100%);
  color: var(--cream);
}

.hex-key.fn-key:active, .hex-key.fn-key.pressed {
  background: linear-gradient(180deg, #7b4a0e 0%, #5b2a04 50%, #3b1a00 100%);
}

/* Power Button */
.power-btn {
  background: linear-gradient(180deg, var(--orange-brand), #c05a10);
  color: white;
  font-family: 'VT323', monospace;
  font-size: 1.5rem;
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    0 4px 0 #8a4a0a,
    0 6px 16px rgba(0,0,0,0.4);
  transition: all 0.1s ease;
}

.power-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 #8a4a0a, 0 2px 8px rgba(0,0,0,0.4);
}

.power-btn.on {
  background: linear-gradient(180deg, #33cc33, #228822);
  box-shadow: 0 4px 0 #115511, 0 6px 16px rgba(0,0,0,0.4), 0 0 20px rgba(51,204,51,0.3);
}

/* Panel styles */
.panel {
  background: linear-gradient(180deg, rgba(42,30,18,0.95), rgba(26,18,10,0.98));
  border: 1px solid rgba(139,115,85,0.3);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  background: linear-gradient(90deg, rgba(232,124,30,0.2), transparent);
  padding: 8px 12px;
  border-bottom: 1px solid rgba(139,115,85,0.2);
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  color: var(--orange-brand);
  cursor: pointer;
  user-select: none;
}

/* ROM slot */
.rom-slot {
  background: rgba(0,0,0,0.3);
  border: 1px dashed rgba(139,115,85,0.3);
  border-radius: 6px;
  padding: 8px 10px;
  transition: border-color 0.2s;
}

.rom-slot:hover {
  border-color: var(--orange-brand);
}

.rom-slot.loaded {
  border-color: #33cc33;
  border-style: solid;
}

/* Status indicators */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green { background: #33cc33; box-shadow: 0 0 6px #33cc33; }
.status-dot.red { background: #cc3333; box-shadow: 0 0 6px #cc3333; }
.status-dot.yellow { background: #cccc33; box-shadow: 0 0 6px #cccc33; }
.status-dot.grey { background: #555; }

/* Flag indicators */
.flag-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: bold;
}

.flag-set { background: #228822; color: #33ff33; }
.flag-clear { background: #333; color: #666; }

/* Memory inspector */
.hex-dump {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-y: auto;
  max-height: 200px;
  background: #0a0a0a;
  padding: 8px;
  border-radius: 4px;
}

.hex-dump .addr { color: var(--orange-brand); }
.hex-dump .ram { color: #ccc; }
.hex-dump .rom { color: #6699ff; }
.hex-dump .io { color: var(--orange-brand); }
.hex-dump .unmapped { color: #444; }

/* Console */
.console-output {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.3;
  background: #050505;
  color: var(--crt-green);
  padding: 8px;
  overflow-y: auto;
  max-height: 150px;
  white-space: pre-wrap;
  border-radius: 4px;
}

/* Memory map bar */
.memmap-bar {
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.memmap-bar > div {
  position: relative;
  cursor: pointer;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #333;
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange-brand);
  cursor: pointer;
}

/* Power-on flicker */
@keyframes flicker {
  0% { opacity: 0; }
  10% { opacity: 0.8; }
  15% { opacity: 0.2; }
  20% { opacity: 0.9; }
  25% { opacity: 0.4; }
  30% { opacity: 1; }
  100% { opacity: 1; }
}

.flickering {
  animation: flicker 0.6s ease-out;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    flex-direction: column !important;
  }
}

/* Drop zone */
.drop-zone {
  border: 2px dashed rgba(139,115,85,0.4);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--orange-brand);
  background: rgba(232,124,30,0.1);
}

/* Tooltip */
.tooltip {
  position: absolute;
  background: rgba(0,0,0,0.9);
  color: var(--cream);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}