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

body {
  background-color: #0a1f0a;
  color: #9BBC0F;
  font-family: 'JetBrains Mono', monospace;
  overflow-x: hidden;
}

/* Scanline overlay */
.scanlines {
  position: relative;
}
.scanlines::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* CRT glow effect */
.crt-glow {
  text-shadow: 0 0 5px rgba(155, 188, 15, 0.5);
}

/* Register flash animation */
@keyframes regFlash {
  0% { background-color: #9BBC0F; color: #0F380F; }
  100% { background-color: transparent; color: #9BBC0F; }
}
.reg-flash {
  animation: regFlash 0.4s ease-out;
}

/* Flag pulse */
@keyframes flagPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(155, 188, 15, 0.3); }
  50% { box-shadow: 0 0 12px rgba(155, 188, 15, 0.8); }
}
.flag-active {
  animation: flagPulse 1.5s ease-in-out infinite;
}

/* Pulsing dot */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.pulse-dot {
  animation: pulse 1s ease-in-out infinite;
}

/* Cartridge shape */
.cartridge {
  border-radius: 8px 8px 4px 4px;
  border: 2px solid #1a4a1a;
  background: linear-gradient(180deg, #0d2b0d 0%, #091f09 100%);
  position: relative;
}
.cartridge::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 4px;
  background: #1a4a1a;
  border-radius: 0 0 4px 4px;
}

/* GB Button style */
.gb-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 16px;
  border: 2px solid #306230;
  background: linear-gradient(180deg, #1a4a1a 0%, #0d2b0d 100%);
  color: #9BBC0F;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 20px;
  text-transform: uppercase;
}
.gb-btn:hover {
  background: linear-gradient(180deg, #306230 0%, #1a4a1a 100%);
  border-color: #9BBC0F;
  box-shadow: 0 0 10px rgba(155, 188, 15, 0.3);
}
.gb-btn:active {
  transform: scale(0.95);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.gb-btn.active {
  background: linear-gradient(180deg, #9BBC0F 0%, #8BAC0F 100%);
  color: #0F380F;
  border-color: #9BBC0F;
}



/* Memory hex viewer */
.hex-row {
  display: flex;
  gap: 0;
  font-size: 11px;
  line-height: 1.6;
}
.hex-addr {
  color: #306230;
  min-width: 60px;
}
.hex-byte {
  min-width: 24px;
  text-align: center;
}
.hex-byte.nonzero {
  color: #9BBC0F;
}
.hex-byte.zero {
  color: #1a4a1a;
}
.hex-ascii {
  color: #306230;
  margin-left: 8px;
  letter-spacing: 1px;
}

/* Instruction log */
.inst-current {
  background: rgba(155, 188, 15, 0.15);
  border-left: 3px solid #9BBC0F;
}

/* Serial terminal */
.terminal {
  background: #000;
  color: #33ff33;
  font-family: 'JetBrains Mono', monospace;
  padding: 12px;
  border: 1px solid #1a4a1a;
  min-height: 80px;
  white-space: pre-wrap;
  overflow-y: auto;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a1f0a; }
::-webkit-scrollbar-thumb { background: #306230; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9BBC0F; }

/* VRAM placeholder */
.vram-placeholder {
  border: 3px dashed #306230;
  padding: 24px;
  text-align: center;
  border-radius: 8px;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(48, 98, 48, 0.1) 10px,
    rgba(48, 98, 48, 0.1) 20px
  );
}

/* Crossed-out screen icon */
.screen-icon-container {
  position: relative;
  display: inline-block;
}
.screen-icon {
  display: inline-block;
}
.screen-x {
  position: absolute;
  top: -2px;
  right: -8px;
  font-size: 18px;
  color: #ff4444;
  font-weight: bold;
  text-shadow: 0 0 6px rgba(255, 68, 68, 0.6);
  animation: screenGlitch 4s ease-in-out infinite;
}
.screen-check {
  position: absolute;
  top: -2px;
  right: -8px;
  font-size: 16px;
  color: #9BBC0F;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(155, 188, 15, 0.8);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes screenGlitch {
  0%, 90%, 100% { transform: translate(0,0); }
  92% { transform: translate(-2px, 1px); }
  94% { transform: translate(2px, -1px); }
  96% { transform: translate(-1px, 0px); }
  98% { transform: translate(1px, 1px); }
}

/* PPU Display */
.lcd-canvas {
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 20px rgba(155, 188, 15, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.tile-canvas, .bgmap-canvas {
  display: block;
  margin: 0 auto;
}

.ppu-display-section {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #1a4a1a;
  border-radius: 8px;
  padding: 12px;
}

.ppu-demo-btn {
  position: relative;
  border-color: #306230;
}
.ppu-demo-btn::before {
  content: '📺';
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 8px;
}

.vram-live-preview {
  border: 2px solid #1a4a1a;
  border-radius: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
}

/* PPU mode indicator bar */
@keyframes ppuScanline {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #1a4a1a;
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9BBC0F;
  cursor: pointer;
  border: 2px solid #0F380F;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9BBC0F;
  cursor: pointer;
  border: 2px solid #0F380F;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-content {
  background: #0d2b0d;
  border: 2px solid #9BBC0F;
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  text-align: center;
  animation: modalPop 0.3s ease-out;
}
@keyframes modalPop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #306230;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #9BBC0F;
  background: rgba(155, 188, 15, 0.05);
}

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

/* LED display for registers */
.led-display {
  background: #000;
  border: 1px solid #1a4a1a;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(155, 188, 15, 0.6);
  font-size: 14px;
}

/* Tooltip */
.tooltip-container {
  position: relative;
}
.tooltip-container .tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #0F380F;
  border: 1px solid #9BBC0F;
  color: #9BBC0F;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  z-index: 50;
  transition: opacity 0.2s;
  pointer-events: none;
}
.tooltip-container:hover .tooltip {
  visibility: visible;
  opacity: 1;
}