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

body {
  background: #0d0d1a;
  background-image: 
    radial-gradient(ellipse at 50% 0%, #1a1a3a 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 49px, #ffffff05 49px, #ffffff05 50px),
    repeating-linear-gradient(90deg, transparent, transparent 49px, #ffffff05 49px, #ffffff05 50px);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px;
  overflow-x: hidden;
  font-family: 'JetBrains Mono', monospace;
  color: #ccc;
}

#app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 1200px;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#toolbar button {
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  color: #9BBC0F;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
}
#toolbar button:hover { background: #3a3a5a; }
#toolbar button:active { background: #4a4a6a; transform: scale(0.95); }
#toolbar button.active { background: #306230; border-color: #8BAC0F; }

#volume-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

#volume-slider {
  width: 60px;
  accent-color: #8BAC0F;
}

#toolbar select {
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  color: #9BBC0F;
  padding: 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* Game Boy Shell */
#gameboy-shell {
  background: linear-gradient(145deg, #c8c8b8 0%, #b8b8a8 50%, #a8a898 100%);
  border-radius: 16px 16px 16px 60px;
  padding: 16px 20px 24px;
  box-shadow: 
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 0 rgba(0,0,0,0.15);
  max-width: 380px;
  width: 100%;
  position: relative;
}

#shell-top {
  margin-bottom: 10px;
  padding-left: 4px;
}

#accent-line {
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, #8B1A8B, #5B2C8B);
  border-radius: 2px;
  margin-bottom: 4px;
}

#brand-text {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  color: #2a2a5a;
  letter-spacing: 2px;
}

.brand-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 7px;
  color: #5a5a7a;
  font-style: italic;
  margin-top: 2px;
}

/* Screen */
#screen-bezel {
  background: #3a3a2a;
  border-radius: 10px;
  padding: 12px 14px 14px;
  box-shadow: 
    inset 0 3px 8px rgba(0,0,0,0.6),
    inset 0 -1px 0 rgba(255,255,255,0.08);
  position: relative;
  margin: 0 auto;
  text-align: center;
  transition: box-shadow 0.3s;
}

#screen-bezel.dragover {
  box-shadow: 
    inset 0 3px 8px rgba(0,0,0,0.6),
    0 0 20px rgba(139,172,15,0.6);
}

#power-indicator {
  position: absolute;
  top: 4px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 3px;
}
#power-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cc3333;
  box-shadow: 0 0 4px rgba(204,51,51,0.6);
  transition: all 0.3s;
}
#power-led.running { background: #33cc33; box-shadow: 0 0 6px rgba(51,204,51,0.8); }
#power-led.paused { background: #cccc33; box-shadow: 0 0 4px rgba(204,204,51,0.6); }

#power-indicator span {
  font-family: 'Press Start 2P', cursive;
  font-size: 5px;
  color: #6a6a5a;
}

#screen {
  display: block;
  width: 320px;
  height: 288px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #9BBC0F;
  border-radius: 2px;
  margin: 0 auto;
}

#drop-overlay {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
  color: rgba(139,172,15,0.6);
  pointer-events: none;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}
#drop-overlay.visible { opacity: 1; background: rgba(15,56,15,0.3); }

#rom-info {
  text-align: center;
  margin-top: 6px;
}
#rom-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 7px;
  color: #5a5a7a;
}

/* Controls */
#controls-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 0 8px;
}

#dpad-container {
  width: 100px;
  height: 100px;
  position: relative;
}

#dpad {
  position: relative;
  width: 100px;
  height: 100px;
}

.dpad-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  background: #3a3a3a;
  border: none;
  color: #1a1a1a;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.08s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.dpad-btn:active, .dpad-btn.pressed {
  background: #2a2a2a;
  box-shadow: 0 0 2px rgba(0,0,0,0.4), inset 0 2px 4px rgba(0,0,0,0.4);
  transform: scale(0.95);
}

.dpad-up { top: 0; left: 34px; border-radius: 4px 4px 0 0; }
.dpad-down { bottom: 0; left: 34px; border-radius: 0 0 4px 4px; }
.dpad-left { top: 34px; left: 0; border-radius: 4px 0 0 4px; }
.dpad-right { top: 34px; right: 0; border-radius: 0 4px 4px 0; }
.dpad-center {
  position: absolute;
  top: 32px;
  left: 32px;
  width: 36px;
  height: 36px;
  background: #3a3a3a;
}

