:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #0f1319;
  --bg-panel: #131820;
  --bg-panel-header: #181e28;
  --border: #1e2738;
  --gb-green: #8bac0f;
  --gb-green-dim: #306230;
  --gb-green-bright: #9bbc0f;
  --gb-darkest: #0f380f;
  --text-primary: #c5cdd9;
  --text-secondary: #6b7a90;
  --text-muted: #3d4b5c;
  --accent-red: #ff6b6b;
  --accent-amber: #ffb347;
  --accent-blue: #5b9bd5;
}

[data-theme="light"] {
  --bg-primary: #e8e4d9;
  --bg-secondary: #ddd8cc;
  --bg-panel: #f0ece2;
  --bg-panel-header: #d8d3c7;
  --border: #b8b3a6;
  --gb-green: #306230;
  --gb-green-dim: #8bac0f;
  --gb-green-bright: #0f380f;
  --gb-darkest: #0f380f;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5e;
  --text-muted: #8a8a9e;
  --accent-red: #cc3333;
  --accent-amber: #cc8800;
  --accent-blue: #336699;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

@keyframes flash-green {
  0% { background-color: rgba(139, 172, 15, 0.45); box-shadow: 0 0 8px rgba(139,172,15,0.3); }
  100% { background-color: transparent; box-shadow: none; }
}

@keyframes pulse-led {
  0%, 100% { opacity: 0.5; box-shadow: 0 0 4px currentColor; }
  50% { opacity: 1; box-shadow: 0 0 12px currentColor; }
}

.flash-change {
  animation: flash-green 0.7s ease-out;
}

.led-pulse {
  animation: pulse-led 1.2s ease-in-out infinite;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.panel:hover {
  border-color: rgba(139,172,15,0.15);
}

.panel-header {
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gb-green);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.hex-byte {
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 2px;
  transition: background 0.12s, color 0.12s;
  font-variant-numeric: tabular-nums;
}
.hex-byte:hover {
  background: rgba(139, 172, 15, 0.25);
  color: var(--gb-green-bright);
}

.current-pc-byte {
  background: rgba(139, 172, 15, 0.35) !important;
  color: var(--gb-green-bright) !important;
  font-weight: 700;
  border-radius: 2px;
}

.sp-byte {
  background: rgba(91, 155, 213, 0.2) !important;
  color: var(--accent-blue) !important;
}

.breakpoint-line {
  border-left: 3px solid var(--accent-red) !important;
  background: rgba(255,107,107,0.04);
}

.current-line {
  background: rgba(139, 172, 15, 0.1) !important;
  border-left: 3px solid var(--gb-green) !important;
}

.btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-panel-header);
  color: var(--text-primary);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--gb-green-dim);
  background: rgba(139, 172, 15, 0.1);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: var(--gb-green);
  color: var(--bg-primary);
  border-color: var(--gb-green);
  font-weight: 800;
}
.btn-primary:hover {
  background: var(--gb-green-bright);
  box-shadow: 0 0 12px rgba(139,172,15,0.3);
}
.btn-danger {
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--accent-red);
}
.btn-danger:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--accent-red);
}

.flag-on {
  background: var(--gb-green);
  color: var(--bg-primary);
  font-weight: 800;
  box-shadow: 0 0 8px rgba(139,172,15,0.25);
}
.flag-off {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

input[type="range"] {
  -webkit-appearance: none;
  background: var(--bg-secondary);
  height: 4px;
  border-radius: 2px;
  outline: none;
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gb-green);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(139,172,15,0.3);
}

textarea, input[type="text"] {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
textarea:focus, input[type="text"]:focus {
  border-color: var(--gb-green-dim);
  box-shadow: 0 0 0 2px rgba(139,172,15,0.08);
}

.tooltip {
  position: fixed;
  background: #1a2030;
  border: 1px solid var(--gb-green-dim);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-primary);
  max-width: 300px;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

[data-theme="light"] .tooltip {
  background: #f0ece2;
  border-color: #306230;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.scanline-overlay {
  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.02) 2px,
    rgba(0, 0, 0, 0.02) 4px
  );
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr !important;
  }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  animation: fadeSlideIn 0.3s ease-out backwards;
}

.disasm-row {
  transition: background 0.1s;
}
.disasm-row:hover {
  background: rgba(139,172,15,0.05);
}

.gb-pixel-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--gb-green) 0%, var(--gb-green-dim) 100%);
  border-radius: 3px;
  position: relative;
  box-shadow: 0 0 8px rgba(139,172,15,0.2);
}
.gb-pixel-icon::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 10px; height: 6px;
  background: var(--bg-primary);
  border-radius: 1px;
}