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

:root {
  --bg-deep: #0a0a14;
  --bg-dark: #12121e;
  --bg-card: #1a1a2e;
  --bg-card-alt: #1e1e34;
  --orange: #ff6600;
  --orange-dim: #994400;
  --orange-glow: #ff880044;
  --green: #33ff33;
  --green-dim: #117711;
  --cyan: #00ffcc;
  --cyan-dim: #008877;
  --red: #ff3333;
  --text: #e0ddd0;
  --text-dim: #888880;
  --key-bg: #f5f0e1;
  --key-text: #222;
  --key-shadow: #9a9585;
  --key-active: #ddd5c0;
  --border: #332200;
  --highlight-col: rgba(0, 150, 255, 0.15);
  --highlight-row: rgba(0, 255, 100, 0.15);
  --highlight-cell: rgba(255, 102, 0, 0.6);
}

html {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-deep);
  color: var(--text);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* CRT Scanline Overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

.font-pixel { font-family: 'Press Start 2P', monospace; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* Glow effects */
.glow-orange { box-shadow: 0 0 12px var(--orange-glow), 0 0 4px rgba(255,102,0,0.2); }
.glow-green { box-shadow: 0 0 12px rgba(51,255,51,0.3); }
.glow-cyan { box-shadow: 0 0 12px rgba(0,255,204,0.3); }

/* LED indicators */
.led {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.led-green {
  background: radial-gradient(circle at 35% 35%, #88ff88, #33ff33, #117711);
  box-shadow: 0 0 6px #33ff33, 0 0 12px rgba(51,255,51,0.3);
}
.led-red {
  background: radial-gradient(circle at 35% 35%, #ff8888, #ff3333, #771111);
  box-shadow: 0 0 6px #ff3333, 0 0 12px rgba(255,51,51,0.3);
}
.led-orange {
  background: radial-gradient(circle at 35% 35%, #ffaa44, #ff6600, #773300);
  box-shadow: 0 0 6px #ff6600, 0 0 12px rgba(255,102,0,0.3);
}
.led-off {
  background: radial-gradient(circle at 35% 35%, #444, #333, #222);
  box-shadow: none;
}

/* Key styling */
.oric-key {
  background: linear-gradient(180deg, #f5f0e1 0%, #e8e0cc 60%, #d8d0bc 100%);
  color: #222;
  border: 1px solid #b0a890;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
  box-shadow: 0 3px 0 #9a9585, 0 4px 6px rgba(0,0,0,0.3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
}
.oric-key:hover {
  border-color: var(--orange);
  box-shadow: 0 3px 0 #9a9585, 0 4px 6px rgba(0,0,0,0.3), 0 0 8px var(--orange-glow);
}
.oric-key.pressed {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #9a9585, 0 2px 4px rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #ddd5c0 0%, #d0c8b0 60%, #c8c0a8 100%);
}
.oric-key.highlighted {
  border-color: var(--orange);
  box-shadow: 0 3px 0 #9a9585, 0 0 16px rgba(255,102,0,0.5);
  background: linear-gradient(180deg, #ffe8cc 0%, #ffd8aa 60%, #ffc888 100%);
}

/* Card panel */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Matrix cell */
.matrix-cell {
  transition: all 0.15s ease;
  border: 1px solid #222;
}
.matrix-cell.col-highlight { background: var(--highlight-col) !important; }
.matrix-cell.row-highlight { background: var(--highlight-row) !important; }
.matrix-cell.cell-highlight { background: var(--highlight-cell) !important; box-shadow: 0 0 10px rgba(255,102,0,0.5); }

/* Memory map segment */
.mem-segment {
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 3px;
}
.mem-segment:hover {
  filter: brightness(1.3);
  box-shadow: 0 0 10px rgba(255,255,255,0.15);
}

/* Signal flow path pulse */
@keyframes signalPulse {
  0% { stroke-dashoffset: 20; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
.signal-path {
  stroke-dasharray: 5 5;
  animation: signalPulse 0.4s linear infinite;
}

/* Blink LED */
@keyframes blinkLed {
  0%, 80% { opacity: 1; }
  90% { opacity: 0.3; }
  100% { opacity: 1; }
}
.blink-led { animation: blinkLed 1s ease infinite; }

/* Scan progress bar */
.scan-bar-bg {
  background: #222;
  border-radius: 4px;
  overflow: hidden;
  height: 6px;
}
.scan-bar-fill {
  background: linear-gradient(90deg, var(--orange), #ffaa00);
  height: 100%;
  transition: width 0.05s linear;
  border-radius: 4px;
}

/* Tooltip */
.tooltip-wrap { position: relative; }
.tooltip-content {
  display: none;
  position: absolute;
  z-index: 100;
  background: #222;
  border: 1px solid var(--orange);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  min-width: 200px;
  max-width: 320px;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.tooltip-wrap:hover .tooltip-content { display: block; }

/* Char cell */
.char-cell {
  cursor: pointer;
  border: 1px solid #222;
  transition: all 0.15s ease;
  border-radius: 3px;
}
.char-cell:hover {
  border-color: var(--orange);
  box-shadow: 0 0 8px var(--orange-glow);
}
.char-cell.selected {
  border-color: var(--orange);
  box-shadow: 0 0 12px var(--orange-glow);
  background: rgba(255,102,0,0.1);
}

/* ROM drop zone */
.rom-drop {
  border: 2px dashed #444;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.rom-drop:hover, .rom-drop.drag-over {
  border-color: var(--orange);
  background: rgba(255,102,0,0.05);
}

/* Hex viewer */
.hex-row { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.hex-row:nth-child(even) { background: rgba(255,255,255,0.02); }

/* Easter egg animation */
@keyframes oricBoot {
  0% { opacity: 0; transform: scale(0.8); }
  10% { opacity: 1; transform: scale(1.05); }
  20% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.oric-boot-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: oricBoot 3s ease forwards;
  pointer-events: none;
}

/* Toggle switch */
.toggle-track {
  width: 48px; height: 24px;
  border-radius: 12px;
  background: #333;
  cursor: pointer;
  transition: background 0.2s ease;
  position: relative;
}
.toggle-track.active { background: var(--orange); }
.toggle-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px; left: 2px;
  transition: transform 0.2s ease;
}
.toggle-track.active .toggle-thumb { transform: translateX(24px); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* Section collapse */
.section-header {
  cursor: pointer;
  user-select: none;
}
.section-header:hover { color: var(--orange); }

/* Tab active */
.tab-btn {
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  font-size: 11px;
}
.tab-btn:hover { border-color: var(--orange-dim); }
.tab-btn.active {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}

@media (max-width: 768px) {
  .oric-key { font-size: 6px !important; }
}