#ab-container {
  display: flex;
  gap: 12px;
  transform: rotate(-25deg);
}

.action-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #8B1A4A, #6B1A3A);
  border: none;
  color: #2a0a1a;
  font-family: 'Press Start 2P', cursive;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all 0.08s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.action-btn:active, .action-btn.pressed {
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), inset 0 2px 4px rgba(0,0,0,0.4);
  transform: scale(0.93);
}

#start-select-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  transform: rotate(-25deg);
}

.sys-btn {
  width: 48px;
  height: 16px;
  border-radius: 8px;
  background: #5a5a5a;
  border: none;
  color: #2a2a2a;
  font-family: 'Press Start 2P', cursive;
  font-size: 5px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.08s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.sys-btn:active, .sys-btn.pressed {
  box-shadow: 0 0 2px rgba(0,0,0,0.3), inset 0 2px 3px rgba(0,0,0,0.4);
  transform: scale(0.93);
}

#load-rom-container {
  text-align: center;
  margin-top: 16px;
}

#btn-load-rom {
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  padding: 8px 16px;
  background: #2a2a5a;
  border: 2px solid #4a4a7a;
  color: #9BBC0F;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
#btn-load-rom:hover { background: #3a3a6a; }

/* Cart Info */
#cart-info {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 11px;
  max-width: 380px;
  width: 100%;
}
#cart-details {
  font-family: 'JetBrains Mono', monospace;
  color: #8BAC0F;
  line-height: 1.6;
}

/* Debug Panel */
#debug-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 340px;
  height: 100vh;
  background: #0a0a14;
  border-left: 2px solid #1a3a1a;
  overflow-y: auto;
  padding: 14px;
  z-index: 100;
  transition: transform 0.3s ease;
  font-size: 11px;
}
#debug-panel.hidden {
  transform: translateX(100%);
}

#debug-panel h3 {
  font-family: 'Press Start 2P', cursive;
  font-size: 8px;
  color: #8BAC0F;
  margin: 12px 0 6px;
  border-bottom: 1px solid #1a3a1a;
  padding-bottom: 4px;
}

#debug-regs, #debug-flags, #debug-opcode, #debug-interrupts, #debug-timer, #debug-ppu, #debug-fps {
  font-family: 'JetBrains Mono', monospace;
  color: #33cc66;
  line-height: 1.5;
  font-size: 10px;
}

#debug-flags .flag-set { color: #8BAC0F; font-weight: bold; }
#debug-flags .flag-unset { color: #3a3a3a; }

#vram-canvas {
  image-rendering: pixelated;
  width: 256px;
  height: 384px;
  background: #0F380F;
  border: 1px solid #1a3a1a;
}

#debug-log {
  height: 100px;
  overflow-y: auto;
  background: #050510;
  border: 1px solid #1a3a1a;
  padding: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #33aa55;
  line-height: 1.4;
}

/* Key Hint */
#key-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #4a4a6a;
  text-align: center;
  margin-top: 4px;
}

footer {
  margin-top: 12px;
  text-align: center;
}
footer a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #4a4a6a;
  text-decoration: none;
}
footer a:hover { color: #8BAC0F; }

/* Mobile */
@media (max-width: 500px) {
  #gameboy-shell { max-width: 100%; padding: 12px 14px 20px; }
  #screen { width: 100%; height: auto; aspect-ratio: 160/144; }
  .brand-main { font-size: 12px; }
  #dpad-container { width: 90px; height: 90px; }
  #dpad { width: 90px; height: 90px; }
  .dpad-btn { width: 28px; height: 28px; font-size: 8px; }
  .dpad-up { left: 31px; }
  .dpad-down { left: 31px; }
  .dpad-left { top: 31px; }
  .dpad-right { top: 31px; }
  .dpad-center { top: 28px; left: 28px; width: 34px; height: 34px; }
  .action-btn { width: 40px; height: 40px; }
  #debug-panel { width: 280px; }
  #key-hint { display: none; }
}